【发布时间】:2017-08-06 13:11:30
【问题描述】:
我使用 swagger maven 插件在构建时生成 swagger 文档。
这适用于基本的@SwaggerDefinition 注释。
但子部分securityDefinition在最终的json和yaml文件中并没有生成。
我在 3.1.4 版本中使用 swagger-maven-plugin
任何想法可能缺少什么?
@SwaggerDefinition(
info = @Info(
description = "Interact with example",
version = "V1.1.0",
title = "The example API",
termsOfService = "http://example.com",
contact = @Contact(
name = "André Schild",
email = "a.schild@aarboard.ch",
url = "http://example.com"
),
license = @License(
name = "example License",
url = "http://example.com/"
)
),
host = "api.example.com",
basePath = "/api/v1",
consumes = {"application/json"},
produces = {"application/json"},
schemes = {SwaggerDefinition.Scheme.HTTPS},
securityDefinition = @SecurityDefinition(
basicAuthDefinions = {
@BasicAuthDefinition(key = "basicAuth")},
apiKeyAuthDefintions = {
@ApiKeyAuthDefinition(key = "exampleAuth", name = "apiKey", in = ApiKeyLocation.HEADER)}),
tags = {
@Tag(name = "API", description = "Api for example"),
@Tag(name = "V1", description = "V1 Api for example")
},
externalDocs = @ExternalDocs(
value = "example",
url = "http://example.com"
)
)
最终的 swagger 文件如下所示:
---
swagger: "2.0"
info:
description: "Interact with example"
version: "V1.1.0"
title: "The example API"
termsOfService: "http://example.com"
contact:
name: "André Schild"
url: "http://example.com"
email: "a.schild@aarboard.ch"
license:
name: "example License"
url: "http://example.com/"
host: "api.example.com"
basePath: "/api/v1"
tags:
- name: "categories"
description: "Operations about categories"
paths:
/categories:
get:
.... and more paths/definitions....
【问题讨论】:
标签: java maven annotations swagger