swagger2markup icon indicating copy to clipboard operation
swagger2markup copied to clipboard

References to incorrect anchors after generating markdown

Open 1krutarth opened this issue 7 years ago • 1 comments

After defining a swagger spec, I used swagger2markup-cli - v1.3.2 to convert it to .md. In the responses section, it refers to same anchor. Below's the example that can be used to reproduce (or can be accessed here: yaml-gist).

swagger: '2.0'
info:
  version: '1.0'
  title: Dummy Product Service
  description: Dummy Product Service to reproduce an issue
basePath: /
schemes: ["http"]
consumes: ["application/json"]
produces: ["application/json"]

paths:
  /product:
    get:
      summary: dummy product summary
      description: dummy product description
      produces: ["application/json"]
      responses:
        201:
          description: product information
          schema:
            $ref: "#/definitions/ProductSampleResponse"
        400:
          $ref: "#/responses/InvalidRequest"
        500:
          $ref: "#/responses/ServerError"
definitions:
  ProductSampleResponse:
    type: object
    required: ["id", "name"]
    properties:
      id:
        type: string
        description: Unique product id
      name:
        type: string
        description: product name
responses:
  InvalidRequest:
    description: Response returned in case of invalid request
    schema:
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              code:
                type: string
                enum:
                  - "invalid.request"
  ServerError:
    description: Response returned because of server error
    schema:
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              code:
                type: string
                enum:
                  - "product.service.failure"
              description:
                type: string

to convert swagger2markup convert -i Swagger2Markup_issue.yaml -f Swagger2Markup_issue (swagger2markup is an alias i created for cli), it generated a markdown here: https://gist.github.com/1krutarth/b770fff3a0c5168ce96a4171e1f6c99a#file-swagger2markup_issue-md

The part to notice is the anchors defined for errors in Response 400 and Response 500 (< errors > array) both points to same anchor #product-get-errors. Rather errors should be associated with its appropriate Responses.

1krutarth avatar Aug 07 '18 16:08 1krutarth

Is it still open? I can work on this... @RobWin

aspekt23 avatar Oct 20 '18 15:10 aspekt23