Skip to content
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

[REQ][JAVA][JAXRS-SPEC] Option to disable @JsonCreator with required properties #20569

Closed
jpraet opened this issue Feb 1, 2025 · 0 comments · Fixed by #20570
Closed

[REQ][JAVA][JAXRS-SPEC] Option to disable @JsonCreator with required properties #20569

jpraet opened this issue Feb 1, 2025 · 0 comments · Fixed by #20570

Comments

@jpraet
Copy link
Contributor

jpraet commented Feb 1, 2025

Is your feature request related to a problem? Please describe.

As of openapi-generator 7.11.0 (#19577, #19578), a jackson @JsonCreator constructor is generated for models with required properties.
When deserializing a payload that is missing required properties, jackson throws a MismatchedInputException.
This means that part of the input validation concerns, which are typically handled by Bean Validation, are now done by jackson instead.

This is not always desirable:

Frameworks may translate Bean Validation errors to a proper HTTP 400 Bad Request, while that is not necessarily done for Jackson MismatchedInputException. It is also difficult to distinguish such MismatchedInputException caused by inbound request (should map to HTTP 400) to one caused by an inbound respons (should map to HTTP 500) in a generic way.

There's also a regression causing incorrect validation errors for required properties in oneOf (#20545).

Describe the solution you'd like

A config option "generateJsonCreator" (default true) which can be set to false to disable the generation of the @JsonCreator constructor with required properties.

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