From ba6977efd680f22455fce1be4dc43aa37901edce Mon Sep 17 00:00:00 2001 From: Young Jun Joo Date: Wed, 5 Mar 2025 15:16:14 -0500 Subject: [PATCH 1/2] Fix integer type representation in OpenAPI schema generation This commit fixes an issue where query parameters with integer types were incorrectly being represented as 'number' type in the generated OpenAPI specifications. Now integer types are properly represented as 'integer' in the schema, ensuring that tools consuming the OpenAPI specification correctly understand the expected data type of query parameters. --- packages/openapi-generator/src/openapi.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/openapi-generator/src/openapi.ts b/packages/openapi-generator/src/openapi.ts index a7fe83de..7f0d3736 100644 --- a/packages/openapi-generator/src/openapi.ts +++ b/packages/openapi-generator/src/openapi.ts @@ -20,18 +20,23 @@ export function schemaToOpenAPI( switch (schema.type) { case 'boolean': case 'string': - case 'number': return { type: schema.type, ...(schema.enum ? { enum: schema.enum } : {}), ...defaultOpenAPIObject, }; - case 'integer': + case 'number': return { type: 'number', ...(schema.enum ? { enum: schema.enum } : {}), ...defaultOpenAPIObject, }; + case 'integer': + return { + type: 'integer', + ...(schema.enum ? { enum: schema.enum } : {}), + ...defaultOpenAPIObject, + }; case 'null': // TODO: OpenAPI v3 does not have an explicit null type, is there a better way to represent this? // Or should we just conflate explicit null and undefined properties? From 4ddb7459c510173727a7b4aa29359c295bdc7a4e Mon Sep 17 00:00:00 2001 From: Young Jun Joo Date: Thu, 6 Mar 2025 15:52:37 -0500 Subject: [PATCH 2/2] fix: typo --- website/docs/intro.md | 2 +- website/src/components/HomepageFeatures/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/intro.md b/website/docs/intro.md index cfcbddea..a29ab6d6 100644 --- a/website/docs/intro.md +++ b/website/docs/intro.md @@ -13,5 +13,5 @@ logic is never called with data it can't handle. [parse, don't validate]: https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/ -[type and semantic analysis]: +[type and semantic validation]: https://bitgo.github.io/api-ts/docs/tutorial-basics/create-an-api-spec/#what-problem-does-io-ts-http-solve diff --git a/website/src/components/HomepageFeatures/index.js b/website/src/components/HomepageFeatures/index.js index 4ccdb8c2..e5f9c7fa 100644 --- a/website/src/components/HomepageFeatures/index.js +++ b/website/src/components/HomepageFeatures/index.js @@ -38,7 +38,7 @@ export default function HomepageFeatures() { ), }, { - title: 'API definition', + title: 'API Specification', lightSvg: require('@site/static/img/api-m-light-blue.svg').default, darkSvg: require('@site/static/img/api-m-dark-blue.svg').default, description: (