Skip to content

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

@jpraet

Description

@jpraet

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions