cancel
Showing results for 
Search instead for 
Did you mean: 

Yaml format to represent two different objects in an array

SOLVED
Highlighted
New Contributor

Yaml format to represent two different objects in an array

Hi All,

  I am trying to prepare a Swagger file in YAML format for a request JSON for our API. In our JSON there is an array in below format,

 

"RawParams": [
           {
              "Key": "CSClientLastName",
              "Value": "Stanford"
           },
          {
             "ElementType": "OFIAccountName",
             "ElementList": [
                     {
                        "Key": "ClientFullName",
                        "Value": "Smith D Rogers"
                    },
              ]
         }
],

 

RawParams is an array with Key/Value object and ElementType/ElementList objects separately embedded. So, how to represent this in YAML format? I tried to define as below but Swagger UI throwing error when I defined items twice with "duplicate error". 

 

RawParams:
  type: array
  items:
    type: object
    properties:
        Key:
            type: string
        Value:
            type: string

   items:

     type: object

     properties:

        ElementType:
            type: string
        ElementList:
            type: array
            items:
              type: object
              properties:
                  Key:
                       type: string
                  Value:
                       type: string

 

Could some one please help me?

 

Thanks,

Durga Prasad

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Moderator

Re: Yaml format to represent two different objects in an array

Currently, OpenAPI does not support such a construct.

 

The upcoming release of OpenAPI 3.10 will enable that functionality, but it may take some time for tools to catch up.


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓

View solution in original post

2 REPLIES 2
Highlighted
Moderator

Re: Yaml format to represent two different objects in an array

Currently, OpenAPI does not support such a construct.

 

The upcoming release of OpenAPI 3.10 will enable that functionality, but it may take some time for tools to catch up.


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓

View solution in original post

Highlighted
New Contributor

Re: Yaml format to represent two different objects in an array

Hi Ron,

 

   Thank you very much for your prompt response.

 

Durga Prasad

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors