use of org.motechproject.mds.docs.swagger.model.Property in project motech by motech.
the class SwaggerGeneratorTest method verifyExampleEntLookup.
private void verifyExampleEntLookup(PathEntry pathEntry) {
assertNotNull(pathEntry);
assertEquals("Lookup - By Dt and Locale", pathEntry.getDescription());
assertEquals(asList("org.motechproject.ExampleEnt"), pathEntry.getTags());
assertEquals("byDtAndLocale", pathEntry.getOperationId());
assertEquals(json(), pathEntry.getProduces());
List<Parameter> parameters = pathEntry.getParameters();
Parameter dtParam = parameters.get(0);
assertNotNull(dtParam);
assertEquals("dtField", dtParam.getName());
assertEquals(ParameterType.QUERY, dtParam.getIn());
assertEquals("dtField - " + msg(RANGE_PARAM_DESC_KEY), dtParam.getDescription());
assertEquals(STRING_TYPE, dtParam.getType());
assertNull(dtParam.getFormat());
assertNull(dtParam.getItems());
assertNull(dtParam.getSchema());
Parameter localeParam = parameters.get(1);
assertNotNull(localeParam);
assertEquals("localeField", localeParam.getName());
assertEquals(ParameterType.QUERY, localeParam.getIn());
assertEquals("localeField - " + msg(SET_PARAM_DESC_KEY), localeParam.getDescription());
assertEquals(ARRAY_TYPE, localeParam.getType());
assertNull(localeParam.getFormat());
assertNull(localeParam.getSchema());
Property localeParamItems = localeParam.getItems();
assertNotNull(localeParamItems);
assertEquals(STRING_TYPE, localeParamItems.getType());
assertNull(localeParamItems.getFormat());
assertNull(localeParamItems.getItems());
assertNotNull(parameters);
assertEquals(6, parameters.size());
verifyQueryParameters(pathEntry.getParameters(), asList("doubleField", "dateField", "dtField", "ldField", "localeField", "listField", "owner", "creator", "modifiedBy", "modificationDate", "creationDate"), 2);
Map<Integer, Response> responses = pathEntry.getResponses();
assertNotNull(responses);
assertEquals(3, responses.size());
verify400Response(responses);
verify403Response(responses);
Response response = responses.get(200);
assertTrue(response instanceof ResponseWithSchema);
ResponseWithSchema responseWithSchema = (ResponseWithSchema) response;
assertEquals(msg(RESPONSE_LIST_DESC_KEY, "ExampleEnt"), responseWithSchema.getDescription());
Map<String, String> schema = responseWithSchema.getSchema();
assertNotNull(schema);
assertEquals("#/definitions/org.motechproject.ExampleEnt-WithMetadata", schema.get("$ref"));
}
use of org.motechproject.mds.docs.swagger.model.Property in project motech by motech.
the class SwaggerGenerator method definition.
private Definition definition(Entity entity, boolean includeAuto, boolean includeId) {
final Definition definition = new Definition();
final List<String> required = new ArrayList<>();
final Map<String, Property> properties = new LinkedHashMap<>();
buildDefinitionProperties(properties, required, entity, includeAuto, includeId);
definition.setRequired(required);
definition.setProperties(properties);
return definition;
}
Aggregations