0

I have looked at the questions that were already asked but none of them have been able to solve my issue.

https://stackoverflow.com/questions/45534187/path-and-formdata-paramter-at-the-same-time

https://stackoverflow.com/questions/50562971/swagger-editor-shows-the-schema-error-should-not-have-additional-properties-e

https://stackoverflow.com/questions/48283801/swagger-3-0-schema-error-should-not-have-additional-properties

I am using OpenAPI 3.0.0. I get the following issue at line 6. I have gone through multiple times and indented, moved things around, and started over. I have used the swagger documentation but I still am getting this issue. I will post the yaml below. Any hints will be appreciated.

Error: should not have additional properties: additionalProperty: /author/author{id}

# openapi: 3.0.0

#   info:
#   version: 0.0.1
#   title: Author API
#   description: Author API documentation
openapi: 3.0.0
info:
  title: Author API
  description: Author API
  version: 0.0.1

servers:
  - url: 'http://localhost:8080/'
    description: Local dev server

    # post new author      done
    # find author {id}     done
    # get all author       done
    # update author {id}   done
    # delete author {id}   done


paths:
  /author:
    post:
      summary: Add a author to database
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Author'
      responses:
        '201':
          description: return the author to the user with the id attached
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Author'
    get:
      summary: Get all the authors in the database
      responses:
        '200':
          description: Return all the authors in the database
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Author'

/author/{authorId}:
    update:
      summary: update the author with the id
      parameters:
        - name: authorId
          in: path
          required: true
          description: Id of the author to update
          schema:
            type: integer
      responses:
        '200':
          description: Return just the author at that id
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Author'

      get:
        summary: get the author with the specific id
        paramaters:
          - name: authorId
            in : path
            required: true
            description: Id of the author to retrieve
            schema:
              type: integer
        responses:
          '200':
            description: Return just the author at that id
            content:
              application/json:
                schema:
                  $ref: '#/components/schemas/Author'

      delete:
        summary: Remove a author by the given Id
        parameters: 
          - name: authorId
            in: path
            required: true
            description: Id of the author to delete
            schema:
              type: integer
        responses:
          '200':
            description: The author was successfully removed

components:
  schemas:
    Author:
      type: object
      properties:
        authorId:
          type: integer
        firstName:
          type: string
        lastName:
          type: string
        street:
          type: string
        city:
          type: string
        state:
          type: string
        postalCode:
          type: string
        phone:
          type: string
        email: 
          type : string
Mohamed Ali
  • 702
  • 8
  • 29

1 Answers1

1

Add two spaces before /author/{authorId}, so that this line has the same indentation as /author. YAML requires proper indentation of nested items.

paths:
  /author:
    ...
  /author/{authorId}:
    ...
Helen
  • 87,344
  • 17
  • 243
  • 314