File tree Expand file tree Collapse file tree 7 files changed +145
-1
lines changed
springdoc-openapi-common/src/main/java/org/springdoc/core
springdoc-openapi-webmvc-core/src/test
java/test/org/springdoc/api/app105 Expand file tree Collapse file tree 7 files changed +145
-1
lines changed Original file line number Diff line number Diff line change 2121import java .lang .reflect .ParameterizedType ;
2222import java .lang .reflect .Type ;
2323
24+ import org .springframework .core .GenericTypeResolver ;
2425import org .springframework .core .MethodParameter ;
2526
2627public interface ReturnTypeParser {
2728
2829 default Type getReturnType (MethodParameter methodParameter ) {
2930 if (methodParameter .getGenericParameterType () instanceof ParameterizedType )
30- return methodParameter .getGenericParameterType ();
31+ return GenericTypeResolver . resolveType ( methodParameter .getGenericParameterType (), methodParameter . getContainingClass () );
3132 return methodParameter .getParameterType ();
3233 }
3334}
Original file line number Diff line number Diff line change 1+ package test .org .springdoc .api .app105 ;
2+
3+ import java .util .List ;
4+
5+ import io .swagger .v3 .oas .annotations .Operation ;
6+ import io .swagger .v3 .oas .annotations .Parameter ;
7+
8+ import org .springframework .stereotype .Controller ;
9+ import org .springframework .web .bind .annotation .GetMapping ;
10+ import org .springframework .web .bind .annotation .PathVariable ;
11+ import org .springframework .web .bind .annotation .ResponseBody ;
12+
13+ @ Controller
14+ @ SuppressWarnings ("rawtypes" )
15+ public abstract class CrudController <T extends HavingPK > {
16+
17+ @ GetMapping (path = "{id}" )
18+ @ ResponseBody
19+ @ Operation (description = "Get single object" )
20+ public T get ( //
21+ @ Parameter (description = "The id to get." , required = true ) @ PathVariable ("id" ) int id ) {
22+ return null ;
23+ }
24+
25+ @ GetMapping (path = "" )
26+ @ ResponseBody
27+ @ Operation (description = "Receive a list of objects" )
28+ public List <T > list () {
29+ return null ;
30+ }
31+ }
Original file line number Diff line number Diff line change 1+ package test .org .springdoc .api .app105 ;
2+
3+ public class Design extends HavingPK {
4+ }
Original file line number Diff line number Diff line change 1+ package test .org .springdoc .api .app105 ;
2+
3+ import io .swagger .v3 .oas .annotations .tags .Tag ;
4+
5+ import org .springframework .stereotype .Controller ;
6+ import org .springframework .web .bind .annotation .RequestMapping ;
7+
8+ @ Tag (name = "design" )
9+ @ Controller
10+ @ RequestMapping ("/design" )
11+ public class DesignController extends CrudController <Design > {
12+
13+
14+
15+ }
Original file line number Diff line number Diff line change 1+ package test .org .springdoc .api .app105 ;
2+
3+ public class HavingPK {
4+ }
Original file line number Diff line number Diff line change 1+ package test .org .springdoc .api .app105 ;
2+
3+ import test .org .springdoc .api .AbstractSpringDocTest ;
4+
5+ import org .springframework .boot .autoconfigure .SpringBootApplication ;
6+
7+ public class SpringDocApp105Test extends AbstractSpringDocTest {
8+ @ SpringBootApplication
9+ static class SpringDocTestApp {}
10+ }
Original file line number Diff line number Diff line change 1+ {
2+ "openapi" : " 3.0.1" ,
3+ "info" : {
4+ "title" : " OpenAPI definition" ,
5+ "version" : " v0"
6+ },
7+ "servers" : [
8+ {
9+ "url" : " http://localhost" ,
10+ "description" : " Generated server url"
11+ }
12+ ],
13+ "paths" : {
14+ "/design/{id}" : {
15+ "get" : {
16+ "tags" : [
17+ " design"
18+ ],
19+ "description" : " Get single object" ,
20+ "operationId" : " get" ,
21+ "parameters" : [
22+ {
23+ "name" : " id" ,
24+ "in" : " path" ,
25+ "description" : " The id to get." ,
26+ "required" : true ,
27+ "schema" : {
28+ "type" : " integer" ,
29+ "format" : " int32"
30+ }
31+ }
32+ ],
33+ "responses" : {
34+ "200" : {
35+ "description" : " default response" ,
36+ "content" : {
37+ "*/*" : {
38+ "schema" : {
39+ "$ref" : " #/components/schemas/Design"
40+ }
41+ }
42+ }
43+ }
44+ }
45+ }
46+ },
47+ "/design" : {
48+ "get" : {
49+ "tags" : [
50+ " design"
51+ ],
52+ "description" : " Receive a list of objects" ,
53+ "operationId" : " list" ,
54+ "responses" : {
55+ "200" : {
56+ "description" : " default response" ,
57+ "content" : {
58+ "*/*" : {
59+ "schema" : {
60+ "type" : " array" ,
61+ "items" : {
62+ "$ref" : " #/components/schemas/Design"
63+ }
64+ }
65+ }
66+ }
67+ }
68+ }
69+ }
70+ }
71+ },
72+ "components" : {
73+ "schemas" : {
74+ "Design" : {
75+ "type" : " object"
76+ }
77+ }
78+ }
79+ }
You can’t perform that action at this time.
0 commit comments