File tree Expand file tree Collapse file tree
springfox-spring-web/src/test/java/springfox/documentation/spring/web/dummy/controllers
groovy/springfox/test/contract/swaggertests
resources/contract/swagger2 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2929import io .swagger .annotations .ApiResponses ;
3030import org .springframework .hateoas .Resource ;
3131import org .springframework .http .ResponseEntity ;
32+ import org .springframework .web .bind .annotation .GetMapping ;
3233import org .springframework .web .bind .annotation .ModelAttribute ;
3334import org .springframework .web .bind .annotation .RequestBody ;
3435import org .springframework .web .bind .annotation .RequestMapping ;
4142
4243import javax .servlet .http .HttpServletResponse ;
4344import javax .validation .Valid ;
45+ import javax .validation .constraints .NotNull ;
4446import java .net .MalformedURLException ;
4547import java .net .URL ;
4648import java .nio .ByteBuffer ;
@@ -218,6 +220,24 @@ public void modelWithListOfEnumsAsJson(@RequestBody Model1819 model) {
218220 public void modelWithListOfEnumsAsModelAttribute (@ ModelAttribute Model1819 model ) {
219221 }
220222
223+ @ GetMapping ("/1864" )
224+ public void test (@ Valid Model1864 req ) {
225+
226+ }
227+
228+ public class Model1864 {
229+ @ NotNull
230+ private String somename ;
231+
232+ public String getSomename () {
233+ return somename ;
234+ }
235+
236+ public void setSomename (String somename ) {
237+ this .somename = somename ;
238+ }
239+ }
240+
221241 public class Model1819 {
222242
223243 private List <EnumType > enumTypes ;
Original file line number Diff line number Diff line change @@ -40,8 +40,9 @@ dependencies {
4040 compile project(' :springfox-swagger1' )
4141 compile project(' :springfox-swagger2' )
4242 compile project(' :springfox-data-rest' )
43+ compile project(' :springfox-petstore' )
44+ compile project(' :springfox-bean-validators' )
4345 compile project(' :springfox-spring-web' ). sourceSets. test. output
44- compile project(path : ' :springfox-petstore' )
4546
4647
4748 compile(project(path : ' :springfox-swagger-ui' )) {
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ import org.springframework.test.context.ContextConfiguration
3636import spock.lang.Shared
3737import spock.lang.Specification
3838import spock.lang.Unroll
39+ import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration
3940import springfox.documentation.schema.AlternateTypeRuleConvention
4041import springfox.documentation.spring.web.plugins.JacksonSerializerConvention
4142
@@ -190,7 +191,11 @@ class FunctionContractSpec extends Specification implements FileAccess {
190191 " springfox.test.contract.swagger" ,
191192 " springfox.petstore.controller"
192193 ])
193- @Import ([SecuritySupport , Swagger12TestConfig , Swagger2TestConfig ])
194+ @Import ([
195+ SecuritySupport ,
196+ Swagger12TestConfig ,
197+ Swagger2TestConfig ,
198+ BeanValidatorPluginsConfiguration ])
194199 static class Config {
195200
196201 @Bean
Original file line number Diff line number Diff line change 1414 "host" : " localhost:__PORT__" ,
1515 "basePath" : " /" ,
1616 "tags" : [
17- {
18- "name" : " foo" ,
19- "description" : " Foo Description"
20- },
2117 {
2218 "name" : " bugs-controller" ,
2319 "description" : " Bugs Controller"
20+ },
21+ {
22+ "name" : " foo" ,
23+ "description" : " Foo Description"
2424 }
2525 ],
2626 "produces" : [
530530 "description" : " Remove an apple from a user. You must specify the user name and the apple name." ,
531531 "operationId" : " bug1722UsingPOST_2" ,
532532 "consumes" : [
533- " application/xml " ,
534- " application/json "
533+ " application/json " ,
534+ " application/xml "
535535 ],
536536 "produces" : [
537537 " application/xml" ,
629629 {
630630 "name" : " pageNumber" ,
631631 "in" : " query" ,
632- "required" : false ,
632+ "required" : true ,
633633 "type" : " integer" ,
634+ "minimum" : 1.0 ,
634635 "format" : " int32"
635636 },
636637 {
637638 "name" : " pageSize" ,
638639 "in" : " query" ,
639- "required" : false ,
640+ "required" : true ,
640641 "type" : " integer" ,
642+ "maximum" : 50.0 ,
641643 "format" : " int32"
642644 },
643645 {
894896 }
895897 }
896898 }
899+ },
900+ "/bugs/1864{?somename}" : {
901+ "get" : {
902+ "tags" : [
903+ " bugs-controller"
904+ ],
905+ "summary" : " test" ,
906+ "operationId" : " testUsingGET_2" ,
907+ "consumes" : [
908+ " application/json"
909+ ],
910+ "produces" : [
911+ " application/xml" ,
912+ " application/json"
913+ ],
914+ "parameters" : [
915+ {
916+ "name" : " somename" ,
917+ "in" : " query" ,
918+ "required" : true ,
919+ "type" : " string"
920+ }
921+ ],
922+ "responses" : {
923+ "200" : {
924+ "description" : " OK"
925+ }
926+ }
927+ }
897928 }
898929 },
899930 "securityDefinitions" : {
10761107 }
10771108 }
10781109 }
1079- }
1110+ }
Original file line number Diff line number Diff line change 1414 "host" : " localhost:__PORT__" ,
1515 "basePath" : " /" ,
1616 "tags" : [
17- {
18- "name" : " foo" ,
19- "description" : " Foo Description"
20- },
2117 {
2218 "name" : " bugs-controller" ,
2319 "description" : " Bugs Controller"
20+ },
21+ {
22+ "name" : " foo" ,
23+ "description" : " Foo Description"
2424 }
2525 ],
2626 "produces" : [
541541 "description" : " Remove an apple from a user. You must specify the user name and the apple name." ,
542542 "operationId" : " bug1722UsingPOST_1" ,
543543 "consumes" : [
544- " application/xml " ,
545- " application/json "
544+ " application/json " ,
545+ " application/xml "
546546 ],
547547 "produces" : [
548548 " application/xml" ,
640640 {
641641 "name" : " pageNumber" ,
642642 "in" : " query" ,
643- "required" : false ,
643+ "required" : true ,
644644 "type" : " integer" ,
645+ "minimum" : 1.0 ,
645646 "format" : " int32"
646647 },
647648 {
648649 "name" : " pageSize" ,
649650 "in" : " query" ,
650- "required" : false ,
651+ "required" : true ,
651652 "type" : " integer" ,
653+ "maximum" : 50.0 ,
652654 "format" : " int32"
653655 },
654656 {
905907 }
906908 }
907909 }
910+ },
911+ "/bugs/1864{?somename}" : {
912+ "get" : {
913+ "tags" : [
914+ " bugs-controller"
915+ ],
916+ "summary" : " test" ,
917+ "operationId" : " testUsingGET_1" ,
918+ "consumes" : [
919+ " application/json"
920+ ],
921+ "produces" : [
922+ " application/xml" ,
923+ " application/json"
924+ ],
925+ "parameters" : [
926+ {
927+ "name" : " somename" ,
928+ "in" : " query" ,
929+ "required" : true ,
930+ "type" : " string"
931+ }
932+ ],
933+ "responses" : {
934+ "200" : {
935+ "description" : " OK"
936+ }
937+ }
938+ }
908939 }
909940 },
910941 "securityDefinitions" : {
10951126 }
10961127 }
10971128 }
1098- }
1129+ }
Original file line number Diff line number Diff line change 1515 "basePath" : " /" ,
1616 "tags" : [
1717 {
18- "name" : " pet-store-resource " ,
19- "description" : " Operations about store "
18+ "name" : " generic- pet-controller " ,
19+ "description" : " Generic Pet Controller "
2020 },
2121 {
2222 "name" : " pet-controller" ,
2323 "description" : " Operations about pets"
2424 },
2525 {
26- "name" : " generic- pet-controller " ,
27- "description" : " Generic Pet Controller "
26+ "name" : " pet-store-resource " ,
27+ "description" : " Operations about store "
2828 },
2929 {
3030 "name" : " user-controller" ,
3131 "description" : " Operations about user"
3232 }
3333 ],
3434 "schemes" : [
35- " http " ,
36- " https "
35+ " https " ,
36+ " http "
3737 ],
3838 "produces" : [
3939 " application/xml" ,
990990 }
991991 }
992992 }
993- }
993+ }
You can’t perform that action at this time.
0 commit comments