use of io.swagger.models.properties.StringProperty in project swagger-core by swagger-api.
the class PostParamTest method findAPostOperationWithStringsCollection.
@Test(description = "find a Post operation with collection of strings")
public void findAPostOperationWithStringsCollection() {
Path petPath = getPath("collectionOfStrings");
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 PropertySerializationTest method serializeReadOnlyStringProperty.
@Test(description = "it should serialize a string property with readOnly set")
public void serializeReadOnlyStringProperty() throws IOException {
final Property p = new StringProperty().readOnly();
final String json = "{\"type\":\"string\",\"readOnly\":true}";
assertEquals(m.writeValueAsString(p), json);
}
use of io.swagger.models.properties.StringProperty in project swagger-core by swagger-api.
the class PropertySerializationTest method deserializeNotReadOnlyStringProperty.
@Test(description = "it should serialize a string property with readOnly unset")
public void deserializeNotReadOnlyStringProperty() throws IOException {
final StringProperty p = new StringProperty();
p.setReadOnly(false);
final String json = "{\"type\":\"string\"}";
assertEquals(m.writeValueAsString(p), json);
}
use of io.swagger.models.properties.StringProperty in project swagger-core by swagger-api.
the class DefaultParameterExtension method enforcePrimitive.
private Property enforcePrimitive(Property in, int level) {
if (in instanceof RefProperty) {
return new StringProperty();
}
if (in instanceof ArrayProperty) {
if (level == 0) {
final ArrayProperty array = (ArrayProperty) in;
array.setItems(enforcePrimitive(array.getItems(), level + 1));
} else {
return new StringProperty();
}
}
return in;
}
use of io.swagger.models.properties.StringProperty in project swagger-core by swagger-api.
the class GenericsTest method testEnumCollection.
private void testEnumCollection(QueryParameter p, String name) {
testCollection(p, name, "string", null);
StringProperty schema = (StringProperty) p.getItems();
assertEquals(schema.getEnum(), enumValues);
}
Aggregations