use of io.swagger.models.parameters.RefParameter in project swagger-parser by swagger-api.
the class FileReferenceTests method testIssue421.
@Test
public void testIssue421() {
SwaggerDeserializationResult result = new SwaggerParser().readWithInfo("./src/test/resources/nested-file-references/issue-421.yaml", null, true);
assertNotNull(result.getSwagger());
Swagger swagger = result.getSwagger();
assertNotNull(swagger.getPath("/pet/{petId}"));
assertNotNull(swagger.getPath("/pet/{petId}").getGet());
assertNotNull(swagger.getPath("/pet/{petId}").getGet().getParameters());
assertTrue(swagger.getPath("/pet/{petId}").getGet().getParameters().size() == 1);
assertTrue(swagger.getPath("/pet/{petId}").getGet().getParameters().get(0).getName().equals("petId"));
assertTrue(swagger.getDefinitions().get("Pet") instanceof ModelImpl);
assertTrue(swagger.getDefinitions().get("Pet").getProperties().size() == 6);
assertNotNull(swagger.getPath("/pet/{petId}").getPost());
assertNotNull(swagger.getPath("/pet/{petId}").getPost().getParameters());
assertTrue(swagger.getPath("/pet/{petId}").getPost().getParameters().size() == 3);
assertTrue(swagger.getPath("/pet/{petId}").getPost().getParameters().get(1) instanceof RefParameter);
assertTrue(((RefParameter) swagger.getPath("/pet/{petId}").getPost().getParameters().get(1)).getRefFormat() == RefFormat.INTERNAL);
assertTrue(((RefParameter) swagger.getPath("/pet/{petId}").getPost().getParameters().get(1)).getSimpleRef().equals("name"));
assertNotNull(swagger.getPath("/store/order"));
assertNotNull(swagger.getPath("/store/order").getPost());
assertNotNull(swagger.getPath("/store/order").getPost().getParameters());
assertTrue(swagger.getPath("/store/order").getPost().getParameters().size() == 1);
assertTrue(swagger.getPath("/store/order").getPost().getParameters().get(0) instanceof BodyParameter);
assertNotNull(((BodyParameter) swagger.getPath("/store/order").getPost().getParameters().get(0)).getSchema());
assertTrue(((BodyParameter) swagger.getPath("/store/order").getPost().getParameters().get(0)).getSchema() instanceof RefModel);
assertTrue(((RefModel) ((BodyParameter) swagger.getPath("/store/order").getPost().getParameters().get(0)).getSchema()).getSimpleRef().equals("Order"));
assertTrue(swagger.getDefinitions().get("Order") instanceof ModelImpl);
assertTrue(swagger.getDefinitions().get("Order").getProperties().size() == 6);
}
use of io.swagger.models.parameters.RefParameter in project swagger-parser by swagger-api.
the class SwaggerResolverTest method testOperationParameterRemoteRefs.
@Test(description = "resolve operation parameter remote refs")
public void testOperationParameterRemoteRefs() {
final Swagger swagger = new Swagger();
swagger.path("/fun", new Path().get(new Operation().parameter(new RefParameter("#/parameters/SampleParameter"))));
swagger.parameter("SampleParameter", new QueryParameter().name("skip").property(new IntegerProperty()));
final Swagger resolved = new SwaggerResolver(swagger, null).resolve();
final List<Parameter> params = swagger.getPaths().get("/fun").getGet().getParameters();
assertEquals(params.size(), 1);
final QueryParameter param = (QueryParameter) params.get(0);
assertEquals(param.getName(), "skip");
}
Aggregations