简体   繁体   中英

Swagger editor is throwing error while specifying the response “Not a valid response definition”

I am trying to generate the API documentation using swagger editor . I specified my API specification as follow

paths:
  /opendata/v1/{index}:
    get:
      tags: [verification]
      description: Verify the person information
      parameters:
        - name: index
          in: path
          description: specific data index
          required: true
          type: string
        - name: name
          in: query
          description: name of a person
          required: false
          type: string
        - name: company name
          in: query
          description: name of a company
          required: false
          type: string

      responses:
        '200':
          description: Success
          content:
            application/json:
              schemas:
                $ref: '#/responses/200'



responses:
    '200':
      description: Success
      schema:
        type: object
        properties:
          verification:
            type: string

But its always showing error in the editor that "Not a valid response definition". I checked the specification for response from here . What changes I should do so that error will not come.

Note: I want the response in the json form like below:

{
    verification:string
}

You are mixing OpenAPI/Swagger 2.0 and OpenAPI 3.0 syntax. Your spec seems to be swagger: '2.0' , so you should use:

paths:
  /opendata/v1/{index}:
    get:
      ...

      produces:
        - application/json
      responses:
        200:
          $ref: '#/responses/200'

Here's a related OpenAPI/Swagger 2.0 guide: Describing Responses

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM