Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve error in yaml/swagger?

This is part of my yaml schema:

paths:
  '/testing/all':
    get:
            summary: Get list of open items
            tags:
              - Items
            description: |
              Returns an array of json objects items
            responses:
              '200':
                    description: Array of open items
                    schema:
                        type: array
                        $ref: '#/definitions/itemList'
                default:
                    description: Unexpected error
                    schema:
                        $ref: '#/definitions/Error'

I am aware of the indentation but still there is an error on the line which contains 'responses':

YAMLException: can not read a block mapping entry; a multiline key may not be an implicit key at line 20, column 13:
                        responses:

How can I fix this error, I am using webstorm 2016 and windows 7?

like image 485
bier hier Avatar asked Apr 12 '26 16:04

bier hier


1 Answers

The line with default: has an invalid indentation:

              '200':
\------------/
  14 spaces
              [...]
                default:
\--------------/
   16 spaces

The indentation of each implicit key in a block mapping must match the indentation of the other keys.

(The error message indicates that there is something wrong with the responses: line, but that one is actually valid YAML. If the message does not go away when you fix the error I explained, that is likely a bug of the YAML implementation you use and you should report it.)

like image 105
flyx Avatar answered Apr 15 '26 05:04

flyx



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!