use of io.swagger.models.parameters.BodyParameter in project swagger-core by swagger-api.
the class ParameterProcessorTest method implicitParameterProcessorTest.
@Test(description = "parse implicit parameters from method")
public void implicitParameterProcessorTest() throws NoSuchMethodException {
final ApiImplicitParams params = getClass().getDeclaredMethod("implicitParametrizedMethod").getAnnotation(ApiImplicitParams.class);
final PathParameter param0 = (PathParameter) ParameterProcessor.applyAnnotations(null, new PathParameter(), String.class, Collections.<Annotation>singletonList(params.value()[0]));
assertNotNull(param0);
assertEquals(param0.getIn(), "path");
assertEquals(param0.getName(), "paramName1");
assertEquals(param0.getDescription(), "paramValue1");
assertNull(param0.getEnum());
assertNotNull(param0.getItems());
final BodyParameter param1 = (BodyParameter) ParameterProcessor.applyAnnotations(null, new BodyParameter(), String.class, Collections.<Annotation>singletonList(params.value()[1]));
assertNotNull(param1);
assertEquals(param1.getIn(), "body");
assertEquals(param1.getName(), "body");
assertEquals(param1.getDescription(), "paramValue2");
assertEquals(param1.getAccess(), "test");
final ModelImpl model = (ModelImpl) param1.getSchema();
assertNotNull(model);
assertEquals(model.getDefaultValue(), "10");
}
use of io.swagger.models.parameters.BodyParameter in project swagger-core by swagger-api.
the class ParameterSerializationTest method deserializeRefBodyParameter.
@Test(description = "it should deserialize a ref BodyParameter")
public void deserializeRefBodyParameter() throws IOException {
final String json = "{\"in\":\"body\",\"required\":false,\"schema\":{\"$ref\":\"#/definitions/Cat\"}}";
final Parameter p = m.readValue(json, Parameter.class);
SerializationMatchers.assertEqualsToJson(p, json);
}
use of io.swagger.models.parameters.BodyParameter in project swagger-core by swagger-api.
the class ParameterSerializationTest method serializeRefBodyParameter.
@Test(description = "it should serialize a ref BodyParameter")
public void serializeRefBodyParameter() {
final RefModel model = new RefModel("Cat");
final BodyParameter p = new BodyParameter().schema(model);
final String json = "{\"in\":\"body\",\"required\":false,\"schema\":{\"$ref\":\"#/definitions/Cat\"}}";
SerializationMatchers.assertEqualsToJson(p, json);
}
use of io.swagger.models.parameters.BodyParameter in project swagger-core by swagger-api.
the class ParameterSerializationTest method deserializeBodyParameter.
@Test(description = "it should deserialize a BodyParameter")
public void deserializeBodyParameter() throws IOException {
final String json = "{" + " \"in\":\"body\"," + " \"required\":false," + " \"schema\":{" + " \"properties\":{" + " \"name\":{" + " \"type\":\"string\"" + " }" + " }" + " }" + "}";
final Parameter p = m.readValue(json, Parameter.class);
SerializationMatchers.assertEqualsToJson(p, json);
}
use of io.swagger.models.parameters.BodyParameter in project swagger-core by swagger-api.
the class ParameterSerializationTest method serializeBodyParameter.
@Test(description = "it should serialize a BodyParameter")
public void serializeBodyParameter() {
final ModelImpl model = new ModelImpl().name("Cat").property("name", new StringProperty());
final BodyParameter p = new BodyParameter().schema(model);
final String json = "{" + " \"in\":\"body\"," + " \"required\":false," + " \"schema\":{" + " \"properties\":{" + " \"name\":{" + " \"type\":\"string\"" + " }" + " }" + " }" + "}";
SerializationMatchers.assertEqualsToJson(p, json);
}
Aggregations