3cd24ed4dec356969608289344ddebc88efcff82
[netconf.git] / restconf / sal-rest-docgen / src / main / java / org / opendaylight / netconf / sal / rest / doc / impl / AllModulesDocGenerator.java
1 /*
2  * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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 static org.opendaylight.netconf.sal.rest.doc.impl.ApiDocServiceImpl.OAversion;
11
12 import java.util.Objects;
13 import javax.ws.rs.core.UriInfo;
14 import org.opendaylight.netconf.sal.rest.doc.impl.ApiDocServiceImpl.URIType;
15 import org.opendaylight.netconf.sal.rest.doc.swagger.CommonApiObject;
16 import org.opendaylight.netconf.sal.rest.doc.swagger.SwaggerObject;
17
18 public class AllModulesDocGenerator {
19     private final ApiDocGeneratorDraftO2 apiDocGeneratorDraft02;
20     private final ApiDocGeneratorRFC8040 apiDocGeneratorRFC8040;
21
22     public AllModulesDocGenerator(final ApiDocGeneratorDraftO2 apiDocGeneratorDraft02,
23                                   final ApiDocGeneratorRFC8040 apiDocGeneratorRFC8040) {
24         this.apiDocGeneratorDraft02 = Objects.requireNonNull(apiDocGeneratorDraft02);
25         this.apiDocGeneratorRFC8040 = Objects.requireNonNull(apiDocGeneratorRFC8040);
26     }
27
28     public CommonApiObject getAllModulesDoc(final UriInfo uriInfo, final URIType uriType, final OAversion oaversion) {
29         final DefinitionNames definitionNames = new DefinitionNames();
30         final SwaggerObject doc;
31         if (uriType.equals(URIType.DRAFT02)) {
32             doc = apiDocGeneratorDraft02.getAllModulesDoc(uriInfo, definitionNames, uriType, oaversion);
33         } else {
34             doc = apiDocGeneratorRFC8040.getAllModulesDoc(uriInfo, definitionNames, uriType, oaversion);
35         }
36
37         return BaseYangSwaggerGenerator.getAppropriateDoc(doc, oaversion);
38     }
39 }