未生成 swagger maven 插件文档
swagger maven plugin documentation is not generated
我正在尝试使用 Swagger maven plugin
生成 swagger 文档
但是没有创建任何东西,这是我输入的详细插件:
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.2.2-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>/data/AMEE/ame/api.yaml</inputSpec>
<language>java</language>
<configOptions>
<sourceFolder>/data/AMEE/ame/gen</sourceFolder>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
它没有创建任何文档。然后我试了kongchen swagger maven plugin
插件:
<plugin>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<skipSwaggerGeneration>false</skipSwaggerGeneration>
<apiSources>
<apiSource>
<springmvc>false</springmvc>
<locations>
<location>com.aepona.monatization.api.rest</location>
<location>com.aepona.monatization.inputprocessing.api.rest</location>
<location>com.aepona.monatization.reporting.api.rest</location>
</locations>
<schemes>
<scheme>http</scheme>
<scheme>https</scheme>
</schemes>
<host>localhost:8080</host>
<basePath>/api</basePath>
<descriptionFile>/data/zzzz/descriptionFile</descriptionFile>
<info>
<title>Acccelerite Monatization Engine</title>
<version>1.0.0</version>
<description>DESCRIPTION</description>
<termsOfService>http://terms-of-services.url</termsOfService>
<license>
<url>http://url-to-license.com</url>
<name>LICENSE</name>
</license>
</info>
<outputPath>/data/zzzz/static</outputPath>
<swaggerDirectory>/data/zzzz/swaggerFile</swaggerDirectory>
<attachSwaggerArtifact>true</attachSwaggerArtifact>
</apiSource>
</apiSources>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
依赖关系:
<dependency>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>3.0.0</version>
</dependency>
仍然没有生成文档。我哪里做错了?请帮我。谢谢。
Maven 依赖关系::
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.4.0</version>
</dependency>
注释配置 class 并在 conf class.
中添加以下代码
@Configuration
@EnableWebMvc
@EnableSwagger2
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()).directModelSubstitute(LocalDate.class, String.class).genericModelSubstitutes(ResponseEntity.class)
.useDefaultResponseMessages(false)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
}
@SuppressWarnings("deprecation")
private ApiInfo apiInfo() {
ApiInfo apiInfo = new ApiInfo(
" REST API",
"XXX Rest API for XXX authentication and Loan creation.",
"Mer V1.1",
"Terms of service",
"ER",
"License of API",
"");
return apiInfo;
}
控制器::
@RestController
@Api("/resource")
public class Controller {
}
之后在浏览器中点击 url 下方:
http://localhost:ip/ApplicationName/swagger-ui.html
我正在尝试使用 Swagger maven plugin
生成 swagger 文档但是没有创建任何东西,这是我输入的详细插件:
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.2.2-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>/data/AMEE/ame/api.yaml</inputSpec>
<language>java</language>
<configOptions>
<sourceFolder>/data/AMEE/ame/gen</sourceFolder>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
它没有创建任何文档。然后我试了kongchen swagger maven plugin
插件:
<plugin>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<skipSwaggerGeneration>false</skipSwaggerGeneration>
<apiSources>
<apiSource>
<springmvc>false</springmvc>
<locations>
<location>com.aepona.monatization.api.rest</location>
<location>com.aepona.monatization.inputprocessing.api.rest</location>
<location>com.aepona.monatization.reporting.api.rest</location>
</locations>
<schemes>
<scheme>http</scheme>
<scheme>https</scheme>
</schemes>
<host>localhost:8080</host>
<basePath>/api</basePath>
<descriptionFile>/data/zzzz/descriptionFile</descriptionFile>
<info>
<title>Acccelerite Monatization Engine</title>
<version>1.0.0</version>
<description>DESCRIPTION</description>
<termsOfService>http://terms-of-services.url</termsOfService>
<license>
<url>http://url-to-license.com</url>
<name>LICENSE</name>
</license>
</info>
<outputPath>/data/zzzz/static</outputPath>
<swaggerDirectory>/data/zzzz/swaggerFile</swaggerDirectory>
<attachSwaggerArtifact>true</attachSwaggerArtifact>
</apiSource>
</apiSources>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
依赖关系:
<dependency>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>3.0.0</version>
</dependency>
仍然没有生成文档。我哪里做错了?请帮我。谢谢。
Maven 依赖关系::
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.4.0</version>
</dependency>
注释配置 class 并在 conf class.
中添加以下代码@Configuration
@EnableWebMvc
@EnableSwagger2
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()).directModelSubstitute(LocalDate.class, String.class).genericModelSubstitutes(ResponseEntity.class)
.useDefaultResponseMessages(false)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
}
@SuppressWarnings("deprecation")
private ApiInfo apiInfo() {
ApiInfo apiInfo = new ApiInfo(
" REST API",
"XXX Rest API for XXX authentication and Loan creation.",
"Mer V1.1",
"Terms of service",
"ER",
"License of API",
"");
return apiInfo;
}
控制器::
@RestController
@Api("/resource")
public class Controller {
}
之后在浏览器中点击 url 下方: http://localhost:ip/ApplicationName/swagger-ui.html