Path Response with a Schema which contains multiple items as "ref" is not rendered properly
- swagger-ui version 2.2.10
- a swagger file reproducing the issue generate-swagger-json1.json.zip
There is a definition: http://take.ms/K5fgS and usage of it in the Response of the Path "/user-activities/get-workflow-history-regarding-to": http://take.ms/7qpz8
But if we render the swagger json we don't see complex object as item in the list: http://take.ms/pJuyQ . We just see an empty object in the array what is wrong.
Not an answer, but compare the format of your JSON with a [partially] working example here: https://github.com/swagger-api/swagger-ui/issues/2628
Also, for me, when that sample that I'm referring to isn't present in swagger-json, the UI that I have (which is recent and unmodified "dist" folder) always displays me a sample JSON that - I'm assuming - the UI-script generates based on provided definitions. However, I didn't quite like that example over a concrete example, which I'm able to generate (e.g. { "some-property": "string", "some-int": 0 }, whereas I prefer { "some-property": "Monkey is eating a banana", "some-int": 2 }). So, maybe that helps.
I'm not affiliated with swagger-ui dev team.
Oh, sorry, I realized (too late) that you weren't talking about request-body example, but about response-body example. And, I was able to resolve that problem for myself also, and here's an example excerpt swagger-json
"responses": {
"201": {
"description": "Created (indicates success)",
"schema": {
"$ref": "#/definitions/response:container:single:agent"
},
"examples": {
"application/json": {
"jsonapi": {
"version": "0.1",
"meta": {
"name": "Sample API",
"location": "https://localhost:44342/api/data"
}
},
"meta": {
"request": {
"method": "",
"url": null,
"uid": "FA9D1494-2F41-9DD5-1BDF-FBFB85522D5F",
"received": "2017-01-24T00:02:57.7017459-07:00",
"completed": "2017-01-24T00:02:57.9893875-07:00",
"milliseconds": 287.6416
}
},
"data": {
"type": "agent",
"id": "fw2veokugw2viqkv",
"meta": {
"timestamp": 414168438
},
"attributes": {
"first_name": "Doyle Inc and Sons",
"last_name": "Sipes, Haley and Maggio"
},
"relationships": {
"primary_lab": {
"data": {
"type": "lab",
"id": "fw2veokugw2viqkv"
}
}
},
"links": {
"self": "https://localhost:44342/api/data/agents/fw2veokugw2viqkv"
}
}
}
}
}
That format of the value of examples attribute is the only one that I was able to find that makes both UI and swagger-editor happy (so, when same json pasted into swagger-editor, it will show as valid). Other attempts using the example content formatted as escaped string (for example) worked in swagger-ui, but were showing invalid in the editor. Or - I can't remember details - but there is a way to embed string-representation of sample-json as a string within YAML - however, that didn't work with swagger-ui. That above works for me, and here's some proof (no UI tweaks made):


The issue is most likely because it's an array of a reference to an allOf object.
This should be fixed in 3.X.