cancel
Showing results for 
Search instead for 
Did you mean: 

Missing Json root element

Highlighted
Visitor

Missing Json root element

Hi all,

 

We've set up Swagger UI for a while now (version 1.5.10) on our project but we are trying to find out wether it's possible to integrate the Json root element in the example value.

I see that this problem occurs also in your demo page https://petstore.swagger.io/?_ga=2.186999790.790751393.1601300889-613925661.1599659287

Example:

for the Pet model you display the following Json 

{
  "id": 0,
  "category": {
    "id": 0,
    "name": "string"
  },
  "name": "doggie",
  "photoUrls": [
    "string"
  ],
  "tags": [
    {
      "id": 0,
      "name": "string"
    }
  ],
  "status": "available"
}

Where I'm expecting to see:

 

{
  "Pet": {
    "id": 0,
    "category": {
      "id": 0,
      "name": "string"
    },
    "name": "doggie",
    "photoUrls": [
      "string"
    ],
    "tags": [
      {
        "id": 0,
        "name": "string"
      }
    ],
    "status": "available"
  }
}

 

I tried to add @JsonRootName annotation on my entities and set up WRAP_ROOT_VALUE/UNWRAP_ROOT_VALUE on  the Json serializer but I still don't get the expected result.

 

Thank you very much for your help !

 

Mehdi

 

1 REPLY 1
Highlighted
Occasional Visitor

Re: Missing Json root element

I'm also having the same issues. Is there a way to solve this ?

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors