diff --git a/packages/cli/api-importers/openapi/openapi-ir-to-fern/src/buildQueryParameter.ts b/packages/cli/api-importers/openapi/openapi-ir-to-fern/src/buildQueryParameter.ts index 1d320b9d791..452108871bf 100644 --- a/packages/cli/api-importers/openapi/openapi-ir-to-fern/src/buildQueryParameter.ts +++ b/packages/cli/api-importers/openapi/openapi-ir-to-fern/src/buildQueryParameter.ts @@ -67,10 +67,9 @@ export function buildQueryParameter({ queryParameterSchema.availability = convertAvailability(queryParameter.availability); } - if (typeof typeReference.value === "object" && "type" in typeReference.value) { - const detailedSchema = typeReference.value as RawSchemas.TypeReferenceDetailedSchema; - if (detailedSchema.validation !== undefined) { - queryParameterSchema.validation = detailedSchema.validation; + if (isRawTypeReferenceDetailedSchema(typeReference.value)) { + if (typeReference.value.validation !== undefined) { + queryParameterSchema.validation = typeReference.value.validation; } } @@ -432,3 +431,9 @@ function hasSamePrimitiveValueType({ array, primitive }: { array: Schema; primit array.value.schema.type === primitive.schema.type ); } + +function isRawTypeReferenceDetailedSchema( + rawTypeReference: RawSchemas.TypeReferenceSchema +): rawTypeReference is RawSchemas.TypeReferenceDetailedSchema { + return (rawTypeReference as RawSchemas.TypeReferenceDetailedSchema).type != null; +} diff --git a/packages/cli/ete-tests/src/tests/help/__snapshots__/help.test.ts.snap b/packages/cli/ete-tests/src/tests/help/__snapshots__/help.test.ts.snap index ad693732aeb..a8909f0f8f9 100644 --- a/packages/cli/ete-tests/src/tests/help/__snapshots__/help.test.ts.snap +++ b/packages/cli/ete-tests/src/tests/help/__snapshots__/help.test.ts.snap @@ -1,7 +1,9 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`help > no arguments 1`] = ` -"fern-dev +"(node:21283) [DEP0040] DeprecationWarning: The \`punycode\` module is deprecated. Please use a userland alternative instead. +(Use \`node --trace-deprecation ...\` to show where the warning was created) +fern-dev Commands: fern-dev init Initialize a Fern API diff --git a/packages/cli/ete-tests/src/tests/write-definition/__snapshots__/writeDefinition.test.ts.snap b/packages/cli/ete-tests/src/tests/write-definition/__snapshots__/writeDefinition.test.ts.snap index 591c256bf04..f8917944b6f 100644 --- a/packages/cli/ete-tests/src/tests/write-definition/__snapshots__/writeDefinition.test.ts.snap +++ b/packages/cli/ete-tests/src/tests/write-definition/__snapshots__/writeDefinition.test.ts.snap @@ -67,6 +67,8 @@ service: limit: docs: How many items to return at one time (max 100) type: optional + validation: + max: 100 response: docs: A paged array of pets type: root.Pets @@ -172,6 +174,8 @@ service: limit: docs: How many items to return at one time (max 100) type: optional + validation: + max: 100 response: docs: A paged array of pets type: root.Pets @@ -308,6 +312,8 @@ service: limit: docs: How many items to return at one time (max 100) type: optional + validation: + max: 100 response: docs: A paged array of pets type: neopetsRoot.Pets @@ -1462,12 +1468,16 @@ service: destination: docs: The ID of the destination station type: string + validation: + format: uuid dogs: docs: Only return trips where dogs are known to be allowed type: optional origin: docs: The ID of the origin station type: string + validation: + format: uuid response: docs: A list of available train trips type: GetTripsResponse diff --git a/packages/cli/ete-tests/src/tests/write-definition/fixtures/header-overrides/fern/.definition/pets.yml b/packages/cli/ete-tests/src/tests/write-definition/fixtures/header-overrides/fern/.definition/pets.yml index f25130e86d3..5560f3dd1cf 100644 --- a/packages/cli/ete-tests/src/tests/write-definition/fixtures/header-overrides/fern/.definition/pets.yml +++ b/packages/cli/ete-tests/src/tests/write-definition/fixtures/header-overrides/fern/.definition/pets.yml @@ -30,6 +30,8 @@ service: limit: docs: How many items to return at one time (max 100) type: optional + validation: + max: 100 response: docs: A paged array of pets type: root.Pets diff --git a/packages/cli/ete-tests/src/tests/write-definition/fixtures/namespaced/fern/.definition/neopets/pets.yml b/packages/cli/ete-tests/src/tests/write-definition/fixtures/namespaced/fern/.definition/neopets/pets.yml index e388ff71933..a4a02c84255 100644 --- a/packages/cli/ete-tests/src/tests/write-definition/fixtures/namespaced/fern/.definition/neopets/pets.yml +++ b/packages/cli/ete-tests/src/tests/write-definition/fixtures/namespaced/fern/.definition/neopets/pets.yml @@ -32,6 +32,8 @@ service: limit: docs: How many items to return at one time (max 100) type: optional + validation: + max: 100 response: docs: A paged array of pets type: neopetsRoot.Pets diff --git a/packages/cli/ete-tests/src/tests/write-definition/fixtures/namespaced/fern/.definition/trains/trips.yml b/packages/cli/ete-tests/src/tests/write-definition/fixtures/namespaced/fern/.definition/trains/trips.yml index d6acafb693d..8fa053dea56 100644 --- a/packages/cli/ete-tests/src/tests/write-definition/fixtures/namespaced/fern/.definition/trains/trips.yml +++ b/packages/cli/ete-tests/src/tests/write-definition/fixtures/namespaced/fern/.definition/trains/trips.yml @@ -83,12 +83,16 @@ service: destination: docs: The ID of the destination station type: string + validation: + format: uuid dogs: docs: Only return trips where dogs are known to be allowed type: optional origin: docs: The ID of the origin station type: string + validation: + format: uuid response: docs: A list of available train trips type: GetTripsResponse diff --git a/packages/cli/ete-tests/src/tests/write-definition/fixtures/petstore/fern/.definition/pets.yml b/packages/cli/ete-tests/src/tests/write-definition/fixtures/petstore/fern/.definition/pets.yml index f25130e86d3..5560f3dd1cf 100644 --- a/packages/cli/ete-tests/src/tests/write-definition/fixtures/petstore/fern/.definition/pets.yml +++ b/packages/cli/ete-tests/src/tests/write-definition/fixtures/petstore/fern/.definition/pets.yml @@ -30,6 +30,8 @@ service: limit: docs: How many items to return at one time (max 100) type: optional + validation: + max: 100 response: docs: A paged array of pets type: root.Pets