Skip to content

Commit

Permalink
Add swagger documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
EkaterinaKomar committed Sep 1, 2023
1 parent a7abff0 commit e5980c6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@
<artifactId>dropwizard-assets</artifactId>
<version>${dropwizard.version}</version>
</dependency>
<dependency>
<groupId>com.smoketurner</groupId>
<artifactId>dropwizard-swagger</artifactId>
<version>1.3.12-1</version>
</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 e5980c6

Please sign in to comment.