Error when the response has a field name called "summary"
openapi-typescript version
7.8.0
Node.js version
20.17.0
OS + version
15
Description
Description If we have the field called "summary" in our response, it wouldn't generate types and throwing the error.
TypeError: schemaObject.summary.replace is not a function
Proposal The response name can be anything and in my humble opinion, we shouldn't check the summary field nested deep inside our 200 responses.
Reproduction
If we have the field/property called "summary" in our response, it wouldn't generate types and throwing the error.
/test:
get:
summary: Test
description: Test
responses:
"200":
description: Example description
content:
application/json:
schema:
type: object
properties:
summary: /* this field will cause the issue */
type: array
Expected result
It should not check only top level summary field.
Required
- [x] My OpenAPI schema is valid and passes the Redocly validator (
npx @redocly/cli@latest lint)
Extra
- [x] I’m willing to open a PR (see CONTRIBUTING.md)
Since openapi-typescript is now in maintenance mode, this is fixed in openapi-typesafe, a maintained fork of openapi-typescript, openapi-fetch and openapi-react-query: a summary or title that is not a string (as with a property named summary written without properties:) no longer crashes the generator. Apart from fixes like this one, the CLI flags, Node API and output match openapi-typescript 7.13, and npx openapi-typesafe-migrate --write moves a project over. https://github.com/openapi-typesafe/openapi-typesafe
The 1.0 release candidate is on npm: npm i -D openapi-typesafe@next.