-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
📚implement OpenAPI-Swagger documentation across microservices
- Loading branch information
Adnane Miliari
committed
Nov 29, 2024
1 parent
dc3e201
commit b6bd0fa
Showing
19 changed files
with
513 additions
and
21 deletions.
There are no files selected for viewing
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
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,17 @@ | ||
package swagger; | ||
|
||
import lombok.experimental.UtilityClass; | ||
|
||
@UtilityClass | ||
public class BaseController { | ||
public static final String CUSTOMER_TAG = "Customer Management"; | ||
public static final String CUSTOMER_DESCRIPTION = "Operations about customers including orders and payments"; | ||
public static final String PRODUCT_TAG = "Product Management"; | ||
public static final String PRODUCT_DESCRIPTION = "Operations for managing products catalog and inventory"; | ||
public static final String ORDER_TAG = "Order Management"; | ||
public static final String ORDER_DESCRIPTION = "Operations for managing customer orders and order processing"; | ||
public static final String PAYMENT_TAG = "Payment Management"; | ||
public static final String PAYMENT_DESCRIPTION = "Operations for managing payments and transactions"; | ||
public static final String NOTIFICATION_TAG = "Notification Management"; | ||
public static final String NOTIFICATION_DESCRIPTION = "Operations for managing notifications and communication with customers"; | ||
} |
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 swagger; | ||
|
||
import io.swagger.v3.oas.models.ExternalDocumentation; | ||
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.info.License; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@EnableConfigurationProperties(OpenAPIProperties.class) | ||
public class OpenAPIConfig { | ||
|
||
private final OpenAPIProperties properties; | ||
|
||
public OpenAPIConfig(OpenAPIProperties properties) { | ||
this.properties = properties; | ||
} | ||
|
||
@Bean | ||
public OpenAPI customOpenAPI() { | ||
return new OpenAPI() | ||
.info(new Info() | ||
.title(properties.getTitle()) | ||
.version(properties.getVersion()) | ||
.description(properties.getDescription()) | ||
.contact(new Contact() | ||
.name(properties.getContact().getName()) | ||
.email(properties.getContact().getEmail()) | ||
.url(properties.getContact().getUrl())) | ||
.license(new License() | ||
.name(properties.getLicense().getName()) | ||
.url(properties.getLicense().getUrl()))) | ||
.externalDocs(new ExternalDocumentation() | ||
.description(properties.getExternalDocs().getDescription()) | ||
.url(properties.getExternalDocs().getUrl())); | ||
} | ||
} |
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,38 @@ | ||
package swagger; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
@ConfigurationProperties(prefix = "openapi") | ||
@Getter @Setter | ||
public class OpenAPIProperties { | ||
private String title; | ||
private String version; | ||
private String description; | ||
private Contact contact = new Contact(); | ||
private License license = new License(); | ||
private ExternalDocs externalDocs = new ExternalDocs(); | ||
|
||
@Getter | ||
@Setter | ||
public static class Contact { | ||
private String name; | ||
private String email; | ||
private String url; | ||
} | ||
|
||
@Getter | ||
@Setter | ||
public static class License { | ||
private String name; | ||
private String url; | ||
} | ||
|
||
@Getter | ||
@Setter | ||
public static class ExternalDocs { | ||
private String description; | ||
private String url; | ||
} | ||
} |
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,14 @@ | ||
openapi: | ||
title: Microservices API Documentation | ||
version: 1.0 | ||
description: Documentation for all microservices endpoints | ||
contact: | ||
name: Adnane MILIARI | ||
email: [email protected] | ||
url: https://github.com/miliariadnane | ||
license: | ||
name: Apache 2.0 | ||
url: http://www.apache.org/licenses/LICENSE-2.0.html | ||
external-docs: | ||
description: Project Documentation | ||
url: https://github.com/miliariadnane/demo-microservices |
3 changes: 3 additions & 0 deletions
3
customer/src/main/java/dev/nano/customer/CustomerConstant.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
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
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
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
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
3 changes: 3 additions & 0 deletions
3
notification/src/main/java/dev/nano/notification/NotificationConstant.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
Oops, something went wrong.