Skip to content

Commit

Permalink
Merge pull request #22 from bouanani-soufiane/PIG-72-API-documentation
Browse files Browse the repository at this point in the history
PIG-72-API-documentation
  • Loading branch information
bouanani-soufiane authored Nov 11, 2024
2 parents b265d8e + 055eacb commit 7ca4091
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 13 deletions.
16 changes: 4 additions & 12 deletions src/main/java/ma/yc/PigeonSkyRace/PigeonSkyRaceApplication.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
package ma.yc.PigeonSkyRace;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
import org.springframework.scheduling.annotation.EnableScheduling;

@OpenAPIDefinition(
info = @Info(
title = "Pigeon Sky Race API",
version = "1.0",
description = "API documentation for managing pigeon racing competitions with MongoDB"
)
)

@SpringBootApplication(scanBasePackages = "ma.yc.PigeonSkyRace")
@EnableMongoRepositories
@EnableScheduling
public class PigeonSkyRaceApplication {

public static void main(String[] args) {
ConfigurableApplicationContext context = SpringApplication.run(PigeonSkyRaceApplication.class, args);
public static void main ( String[] args ) {
ConfigurableApplicationContext context = SpringApplication.run(PigeonSkyRaceApplication.class, args);

}
}
}
40 changes: 40 additions & 0 deletions src/main/java/ma/yc/PigeonSkyRace/config/OpenApiConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package ma.yc.PigeonSkyRace.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.servers.Server;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;

@Configuration
@Slf4j
public class OpenApiConfig {

@Bean
public OpenAPI customOpenAPI(@Value("${contact.email}") String email,
@Value("${local-server.url}") String localServerUrl,
@Value("${prod-server.url}") String prodServerUrl,
@Value("${project.version}") String appVersion,
@Value("${project.title}") String title,
@Value("${project.description}") String description) {
log.info("email: {}", email);
log.info("localServerUrl: {}", localServerUrl);

return new OpenAPI().info(new Info()
.title(title)
.version(appVersion)
.description(description)
.contact(new Contact()
.name("Codex Pigeon Sky Race API")
.email(email))
).servers(Arrays.asList(
new Server().description("Local Docker Server").url(localServerUrl),
new Server().description("Production Server (inshallah soon when i deploy on aws)").url(prodServerUrl)
));
}
}
19 changes: 18 additions & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,28 @@ spring:
uri: mongodb://localhost:27017/myapp
authentication-database: admin
auto-index-creation: true

server:
port: 8080
servlet:
context-path: /

logging:
level:
org.springframework.web: DEBUG
ma.yc.PigeonSkyRace: DEBUG
ma.yc.PigeonSkyRace: DEBUG

##---------- API information ---------------------------------
contact:
email: yc.ma

local-server:
url: http://localhost:8080/

prod-server:
url: http://localhost:8080/

project:
version: 1.0
title: Pigeon sky race
description: pigeon sky race pour la gestion des compétitions des pigeons

0 comments on commit 7ca4091

Please sign in to comment.