YAML definition syntax when a field is an array

22 views
Skip to first unread message

Νίκος Σιδηρόπουλος

unread,
Mar 23, 2017, 4:06:46 AM3/23/17
to Swagger
I have a problem in my YAML syntax. My response in JSON is like this:
{
   "wordtxtword": "καρδιολόγος",
   "relations": [
                     {
                      "relation": "treats",
                      "related_words": [
                                      "έμφραγμα",
                                      "στηθάγχη",
                                      "στενοκαρδία",
                                      "μυοκαρδίτιδα",
                                      "ταχυκαρδία",
                                      "ταχυπαλμία",
                                      "ταχυσφυγμία",
                                      "βραδυκαρδία",
                                      "βραδυσφυγμία"
                        ] },
                        {
                         "relation": "practices",
                         "related_words": [
                                      "καρδιολογία"
                          ] }
                      ]
}

I need to write a YAML syntax covering this response. So my get is something like that:
get:
      summary: Return a list of all related words.
      description: |
        This endpoint returns a list of all existing relations of the selected word. Results are grouped by the relation type.
      tags:
        - Word
      responses:
        200:
          description: Multiple arrays of words according to the relation type they have with the word that is searched.
          schema:
            type: array
            items:
              $ref: '#/definitions/relationlist'
        default:
          description: Unexpected error
          schema:
            $ref: '#/definitions/Error'


And in my definitions i have :

relationlist:
    type: object
    properties:
      wordtxt:
        type: string
        description: The matching word as found in the dictionary.
      relations:
        type: object
        description: An array of relation types and words that belong to that relation type.
        properties:
          relation:
            type: string
            description: The relation type
          related_words:
            type: object
            properties:
              words: string

My question is how to express the array of strings that corresponds to the 'related_words' field in my definition. The way i am now expressing it is not correct since there is no 'words' field in my JSON response.

Ron Ratovsky

unread,
Mar 23, 2017, 8:14:23 PM3/23/17
to swagger-sw...@googlegroups.com

 

 

type: object

properties:

                wordtxtword:

                                type string

                relations:

                                type: array

                                items:

                                                type: object

                                                properties:

                                                                relation:

                                                                                type: string

                                                                related_words:

                                                                                type: array

                                                                                items:

                                                                                                type: string

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages