-
-
Notifications
You must be signed in to change notification settings - Fork 603
Closed
Labels
bugSomething isn't workingSomething isn't workingopenapi-tsRelevant to the openapi-typescript libraryRelevant to the openapi-typescript library
Description
openapi-typescript version
7.6.0
Node.js version
20.17.0
OS + version
Arch Linux
Description
openapi 3.1 json:
{
"name": "metrics",
"in": "query",
"required": true,
"schema": {
"type": "array",
"enum": [
"product_requirements_mandatory_completed",
"product_requirements_optional_completed",
"product_requirements_total_completed"
],
"items": {
"type": "string"
},
"minItems": 1
}
},
Generated typings:
export interface operations {
'analytics.data': {
parameters: {
query: {
metrics:
| 'product_requirements_mandatory_completed'
| 'product_requirements_optional_completed'
| 'product_requirements_total_completed'
Expected:
export interface operations {
'analytics.data': {
parameters: {
query: {
metrics: Array<
| 'product_requirements_mandatory_completed'
| 'product_requirements_optional_completed'
| 'product_requirements_total_completed'
>
Reproduction
analytics.json:
{
"openapi": "3.1.0",
"info": {
"title": "API Portal",
"version": "1.0.0",
"description": "This is the **Analytics API** description"
},
"paths": {
"\/analytics\/data": {
"get": {
"operationId": "analytics.data",
"tags": [
"Analytics"
],
"parameters": [
{
"name": "metrics",
"in": "query",
"required": true,
"schema": {
"type": "array",
"enum": [
"product_requirements_mandatory_completed",
"product_requirements_optional_completed",
"product_requirements_total_completed"
],
"items": {
"type": "string"
},
"minItems": 1
}
}
],
"responses": {
"200": {
"description": "`AnalyticsResponseResource`",
"content": {
"application\/json": {
"schema": {
"$ref": "#\/components\/schemas\/AnalyticsResponseResource"
}
}
}
},
"403": {
"$ref": "#\/components\/responses\/AuthorizationException"
}
}
}
}
},
"components": {
"securitySchemes": {
"http": {
"type": "http",
"scheme": "bearer",
"bearerFormat": ""
}
},
"schemas": {
"AnalyticsResponseDataResource": {
"type": "object",
"properties": {
"metricValues": {
"type": "array",
"items": {
"anyOf": [
{
"type": "integer"
},
{
"type": "number"
}
]
}
}
},
"required": [
"metricValues"
],
"title": "AnalyticsResponseDataResource"
},
"AnalyticsResponseResource": {
"type": "object",
"properties": {
"metricHeaders": {
"type": "string"
},
"data": {
"type": "array",
"items": {
"$ref": "#\/components\/schemas\/AnalyticsResponseDataResource"
}
}
},
"required": [
"metricHeaders",
"data"
],
"title": "AnalyticsResponseResource"
}
},
"responses": {
"AuthorizationException": {
"description": "Authorization error",
"content": {
"application\/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string",
"description": "Error overview."
}
},
"required": [
"message"
]
}
}
}
}
}
}
}
npx openapi-typescript analytics.json -o analytics.ts
Expected result
Array<'product_requirements_mandatory_completed' | 'product_requirements_optional_completed' | 'product_requirements_total_completed'>
Required
- My OpenAPI schema is valid and passes the Redocly validator (
npx @redocly/cli@latest lint)
Extra
- I’m willing to open a PR (see CONTRIBUTING.md)
phmasek
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingopenapi-tsRelevant to the openapi-typescript libraryRelevant to the openapi-typescript library