From 00dd9f49193590fe53eddbc37d93247f13b838a1 Mon Sep 17 00:00:00 2001 From: Deep Singhvi Date: Fri, 1 Nov 2024 07:54:32 -0400 Subject: [PATCH] fix(cli): parse examples from primitive OpenAPI schemas (#5061) --- .../converters/endpoint/convertParameters.ts | 6 - .../src/openapi/v3/extensions/getExamples.ts | 10 ++ .../src/schema/examples/getExample.ts | 35 +++-- .../__snapshots__/openapi-docs/ada.json | 9 +- .../__snapshots__/openapi-docs/apiture.json | 39 +++++- .../__snapshots__/openapi-ir/ada.json | 25 +++- .../__snapshots__/openapi-ir/apiture.json | 123 +++++++++++++++++- .../__snapshots__/openapi-ir/webflow.json | 12 ++ .../__test__/__snapshots__/openapi/ada.json | 9 +- .../__snapshots__/openapi/apiture.json | 39 +++++- .../finalIr/types/EndpointResponseExample.ts | 8 +- .../parseIr/types/ResponseWithExample.ts | 12 +- packages/cli/cli/versions.yml | 7 + 13 files changed, 291 insertions(+), 43 deletions(-) create mode 100644 packages/cli/api-importers/openapi/openapi-ir-parser/src/openapi/v3/extensions/getExamples.ts diff --git a/packages/cli/api-importers/openapi/openapi-ir-parser/src/openapi/v3/converters/endpoint/convertParameters.ts b/packages/cli/api-importers/openapi/openapi-ir-parser/src/openapi/v3/converters/endpoint/convertParameters.ts index a020df902f4..b2a18deb15a 100644 --- a/packages/cli/api-importers/openapi/openapi-ir-parser/src/openapi/v3/converters/endpoint/convertParameters.ts +++ b/packages/cli/api-importers/openapi/openapi-ir-parser/src/openapi/v3/converters/endpoint/convertParameters.ts @@ -65,12 +65,6 @@ export function convertParameters({ const parameterBreadcrumbs = [...requestBreadcrumbs, resolvedParameter.name]; const generatedName = getGeneratedTypeName(parameterBreadcrumbs); - if (getExamplesString({ schema: resolvedParameter, logger: context.logger })?.includes(" ")) { - context.logger.warn( - "Parameter example contains a space, which is ambiguous. Consider using enums for multiple examples, or use an encoding if a space is part of the parameter." - ); - } - let schema = resolvedParameter.schema != null ? convertSchema( diff --git a/packages/cli/api-importers/openapi/openapi-ir-parser/src/openapi/v3/extensions/getExamples.ts b/packages/cli/api-importers/openapi/openapi-ir-parser/src/openapi/v3/extensions/getExamples.ts new file mode 100644 index 00000000000..ac53194f831 --- /dev/null +++ b/packages/cli/api-importers/openapi/openapi-ir-parser/src/openapi/v3/extensions/getExamples.ts @@ -0,0 +1,10 @@ +import { OpenAPIV3 } from "openapi-types"; +import { getExtension } from "../../../getExtension"; + +export function getExamples(schema: OpenAPIV3.SchemaObject | OpenAPIV3.ParameterObject): unknown[] { + const examples = getExtension(schema, "examples"); + if (examples != null && Array.isArray(examples)) { + return examples; + } + return []; +} diff --git a/packages/cli/api-importers/openapi/openapi-ir-parser/src/schema/examples/getExample.ts b/packages/cli/api-importers/openapi/openapi-ir-parser/src/schema/examples/getExample.ts index 7612a1e3040..d6341c95a26 100644 --- a/packages/cli/api-importers/openapi/openapi-ir-parser/src/schema/examples/getExample.ts +++ b/packages/cli/api-importers/openapi/openapi-ir-parser/src/schema/examples/getExample.ts @@ -1,5 +1,7 @@ import { Logger } from "@fern-api/logger"; import { OpenAPIV3 } from "openapi-types"; +import { getExtension } from "../../getExtension"; +import { getExamples } from "../../openapi/v3/extensions/getExamples"; export function getExampleAsNumber({ schema, @@ -13,12 +15,15 @@ export function getExampleAsNumber({ if (schema.example != null && typeof schema.example === "number") { return schema.example; } + const examples = getExamples(schema); + for (const example of examples ?? []) { + if (typeof example === "number") { + return example; + } + } if (fallback && typeof fallback === "number") { return fallback; - } else if (fallback) { - logger.warn(`Expected fallback to be a number, but got ${typeof fallback}`); } - return undefined; } @@ -34,10 +39,14 @@ export function getExampleAsBoolean({ if (schema.example != null && typeof schema.example === "boolean") { return schema.example; } + const examples = getExamples(schema); + for (const example of examples ?? []) { + if (typeof example === "boolean") { + return example; + } + } if (fallback && typeof fallback === "boolean") { return fallback; - } else if (fallback) { - logger.warn(`Expected fallback to be a boolean, but got ${typeof fallback}`); } return undefined; } @@ -54,10 +63,14 @@ export function getExamplesString({ if (schema.example != null && typeof schema.example === "string") { return schema.example; } + const examples = getExamples(schema); + for (const example of examples ?? []) { + if (typeof example === "string") { + return example; + } + } if (fallback && typeof fallback === "string") { return fallback; - } else if (fallback) { - logger.warn(`Expected fallback to be a string, but got ${typeof fallback}`); } return undefined; } @@ -74,10 +87,14 @@ export function getExampleAsArray({ if (schema.example != null && Array.isArray(schema.example)) { return schema.example; } + const examples = getExamples(schema); + for (const example of examples ?? []) { + if (Array.isArray(example)) { + return example; + } + } if (fallback && Array.isArray(fallback)) { return fallback; - } else if (fallback) { - logger.warn(`Expected fallback to be a array, but got ${typeof fallback}`); } return undefined; } diff --git a/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi-docs/ada.json b/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi-docs/ada.json index fede910767c..5669b63f4cd 100644 --- a/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi-docs/ada.json +++ b/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi-docs/ada.json @@ -534,6 +534,10 @@ types: ], "examples": [ { + "query-parameters": { + "cursor": "65a17e3f43bec88e2792d0eb", + "limit": 8, + }, "response": { "body": { "key": "value", @@ -677,7 +681,10 @@ service: - root.GetEndUsersRequestTooManyRequestsError - root.GetEndUsersRequestInternalServerError examples: - - response: + - query-parameters: + cursor: 65a17e3f43bec88e2792d0eb + limit: 8 + response: body: key: value source: diff --git a/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi-docs/apiture.json b/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi-docs/apiture.json index 0f8e91ecc82..590a06905ad 100644 --- a/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi-docs/apiture.json +++ b/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi-docs/apiture.json @@ -13859,6 +13859,9 @@ Cutoff times are very slowly changing data. This is a _conditional operation_ wh "path-parameters": { "institutionId": "TIBURON", }, + "query-parameters": { + "timeZoneId": "America/New_York", + }, "response": { "body": { "items": [ @@ -14182,7 +14185,7 @@ This information provides hints to clients, allowing bank customers to select tr "examples": [ { "query-parameters": { - "countryCode": "countryCode", + "countryCode": "US", "locator": "locator", "locatorType": "abaRoutingNumber", }, @@ -14197,7 +14200,7 @@ This information provides hints to clients, allowing bank customers to select tr "locality": "Andalasia", "postalCode": "28407", "regionCode": "NC", - "regionName": "regionName", + "regionName": "NC", }, "locator": "503000196", "locatorType": "abaRoutingNumber", @@ -14212,6 +14215,7 @@ This information provides hints to clients, allowing bank customers to select tr "locality": "Andalasia", "postalCode": "28407", "regionCode": "NC", + "regionName": "NC", }, "locator": "503000196", "locatorType": "abaRoutingNumber", @@ -14314,7 +14318,7 @@ service: - query-parameters: locator: locator locatorType: abaRoutingNumber - countryCode: countryCode + countryCode: US response: body: found: true @@ -14325,7 +14329,7 @@ service: address2: Building 14, Suite 1500 locality: Andalasia countryCode: US - regionName: regionName + regionName: NC regionCode: NC postalCode: '28407' locator: '503000196' @@ -14337,6 +14341,7 @@ service: address2: Building 14, Suite 1500 locality: Andalasia countryCode: US + regionName: NC regionCode: NC postalCode: '28407' locator: '503000196' @@ -14469,6 +14474,8 @@ service: examples: - path-parameters: institutionId: TIBURON + query-parameters: + timeZoneId: America/New_York response: body: timeZoneId: America/New_York @@ -15271,6 +15278,13 @@ The default response lists only recent transactions. Normally, this is transacti "path-parameters": { "accountId": "accountId", }, + "query-parameters": { + "amount": "[1000.00,1200.00)", + "checkNumber": "[1000,1200)", + "createdOn": "2022-05-19", + "occurredOn": "2023-05-19", + "postedOn": "2022-05-19", + }, "response": { "body": { "count": 2381, @@ -15574,6 +15588,12 @@ service: examples: - path-parameters: accountId: accountId + query-parameters: + occurredOn: '2023-05-19' + createdOn: '2022-05-19' + postedOn: '2022-05-19' + amount: '[1000.00,1200.00)' + checkNumber: '[1000,1200)' response: body: limit: 10 @@ -15842,6 +15862,11 @@ Note: This operation requires an identity challenge if the financial institution ], "examples": [ { + "query-parameters": { + "creditsOn": "2022-05-19", + "debitsOn": "2022-05-19", + "scheduledOn": "2022-05-19", + }, "response": { "body": { "count": 1, @@ -16137,7 +16162,11 @@ service: - root.TransfersListTransfersRequestForbiddenError - root.TransfersListTransfersRequestUnprocessableEntityError examples: - - response: + - query-parameters: + scheduledOn: '2022-05-19' + debitsOn: '2022-05-19' + creditsOn: '2022-05-19' + response: body: limit: 10 nextPage_url: >- diff --git a/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi-ir/ada.json b/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi-ir/ada.json index 439d7a7ffa8..bb7d87ed3f8 100644 --- a/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi-ir/ada.json +++ b/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi-ir/ada.json @@ -903,6 +903,7 @@ "generatedName": "GetEndUsersRequestCursor", "value": { "schema": { + "example": "65a17e3f43bec88e2792d0eb", "type": "string" }, "generatedName": "GetEndUsersRequestCursor", @@ -926,6 +927,7 @@ "schema": { "minimum": 1, "maximum": 100, + "example": 8, "type": "int" }, "generatedName": "GetEndUsersRequestLimit", @@ -1247,7 +1249,28 @@ "examples": [ { "pathParameters": [], - "queryParameters": [], + "queryParameters": [ + { + "name": "cursor", + "value": { + "value": { + "value": "65a17e3f43bec88e2792d0eb", + "type": "string" + }, + "type": "primitive" + } + }, + { + "name": "limit", + "value": { + "value": { + "value": 8, + "type": "int" + }, + "type": "primitive" + } + } + ], "headers": [], "response": { "value": { diff --git a/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi-ir/apiture.json b/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi-ir/apiture.json index bc62d72eef9..aebaa96b990 100644 --- a/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi-ir/apiture.json +++ b/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi-ir/apiture.json @@ -7094,6 +7094,7 @@ "schema": { "minLength": 2, "maxLength": 2, + "example": "US", "type": "string" }, "generatedName": "InstitutionsLookUpInstitutionByLocatorRequestCountryCode", @@ -7715,7 +7716,7 @@ "name": "countryCode", "value": { "value": { - "value": "countryCode", + "value": "US", "type": "string" }, "type": "primitive" @@ -7774,7 +7775,7 @@ }, "regionName": { "value": { - "value": "regionName", + "value": "NC", "type": "string" }, "type": "primitive" @@ -7851,6 +7852,13 @@ }, "type": "primitive" }, + "regionName": { + "value": { + "value": "NC", + "type": "string" + }, + "type": "primitive" + }, "regionCode": { "value": { "value": "NC", @@ -9837,7 +9845,18 @@ } } ], - "queryParameters": [], + "queryParameters": [ + { + "name": "timeZoneId", + "value": { + "value": { + "value": "America/New_York", + "type": "string" + }, + "type": "primitive" + } + } + ], "headers": [], "response": { "value": { @@ -11383,6 +11402,7 @@ "value": { "schema": { "pattern": "^\\d{4}-\\d{2}-\\d{2}|([[(](\\d{4}-\\d{2}-\\d{2},(\\d{4}-\\d{2}-\\d{2})?|,\\d{4}-\\d{2}-\\d{2})[)\\]])$", + "example": "2023-05-19", "type": "string" }, "generatedName": "TransactionsListTransactionsRequestOccurredOn", @@ -12588,7 +12608,58 @@ } } ], - "queryParameters": [], + "queryParameters": [ + { + "name": "occurredOn", + "value": { + "value": { + "value": "2023-05-19", + "type": "string" + }, + "type": "primitive" + } + }, + { + "name": "createdOn", + "value": { + "value": { + "value": "2022-05-19", + "type": "string" + }, + "type": "primitive" + } + }, + { + "name": "postedOn", + "value": { + "value": { + "value": "2022-05-19", + "type": "string" + }, + "type": "primitive" + } + }, + { + "name": "amount", + "value": { + "value": { + "value": "[1000.00,1200.00)", + "type": "string" + }, + "type": "primitive" + } + }, + { + "name": "checkNumber", + "value": { + "value": { + "value": "[1000,1200)", + "type": "string" + }, + "type": "primitive" + } + } + ], "headers": [], "response": { "value": { @@ -14256,7 +14327,38 @@ "examples": [ { "pathParameters": [], - "queryParameters": [], + "queryParameters": [ + { + "name": "scheduledOn", + "value": { + "value": { + "value": "2022-05-19", + "type": "string" + }, + "type": "primitive" + } + }, + { + "name": "debitsOn", + "value": { + "value": { + "value": "2022-05-19", + "type": "string" + }, + "type": "primitive" + } + }, + { + "name": "creditsOn", + "value": { + "value": { + "value": "2022-05-19", + "type": "string" + }, + "type": "primitive" + } + } + ], "headers": [], "response": { "value": { @@ -18890,6 +18992,7 @@ "pattern": "^\\*[- _a-zA-Z0-9.]{1,4}$", "minLength": 2, "maxLength": 5, + "example": "*1008", "type": "string" }, "generatedName": "MaskedAccountNumber", @@ -18903,6 +19006,7 @@ "pattern": "^[- a-zA-Z0-9.]{1,32}$", "minLength": 1, "maxLength": 32, + "example": "123456789", "type": "string" }, "generatedName": "FullAccountNumber", @@ -19808,6 +19912,7 @@ "schema": { "pattern": "^America\\/[a-zA-Z_]+(?:\\/[a-zA-Z_]+)*", "maxLength": 36, + "example": "America/New_York", "type": "string" }, "generatedName": "TimeZoneId", @@ -22165,6 +22270,7 @@ "description": "A date range, supporting inclusive or exclusive endpoints. Dates ranges use dates expressed in `YYYY-MM-DD` [RFC 3339](https://tools.ietf.org/html/rfc3339) `date` format. The value may have the following forms: ", "schema": { "pattern": "^\\d{4}-\\d{2}-\\d{2}|([[(](\\d{4}-\\d{2}-\\d{2},(\\d{4}-\\d{2}-\\d{2})?|,\\d{4}-\\d{2}-\\d{2})[)\\]])$", + "example": "2022-05-19", "type": "string" }, "generatedName": "DateRange", @@ -22176,6 +22282,7 @@ "description": "A monetary amount range, supporting inclusive or exclusive endpoints. The value may have the following forms: ", "schema": { "pattern": "^((\\d+(\\.\\d{0,2})?)|([\\[\\(](((\\d+(\\.\\d{0,2})?),((\\d+(\\.\\d{0,2})?))?)|(,(\\d+(\\.\\d{0,2})?)))[\\]\\)]))$", + "example": "[1000.00,1200.00)", "type": "string" }, "generatedName": "AmountRange", @@ -22407,6 +22514,7 @@ "schema": { "minLength": 2, "maxLength": 20, + "example": "NC", "type": "string" }, "generatedName": "AddressRegionName", @@ -22429,6 +22537,7 @@ "schema": { "minLength": 2, "maxLength": 2, + "example": "NC", "type": "string" }, "generatedName": "AddressRegionCode", @@ -22449,6 +22558,7 @@ "schema": { "minLength": 5, "maxLength": 10, + "example": "20521", "type": "string" }, "generatedName": "AddressPostalCode", @@ -22496,6 +22606,7 @@ "description": "A positive integer range, supporting inclusive or exclusive endpoints. The value may have the following forms: ", "schema": { "pattern": "^\\d+|([[(](\\d+,(\\d+)?|,\\d+)[)\\]])$", + "example": "[1000,1200)", "type": "string" }, "generatedName": "PositiveIntegerRange", @@ -23101,6 +23212,7 @@ "description": "The city/town/municipality of the address.", "schema": { "maxLength": 20, + "example": "Wilmington", "type": "string" }, "generatedName": "AddressFieldsLocality", @@ -23118,6 +23230,7 @@ "schema": { "minLength": 2, "maxLength": 2, + "example": "US", "type": "string" }, "generatedName": "AddressFieldsCountryCode", diff --git a/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi-ir/webflow.json b/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi-ir/webflow.json index 60eebacb6f4..3df9a077168 100644 --- a/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi-ir/webflow.json +++ b/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi-ir/webflow.json @@ -49791,6 +49791,7 @@ "schema": { "description": "Name of the Product variant/Option", "schema": { + "example": "Royal Blue", "type": "string" }, "generatedName": "ProductsListResponseItemsItemProductFieldDataSkuPropertiesItemEnumItemName", @@ -49806,6 +49807,7 @@ "schema": { "description": "Slug for the Product variant/Option in the Site URL structure", "schema": { + "example": "royal-blue", "type": "string" }, "generatedName": "ProductsListResponseItemsItemProductFieldDataSkuPropertiesItemEnumItemSlug", @@ -52171,6 +52173,7 @@ "schema": { "description": "Name of the Product variant/Option", "schema": { + "example": "Royal Blue", "type": "string" }, "generatedName": "ProductsCreateRequestProductFieldDataSkuPropertiesItemEnumItemName", @@ -52186,6 +52189,7 @@ "schema": { "description": "Slug for the Product variant/Option in the Site URL structure", "schema": { + "example": "royal-blue", "type": "string" }, "generatedName": "ProductsCreateRequestProductFieldDataSkuPropertiesItemEnumItemSlug", @@ -53527,6 +53531,7 @@ "schema": { "description": "Name of the Product variant/Option", "schema": { + "example": "Royal Blue", "type": "string" }, "generatedName": "ProductsCreateResponseProductFieldDataSkuPropertiesItemEnumItemName", @@ -53542,6 +53547,7 @@ "schema": { "description": "Slug for the Product variant/Option in the Site URL structure", "schema": { + "example": "royal-blue", "type": "string" }, "generatedName": "ProductsCreateResponseProductFieldDataSkuPropertiesItemEnumItemSlug", @@ -55909,6 +55915,7 @@ "schema": { "description": "Name of the Product variant/Option", "schema": { + "example": "Royal Blue", "type": "string" }, "generatedName": "ProductsGetResponseProductFieldDataSkuPropertiesItemEnumItemName", @@ -55924,6 +55931,7 @@ "schema": { "description": "Slug for the Product variant/Option in the Site URL structure", "schema": { + "example": "royal-blue", "type": "string" }, "generatedName": "ProductsGetResponseProductFieldDataSkuPropertiesItemEnumItemSlug", @@ -58334,6 +58342,7 @@ "schema": { "description": "Name of the Product variant/Option", "schema": { + "example": "Royal Blue", "type": "string" }, "generatedName": "ProductsUpdateRequestProductFieldDataSkuPropertiesItemEnumItemName", @@ -58349,6 +58358,7 @@ "schema": { "description": "Slug for the Product variant/Option in the Site URL structure", "schema": { + "example": "royal-blue", "type": "string" }, "generatedName": "ProductsUpdateRequestProductFieldDataSkuPropertiesItemEnumItemSlug", @@ -59681,6 +59691,7 @@ "schema": { "description": "Name of the Product variant/Option", "schema": { + "example": "Royal Blue", "type": "string" }, "generatedName": "ProductsUpdateResponseFieldDataSkuPropertiesItemEnumItemName", @@ -59696,6 +59707,7 @@ "schema": { "description": "Slug for the Product variant/Option in the Site URL structure", "schema": { + "example": "royal-blue", "type": "string" }, "generatedName": "ProductsUpdateResponseFieldDataSkuPropertiesItemEnumItemSlug", diff --git a/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi/ada.json b/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi/ada.json index 7df1dcb72de..92b9fae4a97 100644 --- a/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi/ada.json +++ b/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi/ada.json @@ -296,6 +296,10 @@ types: ], "examples": [ { + "query-parameters": { + "cursor": "65a17e3f43bec88e2792d0eb", + "limit": 8, + }, "response": { "body": { "key": "value", @@ -439,7 +443,10 @@ service: - root.TooManyRequestsError - root.InternalServerError examples: - - response: + - query-parameters: + cursor: 65a17e3f43bec88e2792d0eb + limit: 8 + response: body: key: value source: diff --git a/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi/apiture.json b/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi/apiture.json index 25d52fabb8f..29d88fed784 100644 --- a/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi/apiture.json +++ b/packages/cli/api-importers/openapi/openapi-ir-to-fern-tests/src/__test__/__snapshots__/openapi/apiture.json @@ -6481,6 +6481,9 @@ Cutoff times are very slowly changing data. This is a _conditional operation_ wh "path-parameters": { "institutionId": "TIBURON", }, + "query-parameters": { + "timeZoneId": "America/New_York", + }, "response": { "body": { "items": [ @@ -6804,7 +6807,7 @@ This information provides hints to clients, allowing bank customers to select tr "examples": [ { "query-parameters": { - "countryCode": "countryCode", + "countryCode": "US", "locator": "locator", "locatorType": "abaRoutingNumber", }, @@ -6819,7 +6822,7 @@ This information provides hints to clients, allowing bank customers to select tr "locality": "Andalasia", "postalCode": "28407", "regionCode": "NC", - "regionName": "regionName", + "regionName": "NC", }, "locator": "503000196", "locatorType": "abaRoutingNumber", @@ -6834,6 +6837,7 @@ This information provides hints to clients, allowing bank customers to select tr "locality": "Andalasia", "postalCode": "28407", "regionCode": "NC", + "regionName": "NC", }, "locator": "503000196", "locatorType": "abaRoutingNumber", @@ -6935,7 +6939,7 @@ service: - query-parameters: locator: locator locatorType: abaRoutingNumber - countryCode: countryCode + countryCode: US response: body: found: true @@ -6946,7 +6950,7 @@ service: address2: Building 14, Suite 1500 locality: Andalasia countryCode: US - regionName: regionName + regionName: NC regionCode: NC postalCode: '28407' locator: '503000196' @@ -6958,6 +6962,7 @@ service: address2: Building 14, Suite 1500 locality: Andalasia countryCode: US + regionName: NC regionCode: NC postalCode: '28407' locator: '503000196' @@ -7090,6 +7095,8 @@ service: examples: - path-parameters: institutionId: TIBURON + query-parameters: + timeZoneId: America/New_York response: body: timeZoneId: America/New_York @@ -7880,6 +7887,13 @@ The default response lists only recent transactions. Normally, this is transacti "path-parameters": { "accountId": "accountId", }, + "query-parameters": { + "amount": "[1000.00,1200.00)", + "checkNumber": "[1000,1200)", + "createdOn": "2022-05-19", + "occurredOn": "2023-05-19", + "postedOn": "2022-05-19", + }, "response": { "body": { "count": 2381, @@ -8183,6 +8197,12 @@ service: examples: - path-parameters: accountId: accountId + query-parameters: + occurredOn: '2023-05-19' + createdOn: '2022-05-19' + postedOn: '2022-05-19' + amount: '[1000.00,1200.00)' + checkNumber: '[1000,1200)' response: body: limit: 10 @@ -8451,6 +8471,11 @@ Note: This operation requires an identity challenge if the financial institution ], "examples": [ { + "query-parameters": { + "creditsOn": "2022-05-19", + "debitsOn": "2022-05-19", + "scheduledOn": "2022-05-19", + }, "response": { "body": { "count": 1, @@ -8746,7 +8771,11 @@ service: - root.ForbiddenError - root.UnprocessableEntityError examples: - - response: + - query-parameters: + scheduledOn: '2022-05-19' + debitsOn: '2022-05-19' + creditsOn: '2022-05-19' + response: body: limit: 10 nextPage_url: >- diff --git a/packages/cli/api-importers/openapi/openapi-ir/src/sdk/api/resources/finalIr/types/EndpointResponseExample.ts b/packages/cli/api-importers/openapi/openapi-ir/src/sdk/api/resources/finalIr/types/EndpointResponseExample.ts index 14ade31b162..ed270886849 100644 --- a/packages/cli/api-importers/openapi/openapi-ir/src/sdk/api/resources/finalIr/types/EndpointResponseExample.ts +++ b/packages/cli/api-importers/openapi/openapi-ir/src/sdk/api/resources/finalIr/types/EndpointResponseExample.ts @@ -36,9 +36,9 @@ export declare namespace EndpointResponseExample { export const EndpointResponseExample = { withStreaming: (value: FernOpenapiIr.FullExample[]): FernOpenapiIr.EndpointResponseExample.WithStreaming => { return { - value, + value: value, type: "withStreaming", - _visit <_Result>( + _visit: function <_Result>( this: FernOpenapiIr.EndpointResponseExample.WithStreaming, visitor: FernOpenapiIr.EndpointResponseExample._Visitor<_Result> ) { @@ -49,9 +49,9 @@ export const EndpointResponseExample = { withoutStreaming: (value: FernOpenapiIr.FullExample): FernOpenapiIr.EndpointResponseExample.WithoutStreaming => { return { - value, + value: value, type: "withoutStreaming", - _visit <_Result>( + _visit: function <_Result>( this: FernOpenapiIr.EndpointResponseExample.WithoutStreaming, visitor: FernOpenapiIr.EndpointResponseExample._Visitor<_Result> ) { diff --git a/packages/cli/api-importers/openapi/openapi-ir/src/sdk/api/resources/parseIr/types/ResponseWithExample.ts b/packages/cli/api-importers/openapi/openapi-ir/src/sdk/api/resources/parseIr/types/ResponseWithExample.ts index 199be01f97f..34280af8f90 100644 --- a/packages/cli/api-importers/openapi/openapi-ir/src/sdk/api/resources/parseIr/types/ResponseWithExample.ts +++ b/packages/cli/api-importers/openapi/openapi-ir/src/sdk/api/resources/parseIr/types/ResponseWithExample.ts @@ -59,7 +59,7 @@ export const ResponseWithExample = { return { ...value, type: "file", - _visit <_Result>( + _visit: function <_Result>( this: FernOpenapiIr.ResponseWithExample.File_, visitor: FernOpenapiIr.ResponseWithExample._Visitor<_Result> ) { @@ -72,7 +72,7 @@ export const ResponseWithExample = { return { ...value, type: "json", - _visit <_Result>( + _visit: function <_Result>( this: FernOpenapiIr.ResponseWithExample.Json, visitor: FernOpenapiIr.ResponseWithExample._Visitor<_Result> ) { @@ -85,7 +85,7 @@ export const ResponseWithExample = { return { ...value, type: "text", - _visit <_Result>( + _visit: function <_Result>( this: FernOpenapiIr.ResponseWithExample.Text, visitor: FernOpenapiIr.ResponseWithExample._Visitor<_Result> ) { @@ -98,7 +98,7 @@ export const ResponseWithExample = { return { ...value, type: "streamingSse", - _visit <_Result>( + _visit: function <_Result>( this: FernOpenapiIr.ResponseWithExample.StreamingSse, visitor: FernOpenapiIr.ResponseWithExample._Visitor<_Result> ) { @@ -111,7 +111,7 @@ export const ResponseWithExample = { return { ...value, type: "streamingText", - _visit <_Result>( + _visit: function <_Result>( this: FernOpenapiIr.ResponseWithExample.StreamingText, visitor: FernOpenapiIr.ResponseWithExample._Visitor<_Result> ) { @@ -124,7 +124,7 @@ export const ResponseWithExample = { return { ...value, type: "streamingJson", - _visit <_Result>( + _visit: function <_Result>( this: FernOpenapiIr.ResponseWithExample.StreamingJson, visitor: FernOpenapiIr.ResponseWithExample._Visitor<_Result> ) { diff --git a/packages/cli/cli/versions.yml b/packages/cli/cli/versions.yml index 48a9ae48e90..fb5dddee067 100644 --- a/packages/cli/cli/versions.yml +++ b/packages/cli/cli/versions.yml @@ -1,3 +1,10 @@ +- changelogEntry: + - summary: | + The OpenAPI importer now parses the `examples` field for primitive schema types like `string`, `number`, `array` and `boolean`. + type: fix + irVersion: 53 + version: 0.45.0-rc30 + - changelogEntry: - summary: | The OpenAPI importer now parses the `examples` field that may be present on OpenAPI 3.1 schemas.