0

My POJOs are auto generated from swagger 2.0 using json files. I want certain POJOs to have annotation @JsonIgnoreProperties(ignoreUnknown = true) as class level. The annotation is from com.fasterxml.jackson.annotation.JsonIgnoreProperties. So how can i auto generate this annotation for specific POJOs ?

for example this is my POJO

    "MappingPJO": {
          "type": "object",
          "required": [
            "X-ID",
            "data",
            "datacontenttype",
            "specversion",
            "type"
          ],
          "properties": {
            "X-ID": {
              "type": "string",
              "example": "3cf50cc1-04df-492e-8868-9f135e6c0e05"
            },
            "data": {
              "description": "the data of the mapping event",
              "$ref": "#/definitions/MappingEventData"
            },
            "datacontenttype": {
              "type": "string",
              "example": "application/json",
              "description": "the content type of the mapping event"
            },
            "specversion": {
              "type": "string",
              "example": "1",
              "description": "the specification version of the mapping event"
            },
            "type": {
              "type": "string",
              "example": "MAPPING_CREATED",
              "description": "defines the type of the mapping event"
            }
          },
          "title": "MappingCreatedPOJO",
          
"description": "Data of a successful primary info creation event"
    }

i want to have autogenerated pojo as:

@ApiModel(description = "Data of a successful primary info creation event")
@JsonPropertyOrder({
  MappingCreatedPOJO.JSON_PROPERTY_X_I_D,
  MappingCreatedPOJO.JSON_PROPERTY_DATA,
  MappingCreatedPOJO.JSON_PROPERTY_DATACONTENTTYPE,
  MappingCreatedPOJO.JSON_PROPERTY_SPECVERSION,
  MappingCreatedPOJO.JSON_PROPERTY_TYPE
})
@JsonTypeName("MappingCreatedPOJO")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2021-12-14T09:01:24.289539")
@JsonIgnoreProperties(ignoreUnknown = true) //// WANT THIS ANNOTATION
public class MappingCreatedPOJO{
  public static final String JSON_PROPERTY_X_I_D = "X-ID";
  private String xID;

.....
MiGo
  • 551
  • 2
  • 7
  • 17

0 Answers0