You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// index.jsimportOASNormalizefrom'oas-normalize';constyaml=`openapi: 3.0.4info: version: 1.0.0 title: Petstore simple w/o tagsservers: - url: https://httpbin.orgpaths: '/pet/{id}': parameters: - name: id in: path required: true schema: type: integer get: summary: Find a pet description: This operation will find a pet in the database. responses: '400': description: Invalid status value security: []`;constoas=newOASNormalize(yaml);constdefinition=awaitoas.validate();
Install and run:
npm install
node index.js
Expected result
The script would run without any issues.
Actual result
The script crashes with error:
SyntaxError: Unsupported OpenAPI version: 3.0.4. Swagger Parser only supports versions 3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.1.0
at OpenAPIParser.parse (/path/to/repro/node_modules/@readme/openapi-parser/lib/index.js:95:19)
at async OpenAPIParser.resolve (/path/to/repro/node_modules/@readme/json-schema-ref-parser/lib/index.js:189:5)
at async OpenAPIParser.dereference (/path/to/repro/node_modules/@readme/json-schema-ref-parser/lib/index.js:271:5)
at async OpenAPIParser.validate (/path/to/repro/node_modules/@readme/openapi-parser/lib/index.js:152:5)
at async file:///path/to/repro/repro.js:28:20 {
toJSON: [Function: toJSON],
[Symbol(nodejs.util.inspect.custom)]: [Function: inspect]
}
Node.js v23.5.0
Notes
Support for the latest minor versions of OAS was quite recently fixed in the upstream openapi-parser: APIDevTools/swagger-parser#264
Since there are no functional changes in the latest versions, it's really only about adding support for the newer versions.
As a very ugly workaround, I can (sometimes) modify the OAS before parsing, e.g. for the example above:
Ideally I'd raise this issue against openapi-parser repo, but it doesn't have issues enabled, so I report it here.
Steps to reproduce
Create the following files:
package.json
Install and run:
Expected result
The script would run without any issues.
Actual result
The script crashes with error:
Notes
Support for the latest minor versions of OAS was quite recently fixed in the upstream openapi-parser: APIDevTools/swagger-parser#264
Since there are no functional changes in the latest versions, it's really only about adding support for the newer versions.
As a very ugly workaround, I can (sometimes) modify the OAS before parsing, e.g. for the example above:
The text was updated successfully, but these errors were encountered: