Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Swagger Generation #12

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
#### Responder Service
# Responder Service

* Implemented with Spring Boot - version 2.1.3.RELEASE (aligned with latest RHOAR release).
* JPA with Hibernate
* Spring Kafka client (version 2.2.2.RELEASE) to consume and receive messages from Kafka

REST endpoints specificatons: see openapi.json in project root
REST endpoints specificatons: see openapi.json in project root

## Requirements

* PostgreSQL
* Kafka

## Run the project

./run.sh

## Swagger

* Swagger ui: http://localhost:8080/swagger-ui.html
* Swagger docs: http://localhost:8080/v2/api-docs
11 changes: 11 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<version.commons-dbcp2>2.5.0</version.commons-dbcp2>
<version.fabric8-maven-plugin>3.5.39</version.fabric8-maven-plugin>
<version.logback>1.2.3</version.logback>
<io.springfox.version>2.7.0</io.springfox.version>
</properties>
<dependencyManagement>
<dependencies>
Expand Down Expand Up @@ -144,6 +145,16 @@
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${io.springfox.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${io.springfox.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

mvn spring-boot:run
mvn spring-boot:run -Dspring.config.location=file:./etc/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import springfox.documentation.swagger2.annotations.EnableSwagger2;

@SpringBootApplication
public class Application {

public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.redhat.cajun.navy.responder;

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

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

@Configuration
@EnableSwagger2
public class SwaggerConfiguration {

@Bean
public Docket swagger() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.redhat.cajun.navy.responder"))
.paths(PathSelectors.any())
.build()
.apiInfo(apiInfo());
}

private ApiInfo apiInfo() {

ApiInfo apiInfo = new ApiInfoBuilder()
.title ("API Responder Service")
.description ("Emergency Response - Responder Service API")
.version("1.0.0")
.build();

return apiInfo;
}


}