Skip to content

Commit

Permalink
Merge branch 'main' into 160-scs-multiapi-plugin-homogenize-code-gene…
Browse files Browse the repository at this point in the history
…ration-in-openapi-and-asyncapi

# Conflicts:
#	multiapi-engine/src/main/java/com/sngular/api/generator/plugin/openapi/OpenApiGenerator.java
#	multiapi-engine/src/main/java/com/sngular/api/generator/plugin/openapi/model/SchemaFieldObjectType.java
#	multiapi-engine/src/main/java/com/sngular/api/generator/plugin/openapi/utils/MapperContentUtil.java
#	multiapi-engine/src/main/java/com/sngular/api/generator/plugin/openapi/utils/MapperPathUtil.java
#	multiapi-engine/src/main/java/com/sngular/api/generator/plugin/openapi/utils/MapperUtil.java
  • Loading branch information
jemacineiras committed Apr 24, 2023
2 parents c52f90b + 85affd9 commit 4c312d2
Show file tree
Hide file tree
Showing 30 changed files with 728 additions and 206 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven-central-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
# Uses production profile to sign with gpg plugin
run: |
cd scs-multiapi-maven-plugin
mvn deploy -P production
mvn deploy -DskipLocalStaging=true -P production --file pom.xml
env:
MAVEN_USERNAME: ${{ secrets.JIRAID }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.JIRAPASS }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-wiki.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ jobs:
git add .
git commit -m "scs-multiapi-plugin documentation | GitHub Actions $GITHUB_WORKFLOW $GITHUB_RUN_NUMBER"
git remote add origin-wiki "https://${{secrets.GITBOT_TOKEN}}@github.com/sngular/scs-multiapi-plugin.wiki.git"
git push origin-wiki master
git push origin-wiki main
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Maven and Gradle
- [AsyncApi Generator](#asyncapi-generator)
- [Configuration](#configuration)
- [Generated Sources Folder](#generated-sources-folder)
- [How apiPackage is setted?](#how-apipackage-is-setted)
- [How modelPackage is setted?](#how-modelpackage-is-setted)
- [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)
Expand Down Expand Up @@ -216,8 +216,8 @@ YML files as you want.
**filePath** parameter, that expects to receive the path to the file. Using
the plugin in this way, you can't configure the model package or the api
package in the pom file, neither other options, so they will be configured as
its explained in [apiPackage](#how-apipackage-is-setted) and
[modelPackage](#how-modelpackage-is-setted) sections.
its explained in [apiPackage](#how-is-apipackage-set) and
[modelPackage](#how-is-modelpackage-set) sections.
This way it's limited to the usage of Consumer and Supplier methods.

```xml
Expand Down Expand Up @@ -301,7 +301,7 @@ can be configured in the plugin.
result as `EntityClassDTO`. This parameter is optional.
- **apiPackage**: This parameter receive a package name, where the
generated classes will be generated. This parameter is optional.
Check [how the apiPackage is setted](#how-apipackage-is-setted) for
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
Expand All @@ -311,7 +311,7 @@ can be configured in the plugin.
**Note that the plugin doesn't create the entities neither checks their
existence**, it takes their names from the YML file and assume that they are
created by the user. As the previous parameter, this is also optional.
Check [how the modelPackage is setted](#how-modelpackage-is-setted) for more
Check [how is the modelPackage set](#how-is-modelpackage-set) for more
information about how his parameter works, and the values it could have.

The configuration of `consumer`, `supplier` and `streamBridge` are independent.
Expand All @@ -330,7 +330,7 @@ By default, it's values is `generated-sources`, so the files will be in
the pom.xml file, as in the example above, files will remain in
`.../target/sources-generated/apigenerator/...`.

### How apiPackage is setted?
### How is apiPackage set?

The api package could be set in three different ways.

Expand All @@ -342,7 +342,7 @@ The api package could be set in three different ways.
plugin will use a default package name, that is stablished as
`com.sngular.apigenerator.asyncapi`.

### How modelPackage is setted?
### How is modelPackage set?

The model package could be set in four different ways.

Expand Down Expand Up @@ -666,14 +666,15 @@ that will be used. Each specFile has their own configuration:
| Name | Description | Example |
|--------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------|
| filePath | Path where the yaml is located | ${project.basedir}/src/main/resources/api/api.yml |
| apiPackage | Path where the api interface will be located | com.sngular.apigenerator.openapi |
| modelPackage | Path where the models will be located | com.sngular.apigenerator.openapi.model |
| apiPackage | Path where the api interface will be located | com.sngular.apigenerator.openapi |
| modelPackage | Path where the models will be located | com.sngular.apigenerator.openapi.model |
| modelNamePrefix | Prefix that will be used ahead of every model´s name | Api |
| modelNameSuffix | Suffix that will be used after every model´s name | DTO |
| callMode | Boolean value to decide if you want to generate the api for external calls. **Use RestClient by default. It´s initialized to false by default** | false |
| useTagsGroup | Boolean value to decide if using tags instead of an URL for group the API. **It´s initialized to false by default** | false |
| useLombokModelAnnotation | Boolean value to decide if you want your models with Lombok or not **It´s initialized to false by default** | false |
| isReactive | Boolean value to decide if you want to generate the api with responses in Mono/Flux Reactor types. If callmode = true use WebClient instead of RestClient. **It´s initialized to false by default** | false |
| useTimeType | Enum TimeType value. Controls the types used when generating dates. Can be local, zoned, or offset. **Initialized to TimeType.LOCAL by default** | TimeType.OFFSET |

As the configuration options already indicate, the data model will also be
created within the specified path.This model will be created with the indicated
Expand Down
3 changes: 2 additions & 1 deletion multiapi-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.sngular</groupId>
<artifactId>multiapi-engine</artifactId>
<version>4.5.2</version>
<version>4.6.1</version>
<packaging>jar</packaging>

<properties>
Expand Down Expand Up @@ -241,6 +241,7 @@
<plugin>
<groupId>com.github.ekryd.sortpom</groupId>
<artifactId>sortpom-maven-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<goals>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,41 +323,42 @@ private static void handleItems(final JsonNode schema, final Collection<String>
private static void setFieldProperties(final SchemaFieldObject fieldObject, final JsonNode schema) {
final Iterator<Map.Entry<String, JsonNode>> iterator = schema.fields();
Entry<String, JsonNode> current;
final SchemaFieldObjectProperties props = fieldObject.getRestrictions();
while (iterator.hasNext()) {
current = iterator.next();
switch (current.getKey()) {
case "minimum":
fieldObject.getRestrictions().setMinimum(current.getValue().asText());
props.setMinimum(current.getValue().asText());
break;
case "maximum":
fieldObject.getRestrictions().setMaximum(current.getValue().asText());
props.setMaximum(current.getValue().asText());
break;
case "exclusiveMinimum":
fieldObject.getRestrictions().setExclusiveMinimum(current.getValue().booleanValue());
props.setExclusiveMinimum(current.getValue().booleanValue());
break;
case "exclusiveMaximum":
fieldObject.getRestrictions().setExclusiveMaximum(current.getValue().booleanValue());
props.setExclusiveMaximum(current.getValue().booleanValue());
break;
case "maxItems":
fieldObject.getRestrictions().setMaxItems(current.getValue().intValue());
props.setMaxItems(current.getValue().intValue());
break;
case "maxLength":
fieldObject.getRestrictions().setMaxLength(current.getValue().intValue());
props.setMaxLength(current.getValue().intValue());
break;
case "minItems":
fieldObject.getRestrictions().setMinItems(current.getValue().intValue());
props.setMinItems(current.getValue().intValue());
break;
case "minLength":
fieldObject.getRestrictions().setMinLength(current.getValue().intValue());
props.setMinLength(current.getValue().intValue());
break;
case "pattern":
fieldObject.getRestrictions().setPattern(current.getValue().toString().replaceAll("\"", ""));
props.setPattern(current.getValue().toString().replaceAll("\"", ""));
break;
case "uniqueItems":
fieldObject.getRestrictions().setUniqueItems(current.getValue().booleanValue());
props.setUniqueItems(current.getValue().booleanValue());
break;
case "multipleOf":
fieldObject.getRestrictions().setMultipleOf(current.getValue().asText());
props.setMultipleOf(current.getValue().asText());
break;
default:
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ public class OpenApiGenerator {

private boolean useLombok;


public OpenApiGenerator(final Boolean overwriteModel, final String processedGeneratedSourcesFolder, final String groupId, final File targetFolder, final File basedir) {
templateFactory = new TemplateFactory();
this.overwriteModel = overwriteModel;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import static com.sngular.api.generator.plugin.openapi.model.SchemaFieldObjectType.OBJECT;

@Data
@Builder
@NoArgsConstructor
Expand All @@ -27,8 +25,9 @@ public class SchemaFieldObject {
private String baseName;

@Default
private SchemaFieldObjectType dataType = new SchemaFieldObjectType(OBJECT);
private SchemaFieldObjectType dataType = new SchemaFieldObjectType(TypeConstants.OBJECT);

@Default
private SchemaFieldObjectProperties restrictionProperties = new SchemaFieldObjectProperties();

private String importClass;
Expand Down
Loading

0 comments on commit 4c312d2

Please sign in to comment.