File tree Expand file tree Collapse file tree 3 files changed +93
-0
lines changed
springdoc-openapi-security/src/test
java/test/org/springdoc/api/app8 Expand file tree Collapse file tree 3 files changed +93
-0
lines changed Original file line number Diff line number Diff line change 1+ package test .org .springdoc .api .app8 ;
2+
3+ import io .swagger .v3 .oas .models .OpenAPI ;
4+ import io .swagger .v3 .oas .models .info .Info ;
5+ import io .swagger .v3 .oas .models .info .License ;
6+ import org .springframework .boot .autoconfigure .SpringBootApplication ;
7+ import org .springframework .context .annotation .Bean ;
8+ import org .springframework .test .context .TestPropertySource ;
9+ import test .org .springdoc .api .AbstractSpringDocTest ;
10+
11+ @ TestPropertySource (properties = "springdoc.show-login-endpoint=true" )
12+ public class SpringDocApp8Test extends AbstractSpringDocTest {
13+
14+ @ SpringBootApplication (scanBasePackages = { "test.org.springdoc.api.configuration,test.org.springdoc.api.app8" })
15+ static class SpringDocTestApp {
16+ @ Bean
17+ public OpenAPI customOpenAPI () {
18+ return new OpenAPI ()
19+ .info (new Info ().title ("Security API" ).version ("v1" )
20+ .license (new License ().name ("Apache 2.0" ).url ("http://springdoc.org" )));
21+ }
22+ }
23+ }
Original file line number Diff line number Diff line change 1+ package test .org .springdoc .api .app8 .security ;
2+
3+ import org .springframework .core .annotation .Order ;
4+ import org .springframework .security .config .annotation .web .builders .HttpSecurity ;
5+ import org .springframework .security .config .annotation .web .configuration .EnableWebSecurity ;
6+ import org .springframework .security .config .annotation .web .configuration .WebSecurityConfigurerAdapter ;
7+
8+ @ EnableWebSecurity
9+ @ Order (200 )
10+ public class WebConfig extends WebSecurityConfigurerAdapter {
11+
12+ @ Override
13+ protected void configure (HttpSecurity http ) throws Exception {
14+ http .formLogin ()
15+ .loginProcessingUrl ("/api/login" );
16+ }
17+ }
Original file line number Diff line number Diff line change 1+ {
2+ "openapi" : " 3.0.1" ,
3+ "info" : {
4+ "title" : " Security API" ,
5+ "license" : {
6+ "name" : " Apache 2.0" ,
7+ "url" : " http://springdoc.org"
8+ },
9+ "version" : " v1"
10+ },
11+ "servers" : [
12+ {
13+ "url" : " http://localhost" ,
14+ "description" : " Generated server url"
15+ }
16+ ],
17+ "paths" : {
18+ "/api/login" : {
19+ "post" : {
20+ "tags" : [
21+ " login-endpoint"
22+ ],
23+ "requestBody" : {
24+ "content" : {
25+ "application/json" : {
26+ "schema" : {
27+ "type" : " object" ,
28+ "properties" : {
29+ "username" : {
30+ "type" : " string"
31+ },
32+ "password" : {
33+ "type" : " string"
34+ }
35+ }
36+ }
37+ }
38+ }
39+ },
40+ "responses" : {
41+ "200" : {
42+ "description" : " OK"
43+ },
44+ "403" : {
45+ "description" : " Forbidden"
46+ }
47+ }
48+ }
49+ }
50+ },
51+ "components" : {
52+ }
53+ }
You can’t perform that action at this time.
0 commit comments