From 9970f648c601dfd931fa01a48de4035c23956dd4 Mon Sep 17 00:00:00 2001 From: rafaelgonzalezsimon Date: Tue, 6 Feb 2024 16:45:25 +0100 Subject: [PATCH 01/10] multiapi-312: added mandatory dependencies to README.md --- README.md | 91 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 65 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 8ba3efc9..0d4b060f 100644 --- a/README.md +++ b/README.md @@ -11,23 +11,23 @@ Maven and Gradle - [SCS MultiApi Plugin](#scs-multiapi-plugin) - [Index](#index) - [Main Configuration](#main-configuration) - - [How to configure the POM file](#how-to-configure-the-pom-file) - - [How to configure the build.gradle file](#how-to-configure-the-build-file) + - [How to configure the POM file](#how-to-configure-the-pom-file) + - [How to configure the build.gradle file](#how-to-configure-the-build-file) - [AsyncApi Generator](#asyncapi-generator) - - [Configuration](#configuration) - - [Generated Sources Folder](#generated-sources-folder) - - [How is apiPackage set?](#how-is-apipackage-set) - - [How is modelPackage set?](#how-is-modelpackage-set) - - [Class Generation](#class-generation) - - [Consumer and Supplier classes](#consumer-and-supplier-classes) - - [Method interfaces](#method-interfaces) - - [Mapper](#mapper) - - [Implementation](#implementation) - - [Stream Bridge class](#stream-bridge-class) + - [Configuration](#configuration) + - [Generated Sources Folder](#generated-sources-folder) + - [How is apiPackage set?](#how-is-apipackage-set) + - [How is modelPackage set?](#how-is-modelpackage-set) + - [Class Generation](#class-generation) + - [Consumer and Supplier classes](#consumer-and-supplier-classes) + - [Method interfaces](#method-interfaces) + - [Mapper](#mapper) + - [Implementation](#implementation) + - [Stream Bridge class](#stream-bridge-class) - [OpenApi Generator](#openapi-generator) - - [Getting Started](#getting-started) - - [Initial Considerations](#initial-considerations) - - [Usage](#usage) + - [Getting Started](#getting-started) + - [Initial Considerations](#initial-considerations) + - [Usage](#usage) - [Property Validation](#property-validation) ## Main Configuration @@ -104,6 +104,32 @@ In the [AsyncApi Generator](#asyncapi-generator) and the [OpenApi Generator](#openapi-generator) sections, you can find more information about how they work, and the parameters and configuration options they offer. +### Mandatory dependencies + +These dependencies are used by generated code + +``` + + + io.swagger.parser.v3 + swagger-parser-core + 2.1.20 + + + + io.swagger.core.v3 + swagger-annotations-jakarta + 2.2.20 + + + + jakarta.validation + jakarta.validation-api + 3.0.2 + + +``` + ### How to configure the build file To maintain the generation of the different types of classes independent, they @@ -138,6 +164,16 @@ In the [AsyncApi Generator](#asyncapi-generator) and the [OpenApi Generator](#openapi-generator) sections, you can find more information about how they work, and the parameters and configuration options they offer. +### Mandatory dependencies + +These dependencies are used by generated code + +``` +implementation 'io.swagger.parser.v3:swagger-parser-core:2.1.20' +implementation 'io.swagger.core.v3:swagger-annotations-jakarta:2.2.20' +implementation 'jakarta.validation:jakarta.validation-api:3.0.2' +``` + ## AsyncApi Generator ### Configuration @@ -283,7 +319,7 @@ can be configured in the plugin. - **filePath**: This parameter works in the same way as in the first option. - **consumer**, **supplier** and **streamBridge**: They are both configured in the same way and can receive the same parameters. These parameters are: - - **ids**: With this parameter you can set the operationId that you want to + - **ids**: With this parameter you can set the operationId that you want to be generated as subscriber or publisher. If this parameter is not defined for the `consumer` section, all the subscribe operations defined in the YML file, will be generated. If only one of `supplier` and `streamBridge` sections are @@ -291,20 +327,20 @@ can be configured in the plugin. operations defined in the YML file will be generated. If both `supplier` and `streamBridge` sections are defined, it`s needed to define which operations belong to each category. - - **classNamePostfix**: This parameter receives the name of the class that + - **classNamePostfix**: This parameter receives the name of the class that it's going to be generated containing the Beans. This parameter is optional, and by default the classes will be called `Producer`, `StreamBridgeProducer` and `Subscriber`. - - **modelNameSuffix**: With this parameter you can set the suffix that is + - **modelNameSuffix**: With this parameter you can set the suffix that is going to be used in the entities of the generated classes. For example if you set this to `DTO`, and there is a class named `EntityClass`, it will result as `EntityClassDTO`. This parameter is optional. - - **apiPackage**: This parameter receive a package name, where the + - **apiPackage**: This parameter receive a package name, where the generated classes will be generated. This parameter is optional. Check [how is the apiPackage set](#how-is-apipackage-set) for more information about how this parameter works, and the values it could have. - - **modelPackage**: This parameter receives a package name, where the entities + - **modelPackage**: This parameter receives a package name, where the entities used for the generated classes are defined. As it's explained in the [Mapper Section](#mapper), those entities are usually auto-generated, so the plugin expects the modelPackage to be the package where them are included. @@ -313,14 +349,14 @@ can be configured in the plugin. created by the user. As the previous parameter, this is also optional. Check [how is the modelPackage set](#how-is-modelpackage-set) for more information about how his parameter works, and the values it could have. - - **dateFormat**: This parameter changes the format annotation for `LocalDate` fields. + - **dateFormat**: This parameter changes the format annotation for `LocalDate` fields. The syntax follow the [Java SimpleDateFormat](https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html). The default value are `yyyy-MM-dd`. - - **dateTimeFormat**: This parameter changes the format annotation for `LocalDateTime` + - **dateTimeFormat**: This parameter changes the format annotation for `LocalDateTime` fields. The syntax follow the [Java SimpleDateFormat](https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html). The default value are `yyyy-MM-dd'T'HH:mm:ss`. - - **useTimeType**: Enum TimeType value. Controls the types used when generating dates. Can be `LOCAL` or `ZOINED`. - The default value is `TimeType.LOCAL`. + - **useTimeType**: Enum TimeType value. Controls the types used when generating dates. Can be `LOCAL` or `ZOINED`. + The default value is `TimeType.LOCAL`. The configuration of `consumer`, `supplier` and `streamBridge` are independent. If only one of them is configured in the pom file, only that one will be @@ -443,8 +479,10 @@ public interface ISubscribeOperation { #### Bindings -Asyncapi support a way to specify specific configuration for certain protocols. Nowadays we only support Kafka specific information to define a Key form Messages as you can find [here](). -When a binding is specified in a message we will generate a generic class named as MessageWrapper which will contain the payload and the key used in to build a Message. +Asyncapi support a way to specify specific configuration for certain protocols. Nowadays we only support Kafka specific information to +define a Key form Messages as you can find [here](). +When a binding is specified in a message we will generate a generic class named as MessageWrapper which will contain the payload and the key +used in to build a Message. You will find such class by each api package you define. ##### Mapper @@ -755,6 +793,7 @@ Here's an example configuration for the maven plugin that loads an AsyncAPI spec from a local JAR containing `contracts/event-api.yml` in its resources: ```xml + com.sngular scs-multiapi-maven-plugin From fd767102a8862b81d375f3e58eb88ed47dd53be3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Enrique=20Garc=C3=ADa=20Maci=C3=B1eiras?= Date: Fri, 9 Feb 2024 14:37:52 +0100 Subject: [PATCH 02/10] Duplicated name Test added --- README.md | 11 ++++++++--- .../plugin/openapi/OpenApiGeneratorFixtures.java | 3 ++- .../openapi/OpenApiGeneratorJakartaTest.java | 2 +- styles/OSS_style_idea.xml | 16 +++++++++------- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 0d4b060f..2f6456c8 100644 --- a/README.md +++ b/README.md @@ -702,9 +702,14 @@ openapimodel { specFile { { filePath = './src/main/resources/api/api.yml' - apiPackage = 'com.sngular.apigenerator.openapi.api' - modelPackage = 'com.sngular.apigenerator.openapi.api.model' - useTagsGroup = true + consumer { + apiPackage = 'com.sngular.apigenerator.openapi.api' + modelPackage = 'com.sngular.apigenerator.openapi.api.model' + } + supplier { + apiPackage = 'com.sngular.apigenerator.openapi.api' + modelPackage = 'com.sngular.apigenerator.openapi.api.model' + } } overWriteModel = true } diff --git a/multiapi-engine/src/test/java/com/sngular/api/generator/plugin/openapi/OpenApiGeneratorFixtures.java b/multiapi-engine/src/test/java/com/sngular/api/generator/plugin/openapi/OpenApiGeneratorFixtures.java index 565a8d21..5e93e42b 100644 --- a/multiapi-engine/src/test/java/com/sngular/api/generator/plugin/openapi/OpenApiGeneratorFixtures.java +++ b/multiapi-engine/src/test/java/com/sngular/api/generator/plugin/openapi/OpenApiGeneratorFixtures.java @@ -1115,6 +1115,7 @@ static Function validateCoconutSchema() { return (path) -> commonTest(path, expectedTestApiFile, expectedTestApiModelFiles, DEFAULT_TARGET_API, DEFAULT_MODEL_API, expectedExceptionFiles, DEFAULT_EXCEPTION_API); } + static Function validateRestrictionsSchema() { final String DEFAULT_TARGET_API = "generated/com/sngular/multifileplugin/testRestrictionsSchema"; @@ -1156,7 +1157,7 @@ static Function validateRestrictionsSchema() { return (path) -> commonTest(path, expectedTestApiFile, expectedTestApiModelFiles, DEFAULT_TARGET_API, DEFAULT_MODEL_API, expectedExceptionFiles, DEFAULT_EXCEPTION_API); } -static Function validateSimpleBuild() { + static Function validateSimpleBuild() { final String DEFAULT_TARGET_API = "generated/com/sngular/multifileplugin/testsimplebuild"; diff --git a/multiapi-engine/src/test/java/com/sngular/api/generator/plugin/openapi/OpenApiGeneratorJakartaTest.java b/multiapi-engine/src/test/java/com/sngular/api/generator/plugin/openapi/OpenApiGeneratorJakartaTest.java index 082722c8..174575a2 100644 --- a/multiapi-engine/src/test/java/com/sngular/api/generator/plugin/openapi/OpenApiGeneratorJakartaTest.java +++ b/multiapi-engine/src/test/java/com/sngular/api/generator/plugin/openapi/OpenApiGeneratorJakartaTest.java @@ -28,7 +28,7 @@ class OpenApiGeneratorJakartaTest { private static OpenApiGenerator openApiGenerator; - private static int SPRING_BOOT_VERSION = 3; + private static final int SPRING_BOOT_VERSION = 3; @BeforeAll static void setup() { diff --git a/styles/OSS_style_idea.xml b/styles/OSS_style_idea.xml index 8cb64cb0..9b42a81d 100644 --- a/styles/OSS_style_idea.xml +++ b/styles/OSS_style_idea.xml @@ -1,4 +1,4 @@ - + - + @@ -33,13 +33,18 @@