2 * Copyright (c) 2014 Cisco Systems, Inc. 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.controller.sal.rest.doc.impl;
10 import javax.ws.rs.core.UriInfo;
12 import org.opendaylight.controller.sal.core.api.model.SchemaService;
13 import org.opendaylight.controller.sal.rest.doc.swagger.ApiDeclaration;
14 import org.opendaylight.controller.sal.rest.doc.swagger.ResourceList;
15 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
19 import com.google.common.base.Preconditions;
22 * This class gathers all yang defined {@link Module}s and generates Swagger
23 * compliant documentation.
25 public class ApiDocGenerator extends BaseYangSwaggerGenerator {
27 private static Logger _logger = LoggerFactory.getLogger(ApiDocGenerator.class);
29 private static final ApiDocGenerator INSTANCE = new ApiDocGenerator();
30 private SchemaService schemaService;
32 public ResourceList getResourceListing(UriInfo uriInfo) {
33 Preconditions.checkState(schemaService != null);
34 SchemaContext schemaContext = schemaService.getGlobalContext();
35 Preconditions.checkState(schemaContext != null);
36 return super.getResourceListing(uriInfo, schemaContext, "");
39 public ApiDeclaration getApiDeclaration(String module, String revision, UriInfo uriInfo) {
40 SchemaContext schemaContext = schemaService.getGlobalContext();
41 Preconditions.checkState(schemaContext != null);
42 return super.getApiDeclaration(module, revision, uriInfo, schemaContext, "");
46 * Returns singleton instance
50 public static ApiDocGenerator getInstance() {
56 * @param schemaService
58 public void setSchemaService(SchemaService schemaService) {
59 this.schemaService = schemaService;