'How i can customize objectMapper of swagger?
I have spring boot application with openapi. My openapi was generated by swagger.
Problem:
When i add additional field to response which my service have to parse, i get error
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "myField”
Because openapi of my service doesn’t know about this field.
And solution for it :
- Just add annotation to generated classes
@JsonIgnoreProperties(ignoreUnknown = true)
or
- add this code snippet
objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
How i can do it in swagger?
- How i can customize code generation that swagger generates classes with this annotation?
@JsonIgnoreProperties(ignoreUnknown = true)
- How i can customize objectMapper of swagger therefore swagger used with objectMapper tuned with this option DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
