SwaggerUi 不从 yml 文件中取数据

SwaggerUi does not take the data from the yml file

我是 Swagger 世界的新手,正在尝试为我自己的应用程序实现它。我的问题是 SwaggerUi 没有获取我的 swagger.yml 文件,而是将其放入控制器中。事实上,我在身份验证方面遇到了问题。

Swagger.yml

swagger: "2.0"
info:
  version: "1.1"
  title:  ABC Operations
  termsOfService: http://swagger.io/terms/
host: <HOST>
basePath: /abc/operations
tags:
- name: Stored Message
  description: Stored Message Operations
schemes:
- http
- https
security:
  - basic_auth: []
paths:
  /stored-message/{transactionId}:
    get:
      tags:
      - Stored Message
      summary: Stored Message Retrieval by TransactionId
      produces:
      - application/json
      parameters:
      - in: path
        name: transactionId
        required: true
        type: string
           
      responses:
        200:
          description: OK
          schema:
            type: object
        404:
          description: Not Found
        500:
          description: Internal Server Error

    put:
      tags:
      - Stored Message
      summary: Stored Message Update
      consumes:
      - application/json
      produces:
      - application/json
      parameters:
      - in: path
        name: transactionId
        required: true
        type: string
      - in: body
        name: Modified Stored Message
        schema:
         type: object
      responses:
        200:
          description: OK
        404:
          description: Not Found
        500:
          description: Internal Server Error
  
securityDefinitions:
  basic_auth:
    type: basic
externalDocs:
  description: Find out more about Swagger
  url: http://swagger.io

实际上在 SwaggerUi 部分默认不填写新字段。 如何让 swagger Ui 从 swagger.yml 获取数据?

在你的“application.property”文件中你必须添加这个字符串

springdoc.swagger-ui.url: /yourfilename.yml

并指定要用于启动 swaggerUi 的 yml 文件。

文件必须在 src->resource->static 中才能查看。推荐大家看一下Springdoc官网的官方文档https://springdoc.org/faq.html.

美好的一天