cancel
Showing results for 
Search instead for 
Did you mean: 

API Design: XML response returns a nested array

Highlighted
Visitor

API Design: XML response returns a nested array

I'm having difficulty writing a definition for an XML response object which includes two strings and an array of integers in the same parent element.

 

```yml

Element:
type: array
description: returns a list of report ID's
required:
- result
- title
- dogs
properties:
result:
description: Server Response
type: string
name:
description: blah
type: string
items:
$ref: '#/components/schemas/name'
title:
description: Report ID
type: array
items:
$ref: '#/components/schemas/title'
xml:
wrapped: true

```

```xml

<element>

      <name>jeremy</name>

      <title>designer</title>

      <dogs>tito</dogs>

      <dogs>burrito</dogs>

      <dogs>cheeto</dogs>

</element>

```

1 REPLY 1
Highlighted
Moderator

Re: API Design: XML response returns a nested array

Hi Jeremy,

Your example

 

<element>
  <name>jeremy</name>
  <title>designer</title>
  <dogs>tito</dogs>
  <dogs>burrito</dogs>
  <dogs>cheeto</dogs>
</element>

 

can be defined as follows:

 

components:
  schemas:
    element:
      type: object
      properties:
        name:
          type: string
          example: jeremy
        title:
          type: string
          example: designer
        dogs:
          type: array
          items:
            type: string
          xml:
            wrapped: false
          example:
            - tito
            - burrito
            - cheeto

 

See also Representing XML.


Helen Kosova
SmartBear Documentation Team Lead
________________________
Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors
Top Kudoed Posts