use of io.swagger.v3.parser.OpenAPIResolver in project swagger-parser by swagger-api.
the class OpenAPIResolverTest method testOperationBodyparamRemoteRefs.
private void testOperationBodyparamRemoteRefs(String remoteRef) {
final OpenAPI swagger = new OpenAPI();
swagger.path("/fun", new PathItem().get(new Operation().requestBody(new RequestBody().content(new Content().addMediaType("*/*", new MediaType().schema(new Schema().$ref(remoteRef)))))));
final OpenAPI resolved = new OpenAPIResolver(swagger, null).resolve();
final RequestBody param = swagger.getPaths().get("/fun").getGet().getRequestBody();
final Schema ref = param.getContent().get("*/*").getSchema();
assertEquals(ref.get$ref(), "#/components/schemas/Tag");
assertNotNull(swagger.getComponents().getSchemas().get("Tag"));
}
use of io.swagger.v3.parser.OpenAPIResolver in project swagger-parser by swagger-api.
the class OpenAPIResolverTest method testOperationBodyParameterRemoteRefs.
@Test
public void testOperationBodyParameterRemoteRefs() {
final Schema schema = new Schema();
final OpenAPI swagger = new OpenAPI();
swagger.path("/fun", new PathItem().get(new Operation().parameters(Arrays.asList(new Parameter().$ref("#/components/parameters/SampleParameter")))));
swagger.path("/times", new PathItem().get(new Operation().parameters(Arrays.asList(new Parameter().$ref("#/components/parameters/SampleParameter")))));
swagger.components(new Components().addParameters("SampleParameter", new Parameter().name("skip").schema(schema)));
final OpenAPI resolved = new OpenAPIResolver(swagger, null).resolve();
final List<Parameter> params = swagger.getPaths().get("/fun").getGet().getParameters();
assertEquals(params.size(), 1);
final Parameter param = params.get(0);
assertEquals(param.getName(), "skip");
}
Aggregations