Skip to content

Commit

Permalink
Merge pull request #3 from obrienlabs/ref-15-add-swagger2
Browse files Browse the repository at this point in the history
#2 - add swagger2
  • Loading branch information
obriensystems authored Sep 6, 2020
2 parents b255db3 + 466ed75 commit 9d8e6cb
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 17 deletions.
19 changes: 16 additions & 3 deletions reference-nbi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@
<scope>test</scope>
</dependency>


<!-- swagger -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>

<!-- https://jersey.java.net/documentation/latest/modules-and-dependencies.html -->
<dependency>
<groupId>javax.ws.rs</groupId>
Expand Down Expand Up @@ -193,7 +206,7 @@
</build>

<profiles>
<profile>
<!-- profile>
<id>docker</id>
<build>
<plugins>
Expand Down Expand Up @@ -279,7 +292,7 @@
<id>copy-dockerfile</id>
<goals>
<goal>copy-resources</goal>
</goals><!-- here the phase you need -->
</goals>
<phase>package</phase>
<configuration>
<outputDirectory>${project.basedir}/target/docker-stage</outputDirectory>
Expand Down Expand Up @@ -414,6 +427,6 @@
</plugin>
</plugins>
</build>
</profile>
</profile-->
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,32 @@
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Order(1)
// disable for now
//@Component
//@Order(1)
public class Base64Filter implements Filter {
private final static Logger LOG = Logger.getLogger(Base64Filter.class.getName());
public static final Boolean enabled = false;

@Override
public void doFilter(ServletRequest request, javax.servlet.ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) request;
// Note: the query string does not include the anchor hash (clent) content
String queryString = req.getQueryString();
LOG.info("Pre request + querystring: " + req.getRequestURI() + "?" + queryString);
//LOG.info(encode(queryString));
// decode base64 encoded parameters high in the chain
String decoded = decode(queryString);
LOG.info("decoded: " + decoded);
if(enabled) {
HttpServletRequest req = (HttpServletRequest) request;

// Note: the query string does not include the anchor hash (clent) content
String queryString = req.getQueryString();
LOG.info("Pre request + querystring: " + req.getRequestURI() + "?" + queryString);
//LOG.info(encode(queryString));
// decode base64 encoded parameters high in the chain
String decoded = decode(queryString);
LOG.info("decoded: " + decoded);

// 3 solutions to emulate a setQueryParameter() call (wrapping request, request attributes, or custom parameters)
req.setAttribute("qs", decoded);
chain.doFilter(request, response);
LOG.info("Post request: " + req.getRequestURI());
// 3 solutions to emulate a setQueryParameter() call (wrapping request, request attributes, or custom parameters)
req.setAttribute("qs", decoded);
chain.doFilter(request, response);
LOG.info("Post request: " + req.getRequestURI());
}
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package cloud.containerization.reference.nbi;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();

}

}
1 change: 1 addition & 0 deletions reference-nbi/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
server.servlet.context-path=/nbi
logging.level.org.springframework.web=DEBUG

0 comments on commit 9d8e6cb

Please sign in to comment.