Skip to content

Commit

Permalink
Merge pull request #100 from veraPDF/feature/swagger
Browse files Browse the repository at this point in the history
Add swagger documentation
  • Loading branch information
MaximPlusov committed Sep 11, 2023
2 parents ad80edb + 9772baf commit 1a8c3e6
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,32 @@
<artifactId>dropwizard-assets</artifactId>
<version>${dropwizard.version}</version>
</dependency>
<dependency>
<groupId>com.smoketurner</groupId>
<artifactId>dropwizard-swagger</artifactId>
<version>1.3.12-1</version>
<exclusions>
<exclusion>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.10</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>commons-codec</groupId>
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/verapdf/rest/app/VeraPdfRestApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import javax.servlet.DispatcherType;
import javax.servlet.FilterRegistration;

import io.federecio.dropwizard.swagger.SwaggerBundle;
import io.federecio.dropwizard.swagger.SwaggerBundleConfiguration;
import org.eclipse.jetty.servlets.CrossOriginFilter;
import org.verapdf.rest.resources.ApiResource;
import org.verapdf.rest.resources.HomePageResource;
Expand Down Expand Up @@ -50,6 +52,16 @@ public String getName() {
public void initialize(Bootstrap<VeraPdfRestConfiguration> bootstrap) {
bootstrap.addBundle(new MultiPartBundle());
bootstrap.addBundle(new ViewBundle<>());
bootstrap.addBundle(new SwaggerBundle<VeraPdfRestConfiguration>() {
@Override
protected SwaggerBundleConfiguration getSwaggerBundleConfiguration(
VeraPdfRestConfiguration configuration) {
SwaggerBundleConfiguration config = new SwaggerBundleConfiguration();
config.setResourcePackage("org.verapdf.rest.resources");
return config;
}
});

bootstrap.addBundle(new AssetsBundle("/assets/css", "/css", null, "css")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
bootstrap.addBundle(new AssetsBundle("/assets/js", "/js", null, "js")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
bootstrap.addBundle(new AssetsBundle("/assets/img", "/img", null, "img")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/org/verapdf/rest/resources/ApiResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import io.swagger.annotations.Api;
import io.swagger.annotations.Info;
import io.swagger.annotations.License;
import io.swagger.annotations.SwaggerDefinition;
import org.verapdf.ReleaseDetails;
import org.verapdf.rest.environment.Environment;
import org.verapdf.rest.environment.Environments;
Expand All @@ -20,6 +24,15 @@
*
*/
@Path("/api")
@Api(value = "veraPDF")
@SwaggerDefinition(info = @Info(
description = "Rest API for veraPDF",
version = "V0.2.0",
title = "veraPDF API",
license = @License(name = "Apache 2.0", url = "https://www.apache.org/licenses/LICENSE-2.0")),
schemes = {SwaggerDefinition.Scheme.HTTP}
)

public final class ApiResource {
private static ReleaseDetails buildDetails = ReleaseDetails.addDetailsFromResource(
ReleaseDetails.APPLICATION_PROPERTIES_ROOT + "rest." + ReleaseDetails.PROPERTIES_EXT);
Expand Down

0 comments on commit 1a8c3e6

Please sign in to comment.