Description
Description
TypeScript is treating the numeric status codes as invalid TypeScript and is throwing error when wildcard status codes like 5XX
are used. You can see the output and errors in the TypeScript playground.
Name | Version |
---|---|
openapi-typescript |
6.10.0 - from npx |
Node.js | 16.16.x |
OS + version | macOS 12 |
Reproduction
- Convert the following spec.
- Copy/paste the resulting TypeScript file into the TypeScript playground](https://www.typescriptlang.org/play)
- See the error around the
5xx
status code
openapi: 3.0.0
info:
title: Test API
version: 1.0.0
servers:
- url: https://my-api.com
description: Test
paths:
/path:
get:
operationId: test
responses:
"200":
$ref: "#/components/responses/Success"
"5XX":
$ref: "#/components/responses/Error"
components:
responses:
Success:
description: A response
content:
application/json:
schema:
type: string
Error:
description: Details
content:
application/json:
schema:
type: string
Expected result
Response codes should probably be strings. The spec states that the responses objects keys should always be quoted.
This field MUST be enclosed in quotation marks (for example, "200") for compatibility between JSON and YAML. To define a range of response codes, this field MAY contain the uppercase wildcard character
X
. For example,2XX
represents all response codes between[200-299]
.
It seems like the spec really intends for this to be a string. Searching around I think this might have been introduced in #381?
Checklist
- I’m willing to open a PR (see CONTRIBUTING.md)