wkennedy / swagger4spring-web

Swagger support for Spring MVC
89 stars 46 forks source link

When ModelA contains List<ModelB>, then instead of "$ref": "ModelB", it returns "ref": "ModelB" #76

Open zutnop opened 10 years ago

zutnop commented 10 years ago

Somehow the swagger4spring-web loses the $ symbol from the specified "$ref" field.

This can be easily reproduced in the swagger4spring-web-example project:

  1. Open Person.java model
  2. Add a new field (+getter/setter also):
@ApiModelProperty(value = "categories test")
private List<Category> categories;
  1. Now when the API json is constructed and serialized to the response, it must be (based on the Swagger specification) something like this (after removing the irrelevant lines):
"models": {
  "Person": {
    "properties": {
      "categories": {
        "type": "List"
        "items": {
          "$ref": "Category"

BUT, instead it looks like this:

"models": {
  "Person": {
    "properties": {
      "categories": {
        "type": "List"
        "items": {
          "ref": "Category"

(the $ sign is missing).

This means that swagger-ui doesn't pick up the collection type and doesn't show the model definition etc.

mayonesa commented 9 years ago

when is this fix going in?