Skip to content
Snippets Groups Projects
Commit 4cf7b261 authored by Martin Weise's avatar Martin Weise
Browse files

problem with swagger ui

parent 34dbde2f
No related branches found
No related tags found
No related merge requests found
Showing
with 42 additions and 107 deletions
......@@ -20,8 +20,6 @@ services:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: fda
fda-discovery-server:
restart: always
container_name: fda-discovery-server
......@@ -96,8 +94,10 @@ services:
- /var/run/docker.sock:/var/run/docker.sock
links:
- fda-discovery-server
- fda-metadata-db
depends_on:
- fda-discovery-server
- fda-metadata-db
logging:
driver: json-file
......
......@@ -10,7 +10,7 @@ COPY ./api ./api
COPY ./rest-service ./rest-service
COPY ./services ./services
RUN mvn -q clean package -DskipTests > /dev/null
RUN mvn -q clean package -DskipTests
###### SECOND STAGE ######
FROM openjdk:11-jre-slim as runtime
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.9.RELEASE</version>
<version>2.4.3</version>
</parent>
<groupId>at.tuwien</groupId>
......@@ -27,7 +27,8 @@
<mapstruct.version>1.4.2.Final</mapstruct.version>
<docker.version>3.2.7</docker.version>
<testcontainers.version>1.15.2</testcontainers.version>
<swagger.version>2.8.0</swagger.version>
<swagger.version>3.0.0</swagger.version>
<openapi.version>1.5.5</openapi.version>
</properties>
<dependencies>
......@@ -38,6 +39,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>3.0.1</version>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
......@@ -107,55 +109,14 @@
<artifactId>mapstruct</artifactId>
<version>${mapstruct.version}</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.20</version>
</dependency>
<!-- Swagger -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
<exclusions>
<exclusion>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</exclusion>
</exclusions>
<artifactId>springfox-boot-starter</artifactId>
<version>${swagger.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<!-- build config in ./rest-service/pom.xml -->
</project>
......@@ -26,4 +26,13 @@
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
......@@ -5,13 +5,13 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import springfox.documentation.oas.annotations.EnableOpenApi;
@SpringBootApplication
@EnableJpaAuditing
@EnableOpenApi
@EnableJpaRepositories(basePackages = {"at.tuwien.repository"})
@EntityScan(basePackages = {"at.tuwien.entity"})
@EnableSwagger2
public class FdaContainerManagingApplication {
public static void main(String[] args) {
......
......@@ -2,33 +2,36 @@ package at.tuwien.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.ApiKey;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.Collections;
import java.util.HashSet;
import static com.google.common.collect.Lists.newArrayList;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket swaggerConfiguration() {
@Bean
public Docket databaseApi() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("database-api")
.apiInfo(apiInfo())
.select()
.paths(PathSelectors.ant("/api/*"))
.apis(RequestHandlerSelectors.basePackage("at.tuwien.endpoints"))
.build()
.apiInfo(apiInfo());
.paths(PathSelectors.ant("/api/database.*"))
.build();
}
private ApiInfo apiInfo() {
return new ApiInfo("FDA-Container-Managing API",
"Docker at.tuwien.service that can manage Docker services",
"Service that can manage Docker containers",
"1.0",
null,
new Contact("Martin Weise", "https://informatics.tuwien.ac.at/people/martin-weise", "martin.weise@tuwien.ac.at"),
......
......@@ -11,7 +11,6 @@ import at.tuwien.exception.DockerClientException;
import at.tuwien.exception.ImageNotFoundException;
import at.tuwien.mapper.DatabaseContainerMapper;
import at.tuwien.service.ContainerService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
......@@ -38,7 +37,6 @@ public class DatabaseContainerController {
}
@GetMapping("/database")
@ApiOperation("Get all database containers")
public ResponseEntity<List<DatabaseContainerBriefDto>> listDatabaseContainers() {
final List<DatabaseContainer> containers = containerService.getAll();
return ResponseEntity.ok()
......@@ -48,7 +46,6 @@ public class DatabaseContainerController {
}
@PostMapping("/database")
@ApiOperation("Create a new database container")
public ResponseEntity<DatabaseContainerCreateResponseDto> create(@RequestBody DatabaseContainerCreateRequestDto data)
throws ImageNotFoundException {
final DatabaseContainer container = containerService.create(data);
......@@ -58,7 +55,6 @@ public class DatabaseContainerController {
}
@GetMapping("/database/{id}")
@ApiOperation("Get info of database container")
public ResponseEntity<DatabaseContainerDto> findById(@RequestParam String id) throws ContainerNotFoundException {
final DatabaseContainer container = containerService.getById(id);
return ResponseEntity.ok()
......@@ -66,7 +62,6 @@ public class DatabaseContainerController {
}
@PutMapping("/database/{id}")
@ApiOperation("Update a database container")
public ResponseEntity<DatabaseContainerBriefDto> change(@RequestParam String id, @RequestBody ContainerChangeDto changeDto) throws ContainerNotFoundException, DockerClientException {
final DatabaseContainer container;
if (changeDto.getAction().equals(START)) {
......@@ -84,7 +79,6 @@ public class DatabaseContainerController {
}
@DeleteMapping("/database/{id}")
@ApiOperation("Delete a database container")
public ResponseEntity<DatabaseContainerBriefDto> deleteDatabaseContainer(@RequestParam String id) {
return ResponseEntity.status(HttpStatus.ACCEPTED).build();
}
......
......@@ -7,12 +7,8 @@ spring:
password: postgres
jpa:
show-sql: true
properties:
hibernate:
ddl-auto: update
dialect: org.hibernate.dialect.PostgreSQLDialect
hibernate.ddl-auto: none
hibernate.show-sql: true
application:
name: fda-container-managing
cloud:
......
spring:
main.banner-mode: off
datasource:
url: jdbc:postgresql://localhost:5432/fda
driver-class-name: org.postgresql.Driver
username: postgres
password: postgres
jpa:
show-sql: true
properties:
hibernate:
ddl-auto: create-drop
dialect: org.hibernate.dialect.PostgreSQLDialect
hibernate.ddl-auto: none
hibernate.show-sql: true
application:
name: fda-container-managing
server.port: 9091
logging:
pattern.console: "%d %highlight(%-5level) %msg%n"
level:
root: warn
at.: debug
eureka:
client:
registerWithEureka: false
fetchRegistry: false
\ No newline at end of file
......@@ -7,14 +7,12 @@ spring:
password: postgres
jpa:
show-sql: true
properties:
hibernate:
ddl-auto: create-drop
dialect: org.hibernate.dialect.PostgreSQLDialect
hibernate.ddl-auto: none
hibernate.show-sql: true
ddl-auto: update
application:
name: fda-container-managing
cloud:
loadbalancer.ribbon.enabled: false
server.port: 9091
logging:
pattern.console: "%d %highlight(%-5level) %msg%n"
......@@ -22,4 +20,5 @@ logging:
root: warn
at.: debug
eureka:
client.serviceUrl.defaultZone: http://localhost:9090/eureka/
\ No newline at end of file
instance.hostname: fda-discovery-server
client.serviceUrl.defaultZone: http://${eureka.instance.hostname}:9090/eureka/
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment