Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
477d62c
[version bump] new dev version
actions-user Jun 1, 2021
ec4b07f
Fix: added documentation for artifact input feature
sophiejanssens Jun 2, 2021
cbc6b61
Fix: link to relevant it tests for config examples
sophiejanssens Jun 7, 2021
e403af9
BOAT MARINA. Multiple Docs
bartv-bb Jun 14, 2021
b58785e
BOAT MARINA. Multiple Docs
bartv-bb Jun 15, 2021
d5b0752
Test
Jun 17, 2021
725063a
Patch HandlebarsEngine to write indented json adn avoid nulls
bartv-bb Jun 17, 2021
3523211
It's magic
bartv-bb Jun 17, 2021
66f80b0
Revert "Our policies state:"
christopherm-backbase Jun 28, 2021
846ae26
#205 Fix uncompilable mock generated from unbundled example file
daiscog Jun 30, 2021
7fb3755
#204 Guard against NPE in BoatExample.java
daiscog Jun 30, 2021
77a656c
Remove unused templates
Jul 5, 2021
fe57956
Removes unused templates
Jul 5, 2021
a88571d
Merge pull request #202 from Backbase/feature/Artifact-input-use-adde…
bartveenstra Jul 5, 2021
83c663c
Upgraded Jacoco
bartv-bb Jul 5, 2021
e1a21e5
Fixed Build & added release notes
bartv-bb Jul 5, 2021
ef7bef7
Create catalog-info.yaml
torrespro Jul 6, 2021
9c13246
Update catalog-info.yaml
torrespro Jul 6, 2021
f750763
prevent index.html to be generated in boat-marina
bartv-bb Jul 7, 2021
b781ddb
docs: update catalog-info with useful links
torrespro Jul 7, 2021
b4937ce
Set generator name conditionally
bartv-bb Jul 7, 2021
74f897e
Use Directory scanner
bartv-bb Jul 7, 2021
258d0b8
pom.xml restored from integration tests
bartv-bb Jul 7, 2021
34d4230
Fixed unit test
bartv-bb Jul 7, 2021
caf52fa
Improved Code Quality
bartv-bb Jul 8, 2021
612fd84
Updated readme
bartv-bb Jul 8, 2021
691769b
Improve code quality
bartv-bb Jul 8, 2021
aba94e8
Fixed assertion
bartv-bb Jul 8, 2021
2cc7cdc
Merge pull request #207 from Backbase/feature/boat-marina-spa
bartveenstra Jul 8, 2021
9c1de4e
Merge branch 'release'
bartv-bb Jul 8, 2021
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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ The project is very much Work In Progress and will be published on maven central
# Release Notes
BOAT is still under development and subject to change.

## 0.14.4

* *Boat Marina*
* Added a now BOAT Scaffold template called Marina, as that is where the models hang out. The Boat Marina template outputs a single JSON file that is used to offer a rich user interface built from the specs including search, page per operation and many more features!

* *Maven Plugin*
* The boat:doc goal now recursively search OpenAPI specs in a directory to generate docs for each found spec.

## 0.14.3

* *Maven Plugin*
Expand Down
2 changes: 1 addition & 1 deletion boat-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.backbase.oss</groupId>
<artifactId>backbase-openapi-tools</artifactId>
<version>0.14.3</version>
<version>0.14.4-SNAPSHOT</version>
</parent>
<artifactId>boat-engine</artifactId>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.nio.charset.StandardCharsets;

@Log
@SuppressWarnings({"java:S3740", "rawtypes"})
@SuppressWarnings({"java:S3740", "rawtypes", "java:S2755"})
public class XmlSchemaToOpenApi {
public static final String NAME = "name";
public static final String TYPE = "type";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ private void dereferenceExample(ExampleHolder exampleHolder) {
private Object convertExampleContent(ExampleHolder exampleHolder, String refPath) {
try {
if (exampleHolder.getRef().endsWith("json") || refPath.endsWith("json")) {
return Json.mapper().readValue(exampleHolder.getContent(), Object.class);
return Json.mapper().readValue(exampleHolder.getContent(), JsonNode.class);
}
return exampleHolder.getContent();
} catch (JsonProcessingException | RuntimeException e) {
Expand Down
59 changes: 56 additions & 3 deletions boat-maven-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ defined on openapi-generator-maven-plugin can be applied here too.

Boat maven plugin uses slightly modified templates for html, java and webclient that help generate specs and clients that work best in a Backbase projects.

All inputSpec parameters for this goal may additionally be configured as an artifact. See [Example inputMavenArtifact parameter](#example-inputMavenArtifact-parameter) or [integration tests](https://github.com/Backbase/backbase-openapi-tools/tree/main/boat-maven-plugin/src/it/example/boat-artifact-input) for examples.

## boat:generate-spring-boot-embedded

Same with `generate` but with opinionated defaults for Spring
Expand Down Expand Up @@ -152,7 +154,11 @@ Available parameters:
inputSpec
Required: true
Input spec directory or file.

Optionaly inputMavenArtifact parameter can be used instead to configure an artifact input.

inputMavenArtifact
Input spec artifact

output (Default: ${project.build.directory}/boat-lint-reports)
Output directory for lint reports.

Expand All @@ -171,12 +177,15 @@ Example:
<ignoreRules>${ignored-lint-rules}</ignoreRules>
<showIgnoredRules>true</showIgnoredRules>
</configuration>

To see details and an example of inputMavenArtifact:
[Example inputMavenArtifact parameter](#example-inputMavenArtifact-parameter)

To see details about this goal:

mvn help:describe -DgroupId=com.backbase.oss -DartifactId=boat-maven-plugin -Dgoal=lint -Ddetail`


## boat:bundle

Bundles a spec by resolving external references.
Expand Down Expand Up @@ -321,3 +330,47 @@ Configuration example
</pipeline>
</configuration>
```

## Example inputMavenArtifact parameter

Example:

```$xml
<inputMavenArtifact>
<groupId>com.backbase.oss.boat.example</groupId>
<artifactId>openapi-zips</artifactId>
<version>1.0.0-SNAPSHOT</version>
<classifier>api</classifier>
<type>zip</type>
<fileName>presentation-client-api/openapi.yaml</fileName>
</inputMavenArtifact>
```

Parameters:

groupId
Required: true
Input artifacts groupId
artifactId
Required: true
Input artifacts artifactId
version
Required: true
Input artifacts version
classifier
Required: true
Input artifacts classifier (must be api)
type
Required: true
Input artifacts type (must be zip)
fileName
Required: true
directory or file in artifact to be processed by goal


This parameter is available as a replacement for the inputSpec parameter in goals [generate](#boat:generate) and [lint](#boat:lint).

It downloads a copy of the artifact if it is not already present, and uses a specified spec (or directory of specs)
from the artifact as the inputSpec for the goal.

More examples can be found in integration tests.
4 changes: 2 additions & 2 deletions boat-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.backbase.oss</groupId>
<artifactId>backbase-openapi-tools</artifactId>
<version>0.14.3</version>
<version>0.14.4-SNAPSHOT</version>
</parent>
<artifactId>boat-maven-plugin</artifactId>

Expand Down Expand Up @@ -239,7 +239,7 @@
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
<settingsFile>src/it/settings.xml</settingsFile>
<extraArtifacts>
<extraArtifact>org.jacoco:org.jacoco.agent:0.8.4:jar:runtime</extraArtifact>
<extraArtifact>org.jacoco:org.jacoco.agent:${jacoco-maven-plugin.version}:jar:runtime</extraArtifact>
</extraArtifacts>
</configuration>
<executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@

@Mojo(name = "doc", threadSafe = true)
@Slf4j
public class GenerateDocMojo extends GenerateFromDirectoryDocMojo {
public class GenerateDocMojo extends GenerateFromDirectoryDocMojo {

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
getLog().info("Generating Boat Docs");
generatorName = "boat-docs";
if (generatorName == null) {
generatorName = "boat-docs";
}
super.execute();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.plexus.util.DirectoryScanner;

import java.io.File;
import java.util.Arrays;
import java.util.stream.Collectors;

/**
* Allows generate::Doc to accept inputSpec as a directory
Expand All @@ -13,6 +17,9 @@
@Slf4j
public class GenerateFromDirectoryDocMojo extends GenerateMojo {

@Parameter(defaultValue = "**/*-api-*.yaml")
protected String openApiFileFilters;


@Override
public void execute() throws MojoExecutionException, MojoFailureException {
Expand All @@ -33,22 +40,26 @@ private void fileInputExecute(File inputSpecFile) throws MojoExecutionException,
File[] inputSpecs;
File outPutDirectory = output;

inputSpecs = inputSpecFile.listFiles(pathname -> pathname.getName().endsWith(".yaml"));
inputSpecs = findAllOpenApiSpecs(inputSpecFile);

if (inputSpecs == null || inputSpecs.length == 0) {
if (inputSpecs.length == 0) {
throw new MojoExecutionException("No OpenAPI specs found in: " + inputSpec);
}

for (File f : inputSpecs) {
inputSpec = f.getPath();
output = new File(outPutDirectory.getPath(), f.getName().substring(0, f.getName().lastIndexOf(".")).concat("-docs"));
output = new File(outPutDirectory.getPath(), f.getName().substring(0, f.getName().lastIndexOf(".")));

if (!output.exists()) {
output.mkdir();
}

log.info(" Generating docs for spec {} in directory", f.getName());
super.execute();
try {
super.execute();
} catch (MojoExecutionException | MojoFailureException e) {
log.error("Failed to generate doc for spec: {}", inputSpec);
}
}

} else {
Expand All @@ -58,4 +69,15 @@ private void fileInputExecute(File inputSpecFile) throws MojoExecutionException,

}
}

private File[] findAllOpenApiSpecs(File specDirectory) {
DirectoryScanner directoryScanner = new DirectoryScanner();
directoryScanner.setBasedir(specDirectory);
directoryScanner.setIncludes(openApiFileFilters.replace(" ", "").split(","));
directoryScanner.scan();

String[] includedFiles = directoryScanner.getIncludedFiles();
return Arrays.stream(includedFiles).map(pathname -> new File(specDirectory, pathname))
.collect(Collectors.toList()).toArray(new File[]{});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,12 @@ class ExportBomMojoTests {
@Mock
Metadata metadatamock;

@Captor
ArgumentCaptor<List> argCaptor;


@Test
void testExportBomEmptyMeta() throws MojoFailureException, MojoExecutionException, ArtifactResolutionException {
void testExportBomEmptyMeta() throws MojoExecutionException {
artifactResolver = mock(ArtifactResolver.class);
artifactResult = mock( ArtifactResult.class);
metadataResolver = mock(MetadataResolver.class);
org.eclipse.aether.artifact.Artifact artifact = mock(org.eclipse.aether.artifact.Artifact.class);

when(metadataResolver.resolveMetadata(any(),any())).thenReturn(Collections.singletonList(metadataResult));

Expand All @@ -77,13 +73,14 @@ void testExportBomEmptyMeta() throws MojoFailureException, MojoExecutionExceptio
build.setDirectory("target");

MavenProject project = new MavenProject();
mojo.remoteRepositories = Collections.EMPTY_LIST;
mojo.remoteRepositories = Collections.emptyList();
project.setBuild(build);
mojo.project = project;
mojo.repositorySession = mock(RepositorySystemSession.class);
mojo.execute();

assertThat(output.list()).isEmpty();
assertThat(output).isEmptyDirectory();

}

@Test
Expand All @@ -98,7 +95,7 @@ void testExportBomUseOfArtifactResolver() throws MojoFailureException, MojoExecu
artifactResolver = mock(ArtifactResolver.class);
artifactResult = mock( ArtifactResult.class);
org.eclipse.aether.artifact.Artifact artifact; //= mock(org.eclipse.aether.artifact.Artifact.class);
artifact = new DefaultArtifact(groupId, artifactId, "", type, version,Collections.EMPTY_MAP, pomFile);
artifact = new DefaultArtifact(groupId, artifactId, "", type, version,Collections.emptyMap(), pomFile);


when(artifactResolver.resolveArtifact(any(),any())).thenReturn(artifactResult);
Expand Down Expand Up @@ -138,14 +135,14 @@ void testExportBomUseOfArtifactResolver() throws MojoFailureException, MojoExecu
build.setDirectory("target");

MavenProject project = new MavenProject();
mojo.remoteRepositories = Collections.EMPTY_LIST;
mojo.remoteRepositories = Collections.emptyList();

project.setBuild(build);
mojo.project = project;
mojo.repositorySession = mock(RepositorySystemSession.class);
mojo.execute();

assertThat(output.list()).isEmpty();
assertThat(output).isEmptyDirectory();

}
private File getFile(String fileName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ void testBoatDocsWithDirectory() throws MojoExecutionException, MojoFailureExcep
mojo.skipIfSpecIsUnchanged = false;
mojo.bundleSpecs = true;
mojo.dereferenceComponents = true;
mojo.openApiFileFilters = "**/*.yaml";
mojo.execute();
assertThat(output.list()).containsExactlyInAnyOrder("link-docs", "petstore-docs", "petstore-new-non-breaking-docs", "upto-docs");
assertThat(output.list()).contains("link", "petstore", "petstore-new-non-breaking", "upto");
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion boat-quay/boat-quay-lint/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.backbase.oss</groupId>
<artifactId>boat-quay</artifactId>
<version>0.14.3</version>
<version>0.14.4-SNAPSHOT</version>
</parent>
<artifactId>boat-quay-lint</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion boat-quay/boat-quay-rules/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.backbase.oss</groupId>
<artifactId>boat-quay</artifactId>
<version>0.14.3</version>
<version>0.14.4-SNAPSHOT</version>
</parent>
<artifactId>boat-quay-rules</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion boat-quay/boat-quay-rules/src/main/resources/boat.conf
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ StringPropertyLengthBoundsRule {
}

OpenApiVersionRule {
openApiVersions: [ 3.1.0 ]
openApiVersions: [ 3.0.3, 3.0.4 ]
}

ExtraRuleAnnotations {
Expand Down
2 changes: 1 addition & 1 deletion boat-quay/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.backbase.oss</groupId>
<artifactId>backbase-openapi-tools</artifactId>
<version>0.14.3</version>
<version>0.14.4-SNAPSHOT</version>
</parent>


Expand Down
4 changes: 2 additions & 2 deletions boat-scaffold/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.backbase.oss</groupId>
<artifactId>backbase-openapi-tools</artifactId>
<version>0.14.3</version>
<version>0.14.4-SNAPSHOT</version>
</parent>
<artifactId>boat-scaffold</artifactId>

Expand Down Expand Up @@ -86,7 +86,7 @@
<dependency>
<groupId>com.backbase.oss</groupId>
<artifactId>boat-trail-resources</artifactId>
<version>0.14.3</version>
<version>0.14.4-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.backbase.oss.codegen;

import org.openapitools.codegen.DefaultGenerator;

public class BoatDefaultGenerator extends DefaultGenerator {
}
Loading