use of io.swagger.models.parameters.Parameter in project swagger-core by swagger-api.
the class ScannerTest method scanBeanParamResource.
@Test(description = "scan a bean param resource")
public void scanBeanParamResource() {
final Swagger swagger = getSwagger(ResourceWithBeanParams.class);
final List<Parameter> params = getParameters(swagger, "/bean/{id}");
final HeaderParameter headerParam1 = (HeaderParameter) params.get(0);
assertEquals(headerParam1.getDefaultValue(), 1);
assertEquals(headerParam1.getName(), "test order annotation 1");
final HeaderParameter headerParam2 = (HeaderParameter) params.get(1);
assertEquals(headerParam2.getDefaultValue(), 2);
assertEquals(headerParam2.getName(), "test order annotation 2");
final QueryParameter priority1 = (QueryParameter) params.get(2);
assertNull(priority1.getDefaultValue());
assertEquals(priority1.getName(), "test priority 1");
final QueryParameter priority2 = (QueryParameter) params.get(3);
assertEquals(priority2.getDefaultValue(), 4);
assertEquals(priority2.getName(), "test priority 2");
final ModelImpl bodyParam1 = (ModelImpl) ((BodyParameter) params.get(4)).getSchema();
assertEquals(bodyParam1.getDefaultValue(), "bodyParam");
}
use of io.swagger.models.parameters.Parameter in project swagger-core by swagger-api.
the class ReaderTest method scanApiImplicitParamAnnotationWhichAreOnlyPresentInInterfaceAndNotInImplementation.
@Test(description = "scan resource (impl) which has the ApiParam annotations only declared in its interface")
public void scanApiImplicitParamAnnotationWhichAreOnlyPresentInInterfaceAndNotInImplementation() {
Swagger swagger = getSwagger(ResourceWithAnnotationsOnlyInInterfaceImpl.class);
assertNotNull(swagger);
List<Parameter> parameters = getGet(swagger, "/pet/randomPet").getParameters();
assertNotNull(parameters);
assertEquals(parameters.size(), 1);
assertEquals(parameters.get(0).getName(), "petImplicitIdParam");
}
use of io.swagger.models.parameters.Parameter in project swagger-core by swagger-api.
the class ReaderTest method scanImplicitWithFile.
@Test(description = "scan implicit params with file objct")
public void scanImplicitWithFile() {
Swagger swagger = getSwagger(ResourceWithImplicitFileParam.class);
Parameter param = swagger.getPath("/testString").getPost().getParameters().get(0);
assertTrue(param instanceof FormParameter);
FormParameter fp = (FormParameter) param;
assertEquals("file", fp.getType());
}
use of io.swagger.models.parameters.Parameter 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.parameters.Parameter 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);
}
Aggregations