Search code examples
swaggerswagger-uiswagger-editor

Swagger throwing "Not a valid parameter definition"


I am creating API documentation utilizing Swagger UI. I have many errors that say "Not a valid parameter definition" and I don't know why. Can anyone tell what or why this is happening? I include a section of the code and a picture with the line numbers and the error descriptions.

swagger example

#sys_application

/api/application/add:
  post:
    description: Adds specified application(s).
    parameters:

    - name: name
      in: body
      description: name of the application
      required: true
      type: string

    - name: appId
      in: body
      description: application id
      required: true
      type: string

    - name: icon
      in: body
      description: application icon
      required: true
      type: string

    - name: state
      in: body
      description: current state of the application
      required: true
      type: string

    - name: profileRoute
      in: body
      description: embedded profile route that is displayed within the map app
      required: true
      type: string

    - name: type
      in: body
      description: type of the application
      required: true
      type: string

    - name: permissions
      in: body
      description: user permissions for application
      required: false
      type: string

    - name: subscriptions
      in: body
      description: application subscriptions
      required: false
      type: string

swagger error

enter image description here


Solution

  • when you use in: body, the spec expects a schema element, such as:

    name: user
    in: body
    schema:
      type: object
      properties:
        userId:
          type: string
    

    If you're not using a body parameter, you are expected to use a primitive value, such as type: string.