@Test public void testProcessComposedSchema() throws Exception { setupPropertyAndExternalRefProcessors(); final String ref1 = "http: final String ref2 = "http: final String ref3 = "http: SchemaProcessor modelProcessor = new SchemaProcessor(cache, openAPI); new Expectations() {{ externalRefProcessor.processRefToExternalSchema(ref1, RefFormat.URL); times = 1; result = "bar"; externalRefProcessor.processRefToExternalSchema(ref2, RefFormat.URL); times = 1; result = "that"; externalRefProcessor.processRefToExternalSchema(ref3, RefFormat.URL); times = 1; result = "world"; }}; ComposedSchema composedModel = new ComposedSchema(); composedModel.addAllOfItem(new Schema().$ref(ref1)); composedModel.addAllOfItem(new Schema().$ref(ref2)); composedModel.addAllOfItem(new Schema().$ref(ref3)); modelProcessor.processSchema(composedModel); new FullVerifications() {{ externalRefProcessor.processRefToExternalSchema(ref1, RefFormat.URL); times = 1; externalRefProcessor.processRefToExternalSchema(ref2, RefFormat.URL); times = 1; externalRefProcessor.processRefToExternalSchema(ref3, RefFormat.URL); times = 1; }}; assertEquals(composedModel.getAllOf().get(0).get$ref(),"#/components/schemas/bar"); assertEquals(composedModel.getAllOf().get(1).get$ref(), "#/components/schemas/that"); assertEquals(composedModel.getAllOf().get(2).get$ref(), "#/components/schemas/world"); }
public void processComposedSchema(ComposedSchema composedSchema) { if(composedSchema.getAllOf() != null) { final List<Schema> schemas = composedSchema.getAllOf(); if (schemas != null) { for (Schema schema : schemas) { if (schema.get$ref() != null) { processReferenceSchema(schema); } else { processSchemaType(schema); } } } }if(composedSchema.getOneOf() != null){ final List<Schema> schemas = composedSchema.getOneOf(); if (schemas != null) { for (Schema schema : schemas) { if (schema.get$ref() != null) { String oldRef = schema.get$ref(); processReferenceSchema(schema); String newRef = schema.get$ref(); changeDiscriminatorMapping(composedSchema, oldRef, newRef); } else { processSchemaType(schema); } } } }if(composedSchema.getAnyOf() != null){ final List<Schema> schemas = composedSchema.getAnyOf(); if (schemas != null) { for (Schema schema : schemas) { if (schema.get$ref() != null) { processReferenceSchema(schema); } else { processSchemaType(schema); } } } } }
SchemaProcessor { public void processComposedSchema(ComposedSchema composedSchema) { if(composedSchema.getAllOf() != null) { final List<Schema> schemas = composedSchema.getAllOf(); if (schemas != null) { for (Schema schema : schemas) { if (schema.get$ref() != null) { processReferenceSchema(schema); } else { processSchemaType(schema); } } } }if(composedSchema.getOneOf() != null){ final List<Schema> schemas = composedSchema.getOneOf(); if (schemas != null) { for (Schema schema : schemas) { if (schema.get$ref() != null) { String oldRef = schema.get$ref(); processReferenceSchema(schema); String newRef = schema.get$ref(); changeDiscriminatorMapping(composedSchema, oldRef, newRef); } else { processSchemaType(schema); } } } }if(composedSchema.getAnyOf() != null){ final List<Schema> schemas = composedSchema.getAnyOf(); if (schemas != null) { for (Schema schema : schemas) { if (schema.get$ref() != null) { processReferenceSchema(schema); } else { processSchemaType(schema); } } } } } }
SchemaProcessor { public void processComposedSchema(ComposedSchema composedSchema) { if(composedSchema.getAllOf() != null) { final List<Schema> schemas = composedSchema.getAllOf(); if (schemas != null) { for (Schema schema : schemas) { if (schema.get$ref() != null) { processReferenceSchema(schema); } else { processSchemaType(schema); } } } }if(composedSchema.getOneOf() != null){ final List<Schema> schemas = composedSchema.getOneOf(); if (schemas != null) { for (Schema schema : schemas) { if (schema.get$ref() != null) { String oldRef = schema.get$ref(); processReferenceSchema(schema); String newRef = schema.get$ref(); changeDiscriminatorMapping(composedSchema, oldRef, newRef); } else { processSchemaType(schema); } } } }if(composedSchema.getAnyOf() != null){ final List<Schema> schemas = composedSchema.getAnyOf(); if (schemas != null) { for (Schema schema : schemas) { if (schema.get$ref() != null) { processReferenceSchema(schema); } else { processSchemaType(schema); } } } } } SchemaProcessor(ResolverCache cache, OpenAPI openAPI); }
SchemaProcessor { public void processComposedSchema(ComposedSchema composedSchema) { if(composedSchema.getAllOf() != null) { final List<Schema> schemas = composedSchema.getAllOf(); if (schemas != null) { for (Schema schema : schemas) { if (schema.get$ref() != null) { processReferenceSchema(schema); } else { processSchemaType(schema); } } } }if(composedSchema.getOneOf() != null){ final List<Schema> schemas = composedSchema.getOneOf(); if (schemas != null) { for (Schema schema : schemas) { if (schema.get$ref() != null) { String oldRef = schema.get$ref(); processReferenceSchema(schema); String newRef = schema.get$ref(); changeDiscriminatorMapping(composedSchema, oldRef, newRef); } else { processSchemaType(schema); } } } }if(composedSchema.getAnyOf() != null){ final List<Schema> schemas = composedSchema.getAnyOf(); if (schemas != null) { for (Schema schema : schemas) { if (schema.get$ref() != null) { processReferenceSchema(schema); } else { processSchemaType(schema); } } } } } SchemaProcessor(ResolverCache cache, OpenAPI openAPI); void processSchema(Schema schema); void processSchemaType(Schema schema); void processPropertySchema(Schema schema); void processComposedSchema(ComposedSchema composedSchema); void processArraySchema(ArraySchema arraySchema); }
SchemaProcessor { public void processComposedSchema(ComposedSchema composedSchema) { if(composedSchema.getAllOf() != null) { final List<Schema> schemas = composedSchema.getAllOf(); if (schemas != null) { for (Schema schema : schemas) { if (schema.get$ref() != null) { processReferenceSchema(schema); } else { processSchemaType(schema); } } } }if(composedSchema.getOneOf() != null){ final List<Schema> schemas = composedSchema.getOneOf(); if (schemas != null) { for (Schema schema : schemas) { if (schema.get$ref() != null) { String oldRef = schema.get$ref(); processReferenceSchema(schema); String newRef = schema.get$ref(); changeDiscriminatorMapping(composedSchema, oldRef, newRef); } else { processSchemaType(schema); } } } }if(composedSchema.getAnyOf() != null){ final List<Schema> schemas = composedSchema.getAnyOf(); if (schemas != null) { for (Schema schema : schemas) { if (schema.get$ref() != null) { processReferenceSchema(schema); } else { processSchemaType(schema); } } } } } SchemaProcessor(ResolverCache cache, OpenAPI openAPI); void processSchema(Schema schema); void processSchemaType(Schema schema); void processPropertySchema(Schema schema); void processComposedSchema(ComposedSchema composedSchema); void processArraySchema(ArraySchema arraySchema);  }