Skip to content

Commit

Permalink
Add Open API
Browse files Browse the repository at this point in the history
  • Loading branch information
juncevich committed Aug 10, 2023
1 parent a0887e9 commit 143b9ff
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
2 changes: 2 additions & 0 deletions relay-store-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ dependencies {
implementation 'org.jetbrains:annotations:16.0.2'
implementation 'org.flywaydb:flyway-core'

implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'

// implementation 'org.springframework.cloud:spring-cloud-starter-sleuth'
runtimeOnly 'io.micrometer:micrometer-registry-prometheus'
// implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.relay.config;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.enums.SecuritySchemeIn;
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
import io.swagger.v3.oas.annotations.info.Contact;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.security.SecurityScheme;
import io.swagger.v3.oas.annotations.servers.Server;

@OpenAPIDefinition(
info = @Info(
title = "Open API specification",
contact = @Contact(
email = "example@mail.com",
url = "https://localhost.com"
),
version = "1.0.0",
description = "Open API for store service"
),
servers = {
@Server(
description = "Local server",
url = "http://localhost:8080"
),
@Server(
description = "Prod server",
url = "http://google.com"
)
},
security = {
@SecurityRequirement(
name = "BearerAuth"
)
}
)
@SecurityScheme(
name = "BearerAuth",
scheme = "bearer",
type = SecuritySchemeType.HTTP,
bearerFormat = "JWT",
in = SecuritySchemeIn.COOKIE

)
public record OpenAiConfig() {
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.relay.core.service.RelayService;
import com.relay.web.model.Relay;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.websocket.server.PathParam;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.PageRequest;
Expand All @@ -15,6 +17,7 @@

@RestController
@RequiredArgsConstructor
@Tag(name = "Relays controller")
public class RelayController {

/**
Expand All @@ -23,6 +26,10 @@ public class RelayController {
private final RelayService relayService;

@GetMapping(value = "/relays")
@Operation(
description = "Get all relays description",
summary = "Get all relays summary"
)
public List<Relay> findAllRelays() {
return relayService.findAll(PageRequest.of(0, 100)).getContent();
}
Expand Down
5 changes: 5 additions & 0 deletions relay-store-service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,8 @@ custom:
sub-config:
custom-string: 'custom'
custom-number: 100


springdoc:
swagger-ui:
path=/swagger-ui.html

0 comments on commit 143b9ff

Please sign in to comment.