Skip to content

Commit

Permalink
release 1.9.0
Browse files Browse the repository at this point in the history
Signed-off-by: Bartosz Michalik <[email protected]>
  • Loading branch information
bartoszm committed Aug 22, 2022
1 parent 40382e3 commit 392a8e1
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 22 deletions.
43 changes: 29 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ mvn clean package
Project requires Java runtime in version 11 or greater.

```shell script
java -jar blender-1.x.jar <command> [args]
java -jar blender-all-in.jar <command> [args]
```

## Tool `generate` command synopsis
Expand Down Expand Up @@ -92,7 +92,7 @@ Assuming you have a valid spring generator configuration
(as explained [here](https://openapi-generator.tech/docs/generators/spring)) in `configurations/spring`
```shell script
java -jar blender-1.x.jar generate -i .\productApi\serviceability\offeringQualification\productOfferingQualificationManagement.api.yaml \
java -jar blender-all-in.jar generate -i .\productApi\serviceability\offeringQualification\productOfferingQualificationManagement.api.yaml \
-c ./configurations/spring/spring-server.yaml \
-d .\productSchema\carrierEthernet \
-b accessEline\accessElineOvc.yaml -b carrierEthernetOperatorUni\carrierEthernetOperatorUni.yaml
Expand All @@ -110,12 +110,14 @@ NAME
SYNOPSIS
sonata-blending-tool-cli blend
[ {-b | --blending-schema} <specifications to be blend (integrate) in>... ]
[ {-d | --spec-root-dir} <root directory for specificatins to be blended> ]
[ {-d | --spec-root-dir} <root directory for specifications to be blended> ]
[ {-e | -encoding} <files encoding> ]
[ {-f | --force-override} ] [ {-i | --input-spec} <spec file> ]
[ {-m | --model-name} <model to be augmented> ]
[ {-o | --output} <Output file name> ]
[ --sorted ] [ --strict-mode ]
[ {-p | --product-spec} <deprecated. product specifications>... ]
[ --path-security <pathSecurity> ] [ --sorted ]
[ --strict-mode ]

OPTIONS
-b <specifications to be blend (integrate) in>, --blending-schema
Expand All @@ -127,10 +129,9 @@ OPTIONS
one option may be specified


-d <root directory for specificatins to be blended>, --spec-root-dir
<root directory for specificatins to be blended>
sets of product specification root directory for specifications you
would like to integrate
-d <root directory for specifications to be blended>, --spec-root-dir
<root directory for specifications to be blended>
root directory for specifications.

This option may occur a maximum of 1 times

Expand All @@ -140,7 +141,7 @@ OPTIONS
system encoding is used

-f, --force-override

Override output if exist

This option may occur a maximum of 1 times

Expand All @@ -162,6 +163,20 @@ OPTIONS
This option may occur a maximum of 1 times


-p <deprecated. product specifications>, --product-spec <deprecated. product specifications>
sets of product specification you would like to integrate

This option is part of the group 'allOrSelective' from which only
one option may be specified


--path-security <pathSecurity>
mechanism to use to secure API paths. default disabled

This options value is restricted to the following set of values:
oauth2
disabled

--sorted
sort data types in a lexical order

Expand All @@ -172,7 +187,7 @@ OPTIONS
Verify that model to be augmented allows for extension (contains
discriminator definition).
If strict-mode is `false` tool will add a discriminator on the fly
if possible.
if possible.
```
Expand All @@ -181,7 +196,7 @@ OPTIONS
Assumption is that this command is run from root of the Sonata SDK directory and jar file is in the same directory.
```shell script
java -jar blender-1.x.jar blend -i .\productApi\serviceability\offeringQualification\productOfferingQualificationManagement.api.yaml \
java -jar blender-all-in.jar blend -i .\productApi\serviceability\offeringQualification\productOfferingQualificationManagement.api.yaml \
-d .\productSchema\carrierEthernet \
-b accessEline\accessElineOvc.yaml \
-b carrierEthernetOperatorUni\carrierEthernetOperatorUni.yaml
Expand All @@ -192,7 +207,7 @@ java -jar blender-1.x.jar blend -i .\productApi\serviceability\offeringQualifica
Assumption is that this command is run from root of the Legato SDK directory and jar file is in the same directory.
```shell script
java -jar blender-1.x.jar blend -d spec/legato/carrierEthernet -m MefServiceConfiguration \
java -jar blender-all-in.jar blend -d spec/legato/carrierEthernet -m MefServiceConfiguration \
-i ./api/legato/serviceProvisioning/serviceOrdering/v4/serviceOrderingApi.openapi.yaml \
-b carrierEthernetOvc.yaml \
-b carrierEthernetSubscriberUni.yaml
Expand Down Expand Up @@ -256,7 +271,7 @@ Assumption is that this command is run from any directory. `-d` parameter points
In this example this directory hosts
```shell script
java -jar blender-1.x.jar merge \
java -jar blender-all-in.jar merge \
-d ${rootSchemaDirectory} \
-b accessEline\accessElineOvc.yaml \
-b carrierEthernetOperatorUni\carrierEthernetOperatorUni.yaml
Expand All @@ -268,7 +283,7 @@ Assumption is that this command is run from the schema directory. You could also
different directory as in the example above.
```shell script
java -jar blender-1.x.jar merge \
java -jar blender-all-in.jar merge \
-b carrierEthernetOvc.yaml \
-b carrierEthernetSubscriberUni.yaml
```
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<groupId>com.amartus.sonata</groupId>
<artifactId>blender</artifactId>
<description>SonataBlendingTool</description>
<version>1.8.1-SNAPSHOT</version>
<version>1.9.0</version>
<properties>
<openapi.generator.version>5.4.0</openapi.generator.version>
</properties>
Expand Down
30 changes: 23 additions & 7 deletions src/main/java/com/amartus/sonata/blender/cmd/Blend.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@

import com.amartus.sonata.blender.impl.MergeSchemasAction;
import com.amartus.sonata.blender.impl.postprocess.ComposedPostprocessor;
import com.amartus.sonata.blender.impl.postprocess.SecureEndpointsWithOAuth2;
import com.amartus.sonata.blender.impl.postprocess.SortTypesByName;
import com.amartus.sonata.blender.impl.util.IdSchemaResolver;
import com.amartus.sonata.blender.impl.util.SerializationUtils;
import com.github.rvesse.airline.annotations.Command;
import com.github.rvesse.airline.annotations.Option;
import com.github.rvesse.airline.annotations.restrictions.AllowedEnumValues;
import com.github.rvesse.airline.annotations.restrictions.Once;
import io.swagger.parser.OpenAPIParser;
import io.swagger.v3.oas.models.OpenAPI;
Expand All @@ -47,6 +49,13 @@
public class Blend extends AbstractBlend implements Runnable {
private static final Logger log = LoggerFactory.getLogger(Blend.class);

@Option(
name = {"-f", "--force-override"},
description = "Override output if exist"
)
@Once
private boolean forceWrite = false;

@Option(
name = {"--sorted"},
title = "sort data types",
Expand All @@ -61,15 +70,13 @@ public class Blend extends AbstractBlend implements Runnable {
)
@Once
private String outputFile;

@Option(
name = {"-f", "--force-override"},
title = "Override output if exist"
)
@Once
private boolean forceWrite = false;

name = {"--path-security"},
description = "mechanism to use to secure API paths. default disabled"

)
@AllowedEnumValues(PathSecurity.class)
private PathSecurity pathSecurity = PathSecurity.disabled;

@Override
public void run() {
Expand Down Expand Up @@ -104,6 +111,10 @@ public void run() {
new SortTypesByName().accept(openAPI);
}

if (pathSecurity == PathSecurity.oauth2) {
new SecureEndpointsWithOAuth2().accept(openAPI);
}

var mapper = SerializationUtils.yamlMapper();

try {
Expand All @@ -115,6 +126,11 @@ public void run() {
}
}


private enum PathSecurity {
oauth2, disabled
}

private List<String> findAllProductSpecifications(String allSchemas) {
return new IdSchemaResolver(allSchemas)
.findProductSpecifications(Path.of(productsRootDir)).stream()
Expand Down

0 comments on commit 392a8e1

Please sign in to comment.