use of org.opendaylight.netconf.sal.rest.doc.impl.DefinitionNames in project netconf by opendaylight.
the class MountPointSwagger method getMountPointApi.
public CommonApiObject getMountPointApi(final UriInfo uriInfo, final Long id, final Optional<Integer> pageNum, final URIType uriType, final OAversion oaversion) {
final YangInstanceIdentifier iid = getInstanceId(id);
final EffectiveModelContext context = getSchemaContext(iid);
final String urlPrefix = getYangMountUrl(iid);
final String deviceName = extractDeviceName(iid);
if (context == null) {
return null;
}
final DefinitionNames definitionNames = new DefinitionNames();
boolean includeDataStore = true;
Optional<Range<Integer>> range = Optional.empty();
if (pageNum.isPresent()) {
final int pageNumValue = pageNum.get();
final int end = DEFAULT_PAGESIZE * pageNumValue - 1;
int start = end - DEFAULT_PAGESIZE;
if (pageNumValue == 1) {
start++;
} else {
includeDataStore = false;
}
range = Optional.of(Range.closed(start, end));
}
final SwaggerObject doc;
final SwaggerObject swaggerObject = swaggerGenerator.getAllModulesDoc(uriInfo, range, context, Optional.of(deviceName), urlPrefix, definitionNames, uriType, oaversion);
if (includeDataStore) {
doc = generateDataStoreApiDoc(uriInfo, urlPrefix, deviceName);
addFields(doc.getPaths(), swaggerObject.getPaths().fields());
addFields(doc.getDefinitions(), swaggerObject.getDefinitions().fields());
doc.getInfo().setTitle(swaggerObject.getInfo().getTitle());
} else {
doc = swaggerObject;
}
return BaseYangSwaggerGenerator.getAppropriateDoc(doc, oaversion);
}
use of org.opendaylight.netconf.sal.rest.doc.impl.DefinitionNames in project netconf by opendaylight.
the class SwaggerObjectTest method testConvertToJsonSchema.
@Test
public void testConvertToJsonSchema() throws Exception {
final Optional<? extends Module> module = context.findModule("opflex", Revision.of("2014-05-28"));
assertTrue("Desired module not found", module.isPresent());
final DefinitionGenerator generator = new DefinitionGenerator();
final ObjectNode jsonObject = generator.convertToJsonSchema(module.get(), context, new DefinitionNames(), ApiDocServiceImpl.OAversion.V2_0, true);
Assert.assertNotNull(jsonObject);
}
use of org.opendaylight.netconf.sal.rest.doc.impl.DefinitionNames in project netconf by opendaylight.
the class SwaggerObjectTest method testStringTypes.
@Test
public void testStringTypes() throws Exception {
final Optional<? extends Module> module = context.findModule("string-types");
assertTrue("Desired module not found", module.isPresent());
final DefinitionGenerator generator = new DefinitionGenerator();
final ObjectNode jsonObject = generator.convertToJsonSchema(module.get(), context, new DefinitionNames(), ApiDocServiceImpl.OAversion.V2_0, true);
Assert.assertNotNull(jsonObject);
}
Aggregations