In my Spring Boot rest api, I have the following class:
@Entity
@Table(name="Items")
@JsonPropertyOrder({ "itemId", "description", "viewed" })
public class Item {
@ApiModelProperty(notes="Id of the item.", required=true, value="100000")
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@JsonProperty(access=Access.READ_ONLY)
private int itemId = 0;
@ApiModelProperty(notes="Item description.", required=true, value="Item1")
@NotNull
@Size(min=1, max=256)
private String description;
private int viewed;
public int getItemId() {
return this.itemId;
}
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
public int getViewed() {
return this.viewed;
}
}
When I execute the request, the JsonPropertyOrder is respected, however, in the Swagger UI (and the Swagger doc), the properties are listed as description, itemId, viewed. I.e. alphabetical. I never turned on alphabetical sorting, so not sure why its doing that... any way to turn that off? It's doing that to all my classes which are laid out in common sense / logical order...