java - Swagger Custom Model -
im using swagger , spring boot automatically generate api docs objects. i'm dynamically adding fields json reponse using @jsonanygetter @jsonanysetter. such
public class someresponse { //standard part picked swagger public string field1; public string field2; //dynamic part not picked swagger private hashmap dynamicfields = new hashmap(); @jsonanysetter public final void putdynamicfield(string key, object value){ dynamicfields.put(key, value); } @jsonanygetter public final hashmap getdynamicfields(){ return dynamicfields; } }
produces:
{ "field1":"" "field2":"" }
nb when dynamic fields appear magic of jackson make them appear @ same level @ field1/2 :) swagger doesnt pick them cause appear @ run-time obvioulsy
can tell me how can update generated swagger model or model schema description add custom fields description of sorts of own naming? like:
{ "field1":"" "field2":"" "dynamicfield1": {} "dynamicfieldn": {} }
the @jsonanygetter
, @jsonanysetter
not supported swagger. you'll have have concrete model definitions, or configure custom model converter add run-time fields models.
Comments
Post a Comment