starting with OpenAPI documentation

Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
2024-10-13 00:31:40 +02:00
parent f0a15f6696
commit 87ca71c8f9
7 changed files with 51 additions and 24 deletions

View File

@@ -1,5 +1,5 @@
# Stage that builds the application, a prerequisite for the running stage
FROM eclipse-temurin:21-jdk-jammy AS build
FROM eclipse-temurin:21-jdk-noble AS build
ARG SERVICE_ROOT
@@ -22,7 +22,7 @@ COPY --chown=app:app ${SERVICE_ROOT}/src ./src
RUN ./mvnw --batch-mode clean verify -DskipTests
# Running stage: the part that is used for running the application
FROM eclipse-temurin:21-jre-jammy
FROM eclipse-temurin:21-jre-noble
RUN useradd -m app
USER app

View File

@@ -83,6 +83,11 @@
<artifactId>caffeine</artifactId>
<version>3.1.2</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.6.0</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>

View File

@@ -0,0 +1,24 @@
package dev.mars3142.fhq.timezone_service.config;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.servers.Server;
import java.util.List;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class OpenAPIConfig {
@Bean
public OpenAPI timeZoneOpenAPI() {
return new OpenAPI()
.info(new Info().title("TimeZone API").version("1.0"))
.servers(
List.of(
new Server().url("https://api.firmware-hq.dev/v1/timezone"),
new Server().url("http://localhost:8090")
)
);
}
}

View File

@@ -0,0 +1,16 @@
package dev.mars3142.fhq.timezone_service.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**");
}
}

View File

@@ -1,21 +0,0 @@
package dev.mars3142.fhq.timezone_service.root.web.controller;
import java.net.URI;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/")
public class RootController {
@GetMapping
public ResponseEntity<Void> getRoot() {
return ResponseEntity.status(HttpStatus.SEE_OTHER)
.location(URI.create("https://firmware-hq.dev"))
.build();
}
}

View File

@@ -1,5 +1,5 @@
server:
port: 8085
port: 0
eureka:
client:

View File

@@ -24,3 +24,6 @@ eureka:
defaultZone: http://eureka-service.web:8761/eureka
instance:
instanceId: ${spring.application.name}:${spring.application.instance_id:${random.value}}
springdoc:
swagger-ui:
path: /swagger-ui.html