0

I am creating the POJOs using jsonschema2pojo on inputtype of JSON ( not Json schema ). I need to add the APIModelProperty annotation to each primitive field and I would like to use the value as value for "example" parameter.

@ApiModelProperty(example="2020-02-03T00:00:00.000Z")

I do not want to manually add this annotation to each field afterr the schema is generated. So, I am trying to write a custom annotator that will add this annotation. From the examples I have seen, I am trying to use the

@Override
public void propertyField(JFieldVar field, 
                      JDefinedClass clazz, 
                      String propertyName, 
                      JsonNode propertyNode ) {

    System.out.println("propertyName " + propertyName);
}

This gives me the key names from the JSON. I have 2 questions

  1. I want to add the @APIModelProperty annotation to each primitive field. How do I identify that propertyName field is a primitive and
  2. How do I get the value of propertyName?

Example - "eventCreatedTime": "2020-02-03T00:00:00.000Z"

Thank you

adbdkb
  • 1,897
  • 6
  • 37
  • 66
  • @joelittlejohn - Any pointers on this one as well? I tried to join the google group to ask the question, but it doesn't allow me to join with email id that is not a gmail id – adbdkb May 13 '21 at 11:31
  • Is is not possible to get the value of the key from the json document in the custom annotator that could be used in the @APIModelProperty for "example" parameter for value? – adbdkb May 16 '21 at 08:56
  • Does anybody have any pointers. How can I achieve this @joelittlejohn ? – adbdkb May 21 '21 at 00:27

0 Answers0