-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from bouanani-soufiane/PIG-72-API-documentation
PIG-72-API-documentation
- Loading branch information
Showing
3 changed files
with
62 additions
and
13 deletions.
There are no files selected for viewing
16 changes: 4 additions & 12 deletions
16
src/main/java/ma/yc/PigeonSkyRace/PigeonSkyRaceApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
40
src/main/java/ma/yc/PigeonSkyRace/config/OpenApiConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters