@@ -86,8 +86,9 @@ public class OpenAPIV3ParserTest {
86
86
protected WireMockServer wireMockServer ;
87
87
88
88
@ Test
89
- public void testIssue1643 () throws Exception {
89
+ public void testIssue1643_True () throws Exception {
90
90
ParseOptions options = new ParseOptions ();
91
+ options .setValidateInternalRefs (true );
91
92
String issue1643 = "openapi: \" 3.0.0\" \n " +
92
93
"info:\n " +
93
94
" version: 1.0.0\n " +
@@ -128,6 +129,49 @@ public void testIssue1643() throws Exception{
128
129
assertTrue (result .getMessages ().contains ("attribute components.schemas.Person.Employee is not of type `schema`" ));
129
130
}
130
131
132
+ @ Test
133
+ public void testIssue1643_False () throws Exception {
134
+ ParseOptions options = new ParseOptions ();
135
+ String issue1643 = "openapi: \" 3.0.0\" \n " +
136
+ "info:\n " +
137
+ " version: 1.0.0\n " +
138
+ " title: People\n " +
139
+ "paths:\n " +
140
+ " /person:\n " +
141
+ " get:\n " +
142
+ " operationId: getPerson\n " +
143
+ " parameters:\n " +
144
+ " - name: name\n " +
145
+ " in: query\n " +
146
+ " required: true\n " +
147
+ " schema:\n " +
148
+ " type: string\n " +
149
+ " responses:\n " +
150
+ " '200':\n " +
151
+ " description: The person with the given name. \n " +
152
+ " content:\n " +
153
+ " application/json:\n " +
154
+ " schema:\n " +
155
+ " $ref: '#/components/schemas/Person'\n " +
156
+ "components:\n " +
157
+ " schemas:\n " +
158
+ " Person:\n " +
159
+ " required:\n " +
160
+ " - name\n " +
161
+ " type: object\n " +
162
+ " properties:\n " +
163
+ " name:\n " +
164
+ " type: string\n " +
165
+ " employee:\n " +
166
+ " $ref: '#/components/schemas/Employee'" ;
167
+ SwaggerParseResult result = new OpenAPIV3Parser ().readContents (issue1643 , null , options );
168
+
169
+ Assert .assertNotNull (result );
170
+ Assert .assertNotNull (result .getOpenAPI ());
171
+ assertEquals (result .getMessages ().size (),0 );
172
+ assertFalse (result .getMessages ().contains ("attribute components.schemas.Person.Employee is not of type `schema`" ));
173
+ }
174
+
131
175
@ Test
132
176
public void testExampleFormatByte () throws Exception {
133
177
@@ -328,7 +372,7 @@ public void testCantReadDeepProperties() {
328
372
options .setResolveFully (true );
329
373
330
374
final SwaggerParseResult parseResult = parser .readLocation ("src/test/resources/cant-read-deep-properties.yaml" , null , options );
331
- assertEquals (parseResult .getMessages ().size (), 1 );
375
+ assertEquals (parseResult .getMessages ().size (), 0 );
332
376
Schema projects = (Schema ) parseResult .getOpenAPI ().getComponents ().getSchemas ().get ("Project" ).getProperties ().get ("project_type" );
333
377
assertEquals (projects .getType (), "integer" );
334
378
}
@@ -2511,7 +2555,7 @@ public void testIssue931() {
2511
2555
SwaggerParseResult result = new OpenAPIV3Parser ().readLocation ("Issue_931.json" , null , options );
2512
2556
assertNotNull (result .getOpenAPI ());
2513
2557
assertTrue (result .getMessages ().size () > 0 );
2514
- assertEquals (result .getMessages ().get (1 ).contains ("doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" ), true );
2558
+ assertEquals (result .getMessages ().get (0 ).contains ("doesn't adhere to regular expression ^[a-zA-Z0-9\\ .\\ -_]+$" ), true );
2515
2559
2516
2560
}
2517
2561
0 commit comments