Skip to content

Commit a696c73

Browse files
committed
Added Swagger working on fixing it
1 parent 6fb2b3a commit a696c73

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

src/main/java/io/github/deepanshut041/serendeepia/config/SecurityConfiguration.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,14 @@ protected void configure(HttpSecurity http) throws Exception {
5454
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
5555
.and()
5656
.authorizeRequests()
57-
.antMatchers("/api/auth/**")
57+
.antMatchers(
58+
"/api/auth/**",
59+
"/api/v2/api-docs/**",
60+
"/swagger-ui.html/**",
61+
"/swagger-resources/**",
62+
"/favicon.ico", "/**/*.png", "/**/*.gif", "/**/*.svg", "/**/*.jpg", "/**/*.html", "/**/*.css", "/**/*.js"
63+
64+
)
5865
.permitAll().anyRequest().authenticated();
5966

6067
http.addFilterBefore(tokenAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package io.github.deepanshut041.serendeepia.config;
2+
3+
import org.springframework.context.annotation.Bean;
4+
import org.springframework.context.annotation.Configuration;
5+
import org.springframework.http.ResponseEntity;
6+
import springfox.documentation.builders.ApiInfoBuilder;
7+
import springfox.documentation.builders.PathSelectors;
8+
import springfox.documentation.builders.RequestHandlerSelectors;
9+
import springfox.documentation.service.ApiInfo;
10+
import springfox.documentation.service.Contact;
11+
import springfox.documentation.spi.DocumentationType;
12+
import springfox.documentation.spring.web.plugins.Docket;
13+
14+
import java.util.Optional;
15+
16+
@Configuration
17+
public class SpringFoxConfig {
18+
19+
@Bean
20+
public Docket api() {
21+
return new Docket(DocumentationType.SWAGGER_2)
22+
.genericModelSubstitutes(Optional.class, ResponseEntity.class)
23+
.apiInfo(apiInfo())
24+
.select().apis(RequestHandlerSelectors.any())
25+
.paths(PathSelectors.ant("/api/**"))
26+
.build();
27+
}
28+
private ApiInfo apiInfo() {
29+
return new ApiInfoBuilder().title("Sarte REST API")
30+
.description("Shop Management REST API")
31+
.contact(new Contact("Squrlabs", "www.Squrlabs.com", "squrlabs@gmail.com"))
32+
.license("Apache 2.0")
33+
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html")
34+
.version("0.0.1")
35+
.build();
36+
}
37+
38+
39+
}

0 commit comments

Comments
 (0)