在swagger文档中如何链接和引用self?

时间:2019-06-10 07:49:09

标签: hyperlink swagger openapi self-reference

如果我有一个doc/api端点,该端点应指向当前的swagger文档,那么如何使用OpenAPI 3.0.0对Swagger进行自引用?

例如,给定

openapi: 3.0.0
servers:
  - url: http://hello-world.com
info:
  description: |-
    Hello World!
  version: "4"
  title: Hello World

components:
  schemas:
    SwaggerDoc:
      type: object
      properties:
        address:
          $ref: '#/components/schemas/SwaggerDoc'

paths:
  /docs/api:
    get:
      summary: Swagger Documentation (HTML)
      tags:
        - Service Information
      responses:
        '200':
          description: HTML Document of RIT Translate API
          content:
            'text/html':
              schema:
                $ref: '#/components/schemas/SwaggerDoc'
        '503':
          description: The server is not ready.

https://editor.swagger.io的输出显示:

enter image description here

Links下响应部分的右侧,它显示“无链接。” 是否可以在该链接下添加链接以链接到自身?

对于503,我应该如何将其链接到另一个静态错误页面?

0 个答案:

没有答案