-
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 cannot be generated with 'allOf' #4423
Comments
I found that this can be solved by adding an openapi: '3.0.0'
info:
version: 1.0.0
title: example
servers:
- url: http://localhost:80
paths:
/books:
post:
summary: add a book
requestBody:
content:
application/xml:
schema:
description: book to be added
allOf:
- $ref: '#/components/schemas/book'
xml:
name: book
responses:
'200':
description: OK
components:
schemas:
book:
description: a book
type: object
properties:
id:
type: string
author:
type: string
year:
type: integer
format: int32 Or change to this: openapi: '3.0.0'
info:
version: 1.0.0
title: example
servers:
- url: http://localhost:80
paths:
/books:
post:
summary: add a book
requestBody:
content:
application/xml:
schema:
description: book to be added
allOf:
- $ref: '#/components/schemas/book'
responses:
'200':
description: OK
components:
schemas:
book:
description: a book
xml:
name: book
type: object
properties:
id:
type: string
author:
type: string
year:
type: integer
format: int32 But if this is because of lackness of element name to construct xml, why not just use the type name |
Sounds like a good time to kick XML out your API ! Sorry I know is not helpful, I just could not resist... |
@heldersepu So you mean this is a bug? |
Convince your boss that XML is not as efficient as JSON and your job is done! Ye, it looks like a bug & smells like a bug... |
@heldersepu And I can tell you're a funny person. Anyway, thx a lot! |
Same issue :-( |
@shockey We're facing issue with XML sample generation in case of collection is part of response object. Kindly let us know about ETA on a fix. |
Added the demo project to reproduce the issue with Swashbuckle for Xml sample generation issue. Demo project |
Any update on this? |
Look an example:
Then if I click the 'Example Value' in swagger ui, it gives this info:
However, if I remove 'allOf':
It shows example value correctly:
And if I change application format to json, it shows json example value correctly whether there is
allOf
or not.The reason I want to use
allOf
is for this.So is this a bug of
allOf
or an expected behaviour?If it's an expected behaviour, then how to solve this two problems?
Currently, I'm using Swagger Editor online version in Chrome browser.
This issue seems related.
The text was updated successfully, but these errors were encountered: