Skip to content

Commit

Permalink
Provide OpenApiLightyConfiguration
Browse files Browse the repository at this point in the history
Provide OpenApiLightyConfiguration implementation
to set OpenApi basePath according to lighty.io
JSON based configuration.

JIRA: LIGHTY-297
Signed-off-by: tobias.pobocik <[email protected]>
  • Loading branch information
Tobianas committed May 9, 2024
1 parent 4a6a405 commit 6723cef
Showing 1 changed file with 51 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import io.lighty.core.controller.api.LightyServices;
import io.lighty.modules.northbound.restconf.community.impl.config.RestConfConfiguration;
import io.lighty.server.LightyServerBuilder;
import java.lang.annotation.Annotation;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletContextHandler;
Expand All @@ -21,6 +22,7 @@
import org.opendaylight.netconf.sal.rest.doc.api.ApiDocService;
import org.opendaylight.netconf.sal.rest.doc.impl.ApiDocServiceImpl;
import org.opendaylight.netconf.sal.rest.doc.jaxrs.ApiDocApplication;
import org.opendaylight.restconf.nb.rfc8040.JaxRsNorthbound;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -56,7 +58,7 @@ protected boolean initProcedure() {
LOG.info("basePath: {}", basePathString);

this.apiDocService = new ApiDocServiceImpl(lightyServices.getDOMSchemaService(),
lightyServices.getDOMMountPointService(), basePathString);
lightyServices.getDOMMountPointService(), new SwaggerConfiguration(basePathString));

ApiDocApplication apiDocApplication = new ApiDocApplication(apiDocService);

Expand Down Expand Up @@ -97,4 +99,52 @@ private void addStaticResources(ServletContextHandler mainHandler, String path,
ApiDocService getApiDocService() {
return apiDocService;
}

private static final class SwaggerConfiguration implements JaxRsNorthbound.Configuration {
private final String basePath;

private SwaggerConfiguration(final String basePath) {
this.basePath = basePath;
}

@Override
public int maximum$_$fragment$_$length() {
return 0;
}

@Override
public int heartbeat$_$interval() {
return 10000;
}

@Override
public int idle$_$timeout() {
return 30000;
}

@Override
public String ping$_$executor$_$name$_$prefix() {
return "ping-executor";
}

@Override
public int max$_$thread$_$count() {
return 1;
}

@Override
public boolean use$_$sse() {
return true;
}

@Override
public String restconf() {
return basePath;
}

@Override
public Class<? extends Annotation> annotationType() {
return null;
}
}
}

0 comments on commit 6723cef

Please sign in to comment.