use of io.swagger.models.properties.Property in project swagger-core by swagger-api.
the class DefaultParameterExtension method extractParameters.
@Override
public List<Parameter> extractParameters(List<Annotation> annotations, Type type, Set<Type> typesToSkip, Iterator<SwaggerExtension> chain) {
if (shouldIgnoreType(type, typesToSkip)) {
return new ArrayList<Parameter>();
}
List<Parameter> parameters = new ArrayList<Parameter>();
Parameter parameter = null;
for (Annotation annotation : annotations) {
if (annotation instanceof QueryParam) {
QueryParam param = (QueryParam) annotation;
QueryParameter qp = new QueryParameter().name(param.value());
Property schema = createProperty(type);
if (schema != null) {
qp.setProperty(schema);
}
parameter = qp;
} else if (annotation instanceof PathParam) {
PathParam param = (PathParam) annotation;
PathParameter pp = new PathParameter().name(param.value());
Property schema = createProperty(type);
if (schema != null) {
pp.setProperty(schema);
}
parameter = pp;
} else if (annotation instanceof HeaderParam) {
HeaderParam param = (HeaderParam) annotation;
HeaderParameter hp = new HeaderParameter().name(param.value());
Property schema = createProperty(type);
if (schema != null) {
hp.setProperty(schema);
}
parameter = hp;
} else if (annotation instanceof CookieParam) {
CookieParam param = (CookieParam) annotation;
CookieParameter cp = new CookieParameter().name(param.value());
Property schema = createProperty(type);
if (schema != null) {
cp.setProperty(schema);
}
parameter = cp;
} else if (annotation instanceof FormParam) {
FormParam param = (FormParam) annotation;
FormParameter fp = new FormParameter().name(param.value());
Property schema = createProperty(type);
if (schema != null) {
fp.setProperty(schema);
}
parameter = fp;
} else {
handleAdditionalAnnotation(parameters, annotation, type, typesToSkip);
}
}
if (parameter != null) {
parameters.add(parameter);
}
return parameters;
}
use of io.swagger.models.properties.Property in project swagger-core by swagger-api.
the class Reader method addResponse.
private void addResponse(Operation operation, ApiResponse apiResponse) {
Map<String, Property> responseHeaders = parseResponseHeaders(apiResponse.responseHeaders());
Response response = new Response().description(apiResponse.message()).headers(responseHeaders);
if (apiResponse.code() == 0) {
operation.defaultResponse(response);
} else {
operation.response(apiResponse.code(), response);
}
if (StringUtils.isNotEmpty(apiResponse.reference())) {
response.schema(new RefProperty(apiResponse.reference()));
} else if (!isVoid(apiResponse.response())) {
Type responseType = apiResponse.response();
final Property property = ModelConverters.getInstance().readAsProperty(responseType);
if (property != null) {
response.schema(ContainerWrapper.wrapContainer(apiResponse.responseContainer(), property));
appendModels(responseType);
}
}
}
use of io.swagger.models.properties.Property in project swagger-core by swagger-api.
the class JsonDeserializationTest method givenMapProperty_shouldDeserializeMaxProperties.
@Test
public void givenMapProperty_shouldDeserializeMaxProperties() {
String path = "json-schema-validation/map.json";
MapProperty property = (MapProperty) TestUtils.deserializeJsonFileFromClasspath(path, Property.class);
assertNotNull(property.getMaxProperties());
assertEquals(property.getMaxProperties().intValue(), 10);
}
use of io.swagger.models.properties.Property in project swagger-core by swagger-api.
the class JsonDeserializationTest method givenMapProperty_shouldDeserializeMinProperties.
@Test
public void givenMapProperty_shouldDeserializeMinProperties() {
String path = "json-schema-validation/map.json";
MapProperty property = (MapProperty) TestUtils.deserializeJsonFileFromClasspath(path, Property.class);
assertNotNull(property.getMinProperties());
assertEquals(property.getMinProperties().intValue(), 1);
}
use of io.swagger.models.properties.Property in project swagger-core by swagger-api.
the class JsonDeserializationTest method shouldDeserializeArrayPropertyMaxItems.
@Test
public void shouldDeserializeArrayPropertyMaxItems() throws Exception {
String path = "json-schema-validation/array.json";
ArrayProperty property = (ArrayProperty) TestUtils.deserializeJsonFileFromClasspath(path, Property.class);
assertNotNull(property.getMaxItems());
assertEquals(property.getMaxItems().intValue(), 10);
}
Aggregations