Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
*.tar.gz
*.rar

# IDE files #
*.iml

# Maven build
target/

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Backbase OpenApi Tools

The Backbase Open API Tools is a collection of tools created to work effeciently with OpenAPI
The Backbase Open API Tools is a collection of tools created to work efficiently with OpenAPI

It currently consists of

Expand Down
117 changes: 69 additions & 48 deletions boat-engine/src/main/java/com/backbase/oss/boat/Exporter.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.backbase.oss.boat;

import com.backbase.oss.boat.transformers.Transformer;
import java.util.LinkedList;
import java.util.List;

public class ExporterOptions {

private boolean addJavaTypeExtensions;

private boolean convertExamplesToYaml = true;

private List<Transformer> transformers = new LinkedList<>();

public boolean isAddJavaTypeExtensions() {
return addJavaTypeExtensions;
}

public void setAddJavaTypeExtensions(boolean addJavaTypeExtensions) {
this.addJavaTypeExtensions = addJavaTypeExtensions;
}

public ExporterOptions addJavaTypeExtensions(boolean addJavaTypeExtensions) {
this.addJavaTypeExtensions = addJavaTypeExtensions;
return this;
}

public boolean isConvertExamplesToYaml() {
return convertExamplesToYaml;
}

public void setConvertExamplesToYaml(boolean convertExamplesToYaml) {
this.convertExamplesToYaml = convertExamplesToYaml;
}

public ExporterOptions convertExamplesToYaml(boolean convertExamplesToYaml) {
this.convertExamplesToYaml = convertExamplesToYaml;
return this;
}

public List<Transformer> getTransformers() {
return transformers;
}

public void setTransformers(List<Transformer> transformers) {
this.transformers = transformers;
}

public ExporterOptions transformers(List<Transformer> transformers) {
this.transformers = transformers;
return this;
}
}
11 changes: 11 additions & 0 deletions boat-engine/src/test/java/com/backbase/oss/boat/ExporterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ public void testHelloWorld() throws Exception {
validateExport(export);
}

@Test
public void testWallet() throws Exception {
File inputFile = getFile("/raml-examples/backbase-wallet/presentation-client-api.raml");
OpenAPI openAPI = Exporter.export(inputFile, new ExporterOptions()
.addJavaTypeExtensions(true)
.convertExamplesToYaml(false)
.transformers(Collections.singletonList(new Decomposer())));
String export = SerializerUtils.toYamlString(openAPI);
validateExport(export);
}


@Test
public void testBankingApi() throws Exception {
Expand Down
5 changes: 5 additions & 0 deletions boat-maven-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,15 @@ Configuration example
<description>mock-api-server</description>
</server>
</servers>
<!-- Add additional properties ('additions') element to specified types -->
<addAdditionalProperties>
<schema>User</schema>
<schema>UserItem</schema>
</addAdditionalProperties>
<!-- Adding 'x-java-type' extension when json schema includes 'javaType' (default false) -->
<addJavaTypeExtensions>false</addJavaTypeExtensions>
<!-- Convert request and response body examples to yaml (default true) -->
<convertJsonExamplesToYaml>false</convertJsonExamplesToYaml>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.backbase.oss.boat.transformers.Decomposer;
import com.backbase.oss.boat.transformers.Deprecator;
import com.backbase.oss.boat.transformers.LicenseAdder;
import com.backbase.oss.boat.transformers.Transformer;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
Expand Down Expand Up @@ -82,6 +81,9 @@ abstract class AbstractRamlToOpenApi extends AbstractMojo {
@Parameter(property = "convertJsonExamplesToYaml", defaultValue = "true")
protected boolean convertJsonExamplesToYaml;

@Parameter(property = "addJavaTypeExtensions", defaultValue = "true")
protected boolean addJavaTypeExtensions;

@Parameter(property = "appendDeprecatedMetadataInDescription", defaultValue = "true")
protected boolean appendDeprecatedMetadataInDescription = true;

Expand Down Expand Up @@ -158,23 +160,25 @@ protected File export(String name, Optional<String> version, File ramlFile, File


protected OpenAPI convert(String name, Optional<String> version, File ramlFile) throws ExportException {
List<Transformer> transformers = new ArrayList<>();
ExporterOptions options = new ExporterOptions()
.addJavaTypeExtensions(addJavaTypeExtensions)
.convertExamplesToYaml(convertJsonExamplesToYaml);

if (removeDeprecated) {
transformers.add(new Deprecator());
options.getTransformers().add(new Deprecator());
}
if (decompose) {
transformers.add(new Decomposer());
options.getTransformers().add(new Decomposer());
}
if (!addAdditionalProperties.isEmpty()) {
transformers.add(new AdditionalPropertiesAdder(addAdditionalProperties));
options.getTransformers().add(new AdditionalPropertiesAdder(addAdditionalProperties));
}

if (licenseName != null && licenseUrl != null) {
transformers.add(new LicenseAdder(licenseName, licenseUrl));
options.getTransformers().add(new LicenseAdder(licenseName, licenseUrl));
}

OpenAPI openApi = Exporter.export(ramlFile, convertJsonExamplesToYaml, transformers);
OpenAPI openApi = Exporter.export(ramlFile, options);
pimpInfo(name, version, ramlFile, openApi);
if (appendDeprecatedMetadataInDescription) {
// Iterate over all operations and update the description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static void main(String[] args) {
if (!inputFile.exists()) {
throw new ParseException("Input file does not exist");
}
OpenAPI openApi = Exporter.export(inputFile, true);
OpenAPI openApi = Exporter.export(inputFile, new ExporterOptions().convertExamplesToYaml(true));

String yaml = SerializerUtils.toYamlString(openApi);
if (hasOutputFile) {
Expand Down