use of org.motechproject.mds.docs.swagger.model.Definition in project motech by motech.
the class SwaggerGenerator method buildMetadataDefinition.
private Definition buildMetadataDefinition() {
final Definition definition = new Definition();
final Map<String, Property> properties = new LinkedHashMap<>();
properties.put("entity", new Property(STRING_TYPE));
properties.put("className", new Property(STRING_TYPE));
properties.put("module", new Property(STRING_TYPE));
properties.put("namespace", new Property(STRING_TYPE));
properties.put("totalCount", new Property(INTEGER_TYPE, INT64_FORMAT));
properties.put("page", new Property(INTEGER_TYPE, INT32_FORMAT));
properties.put("pageSize", new Property(INTEGER_TYPE, INT32_FORMAT));
final List<String> required = new ArrayList<>();
required.add("totalCount");
required.add("page");
required.add("pageSize");
required.add("module");
required.add("entity");
required.add("namespace");
required.add("className");
definition.setProperties(properties);
definition.setRequired(required);
return definition;
}
use of org.motechproject.mds.docs.swagger.model.Definition in project motech by motech.
the class SwaggerGenerator method definitionWithMetadata.
private Definition definitionWithMetadata(Entity entity) {
final Definition definition = new Definition();
Property metadata = new Property();
metadata.setRef(definitionPath("Metadata"));
Property data = new Property(ARRAY_TYPE);
data.setRef(definitionPath(entity.getClassName()));
final Map<String, Property> properties = new LinkedHashMap<>();
properties.put("metadata", metadata);
properties.put("data", data);
final List<String> required = new ArrayList<>();
required.add("metadata");
required.add("data");
definition.setProperties(properties);
definition.setRequired(required);
return definition;
}
use of org.motechproject.mds.docs.swagger.model.Definition in project motech by motech.
the class SwaggerGeneratorTest method verifyTestEntityDefinitions.
private void verifyTestEntityDefinitions(Map<String, Definition> definitions) {
Definition definition = definitions.get("org.example.TestEntity");
assertNotNull(definition);
assertEquals(addRequiredAutoGenerated("str", "integerField"), definition.getRequired());
verifyTestEntityDefinitionProps(definition.getProperties(), true, true);
definition = definitions.get("org.example.TestEntity-new");
assertNotNull(definition);
assertEquals(asList("str", "integerField"), definition.getRequired());
verifyTestEntityDefinitionProps(definition.getProperties(), false, false);
}
use of org.motechproject.mds.docs.swagger.model.Definition in project motech by motech.
the class SwaggerGeneratorTest method verifyExampleEntDefinitions.
private void verifyExampleEntDefinitions(Map<String, Definition> definitions) {
Definition definition = definitions.get("org.motechproject.ExampleEnt");
assertNotNull(definition);
assertEquals(addRequiredAutoGenerated("doubleField", "listField"), definition.getRequired());
verifyExampleEntDefinitionProps(definition.getProperties(), true, true);
definition = definitions.get("org.motechproject.ExampleEnt-new-withId");
assertNotNull(definition);
assertEquals(asList("doubleField", "listField"), definition.getRequired());
verifyExampleEntDefinitionProps(definition.getProperties(), false, true);
}
use of org.motechproject.mds.docs.swagger.model.Definition 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