Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheeguerin committed Sep 16, 2024
1 parent 82b83ca commit bd75bd1
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ModelProperty, Operation, createRule } from "@typespec/compiler";
import { getVersions } from "@typespec/versioning";

function isApiVersionParam(prop: ModelProperty): boolean {
return prop.name === "apiVersion" && prop.type.kind === "Scalar" && prop.type.name === "string";
Expand All @@ -15,6 +16,7 @@ export const apiVersionRule = createRule({
create(context) {
return {
operation: (op: Operation) => {
if (!getVersions(context.program, op)[0]) return;
if (!op.namespace) return;
for (const param of op.parameters.properties.values()) {
if (isApiVersionParam(param)) return;
Expand Down

0 comments on commit bd75bd1

Please sign in to comment.