@@ -240,7 +240,7 @@ public void testSiblingsReferenceObjects() {
240
240
}
241
241
242
242
@ Test (description = "Test siblings with $ref for maxItems, properties, description, required" )
243
- public void testSiblingsReferenceJSONSchema () {
243
+ public void testSiblingsReferenceJSONSchema1 () {
244
244
ParseOptions options = new ParseOptions ();
245
245
String refSibling = "openapi: 3.1.0\n " +
246
246
"info:\n " +
@@ -274,4 +274,70 @@ public void testSiblingsReferenceJSONSchema() {
274
274
assertTrue (profile .getProperties ().containsKey ("login" ));
275
275
assertTrue (profile .getProperties ().containsKey ("password" ));
276
276
}
277
+
278
+ @ Test (description = "Test siblings with $ref for patternProperties, pattern, additionalProperties" )
279
+ public void testSiblingsReferenceJSONSchema2 () {
280
+ ParseOptions options = new ParseOptions ();
281
+ String refSibling = "openapi: 3.1.0\n " +
282
+ "info:\n " +
283
+ " title: siblings JSONschema\n " +
284
+ " version: 1.0.0\n " +
285
+ "servers:\n " +
286
+ " - url: /\n " +
287
+ "paths: { }\n " +
288
+ "components:\n " +
289
+ " schemas:\n " +
290
+ " profile:\n " +
291
+ " $ref: ./ex.json#user-profile\n " +
292
+ " pattern: \\ d\\ d\\ d\\ d-\\ d\\ d-\\ d\\ d\n " +
293
+ " patternProperties:\n " +
294
+ " \" ^S_\" :\n " +
295
+ " type: string\n " +
296
+ " \" ^I_\" :\n " +
297
+ " type: integer\n " +
298
+ " additionalProperties: false" ;
299
+ SwaggerParseResult result = new OpenAPIV3Parser ().readContents ( refSibling , null , options );
300
+ OpenAPI openAPI = result .getOpenAPI ();
301
+ assertNotNull (openAPI );
302
+ Schema profile = openAPI .getComponents ().getSchemas ().get ("profile" );
303
+ assertNotNull (profile .get$ref ());
304
+ assertEquals (profile .getPattern (),"\\ d\\ d\\ d\\ d-\\ d\\ d-\\ d\\ d" );
305
+ assertNotNull (profile .getAdditionalProperties ());
306
+ assertTrue (profile .getPatternProperties ().containsKey ("^S_" ));
307
+ }
308
+
309
+ @ Test (description = "Test siblings with $ref for patternProperties, pattern, additionalProperties" )
310
+ public void testSiblingsReferenceJSONSchema3 () {
311
+ ParseOptions options = new ParseOptions ();
312
+ String refSibling = "openapi: 3.1.0\n " +
313
+ "info:\n " +
314
+ " title: siblings JSONschema\n " +
315
+ " version: 1.0.0\n " +
316
+ "servers:\n " +
317
+ " - url: /\n " +
318
+ "paths: { }\n " +
319
+ "components:\n " +
320
+ " schemas:\n " +
321
+ " profile:\n " +
322
+ " $id: profile-id\n " +
323
+ " $anchor: foo\n " +
324
+ " $schema: https://json-schema.org/draft/2020-12/schema\n " +
325
+ " $comment: end user should not see this comment\n " +
326
+ " type:\n " +
327
+ " - string\n " +
328
+ " - integer\n " +
329
+ " exclusiveMaximum: 12\n " +
330
+ " exclusiveMinimum: 1\n " +
331
+ " $ref: ./ex.json#user-profile" ;
332
+ SwaggerParseResult result = new OpenAPIV3Parser ().readContents ( refSibling , null , options );
333
+ OpenAPI openAPI = result .getOpenAPI ();
334
+ assertNotNull (openAPI );
335
+ Schema profile = openAPI .getComponents ().getSchemas ().get ("profile" );
336
+ assertNotNull (profile .get$ref ());
337
+ assertEquals (profile .get$anchor (),"foo" );
338
+ assertEquals (profile .get$id (),"profile-id" );
339
+ assertTrue (profile .getExclusiveMaximumValue ().intValue ()==12 );
340
+ assertTrue (profile .getExclusiveMinimumValue ().intValue ()==1 );
341
+ assertEquals (profile .get$comment (),"end user should not see this comment" );
342
+ }
277
343
}
0 commit comments