-
-
Notifications
You must be signed in to change notification settings - Fork 532
additionalProperties is not correctly defaulted to true #583
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
Comments
Also to note this only seems to be a part of OpenAPI 3 and not OpenAPI 2 |
Hmmm is this right? It also says: Admittedly I'm just sulking because my linter doesn't like |
Yeah this behavior should be behind a flag. I’m not sure which should be the default behavior, but it should be controllable. I’m kinda leaning toward the |
As we're in control of the server side too, I think we'll probably set that additionalProperties flag to false. It's strange to default to true though - "Here is my contract (but I might stick a bunch of random properties on the end if I feel like it)" - that's not my idea of a contract 😄 +1 for putting this behaviour behind a flag. Agree you should be more lenient with the default. |
Phrasing it like that, perhaps it is better default off. It may be something that people aren’t expecting, and may bite them if they’re not aware of it. OK I’ll do that—introduce the flag, then make the default behavior what it used to be before this last release. That shouldn’t be too disruptive seeing as this is relatively new, and you can always opt in if needed. |
I am running into an issue where some of my openapi specifications are not generating to the correct typescript object because they do not include the
additionalProperties
. According to the OpenAPI specification this is default to true (https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md):With this being the case, shouldn't it automatically add the union with
& { [key: string]: any }
unlessadditionalProperties
is set to something else i.e. a schema orfalse
?When I run the following openapi definition:
I get the typescript:
where it should be
Contract: { slug: string; } & { [key: string]: any }
Thanks for your help and all the work put into this project!
The text was updated successfully, but these errors were encountered: