Skip to content

Commit ba6977e

Browse files
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.
1 parent 3359aeb commit ba6977e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/openapi-generator/src/openapi.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,23 @@ export function schemaToOpenAPI(
2020
switch (schema.type) {
2121
case 'boolean':
2222
case 'string':
23-
case 'number':
2423
return {
2524
type: schema.type,
2625
...(schema.enum ? { enum: schema.enum } : {}),
2726
...defaultOpenAPIObject,
2827
};
29-
case 'integer':
28+
case 'number':
3029
return {
3130
type: 'number',
3231
...(schema.enum ? { enum: schema.enum } : {}),
3332
...defaultOpenAPIObject,
3433
};
34+
case 'integer':
35+
return {
36+
type: 'integer',
37+
...(schema.enum ? { enum: schema.enum } : {}),
38+
...defaultOpenAPIObject,
39+
};
3540
case 'null':
3641
// TODO: OpenAPI v3 does not have an explicit null type, is there a better way to represent this?
3742
// Or should we just conflate explicit null and undefined properties?

0 commit comments

Comments
 (0)