sdoca
sdoca

Reputation: 8042

Swagger Editor - Additional Properties Error

I'm just starting to use Swagger Editor/OpenAPI 3 spec and so it's not going good so far. I have installed and running Swagger Editor v. 3.15.2 on my local machine.

This is the yaml I have so far:

openapi: "3.0.0"
info:
  version: 1.0.0
  title: Test
paths:
  /object:
    post:
      summary: Create an object
      operationId: createObject
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Object"
    responses:
      '201':
        description: Created
components:
  schemas:
    Object:
      required:
        - name
        - description
      properties:
        name:
          type: string
        description:
          type: string

And it's displaying this error:

Errors


Resolver error
e is undefined
Structural error at paths./object
should NOT have additional properties
additionalProperty: responses
Jump to line 6
Structural error at paths./object.post
should have required property 'responses'
missingProperty: responses
Jump to line 7

I have ensured that I am using two spaces for all the indents. When I copied the yaml from the editor and put it into Notepad++ it looked fine. I also pasted it into another editor and noticed that it only used line feeds and not carriage returns. I updated it to use both and still get the same error.

I have looked at other questions with the same problem but none of the solutions worked for me. So, not sure what I'm doing wrong. Any guidance is greatly appreciated.

Upvotes: 0

Views: 1382

Answers (1)

eternal_student
eternal_student

Reputation: 716

You have a small indentation problem.

Add one indentation level to

responses:
  '201':
    description: Created

So that you then have:

openapi: "3.0.0"
info:
  version: 1.0.0
  title: Test
paths:
  /object:
    post:
      summary: Create an object
      operationId: createObject
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Object"
      responses:
        '201':
          description: Created
components:
  schemas:
    Object:
      required:
        - name
        - description
      properties:
        name:
          type: string
        description:
          type: string

Upvotes: 2

Related Questions