question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

xml example cannot be generated for response type of array

See original GitHub issue

Q&A (please complete the following information)

  • OS: Windows 10
  • Browser: Firefox, Chrome, Edge
  • Method of installation: npm
  • Swagger-UI version: 3.11.0
  • Swagger/OpenAPI version: Swagger 2.0

Content & configuration

I’ve reproduced this locally, but even easier to demonstrate, petstore has the same issue.

Example Swagger/OpenAPI definition: https://generator.swagger.io/api/swagger.json

snippet from swagger.json

      responses:
        200:
          description: "successful operation"
          schema:
            type: "array"
            items:
              $ref: "#/definitions/Pet"

Describe the bug you’re encountering

In swagger ui, when you have a GET that has a response that is a list, and you selected content type of xml, the Example Value has an error “XML example cannot be generated”.

To reproduce…

Steps to reproduce the behavior:

  1. Go to https://editor.swagger.io
  2. Expand /pet/findByStatus
  3. Make sure Response content type is application/xml
  4. Example Value for status code 200 has “XML example cannot be generated”

Expected behavior

I would expect to see the example xml for the response.

Screenshots

image

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:6
  • Comments:34

github_iconTop GitHub Comments

3reactions
whateverxforevercommented, Jun 8, 2020

I found a work-around for this https://app.swaggerhub.com/apis/whateverxforever/SampleApi/v1-oas3

 get:
      summary: List of all orders
      operationId: getOrderList
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Order'
            application/xml:
              schema:
                type: object
                xml:
                  name: Data
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Order'

I hope this helped! 😉

1reaction
JeroenHeemskerkcommented, Apr 28, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Representing XML - Swagger
In your API specification, you can describe data in both XML and JSON formats as ... books: type: array; items: type: string; xml:...
Read more >
How can I add xml example in Swagger documentation
Hello I am creating swagger documentation for an api and I would like to add xml example but I can`t ...
Read more >
XMLHttpRequest.responseType - Web APIs | MDN
The XMLHttpRequest property responseType is an enumerated string value specifying the type of data contained in the response.
Read more >
Question: Parsing/Mapping JSON profile to XML Response ...
I have imported a json profile containing an example response and i generated a response profile, this one holds an array of these...
Read more >
Working With SOAP Request and Response Messages - SoapUI
Depending on the field type, ReadyAPI renders different editors, including special editors for dates, times, arrays, lists and so on. For example, below...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found