Hi,
I've a Track model with a property URI. The URI was displaying unwanted properties. So I added the below piece of code.
String jsonString = "{" +
" \"id\": \"URI\"," +
" \"properties\": {" +
" \"value\": {" +
" \"required\": true," +
" \"description\": \"A URL to a resource\"," +
" \"type\": \"string\"" +
" }" +
" }" +
"}";
OverrideConverter converter = new OverrideConverter();
converter.add("java.net.URI", jsonString);
ModelConverters.addConverter(converter, true);
The above code removed unwanted properties and displays the json like given below.
"models": {
"Track": {
"id": "Track",
"properties": {
"title": {
"type": "string"
},
"singer": {
"type": "string"
},
"lane": {
"$ref": "Lane"
},
"uri": {
"$ref": "URI"
},
"date": {
"type": "string",
"format": "date-time"
}
}
},
..
"URI": {
"id": "URI",
"required": [
"value"
],
"properties": {
"value": {
"type": "string",
"description": "A URL to a resource"
}
}
}
What I need is instead of
"uri": {
"$ref": "URI"
},
I want the json to display URI like this
"uri": {
"type": "string",
},
How can I achieve this? Can anyone help me with this?
This is my model class.
public class Track {
private String title;
private String singer;
@ApiModelProperty(access = "internal")
private byte[] data;
private Lane lane;
private URI uri;
private Date date;
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getSinger() {
return singer;
}
public void setSinger(String singer) {
this.singer = singer;
}
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.data = data;
}
public Lane getLane() {
return lane;
}
public void setLane(Lane lane) {
this.lane = lane;
}
public URI getUri() {
return uri;
}
public void setUri(URI uri) {
this.uri = uri;
}
}