java - SwaggerUi 不从 yml 文件中取数据
问题描述
我是 Swagger 世界的新手,正在尝试为我自己的应用程序实现它。我的问题是 SwaggerUi 没有接收我的 swagger.yml 文件,而是将其带入控制器。事实上,我在身份验证方面遇到了问题。
大摇大摆的.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
of 并指定要用于启动 swaggerUi 的 yml 文件。
该文件必须在src-> resource->static内才能查看。我建议你在 Springdoc 网站https://springdoc.org/faq.html上查看官方文档。
再会