2017-03-15 8 views
1

ビルド時にswagger mavenプラグインを使用してスワッガードキュメンテーションを生成します。javaからのswagger docusの生成、セキュリティ定義の不足

これは、基本的な@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 = "[email protected]", 
        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: "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: "[email protected]" 
    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.... 

答えて

0

私は私のためにこの作業を得た方法は、別のクラス/インタフェースを作成し、セキュリティ定義と@SwaggerDefinitionでそれに注釈を付けることにより、でした。そして、すべてのAPIのセキュリティ定義を提供しました。

@SwaggerDefinition(securityDefinition = @SecurityDefinition(apiKeyAuthDefinitions = { @ApiKeyAuthDefinition(key = "ApiKey", name = "Authorization", in = ApiKeyLocation.HEADER) })) 
public interface SwaggerSecurityDefinition { 

} 
+2

うーん...これは私のために動作しません。このよう

。私は他の定義と同じ場所に新しいインタフェースクラスを作成しましたが、ドキュメントには含まれていません... –

関連する問題