import org.opendaylight.netconf.sal.rest.doc.impl.BaseYangOpenApiGenerator;
import org.opendaylight.netconf.sal.rest.doc.impl.DefinitionNames;
import org.opendaylight.netconf.sal.rest.doc.openapi.OpenApiObject;
+import org.opendaylight.netconf.sal.rest.doc.openapi.Path;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
if (includeDataStore) {
doc = generateDataStoreApiDoc(uriInfo, urlPrefix, deviceName);
- addFields(doc.getPaths() ,openApiObject.getPaths().fields());
- addFields(doc.getComponents().getSchemas(), openApiObject.getComponents().getSchemas().fields());
+ // Creating mutable copy of map
+ var paths = new HashMap<>(doc.getPaths());
+ paths.putAll(openApiObject.getPaths());
+ doc.setPaths(paths);
doc.getInfo().setTitle(openApiObject.getInfo().getTitle());
+ addFields(doc.getComponents().getSchemas(), openApiObject.getComponents().getSchemas().fields());
} else {
doc = openApiObject;
}
BASE_PATH,
context);
- final ObjectNode pathsObject = JsonNodeFactory.instance.objectNode();
- createGetPathItem("data", "Queries the config (startup) datastore on the mounted hosted.",
- context, deviceName, pathsObject);
- createGetPathItem("operations", "Queries the available operations (RPC calls) on the mounted hosted.",
- context, deviceName, pathsObject);
+ final var data = new Path();
+ data.setGet(createGetPathItem("data",
+ "Queries the config (startup) datastore on the mounted hosted.", deviceName));
+
+ final var operations = new Path();
+ operations.setGet(createGetPathItem("operations",
+ "Queries the available operations (RPC calls) on the mounted hosted.", deviceName));
- declaration.setPaths(pathsObject);
+ final var paths = Map.of(openApiGenerator.getResourcePath("data", context), data,
+ openApiGenerator.getResourcePath("operations", context), operations);
+ declaration.setPaths(paths);
return declaration;
}
- private void createGetPathItem(final String resourceType, final String description, final String context,
- final String deviceName, final ObjectNode pathsObject) {
- final ObjectNode pathItem = JsonNodeFactory.instance.objectNode();
+ private ObjectNode createGetPathItem(final String resourceType, final String description, final String deviceName) {
final ObjectNode operationObject = JsonNodeFactory.instance.objectNode();
- pathItem.set("get", operationObject);
operationObject.put(DESCRIPTION_KEY, description);
operationObject.put(SUMMARY_KEY, HttpMethod.GET + SUMMARY_SEPARATOR + deviceName + SUMMARY_SEPARATOR
+ resourceType);
final ObjectNode responses = JsonNodeFactory.instance.objectNode();
responses.set(String.valueOf(Response.Status.OK.getStatusCode()), okResponse);
operationObject.set(RESPONSES_KEY, responses);
- pathsObject.set(openApiGenerator.getResourcePath(resourceType, context), pathItem);
+ return operationObject;
}
@Override