配置文件yml添加 servlet: context-path: /api后,swagger2在配置文件需要添加什么?
时间: 2024-03-05 07:48:39 浏览: 165
在配置文件中添加以下内容即可:
```yaml
server:
servlet:
context-path: /api
springfox:
documentation:
swagger-ui:
enabled: true
open-api:
enabled: true
swagger-ui:
base-url: /api/swagger-ui/
config:
deepLinking: true
displayOperationId: true
defaultModelsExpandDepth: 2
defaultModelExpandDepth: 2
defaultModelRendering: "example"
displayRequestDuration: false
docExpansion: "none"
filter: false
maxDisplayedTags: 5
operationsSorter: "alpha"
showExtensions: false
tagsSorter: "alpha"
url: "/api/v2/api-docs"
springfox:
api:
info:
title: "API"
description: "API documentation"
version: "1.0.0"
schemes:
- "http"
- "https"
paths:
include: "/api/.*"
produces:
- "application/json"
consumes:
- "application/json"
```
这里的`/api`是你的servlet的context-path,需要与servlet配置文件中的一致。另外,需要根据实际情况更改`schemes`、`paths`、`produces`、`consumes`等参数,以便生成正确的API文档。
阅读全文