package io.swagger.model.override; import io.swagger.annotations.ApiModelProperty; import io.swagger.converter.ModelConverters; import io.swagger.matchers.SerializationMatchers; import io.swagger.models.Model; import org.testng.annotations.Test; import java.util.Map; public class ModelPropertyOverrideTest { @Test public void overrideTest() throws Exception { ModelConverters.getInstance().addConverter(new SamplePropertyConverter()); final Map<String, Model> model = ModelConverters.getInstance().read(MyPojo.class); final String expected = "{" + " \"MyPojo\" : {" + " \"type\" : \"object\"," + " \"properties\" : {" + " \"id\" : {" + " \"type\" : \"string\"" + " }," + " \"myCustomClass\" : {" + " \"type\" : \"string\"," + " \"format\" : \"date-time\"," + " \"description\" : \"instead of modeling this class in the documentation, we will model a string\"" + " }" + " }" + " }" + "}"; SerializationMatchers.assertEqualsToJson(model, expected); } public static class MyPojo { public String getId() { return ""; } public void setId(String id) { } @ApiModelProperty(value = "instead of modeling this class in the documentation, we will model a string") public MyCustomClass getMyCustomClass() { return null; } public void setMyCustomClass(MyCustomClass myCustomClass) { } } }