Skip to content

Error in generated ts file #973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task
FDiskas opened this issue Nov 6, 2022 · 1 comment · Fixed by #971
Closed
1 task

Error in generated ts file #973

FDiskas opened this issue Nov 6, 2022 · 1 comment · Fixed by #971
Labels
bug Something isn't working planned Expected in an upcoming version

Comments

@FDiskas
Copy link
Contributor

FDiskas commented Nov 6, 2022

Description

I was trying to convert https://carapi.app/swagger.json

It could be related to vocab

https://carapi.app/api/vocab

image

image

Name Version
openapi-typescript ^6.0.0-pre.0
Node.js v16.18.0
OS + version macOS 13

Reproduction

npx openapi-typescript https://carapi.app/swagger.json --output swagger.d.ts

Expected result

It should be a valid typescript file

Checklist

@drwpow
Copy link
Contributor

drwpow commented Nov 8, 2022

Yeah this schema is unique in that it has items like:

{
  "allOf": [
    { "$ref": "#/x-swagger-bake/components/schemas/Generic-Collection" }
  ]
}

While that’s technically valid syntax, the x-swagger-bake namespace is a designated custom namespace, which means a generic tool like openapi-typescript doesn’t know how to interpret that. Perhaps in this schema it follows a predictable format, but another schema could choose to use that exact same namespace for something different, and both would be correct and valid.

The fix for this would be to simply ignore all x-* namespaces from the generated output (as the spec outlines). It would then be up to you to add those back in, if you wanted, manually with the transform()/postTransform() hooks (v6; upcoming) or the format() hook (v5).

@drwpow drwpow added bug Something isn't working planned Expected in an upcoming version labels Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working planned Expected in an upcoming version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants