use of io.swagger.models.parameters.BodyParameter 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.BodyParameter 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.BodyParameter 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());
}
use of io.swagger.models.parameters.BodyParameter in project swagger-core by swagger-api.
the class SimpleReaderTest method scanClassWithImplicitExamplePost.
@Test(description = "scan a resource with operation implicit post example")
public void scanClassWithImplicitExamplePost() {
Swagger swagger = getSwagger(ClassWithExamplePost.class);
Parameter param = swagger.getPaths().get("/external/info2").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.BodyParameter in project swagger-core by swagger-api.
the class SimpleReaderTest method scanClassWithExamplePost.
@Test(description = "scan a resource with operation post example")
public void scanClassWithExamplePost() {
Swagger swagger = getSwagger(ClassWithExamplePost.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);
}
Aggregations