XML example cannot be generated with 'allOf'
See original GitHub issueLook an example:
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
type: object
properties:
id:
type: string
author:
type: string
year:
type: integer
format: int32
Then if I click the ‘Example Value’ in swagger ui, it gives this info:
<?xml version="1.0" encoding="UTF-8"?>
<!-- XML example cannot be generated -->
However, if I remove ‘allOf’:
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:
$ref: '#/components/schemas/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
It shows example value correctly:
<?xml version="1.0" encoding="UTF-8"?>
<book>
<id>string</id>
<author>string</author>
<year>0</year>
</book>
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.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Representing XML - Swagger
Representing XML. In your API specification, you can describe data in both XML and JSON formats as they are easily interchangeable. For example,...
Read more >XML for the uninitiated - Microsoft Support
For example, school teachers mark up student papers all of the time. ... A well-formed XML file conforms to a set of very...
Read more >Creating an IS Document Type from an XML Schema Definition
If the cache is not large enough to include all of the generated IS ... if the content models in the XML schema...
Read more >WH-347 Form to Payroll XML Example
Start with the minimal example we created in the last section, but with all of the data left blank, as shown below: Empty...
Read more >Creating XML schemas with Rational Application ... - IBM
If you intend to generate Java™ beans from your XML schema, create a Java ... If you cannot see the XML option, select...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Sounds like a good time to kick XML out your API !
Sorry I know is not helpful, I just could not resist…
Same issue 😦 Enterprise APIs relay on XML. JSON is primary for web development. XML can be transformed with XSLT, data can be found with XPath and defined with XSD. JSON … OMG! Do you know any bank or health system, which works with JSON? I mean in core of systems, not web site integrations? Common, XML is here to stay for a long time.