use of io.swagger.models.properties.StringProperty in project swagger-core by swagger-api.
the class ParameterSerializationTest method serializeStringArrayHeaderParameter.
@Test(description = "it should serialize a string array HeaderParameter")
public void serializeStringArrayHeaderParameter() {
final HeaderParameter p = new HeaderParameter().type(ArrayProperty.TYPE).property(new StringProperty()).collectionFormat("multi");
final String json = "{\"in\":\"header\",\"required\":false,\"type\":\"string\",\"collectionFormat\":\"multi\"}";
SerializationMatchers.assertEqualsToJson(p, json);
}
use of io.swagger.models.properties.StringProperty 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);
}
use of io.swagger.models.properties.StringProperty in project swagger-core by swagger-api.
the class PostParamTest method findAPostOperationWithStringsList.
@Test(description = "find a Post operation with list of strings")
public void findAPostOperationWithStringsList() {
Path petPath = getPath("listOfStrings");
assertNotNull(petPath);
Operation petPost = petPath.getPost();
assertNotNull(petPost);
assertEquals(petPost.getParameters().size(), 1);
BodyParameter petPostBodyParam = (BodyParameter) petPost.getParameters().get(0);
assertEquals(petPostBodyParam.getName(), BODY);
Model inputModel = petPostBodyParam.getSchema();
assertTrue(inputModel instanceof ArrayModel);
ArrayModel ap = (ArrayModel) inputModel;
Property inputSchema = ap.getItems();
assertTrue(inputSchema instanceof StringProperty);
}
use of io.swagger.models.properties.StringProperty in project swagger-core by swagger-api.
the class AbstractSerializableParameter method setProperty.
public void setProperty(Property property) {
setType(property.getType());
this.format = property.getFormat();
if (property instanceof StringProperty) {
final StringProperty string = (StringProperty) property;
setEnum(string.getEnum());
} else if (property instanceof IntegerProperty) {
setEnumValue(((IntegerProperty) property).getEnum());
} else if (property instanceof LongProperty) {
setEnumValue(((LongProperty) property).getEnum());
} else if (property instanceof FloatProperty) {
setEnumValue(((FloatProperty) property).getEnum());
} else if (property instanceof DoubleProperty) {
setEnumValue(((DoubleProperty) property).getEnum());
} else if (property instanceof ArrayProperty) {
final ArrayProperty array = (ArrayProperty) property;
setItems(array.getItems());
}
}
use of io.swagger.models.properties.StringProperty in project java-chassis by ServiceComb.
the class TestProperty method testStringProperty.
@Test
public void testStringProperty() {
SwaggerGenerator generator = new SwaggerGeneratorForTest(context, null);
List<String> enums = Arrays.asList("testStringProperty_a", "testStringProperty_b");
StringProperty sp = new StringProperty();
sp._enum(enums);
StringPropertyConverter spc = new StringPropertyConverter();
JavaType jt = spc.convert(generator.getClassLoader(), generator.ensureGetPackageName(), generator.getSwagger(), sp);
StringProperty spNew = (StringProperty) ModelConverters.getInstance().readAsProperty(jt);
Assert.assertEquals(enums, spNew.getEnum());
}
Aggregations