Skip to content

How to use OpenAPI feature LINKS in Swagger-UI? It does not seem to work properly #7533

Open
@JunoWHJH

Description

@JunoWHJH

Q&A (please complete the following information)

  • OS: macOS
  • Browser: chrome
  • Swagger-UI version: v3.52.3
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Swagger/OpenAPI definition:

openapi: "3.0.2"

info:
  title: Sample API
  description: Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML.
  version: 0.1.9

servers:
  - url: "xxxxx"

paths:
  /hello/user:
    post:
      operationId: createUser
      summary: create a user
      description: create new user
      requestBody:
        description: new user
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/User'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: string

          # -----------------------------------------------------
          # Links
          # -----------------------------------------------------
          links:
            GetUserByUserId:   # <---- arbitrary name for the link
              operationId: getUser
              # or
              # operationRef: '#/paths/~1users~1{userId}/get'
              parameters:
                uid: '$request.body#/uid'
              description: >
                The `uid` value returned in the response can be used as
                the `uid` parameter in `GET /hello/user`.
          # -----------------------------------------------------


    get:
      operationId: getUser
      summary: Return a user
      description: Optional extended description in CommonMark or HTML.
      parameters:
        - in: query
          name: uid
          schema:
            type: integer
      responses:
        '200':    # status code
          description: return a user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'

components:
  schemas:
    User:
      type: Object
      required:
      - uid
      properties:
        name:
          type: string
        uid:
          type: integer
      example:
        uid: 1
        name: 'juno'

Screenshots

Screen Shot 2021-10-02 at 5 27 06 PM

Screen Shot 2021-10-02 at 5 22 06 PM

How can we help?

According to the documentation on Links feature, I would expect there is clickable links in the POST response to link to the GET request here. But I don't see any clickable links there. Could you please check if anything wrong? How does the Links feature work? Many thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions