Skip to content

Why does the generated Java models all have additionalProperties? #675

Closed Answered by jonaslagoni
pontus-eliason asked this question in Q&A
Discussion options

You must be logged in to vote

I assume you are generating models either from AsyncAPI, OpenAPI, or raw JSON schema inputs.

The reason it is generated is that is what you allow in your input schema, by default in JSON Schema draft 7 additionalProperties are true allowing input JSON to contain properties beyond what you define within {properties: {...}}. 🙂

Modelina generates the property so you have a way to set the additional properties at runtime.

To disable it, explicitly set the schema to additionalProperties: false

{"type": "object", "properties": {...}, "additionalProperties": false, ... }

Whether we should support something like a global setting that disable this logic, I would love to hear your reasoning for it 🙂

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by jonaslagoni
Comment options

You must be logged in to vote
3 replies
@jonaslagoni
Comment options

@pontus-eliason
Comment options

@jonaslagoni
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants