use of io.swagger.models.Operation in project swagger-core by swagger-api.
the class GenericsTest method checkCollectionsOfObjectsAsBodyParameter.
@Test(description = "check collection of objects as body parameter")
public void checkCollectionsOfObjectsAsBodyParameter() {
Operation op = getOperation("testObjectsInBody");
assertEquals(op.getParameters().size(), 1);
BodyParameter p = getBodyParameter(op, 0);
ArrayModel objArray = (ArrayModel) p.getSchema();
assertEquals(((RefProperty) objArray.getItems()).getSimpleRef(), "Tag");
}
use of io.swagger.models.Operation in project swagger-core by swagger-api.
the class GenericsTest method checkParametersOfGenericTypes.
@Test(description = "check parameters of generic types")
public void checkParametersOfGenericTypes() {
Set<String> genericTypes = new HashSet(Arrays.asList("GenericTypeString", "GenericTypeUUID", "GenericTypeGenericTypeString", "RenamedGenericTypeString", "RenamedGenericTypeRenamedGenericTypeString"));
assertTrue(swagger.getDefinitions().keySet().containsAll(genericTypes));
Operation opString = getOperation("testGenericType");
testGenericType(opString, "GenericTypeString");
Property strValue = getProperty("GenericTypeString", "value");
assertNotEquals(strValue, null);
assertEquals(strValue.getClass().getName(), StringProperty.class.getName());
Operation opUUID = getOperation("testStringBasedGenericType");
testGenericType(opUUID, "GenericTypeUUID");
Property uuidValue = getProperty("GenericTypeUUID", "value");
assertNotEquals(uuidValue, null);
assertEquals(uuidValue.getClass().getName(), UUIDProperty.class.getName());
Operation opComplex = getOperation("testComplexGenericType");
testGenericType(opComplex, "GenericTypeGenericTypeString");
Property complexValue = getProperty("GenericTypeGenericTypeString", "value");
assertNotEquals(complexValue, null);
assertEquals(complexValue.getClass().getName(), RefProperty.class.getName());
assertEquals(((RefProperty) complexValue).getSimpleRef(), "GenericTypeString");
Operation opRenamed = getOperation("testRenamedGenericType");
testGenericType(opRenamed, "RenamedGenericTypeRenamedGenericTypeString");
Property renamedComplexValue = getProperty("RenamedGenericTypeRenamedGenericTypeString", "value");
assertNotEquals(renamedComplexValue, null);
assertTrue(renamedComplexValue instanceof RefProperty);
assertEquals(((RefProperty) renamedComplexValue).getSimpleRef(), "RenamedGenericTypeString");
}
use of io.swagger.models.Operation in project swagger-core by swagger-api.
the class GenericsTest method checkGenericResult.
@Test(description = "check generic result")
public void checkGenericResult() {
Operation op = swagger.getPath("/generics/testGenericResult").getGet();
Property schema = op.getResponses().get("200").getSchema();
assertEquals(schema.getClass().getName(), RefProperty.class.getName());
assertEquals(((RefProperty) schema).getSimpleRef(), "GenericListWrapperTag");
Property entries = getProperty("GenericListWrapperTag", "entries");
assertNotEquals(entries, null);
assertEquals(entries.getClass().getName(), ArrayProperty.class.getName());
Property items = ((ArrayProperty) entries).getItems();
assertEquals(items.getClass().getName(), RefProperty.class.getName());
assertEquals(((RefProperty) items).getSimpleRef(), "Tag");
}
use of io.swagger.models.Operation in project swagger-core by swagger-api.
the class GenericsTest method checkCollectionsOfEnumerations.
@Test(description = "check collections of enumerations")
public void checkCollectionsOfEnumerations() {
Operation op = getOperation("testEnumContainers");
assertEquals(op.getParameters().size(), 5);
testEnumCollection(getQueryParameter(op, 0), "set");
testEnumCollection(getQueryParameter(op, 1), "list");
testCollection(getQueryParameter(op, 2), "list2D", "string", null);
testEnumCollection(getQueryParameter(op, 3), "array");
QueryParameter scalar = getQueryParameter(op, 4);
testScalar(scalar, "scalar", "string", null);
assertEquals(scalar.getEnum(), enumValues);
}
use of io.swagger.models.Operation in project swagger-core by swagger-api.
the class HiddenParametersScannerTest method shouldScanMethodWithSomeParamsHidden.
@Test
public void shouldScanMethodWithSomeParamsHidden() {
Operation get = getGet("/some-hidden/{id}");
assertNotNull(get);
List<Parameter> parameters = get.getParameters();
assertEquals(parameters.size(), 3);
assertEquals(parameters.get(0).getIn(), "cookie");
assertEquals(parameters.get(1).getIn(), "header");
assertEquals(parameters.get(2).getIn(), "query");
}
Aggregations