2 * Copyright (c) 2018 Inocybe Technologies and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.netconf.sal.rest.doc.impl;
10 import java.util.Optional;
11 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
14 * Base class for an RFC 8040 implementation.
16 * @author Thomas Pantelis
18 public abstract class BaseYangSwaggerGeneratorRFC8040 extends BaseYangSwaggerGenerator {
20 private static final String DEFAULT_BASE_PATH = "rests";
21 private final String basePath;
23 protected BaseYangSwaggerGeneratorRFC8040(final Optional<DOMSchemaService> schemaService) {
25 this.basePath = DEFAULT_BASE_PATH;
28 protected BaseYangSwaggerGeneratorRFC8040(final Optional<DOMSchemaService> schemaService, final String basePath) {
30 this.basePath = basePath;
34 public String getDataStorePath(final String dataStore, final String context) {
35 if ("config".contains(dataStore) || "operational".contains(dataStore)) {
36 return "/" + basePath + "/data" + context;
38 return "/" + basePath + "/operations" + context;
42 public String getContent(final String dataStore) {
43 if ("operational".contains(dataStore)) {
44 return "?content=nonconfig";
45 } else if ("config".contains(dataStore)) {
46 return "?content=config";
53 protected ListPathBuilder newListPathBuilder() {
54 return new ListPathBuilder() {
55 private String prefix = "=";
58 public String nextParamIdentifier(String key) {
59 String str = prefix + "{" + key + "}";
67 protected void appendPathKeyValue(StringBuilder builder, Object value) {
68 builder.deleteCharAt(builder.length() - 1).append("=").append(value).append('/');