use of io.swagger.models.Swagger in project swagger-core by swagger-api.
the class SimpleReaderTest method scanClassWithExamplePostClass.
@Test(description = "scan a resource with operation post example (dataTypeClass)")
public void scanClassWithExamplePostClass() {
Swagger swagger = getSwagger(ClassWithExamplePostClass.class);
Parameter param = swagger.getPaths().get("/external/info").getPost().getParameters().get(0);
BodyParameter bp = (BodyParameter) param;
assertNotNull(bp.getExamples());
assertTrue(bp.getExamples().size() == 1);
String value = bp.getExamples().get("application/json");
assertEquals("[\"a\",\"b\"]", value);
}
use of io.swagger.models.Swagger in project swagger-core by swagger-api.
the class SimpleReaderTest method scanResourceWithMapReturnType.
@Test(description = "scan a resource with map return type")
public void scanResourceWithMapReturnType() {
Swagger swagger = getSwagger(ResourceWithMapReturnValue.class);
Operation get = getGet(swagger, "/{id}");
assertNotNull(get);
assertNotNull(get.getResponses());
Response response = get.getResponses().get("200");
assertNotNull(response);
Property schema = response.getSchema();
assertEquals(schema.getClass(), MapProperty.class);
}
use of io.swagger.models.Swagger in project swagger-core by swagger-api.
the class SimpleReaderTest method scanResourceWithApiOperationTags.
@Test(description = "scan a resource with tags in test 841")
public void scanResourceWithApiOperationTags() {
Swagger swagger = getSwagger(Resource841.class);
assertEquals(swagger.getTags().size(), 3);
List<String> rootTags = getGet(swagger, "/fun").getTags();
assertEquals(rootTags.size(), 2);
assertEquals(rootTags, Arrays.asList("tag1", "tag2"));
List<String> thisTags = getGet(swagger, "/fun/this").getTags();
assertEquals(thisTags.size(), 1);
assertEquals(thisTags, Arrays.asList("tag1"));
List<String> thatTags = getGet(swagger, "/fun/that").getTags();
assertEquals(thatTags.size(), 1);
assertEquals(thatTags, Arrays.asList("tag2"));
}
use of io.swagger.models.Swagger in project swagger-core by swagger-api.
the class SimpleReaderTest method scanClassWithImplicitExampleQuery.
@Test(description = "scan a resource with implicit operation query example")
public void scanClassWithImplicitExampleQuery() {
Swagger swagger = getSwagger(ClassWithExamplePost.class);
Parameter param = swagger.getPaths().get("/external/info2").getGet().getParameters().get(0);
QueryParameter bp = (QueryParameter) param;
assertNotNull(bp.getExample());
Object value = bp.getExample();
assertEquals("77", value);
}
use of io.swagger.models.Swagger in project swagger-core by swagger-api.
the class SimpleReaderTest method scanSimpleResource.
@Test(description = "scan a simple resource")
public void scanSimpleResource() {
Swagger swagger = getSwagger(SimpleResource.class);
assertEquals(swagger.getPaths().size(), 3);
Operation get = getGet(swagger, "/{id}");
assertNotNull(get);
assertEquals(get.getParameters().size(), 2);
PathParameter param1 = (PathParameter) get.getParameters().get(0);
assertEquals(param1.getIn(), "path");
assertEquals(param1.getName(), "id");
assertTrue(param1.getRequired());
assertEquals(param1.getDescription(), "sample param data");
assertEquals(param1.getDefaultValue(), "5");
Parameter param2 = get.getParameters().get(1);
assertEquals(param2.getIn(), "query");
assertEquals(param2.getName(), "limit");
assertFalse(param2.getRequired());
assertNull(param2.getDescription());
List<Parameter> params = getPutParameters(swagger, "/{bodyparams}");
BodyParameter bodyParam1 = (BodyParameter) params.get(0);
assertEquals(bodyParam1.getIn(), "body");
assertEquals(bodyParam1.getName(), "body");
assertTrue(bodyParam1.getRequired());
BodyParameter bodyParam2 = (BodyParameter) params.get(1);
assertEquals(bodyParam2.getIn(), "body");
assertEquals(bodyParam2.getName(), "body");
assertFalse(bodyParam2.getRequired());
}
Aggregations