Last active
February 23, 2017 08:09
-
-
Save premierrt/dd151e928030808baf7db14620c5ad4f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://indrabasak.wordpress.com/2016/04/07/swagger-2-integration-with-spring-rest/ | |
annotacje: | |
https://jakubstas.com/spring-jersey-swagger-create-documentation/#.WKwNLrLhCpo | |
------ | |
servlet disptacher | |
-------- | |
<!-- Direct static mappings --> | |
<mvc:resources mapping="swagger-ui.html" | |
location="classpath:/META-INF/resources/" /> | |
<mvc:resources mapping="/webjars/**" | |
location="classpath:/META-INF/resources/webjars/" /> | |
---------------------------------- | |
konfiguracja spring: | |
--------------------------------------- | |
package org.training.config; | |
import static springfox.documentation.builders.PathSelectors.regex; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.web.servlet.config.annotation.EnableWebMvc; | |
import springfox.documentation.builders.ApiInfoBuilder; | |
import springfox.documentation.builders.RequestHandlerSelectors; | |
import springfox.documentation.service.ApiInfo; | |
import springfox.documentation.spi.DocumentationType; | |
import springfox.documentation.spring.web.plugins.Docket; | |
import springfox.documentation.swagger2.annotations.EnableSwagger2; | |
@Configuration | |
@EnableWebMvc | |
@EnableSwagger2 | |
public class SwaggerConfig | |
{ | |
@Bean | |
public Docket documentation() | |
{ | |
return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.any()).paths(regex("/.*")).build() | |
.ignoredParameterTypes(org.springframework.validation.Errors.class).apiInfo(metadata()) | |
.useDefaultResponseMessages(false); | |
} | |
private ApiInfo metadata() | |
{ | |
return new ApiInfoBuilder().title("Play Rest API").description("Play Rest API for external usage").version("1.0") | |
.license("Not for external usage").build(); | |
} | |
} | |
---- | |
pom.xml | |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>rafalRest1</groupId> | |
<artifactId>rafalRest1</artifactId> | |
<version>0.0.1-SNAPSHOT</version> | |
<build> | |
<sourceDirectory>src</sourceDirectory> | |
<plugins> | |
<plugin> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<version>3.5.1</version> | |
<configuration> | |
<source>1.8</source> | |
<target>1.8</target> | |
</configuration> | |
</plugin> | |
<plugin> | |
<artifactId>maven-dependency-plugin</artifactId> | |
<executions> | |
<execution> | |
<phase>process-sources</phase> | |
<goals> | |
<goal>copy-dependencies</goal> | |
</goals> | |
<configuration> | |
<outputDirectory>${project.basedir}/lib</outputDirectory> | |
</configuration> | |
</execution> | |
</executions> | |
</plugin> | |
</plugins> | |
</build> | |
<dependencies> | |
<dependency> | |
<groupId>io.springfox</groupId> | |
<artifactId>springfox-swagger2</artifactId> | |
<version>2.6.1</version> | |
</dependency> | |
<dependency> | |
<groupId>io.springfox</groupId> | |
<artifactId>springfox-swagger-ui</artifactId> | |
<version>2.6.1</version> | |
</dependency> | |
</dependencies> | |
</project> | |
----- | |
http://stackoverflow.com/questions/26720090/a-simple-way-to-implement-swagger-in-a-spring-mvc-application | |
https://springfox.github.io/springfox/docs/current/#swagger |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment