-
Notifications
You must be signed in to change notification settings - Fork 9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
XML Example for Arrays does not display #3132
Comments
The problem seems to be not with arrays in general, but with inline array and object schemas without Here's a minimal example:
In case of Petstore, the workaround to see an example is to change the response as follows:
or
However, the generated example is still incorrect - it has a single pet and not an array. :( |
Yes, its still broken. |
@bodnia I understand the potential issue here, but it looks like we had a solution for it in 2.x. Can we replicate the same logic here? |
I dont think you did; it doesnt work seem to work right in v2 either which is used in swashbuckle. I have changed swashbuckle to emit "xml: name" properties for an object definition and array definition which removes the "Inline Model" problem, but still makes the XML a single 'broken' node and not an array of nodes. This occurs in v2 and v3: schema:
type: array
items:
$ref: '#/definitions/Channel'
xml:
name: Channels
definitions:
Channel:
type: object
xml:
name: Channel
properties:
id:
format: int32
type: integer
name:
type: string
active:
format: int32
type: integer
defaultTerritoryID:
format: int32
type: integer Emits the following correct JSON: [
{
"id": 0,
"name": "string",
"active": 0,
"defaultTerritoryID": 0
}
] But broken and potentially invalid XML: <?xml version="1.0" encoding="UTF-8"?>
<Channel>
<id>0</id>
<name>string</name>
<active>0</active>
<defaultTerritoryID>0</defaultTerritoryID>
</Channel> |
@coderangerdan, I just realized a single-item example is actually correct. To have array items wrapped into an extra tag, the array schema must have
|
@coderangerdan are you still expiring any issues with XML rendering? @webron all tests from 2.x version were moved to 3.x and also I added more tests, so all functionality present in 2.x is also added to 3.x |
Yes we are but its an issue with Swashbuckle not generating the appropriate swagger doc info; once i add that information in, the UI renders fine ... the Petstore example is also broken in the same way and needs to be amended to include the xml.name/wrapped elements |
@coderangerdan can the issue be closed? |
Well the petstore sample needs fixing, not sure where that data comes from but i guess its not a UI issue so yes. |
Locking due to inactivity. |
When a response is an array of objects, the XML example fails to display anything. The online PetStore sample exhibits this same problem for api:
GET->/pet/findByStatus
Select "application/xml" and the XML example is just:
When its a single object and not an array, like in
Post->/pet/
, it works fine.Sorry, i dont know what version of SwaggerUI the online PetStore example uses but the swagger doc is correct:
The text was updated successfully, but these errors were encountered: