Search code examples
yamlswagger-2.0swagger-editor

Not a valid parameter definition , Swagger 2.0


i am new to swagger and following is the code i was trying to edit in the online editor. But it is displaying an error which says "Not a valid parameter definition" at the parameters field.

# Example YAML to get you started quickly.
# Be aware that YAML has indentation based scoping.
# Code completion support is available so start typing for available options.
swagger: '2.0'

# This is your document metadata
info:
  version: "0.0.0"
  title: <test>

# Describe your paths here
paths:
  # This is a path endpoint. Change it.
  /test:
    # This is a HTTP operation
    post:
      # Describe this verb here. Note: you can use markdown

      description: Pass list of input parameter.
      # This is array of GET operation parameters:
      operationId: test
      produces:
        - application/json
        - application/xml
        - text/xml
        - text/html
      parameters:
        - 
          name: value
          in: body
          description: Input parameter list
          required: true
          schema:
          type: array
          items:
            type: object
            properties:
              Name:
                type: string
              Age:
                type: integer
                format: int32
              Address:
                type: string
              Company:
                type: string
              WorkExperience:
                type: integer
                format: int32

      # Expected responses for this operation:
      responses:
        # Response code
        200:
          description: Successful response
          # A schema describing your response object.
          # Use JSON Schema format
          schema:
            title: ArrayOfPersons
            type: array
            items:
              title: Person
              type: object
              properties:
                name:
                  type: string
                single:
                  type: boolean

The following error is displayed in the swagger previewer

Swagger Error
Not a valid parameter definition
Jump to line 28
Details
 Object
code:  "ONE_OF_MISSING"
 params: Array [0]
message:  "Not a valid parameter definition"
 path: Array [5]
schemaId:  "http://swagger.io/v2/schema.json#"
 inner: Array [2]
level: 900
type:  "Swagger Error"
description:  "Not a valid parameter definition"
lineNumber: 28

Solution

  • The "type: array" definition in the schema field was not indented properly.

          parameters:
            - 
              name: value
              in: body
              description: Input parameter list
              required: true
              schema:
                type: array
                items:
                  type: object
                  properties:
                    Name:
                      type: string
                    Age:
                      type: integer
                      format: int32
                    Address:
                      type: string
                    Company:
                      type: string
                    WorkExperience:
                      type: integer
                      format: int32