diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml
index 86f51ab..b6c5930 100644
--- a/.github/workflows/github-ci.yml
+++ b/.github/workflows/github-ci.yml
@@ -16,15 +16,16 @@ jobs:
continue-on-error: false
steps:
- name: Checking out code base
- uses: actions/checkout@v2
+ uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Set up JDK 11
- uses: actions/setup-java@v1
+ uses: actions/setup-java@v5
with:
java-version: 11
+ distribution: 'temurin'
- name: Cache Maven packages
- uses: actions/cache@v1
+ uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
diff --git a/.gitignore b/.gitignore
index 18afede..0a1624c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@ target
*.iws
/dep
out
+.DS_Store
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index d5fde92..37b45d4 100644
--- a/LICENSE
+++ b/LICENSE
@@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
- Copyright © 2021 Vector Pro
+ Copyright © 2021 Vector Pro (teamvectorpro@googlegroups.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/README.md b/README.md
index 9786540..6443a45 100644
--- a/README.md
+++ b/README.md
@@ -1,18 +1,18 @@
Dropwizard Swagger Integration
==================
-[](//github.com/Vect0rPro/dropwizard-swagger/blob/master/LICENSE)
-[](https://maven-badges.herokuapp.com/maven-central/in.vectorpro.dropwizard/dropwizard-swagger)
+[](https://github.com/Vect0rPro/dropwizard-swagger/blob/master/LICENSE)
+[](https://central.sonatype.com/artifact/in.vectorpro.dropwizard/dropwizard-swagger)
A Dropwizard bundle that serves Swagger UI static content and loads Swagger endpoints.
-Current version has been tested with Dropwizard 2.0.28 and Swagger 2.1.13 which supports OpenApi 3.0 specifications
+Current version has been tested with Dropwizard 2.1.12 and Swagger 2.2.2 which supports OpenApi 3.0 specifications
Requirements
--------------
-* Dropwizard 2.0.28
-* Swagger API 2.1.13
-* Swagger UI 4.6.2
+* Dropwizard 2.1.12
+* Swagger API 2.2.2
+* Swagger UI 5.27.0
Usage
-------------
@@ -23,7 +23,7 @@ Usage
in.vectorpro.dropwizard
dropwizard-swagger
- 2.0.28-2
+ 2.1.12-1
```
@@ -46,8 +46,19 @@ prop2: value2
# the only required property is resourcePackage, for more config options see below
swagger:
resourcePackage:
+
+ # Configure page title or code snippet targets as needed
+ swaggerViewConfiguration:
+ pageTitle: "API Documentation"
+ # Default value of code snippet targets is always provided by the bundle
+ # Include supported snippet targets as per link provided below if modification to default value is required
+ codeSnippetTargets:
+ - java_okhttp
+ - python_requests
```
+Supported code snippet targets: [link](https://github.com/tronto20/swagger-snippet-generator?tab=readme-ov-file#targets)
+
* In your Application class:
```java
diff --git a/pom.xml b/pom.xml
index 80616e2..6497cb1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,7 +21,7 @@
in.vectorpro.dropwizard
dropwizard-swagger
- 2.0.28-3
+ 2.1.12-1
Dropwizard Swagger v2.x and OpenAPI 3.x Integration
https://github.com/Vect0rPro/dropwizard-swagger
A simple way to document your REST APIs in Dropwizard using Swagger
@@ -69,17 +69,6 @@
https://github.com/Vect0rPro/dropwizard-swagger/issues
-
-
- ossrh
- https://s01.oss.sonatype.org/content/repositories/snapshots
-
-
- ossrh
- https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/
-
-
-
8
1.8
@@ -89,12 +78,12 @@
UTF-8
UTF-8
- 2.0.28
- 30.1.1-jre
- 5.8.2
- 2.1.13
- 4.6.2
- 3.28.0-GA
+ 2.1.12
+ 33.5.0-jre
+ 5.10.5
+ 2.2.2
+ 5.27.0
+ 3.30.2-GA
@@ -104,6 +93,13 @@
guava
${guava.version}
+
+ io.dropwizard
+ dropwizard-bom
+ ${dropwizard.version}
+ pom
+ import
+
@@ -184,7 +180,7 @@
org.apache.maven.plugins
maven-gpg-plugin
- 3.0.1
+ 3.2.8
sign-artifacts
@@ -195,6 +191,15 @@
+
+ org.sonatype.central
+ central-publishing-maven-plugin
+ 0.9.0
+ true
+
+ central
+
+
@@ -206,7 +211,7 @@
org.apache.maven.plugins
maven-compiler-plugin
- 3.10.1
+ 3.14.1
@@ -214,12 +219,12 @@
org.apache.maven.plugins
maven-surefire-plugin
- 2.22.2
+ 3.5.4
org.apache.maven.plugins
maven-failsafe-plugin
- 2.22.2
+ 3.5.4
@@ -232,7 +237,7 @@
org.apache.maven.plugins
maven-source-plugin
- 3.2.1
+ 3.3.1
attach-sources
@@ -245,7 +250,7 @@
org.apache.maven.plugins
maven-jar-plugin
- 3.2.2
+ 3.5.0
@@ -257,7 +262,7 @@
org.apache.maven.plugins
maven-compiler-plugin
- 3.10.1
+ 3.14.1
true
@@ -265,12 +270,12 @@
org.apache.maven.plugins
maven-dependency-plugin
- 3.3.0
+ 3.9.0
org.apache.maven.plugins
maven-javadoc-plugin
- 3.3.2
+ 3.12.0
@@ -286,15 +291,52 @@
- org.sonatype.plugins
- nexus-staging-maven-plugin
- 1.6.12
- true
-
- ossrh
- https://s01.oss.sonatype.org/
- true
-
+ org.apache.maven.plugins
+ maven-enforcer-plugin
+ 3.6.2
+
+
+ enforce
+
+ true
+
+
+
+ LICENSE
+
+
+
+ LICENSE
+ 52965201dab336f278d9ca6786e36b69cd0db6fbbac88d05923004518fe4166d
+ sha256
+
+
+
+
+ enforce
+
+
+
+
+
+ org.jboss.maven.plugins
+ bom-builder-maven-plugin
+ 1.2.0
+
+
+ build-bom
+ package
+
+ build-bom
+
+
+ ${project.groupId}
+ ${project.artifactId}-bom
+ ${project.version}
+ ${project.name} :: Bill of Materials
+
+
+
diff --git a/src/main/java/in/vectorpro/dropwizard/swagger/SwaggerView.java b/src/main/java/in/vectorpro/dropwizard/swagger/SwaggerView.java
index 884fcda..77eb566 100644
--- a/src/main/java/in/vectorpro/dropwizard/swagger/SwaggerView.java
+++ b/src/main/java/in/vectorpro/dropwizard/swagger/SwaggerView.java
@@ -86,32 +86,9 @@ public String getContextPath() {
return contextPath;
}
- /**
- * Returns the location of the validator URL or null to disable
- *
- * @return String
- */
- @Nullable
- public String getValidatorUrl() {
- return viewConfiguration.getValidatorUrl();
- }
-
- /**
- * Returns whether to display the authorization input boxes
- *
- * @return String
- */
- public boolean getShowAuth() {
- return viewConfiguration.isShowAuth();
- }
-
- /**
- * Returns whether to display the swagger spec selector
- *
- * @return boolean
- */
- public boolean getShowApiSelector() {
- return viewConfiguration.isShowApiSelector();
+ /** @return {@link SwaggerViewConfiguration} containing every properties to customize swagger */
+ public SwaggerViewConfiguration getViewConfiguration() {
+ return viewConfiguration;
}
/** @return {@link SwaggerOAuth2Configuration} containing every properties to init oauth2 */
diff --git a/src/main/java/in/vectorpro/dropwizard/swagger/SwaggerViewConfiguration.java b/src/main/java/in/vectorpro/dropwizard/swagger/SwaggerViewConfiguration.java
index d18fc52..bc5a02c 100644
--- a/src/main/java/in/vectorpro/dropwizard/swagger/SwaggerViewConfiguration.java
+++ b/src/main/java/in/vectorpro/dropwizard/swagger/SwaggerViewConfiguration.java
@@ -15,6 +15,8 @@
*/
package in.vectorpro.dropwizard.swagger;
+import com.google.common.collect.Sets;
+import java.util.Set;
import javax.annotation.Nullable;
/**
@@ -25,22 +27,30 @@ public class SwaggerViewConfiguration {
private static final String DEFAULT_TITLE = "Swagger UI";
private static final String DEFAULT_TEMPLATE = "index.ftl";
+ private static final Set DEFAULT_CODE_SNIPPET_TARGETS = Sets.newHashSet("shell_wget", "python_requests",
+ "java_okhttp", "node_request", "go_native");
- @Nullable private String pageTitle;
+ @Nullable
+ private String pageTitle;
- @Nullable private String templateUrl;
+ @Nullable
+ private String templateUrl;
- @Nullable private String validatorUrl;
+ @Nullable
+ private String validatorUrl;
private boolean showApiSelector;
private boolean showAuth;
+ private Set codeSnippetTargets;
+
public SwaggerViewConfiguration() {
this.pageTitle = DEFAULT_TITLE;
this.templateUrl = DEFAULT_TEMPLATE;
this.validatorUrl = null;
this.showApiSelector = true;
this.showAuth = true;
+ this.codeSnippetTargets = DEFAULT_CODE_SNIPPET_TARGETS;
}
@Nullable
@@ -85,4 +95,22 @@ public boolean isShowAuth() {
public void setShowAuth(boolean showAuth) {
this.showAuth = showAuth;
}
+
+ public Set getCodeSnippetTargets() {
+ return codeSnippetTargets;
+ }
+
+ public void setCodeSnippetTargets(Set codeSnippetTargets) {
+
+ this.codeSnippetTargets = codeSnippetTargets;
+
+ // Syntax highlighting with swagger snippet generator js works only if node is included in the snippet targets
+ // Otherwise snippets are generated without syntax highlighting
+ // Hence identifying if node is missing and adding it to the set
+ final boolean noTargetStartsWithNode = this.codeSnippetTargets.stream()
+ .noneMatch(target -> target.startsWith("node"));
+ if (noTargetStartsWithNode) {
+ this.codeSnippetTargets.add("node_request");
+ }
+ }
}
diff --git a/src/main/resources/in/vectorpro/dropwizard/swagger/index.ftl b/src/main/resources/in/vectorpro/dropwizard/swagger/index.ftl
index 2a52579..3957991 100644
--- a/src/main/resources/in/vectorpro/dropwizard/swagger/index.ftl
+++ b/src/main/resources/in/vectorpro/dropwizard/swagger/index.ftl
@@ -4,67 +4,52 @@
- Swagger UI
-
+ ${viewConfiguration.pageTitle}
+
+
-
-
+
+