Skip to content

Schema without a type should be "any" or "unknown" instead of a generic map type #693

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
pbzdyl opened this issue Jul 14, 2021 · 2 comments · Fixed by #769
Closed

Schema without a type should be "any" or "unknown" instead of a generic map type #693

pbzdyl opened this issue Jul 14, 2021 · 2 comments · Fixed by #769

Comments

@pbzdyl
Copy link

pbzdyl commented Jul 14, 2021

According to the OpenAPI spec, when a schema is defined without a type it is the equivalent of:

      anyOf:
        - type: string
        - type: number
        - type: integer
        - type: boolean
        - type: array
          items: {}
        - type: object

but openapi-typescript uses object type as the default and generates { [key: string]: unknown }. Instead it should generate just unknown.

@drwpow
Copy link
Contributor

drwpow commented Sep 30, 2021

I’m in favor of this change. I’m thinking that this along with #554 should result in a new major (breaking) version bump that makes these type changes. I have held off on these because it would be just disruptive enough to people that I’d want them to be able to delay switching. But I agree that long-term, following the spec more closely is best.

@pbzdyl
Copy link
Author

pbzdyl commented Oct 1, 2021

Thank you so much @drwpow!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants