Update swagger generator to OpenAPI 3.0
[netconf.git] / restconf / sal-rest-docgen / src / main / java / org / opendaylight / netconf / sal / rest / doc / impl / BaseYangSwaggerGeneratorDraft02.java
1 /*
2  * Copyright (c) 2018 Inocybe Technologies and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.netconf.sal.rest.doc.impl;
9
10 import java.util.Optional;
11 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
12
13 /**
14  * Base class for a bierman draft02 implementation.
15  *
16  * @author Thomas Pantelis
17  */
18 public abstract class BaseYangSwaggerGeneratorDraft02 extends BaseYangSwaggerGenerator {
19
20     private static final String PATH_VERSION = "draft02";
21     private static final String DEFAULT_BASE_PATH = "restconf";
22     private final String basePath;
23
24     protected BaseYangSwaggerGeneratorDraft02(final Optional<DOMSchemaService> schemaService) {
25         super(schemaService);
26         this.basePath = DEFAULT_BASE_PATH;
27     }
28
29     protected BaseYangSwaggerGeneratorDraft02(final Optional<DOMSchemaService> schemaService, final String basePath) {
30         super(schemaService);
31         this.basePath = basePath;
32     }
33
34     @Override
35     protected String getPathVersion() {
36         return PATH_VERSION;
37     }
38
39     @Override
40     public String getResourcePath(final String resourceType, final String context) {
41         return "/" + basePath + "/" + resourceType + context;
42     }
43
44     @Override
45     public String getResourcePathPart(final String resourceType) {
46         return resourceType;
47     }
48
49     @Override
50     protected ListPathBuilder newListPathBuilder() {
51         return key -> "/{" + key + "}";
52     }
53
54     @Override
55     protected void appendPathKeyValue(final StringBuilder builder, final Object value) {
56         builder.append(value).append('/');
57     }
58 }