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
My typescript vernacular is limited but from what I can tell when using discriminator values that relates to some related type, then type generation works fine up until the alphabetical point where you encounter that related type.
I have a specific test case and output attached to this issue.
contentType: "JDocumentContentModel"; is wrong, it should be set to jDocument.
Just as the above working example is generated to contentType: "aDocument";.
The input from Swagger here clearly defines the discriminator:
This was run in an Alpine Node 22.11 Docker image.
Running this, notice this result.
I have attached a complete generated output that shows the error: myoutput.d.txt
(github upload does not allow .ts files so I had to rename it to .txt)
Expected result
In this example, all discriminators contentType are set but with different approaches, and I expect them to be correct according to the Swagger specification.
For example jDocument instead of JDocumentContentModel.
Required
My OpenAPI schema is valid and passes the Redocly validator (npx @redocly/cli@latest lint)
openapi-typescript version
7.6.1
Node.js version
22.11
OS + version
node:22.11-alpine docker image
Description
My typescript vernacular is limited but from what I can tell when using discriminator values that relates to some related type, then type generation works fine up until the alphabetical point where you encounter that related type.
I have a specific test case and output attached to this issue.
In short, when it works, it could look like this:
and then anything alphabetically "after"
IApiContentModelBase
will fail by instead outputting:contentType: "JDocumentContentModel";
is wrong, it should be set tojDocument
.Just as the above working example is generated to
contentType: "aDocument";
.The input from Swagger here clearly defines the discriminator:
From all my testing it seems that since these types depend on the IApiContentModelBase, anything a-h works fine, and anything j-z fails.
This might be a regression issue. If I go all the way back to version 6.7.6 then it works fine.
Reproduction
Use the attached
swagger.json
file here.swagger.json
Run:
npx openapi-typescript swagger.json --output myoutput.d.ts
This was run in an Alpine Node 22.11 Docker image.
Running this, notice this result.
I have attached a complete generated output that shows the error:
myoutput.d.txt
(github upload does not allow .ts files so I had to rename it to .txt)
Expected result
In this example, all discriminators
contentType
are set but with different approaches, and I expect them to be correct according to the Swagger specification.For example
jDocument
instead ofJDocumentContentModel
.Required
npx @redocly/cli@latest lint
)Extra
The text was updated successfully, but these errors were encountered: