This repository was archived by the owner on Nov 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree
modules/swagger-parser-v3/src
main/java/io/swagger/v3/parser/processors
java/io/swagger/v3/parser/test Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -83,6 +83,11 @@ public List<Parameter> processParameters(List<Parameter> parameters) {
8383 if (parameter .get$ref () != null ) {
8484 RefFormat refFormat = computeRefFormat (parameter .get$ref ());
8585 final Parameter resolvedParameter = cache .loadRef (parameter .get$ref (), refFormat , Parameter .class );
86+ if (parameter .get$ref ().startsWith ("#" ) && parameter .get$ref ().indexOf ("#/components/parameters" ) <= -1 ) {
87+ //TODO: Not possible to add warning during resolve doesn't accept result as an input. Hence commented below line.
88+ //result.warning(location, "The parameter should use Reference Object to link to parameters that are defined at the OpenAPI Object's components/parameters.");
89+ continue ;
90+ }
8691
8792 if (resolvedParameter == null ) {
8893 // can't resolve it!
@@ -92,7 +97,7 @@ public List<Parameter> processParameters(List<Parameter> parameters) {
9297 // if the parameter exists, replace it
9398 boolean matched = false ;
9499 for (Parameter param : processedPathLevelParameters ) {
95- if (param .getName ().equals (resolvedParameter .getName ())) {
100+ if (param != null && param . getName () != null && param .getName ().equals (resolvedParameter .getName ())) {
96101 // ref param wins
97102 matched = true ;
98103 break ;
Original file line number Diff line number Diff line change 3030import io .swagger .v3 .oas .models .parameters .RequestBody ;
3131import io .swagger .v3 .oas .models .responses .ApiResponse ;
3232import io .swagger .v3 .oas .models .security .SecurityScheme ;
33+ import io .swagger .v3 .parser .OpenAPIResolver ;
3334import io .swagger .v3 .parser .OpenAPIV3Parser ;
3435import io .swagger .v3 .parser .core .models .AuthorizationValue ;
3536import io .swagger .v3 .parser .core .models .ParseOptions ;
@@ -1631,6 +1632,16 @@ public void testIssue931() {
16311632
16321633 }
16331634
1635+ @ Test
1636+ public void testIssue948 () {
1637+ ParseOptions options = new ParseOptions ();
1638+ options .setResolve (true );
1639+ SwaggerParseResult result = new OpenAPIV3Parser ().readLocation ("Issue_948.json" , null , options );
1640+ new OpenAPIResolver (result .getOpenAPI ()).resolve ();
1641+ assertNotNull (result .getOpenAPI ());
1642+
1643+ }
1644+
16341645 public void shouldParseParameters () {
16351646 ParseOptions parseOptions = new ParseOptions ();
16361647 parseOptions .setResolveFully (true );
Original file line number Diff line number Diff line change 1+ {
2+ "openapi" :" 3.0.0" ,
3+ "info" :{
4+ "title" :" Test" ,
5+ "description" :" Test API" ,
6+ "version" :" 1.0"
7+ },
8+ "servers" :[
9+ {
10+ "url" :" http://localhost:8888/api"
11+ }
12+ ],
13+ "paths" :{
14+ "/devices" :{
15+ "get" :{
16+ "tags" :[
17+ " devices"
18+ ],
19+ "summary" :" List all Devices" ,
20+ "operationId" :" getDevices" ,
21+ "parameters" :[
22+ {
23+ "$ref" :" #/components/headers/Content-Type"
24+ },
25+ {
26+ "$ref" :" #/components/parameters/idFrom"
27+ },
28+ {
29+ "name" :" category" ,
30+ "in" :" query" ,
31+ "description" :" A request parameter that matches against the device category." ,
32+ "schema" :{
33+ "$ref" :" #/components/schemas/deviceCategory"
34+ }
35+ },
36+ {
37+ "name" :" manufacturer" ,
38+ "in" :" query" ,
39+ "description" :" A request parameter that performs LIKE matching against the device manufacturer." ,
40+ "schema" :{
41+ "maxLength" :200 ,
42+ "minLength" :1 ,
43+ "type" :" string" ,
44+ "example" :" Sony"
45+ }
46+ }
47+ ],
48+ "responses" :{
49+ "200" :{
50+ "description" :" An array of devices that match the request parameters requested." ,
51+ "content" :{
52+ "application/json" :{
53+ "schema" :{
54+ "type" :" object" ,
55+ "properties" :{
56+ "device" :{
57+ "$ref" :" #/components/schemas/device"
58+ }
59+ }
60+ }
61+ }
62+ }
63+ }
64+ }
65+ }
66+ }
67+ },
68+ "components" :{
69+ "schemas" :{
70+ "deviceCategory" :{
71+ "type" :" string" ,
72+ "description" :" The list of avialable viewer device categories." ,
73+ "example" :" TV" ,
74+ "enum" :[
75+ " TV" ,
76+ " Phone" ,
77+ " Tablet" ,
78+ " Laptop" ,
79+ " Monitor" ,
80+ " Other"
81+ ]
82+ },
83+ "device" :{
84+ "type" :" string" ,
85+ "description" :" Captures the possible states for an analysis."
86+ }
87+ },
88+ "parameters" :{
89+ "idFrom" :{
90+ "name" :" idFrom" ,
91+ "in" :" query" ,
92+ "description" :" The lower-bound of a request parameter filtering based on unique object identifier." ,
93+ "schema" :{
94+ "type" :" integer"
95+ }
96+ }
97+ },
98+ "headers" :{
99+ "Content-Type" :{
100+ "required" :true ,
101+ "schema" :{
102+ "type" :" string" ,
103+ "example" :" application/json;charset=UTF-8" ,
104+ "default" :" application/json;charset=UTF-8"
105+ }
106+ }
107+ }
108+ }
109+ }
You can’t perform that action at this time.
0 commit comments