From 5dd5781afdb04478499e79219382da1e781a474b Mon Sep 17 00:00:00 2001 From: Sophie Janssens Date: Tue, 26 Jan 2021 21:33:03 +0000 Subject: [PATCH 01/12] started to create demo projects --- boat-maven-plugin/pom.xml | 6 + .../src/it/example/boat-bay/petstore1/pom.xml | 48 ++++++ .../src/main/resources/petstore.yaml | 138 ++++++++++++++++++ .../src/it/example/boat-bay/petstore2/pom.xml | 46 ++++++ .../src/main/resources/petstore.yaml | 0 .../src/it/example/boat-bay/petstore3/pom.xml | 25 ++++ .../src/it/example/boat-bay/petstore4/pom.xml | 47 ++++++ .../src/main/resources/petstore.yaml | 138 ++++++++++++++++++ .../src/it/example/boat-bay/pom.xml | 30 ++++ boat-maven-plugin/src/it/example/pom.xml | 1 + .../java/com/backbase/oss/boat/LintMojo.java | 99 +++++++++++++ .../com/backbase/oss/boat/ValidateMojo.java | 21 +++ 12 files changed, 599 insertions(+) create mode 100644 boat-maven-plugin/src/it/example/boat-bay/petstore1/pom.xml create mode 100644 boat-maven-plugin/src/it/example/boat-bay/petstore1/src/main/resources/petstore.yaml create mode 100644 boat-maven-plugin/src/it/example/boat-bay/petstore2/pom.xml create mode 100644 boat-maven-plugin/src/it/example/boat-bay/petstore2/src/main/resources/petstore.yaml create mode 100644 boat-maven-plugin/src/it/example/boat-bay/petstore3/pom.xml create mode 100644 boat-maven-plugin/src/it/example/boat-bay/petstore4/pom.xml create mode 100644 boat-maven-plugin/src/it/example/boat-bay/petstore4/src/main/resources/petstore.yaml create mode 100644 boat-maven-plugin/src/it/example/boat-bay/pom.xml diff --git a/boat-maven-plugin/pom.xml b/boat-maven-plugin/pom.xml index 5a2420f18..bccf724f6 100644 --- a/boat-maven-plugin/pom.xml +++ b/boat-maven-plugin/pom.xml @@ -127,6 +127,12 @@ test + + com.backbase.oss.boat.bay + boat-bay-client + 0.0.1-SNAPSHOT + + diff --git a/boat-maven-plugin/src/it/example/boat-bay/petstore1/pom.xml b/boat-maven-plugin/src/it/example/boat-bay/petstore1/pom.xml new file mode 100644 index 000000000..54984f9df --- /dev/null +++ b/boat-maven-plugin/src/it/example/boat-bay/petstore1/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + + + + com.backbase.oss.boat.example + example + 1.0.0-SNAPSHOT + + + petstore1 + + BOAT :: Lint Upload :: Spec + + + Example projects showing how BOAT can help you generate code + + + pom + + + + + com.backbase.oss + boat-maven-plugin + + + lint + validate + + lint + + + ${project.basedir}/src/main/resources/petstore.yaml + ${project.basedir}/src/main/resources/output + 5 + + + + + + + + + diff --git a/boat-maven-plugin/src/it/example/boat-bay/petstore1/src/main/resources/petstore.yaml b/boat-maven-plugin/src/it/example/boat-bay/petstore1/src/main/resources/petstore.yaml new file mode 100644 index 000000000..137eaff93 --- /dev/null +++ b/boat-maven-plugin/src/it/example/boat-bay/petstore1/src/main/resources/petstore.yaml @@ -0,0 +1,138 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: Swagger Petstore + license: + name: MIT +servers: + - url: http://petstore.swagger.io/v1 +paths: + /pets: + get: + summary: List all pets + operationId: listPets + tags: + - pets + parameters: + - name: limit + in: query + description: How many items to return at one time (max 100) + required: false + schema: + type: integer + format: int32 + responses: + '200': + description: A paged array of pets + headers: + x-next: + description: A link to the next page of responses + schema: + type: string + content: + application/json: + schema: + $ref: "#/components/schemas/Pets" + text/csv: + schema: + type: string + 500: + content: + application/json: + schema: + $ref: '#/components/schemas/InternalServerError' + description: InternalServerError + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + summary: Create a pet + operationId: createPets + tags: + - pets + responses: + '201': + description: Null response + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /pets/{petId}: + get: + summary: Info for a specific pet + operationId: showPetById + tags: + - pets + parameters: + - name: petId + in: path + required: true + description: The id of the pet to retrieve + schema: + type: string + responses: + '200': + description: Expected response to a valid request + content: + application/json: + schema: + $ref: "#/components/schemas/Pet" + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /no-schema: + get: + summary: No Schema + operationId: getNoSchema + tags: + - pets + responses: + 200: + description: A response that does not specify a schema + content: + application/json: {} +components: + schemas: + Pet: + type: object + required: + - id + - name + properties: + id: + type: integer + format: int64 + name: + type: string + tag: + type: string + Pets: + type: array + items: + $ref: "#/components/schemas/Pet" + Error: + type: object + required: + - code + - message + properties: + code: + type: integer + format: int32 + message: + type: string + InternalServerError: + type: object + required: + - message + properties: + message: + type: string \ No newline at end of file diff --git a/boat-maven-plugin/src/it/example/boat-bay/petstore2/pom.xml b/boat-maven-plugin/src/it/example/boat-bay/petstore2/pom.xml new file mode 100644 index 000000000..f1cbe6101 --- /dev/null +++ b/boat-maven-plugin/src/it/example/boat-bay/petstore2/pom.xml @@ -0,0 +1,46 @@ + + + 4.0.0 + + + com.backbase.oss.boat.example + example + 1.0.0-SNAPSHOT + + + petstore2 + + BOAT :: Lint Upload :: Empty Spec + + + Example projects showing how BOAT can help you generate code + + + pom + + + + com.backbase.oss + boat-maven-plugin + + + lint + validate + + lint + + + ${project.basedir}/src/main/resources/petstore.yaml + ${project.basedir}/src/main/resources/output + 5 + + + + + + + + + diff --git a/boat-maven-plugin/src/it/example/boat-bay/petstore2/src/main/resources/petstore.yaml b/boat-maven-plugin/src/it/example/boat-bay/petstore2/src/main/resources/petstore.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/boat-maven-plugin/src/it/example/boat-bay/petstore3/pom.xml b/boat-maven-plugin/src/it/example/boat-bay/petstore3/pom.xml new file mode 100644 index 000000000..08ff1808b --- /dev/null +++ b/boat-maven-plugin/src/it/example/boat-bay/petstore3/pom.xml @@ -0,0 +1,25 @@ + + + 4.0.0 + + + com.backbase.oss.boat.example + example + 1.0.0-SNAPSHOT + + + petstore3 + + BOAT :: Lint Upload :: Spec + + + Example projects showing how BOAT can help you generate code + + + pom + + + + diff --git a/boat-maven-plugin/src/it/example/boat-bay/petstore4/pom.xml b/boat-maven-plugin/src/it/example/boat-bay/petstore4/pom.xml new file mode 100644 index 000000000..e4cac3496 --- /dev/null +++ b/boat-maven-plugin/src/it/example/boat-bay/petstore4/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + + + + com.backbase.oss.boat.example + example + 1.0.0-SNAPSHOT + + + petstore4 + + BOAT :: Lint Upload :: Spec Validate + + + Example projects showing how BOAT can help you generate code + + + pom + + + + + com.backbase.oss + boat-maven-plugin + + + validate + validate + + validate + + + true + ${project.basedir}/src/main/resources/petstore.yaml + + + + + + + + + diff --git a/boat-maven-plugin/src/it/example/boat-bay/petstore4/src/main/resources/petstore.yaml b/boat-maven-plugin/src/it/example/boat-bay/petstore4/src/main/resources/petstore.yaml new file mode 100644 index 000000000..137eaff93 --- /dev/null +++ b/boat-maven-plugin/src/it/example/boat-bay/petstore4/src/main/resources/petstore.yaml @@ -0,0 +1,138 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: Swagger Petstore + license: + name: MIT +servers: + - url: http://petstore.swagger.io/v1 +paths: + /pets: + get: + summary: List all pets + operationId: listPets + tags: + - pets + parameters: + - name: limit + in: query + description: How many items to return at one time (max 100) + required: false + schema: + type: integer + format: int32 + responses: + '200': + description: A paged array of pets + headers: + x-next: + description: A link to the next page of responses + schema: + type: string + content: + application/json: + schema: + $ref: "#/components/schemas/Pets" + text/csv: + schema: + type: string + 500: + content: + application/json: + schema: + $ref: '#/components/schemas/InternalServerError' + description: InternalServerError + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + summary: Create a pet + operationId: createPets + tags: + - pets + responses: + '201': + description: Null response + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /pets/{petId}: + get: + summary: Info for a specific pet + operationId: showPetById + tags: + - pets + parameters: + - name: petId + in: path + required: true + description: The id of the pet to retrieve + schema: + type: string + responses: + '200': + description: Expected response to a valid request + content: + application/json: + schema: + $ref: "#/components/schemas/Pet" + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /no-schema: + get: + summary: No Schema + operationId: getNoSchema + tags: + - pets + responses: + 200: + description: A response that does not specify a schema + content: + application/json: {} +components: + schemas: + Pet: + type: object + required: + - id + - name + properties: + id: + type: integer + format: int64 + name: + type: string + tag: + type: string + Pets: + type: array + items: + $ref: "#/components/schemas/Pet" + Error: + type: object + required: + - code + - message + properties: + code: + type: integer + format: int32 + message: + type: string + InternalServerError: + type: object + required: + - message + properties: + message: + type: string \ No newline at end of file diff --git a/boat-maven-plugin/src/it/example/boat-bay/pom.xml b/boat-maven-plugin/src/it/example/boat-bay/pom.xml new file mode 100644 index 000000000..53f5403da --- /dev/null +++ b/boat-maven-plugin/src/it/example/boat-bay/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + + + com.backbase.oss.boat.example + example + 1.0.0-SNAPSHOT + + + boat-bay + + BOAT :: Lint Upload + + + Example projects showing how BOAT can help you generate code + + + pom + + + petstore1 + petstore2 + petstore3 + petstore4 + + + diff --git a/boat-maven-plugin/src/it/example/pom.xml b/boat-maven-plugin/src/it/example/pom.xml index 4c8001a69..ebae28962 100644 --- a/boat-maven-plugin/src/it/example/pom.xml +++ b/boat-maven-plugin/src/it/example/pom.xml @@ -40,6 +40,7 @@ BOAT :: Examples + boat-bay boat-doc boat-export boat-generate diff --git a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/LintMojo.java b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/LintMojo.java index 0e73c4952..6ccf4c1f2 100644 --- a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/LintMojo.java +++ b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/LintMojo.java @@ -1,16 +1,25 @@ package com.backbase.oss.boat; +import com.backbase.oss.boat.bay.client.ApiException; +import com.backbase.oss.boat.bay.client.api.UploadPluginApi; +import com.backbase.oss.boat.loader.OpenAPILoader; +import com.backbase.oss.boat.loader.OpenAPILoaderException; import com.backbase.oss.boat.quay.model.BoatLintReport; import com.backbase.oss.codegen.lint.BoatLintConfig; import com.backbase.oss.codegen.lint.BoatLintGenerator; import java.io.File; +import java.io.IOException; +import java.net.URL; import java.util.List; + +import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.project.MavenProject; @SuppressWarnings("FieldMayBeFinal") @Mojo(name = "lint", requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true) @@ -32,11 +41,26 @@ public class LintMojo extends AbstractLintMojo { @Parameter(name = "writeLintReport", defaultValue = "true") private boolean writeLintReport; + @Parameter(readonly = true, required = true, defaultValue = "${project}") + protected MavenProject project; + + @Parameter(name = "sourceId") + private String sourceId; + + private UploadLint boatBaySpecUpload; + @Override public void execute() throws MojoExecutionException, MojoFailureException { + boolean boatbay = false; + + List boatLintReports = null; try { + +// if(boatbay){ +// new UploadLint(inputSpec,output,project).upload(sourceId); +// } boatLintReports = lint(); } catch (MojoExecutionException e) { if (failOnWarning) { @@ -91,6 +115,81 @@ private File getOutput() { return this.output; } +// private List uploadAndLint() throws IOException, OpenAPILoaderException { +// OkHttpClient client = new OkHttpClient(); +// +// Request request = new Request.Builder() +// .url(new URL("http://localhost:8080/api/boat-maven-plugin/"+sourceId+"/upload")) +// .put(createRequest()) +// .build(); +// +// +// Response response = client.newCall(request).execute(); +// log.debug("response {}", response.body().toString() ); +// ObjectMapper objectMapper = new ObjectMapper(); +// List reports = objectMapper.readValue( response.body().toString(), List.class); +// return reports; +// } + + +// URL client = new URL("http://localhost:8080/api/boat-maven-plugin/"+sourceId+"/upload"); +// +// HttpURLConnection connection = (HttpURLConnection) client.openConnection(); +// connection.setDoOutput(true); +// connection.setRequestMethod(PUT); +// connection.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4="); +// connection.setRequestProperty("Content-Type", "application/json"); +// OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream()); +// out.write(createRequest()); +// out.close(); +// if (connection.getResponseCode() != HttpURLConnection.HTTP_OK){ +// throw new HttpResponseException(connection.getResponseCode(),"Unsuccessful lint request"); +// } +// HttpEntity> responseBody; +// InputStreamReader response = new InputStreamReader(connection.getInputStream()); +//// String responseEntity = new BufferedReader(response).lines().collect(Collectors.joining("\n")); +//// ResponseEntity reports = new ObjectMapper().readValue(responseEntity, ResponseEntity.class); +//// Object body = reports.getBody(); +//// if (body.getClass().isInstance(List.class)){ +//// List list = (List) body; +//// if (list.get(0).getClass().isInstance()) +//// } +// connection.getResponseCode() +// +// return new ObjectMapper().readValue(response,List.class); +// +// +// +// +// } +// +// private RequestBody createRequest() throws OpenAPILoaderException { +// MediaType JSON = MediaType.parse("application/json; charset=utf-8"); +// String request = String.format("{\"specs\": [ {" + +// "\"key\": \"%s\" , " + +// "\"name\" : \"%s\", " + +// "\"openApi\" : \"%s\", " + +// "\"filename\": \"%s\", " + +// "} ], " + +// "\"location\": \"%s\", " + +// "\"projectId\": \"%s\"," + +// "\"artifactId\": \"%s\"," + +// "\"version\": \"%s\"}", +// inputSpec.getName().substring(0, inputSpec.getName().lastIndexOf('-')), +// inputSpec.getName(), +// OpenAPILoader.load(inputSpec).getOpenapi(), +// inputSpec.getName(), +// output.getParentFile().getPath(), +// project.getGroupId(), +// project.getArtifactId() , +// project.getVersion() +// ); +// +// return RequestBody.create(JSON, request); +// } + + + public void setWriteLintReport(boolean writeLintReport) { this.writeLintReport = writeLintReport; } diff --git a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/ValidateMojo.java b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/ValidateMojo.java index 75ae3e0cd..b49076bea 100644 --- a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/ValidateMojo.java +++ b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/ValidateMojo.java @@ -1,11 +1,15 @@ package com.backbase.oss.boat; +import com.backbase.oss.boat.bay.client.ApiClient; +import com.backbase.oss.boat.bay.client.api.UploadPluginApi; import com.backbase.oss.boat.serializer.SerializerUtils; import io.swagger.parser.OpenAPIParser; import io.swagger.v3.parser.core.models.ParseOptions; import io.swagger.v3.parser.core.models.SwaggerParseResult; import java.io.File; import java.util.ArrayList; + +import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugin.AbstractMojo; @@ -13,6 +17,8 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.project.MavenProject; +import org.springframework.beans.factory.annotation.Autowired; /** * Validates OpenAPI specs. @@ -27,6 +33,14 @@ public class ValidateMojo extends AbstractMojo { @Parameter(name = "failOnWarning", required = true) private boolean failOnWarning; + @Parameter(readonly = true, required = true, defaultValue = "${project}") + protected MavenProject project; +/// cant get it to be sent in source pom flile ??? + @Parameter(name = "sourceId", defaultValue = "", property = "inputSpec") + private String sourceId; + + private UploadLint boatbayUploadSpecClient; + public void setInput(File input) { this.input = input; } @@ -34,6 +48,10 @@ public void setFailOnWarning(boolean failOnWarning) { this.failOnWarning= failOnWarning; } + + + + @SneakyThrows @Override public void execute() throws MojoFailureException { @@ -48,6 +66,9 @@ public void execute() throws MojoFailureException { } } else { validate(input); + if (false){ + new UploadLint(input,null,project).upload(sourceId); + } } } From 7d89619e5bc237b5f9ce9db03f8d2e71c4f000d4 Mon Sep 17 00:00:00 2001 From: Sophie Janssens Date: Wed, 27 Jan 2021 08:29:46 +0000 Subject: [PATCH 02/12] removed redundant commented code --- .../java/com/backbase/oss/boat/LintMojo.java | 73 ------------------- 1 file changed, 73 deletions(-) diff --git a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/LintMojo.java b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/LintMojo.java index 6ccf4c1f2..660834915 100644 --- a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/LintMojo.java +++ b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/LintMojo.java @@ -115,79 +115,6 @@ private File getOutput() { return this.output; } -// private List uploadAndLint() throws IOException, OpenAPILoaderException { -// OkHttpClient client = new OkHttpClient(); -// -// Request request = new Request.Builder() -// .url(new URL("http://localhost:8080/api/boat-maven-plugin/"+sourceId+"/upload")) -// .put(createRequest()) -// .build(); -// -// -// Response response = client.newCall(request).execute(); -// log.debug("response {}", response.body().toString() ); -// ObjectMapper objectMapper = new ObjectMapper(); -// List reports = objectMapper.readValue( response.body().toString(), List.class); -// return reports; -// } - - -// URL client = new URL("http://localhost:8080/api/boat-maven-plugin/"+sourceId+"/upload"); -// -// HttpURLConnection connection = (HttpURLConnection) client.openConnection(); -// connection.setDoOutput(true); -// connection.setRequestMethod(PUT); -// connection.setRequestProperty("Authorization", "Basic YWRtaW46YWRtaW4="); -// connection.setRequestProperty("Content-Type", "application/json"); -// OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream()); -// out.write(createRequest()); -// out.close(); -// if (connection.getResponseCode() != HttpURLConnection.HTTP_OK){ -// throw new HttpResponseException(connection.getResponseCode(),"Unsuccessful lint request"); -// } -// HttpEntity> responseBody; -// InputStreamReader response = new InputStreamReader(connection.getInputStream()); -//// String responseEntity = new BufferedReader(response).lines().collect(Collectors.joining("\n")); -//// ResponseEntity reports = new ObjectMapper().readValue(responseEntity, ResponseEntity.class); -//// Object body = reports.getBody(); -//// if (body.getClass().isInstance(List.class)){ -//// List list = (List) body; -//// if (list.get(0).getClass().isInstance()) -//// } -// connection.getResponseCode() -// -// return new ObjectMapper().readValue(response,List.class); -// -// -// -// -// } -// -// private RequestBody createRequest() throws OpenAPILoaderException { -// MediaType JSON = MediaType.parse("application/json; charset=utf-8"); -// String request = String.format("{\"specs\": [ {" + -// "\"key\": \"%s\" , " + -// "\"name\" : \"%s\", " + -// "\"openApi\" : \"%s\", " + -// "\"filename\": \"%s\", " + -// "} ], " + -// "\"location\": \"%s\", " + -// "\"projectId\": \"%s\"," + -// "\"artifactId\": \"%s\"," + -// "\"version\": \"%s\"}", -// inputSpec.getName().substring(0, inputSpec.getName().lastIndexOf('-')), -// inputSpec.getName(), -// OpenAPILoader.load(inputSpec).getOpenapi(), -// inputSpec.getName(), -// output.getParentFile().getPath(), -// project.getGroupId(), -// project.getArtifactId() , -// project.getVersion() -// ); -// -// return RequestBody.create(JSON, request); -// } - public void setWriteLintReport(boolean writeLintReport) { From 346481b9eb2c3e1aa951d3e7a220a35c27883d8d Mon Sep 17 00:00:00 2001 From: Sophie Janssens Date: Wed, 27 Jan 2021 08:45:26 +0000 Subject: [PATCH 03/12] added example project for broken spec upload --- .../src/it/example/boat-bay/petstore3/pom.xml | 26 +++- .../src/main/resource/petstore-breaking.yaml | 113 ++++++++++++++++++ 2 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 boat-maven-plugin/src/it/example/boat-bay/petstore3/src/main/resource/petstore-breaking.yaml diff --git a/boat-maven-plugin/src/it/example/boat-bay/petstore3/pom.xml b/boat-maven-plugin/src/it/example/boat-bay/petstore3/pom.xml index 08ff1808b..491f4c909 100644 --- a/boat-maven-plugin/src/it/example/boat-bay/petstore3/pom.xml +++ b/boat-maven-plugin/src/it/example/boat-bay/petstore3/pom.xml @@ -12,7 +12,7 @@ petstore3 - BOAT :: Lint Upload :: Spec + BOAT :: Lint Upload :: Spec Breaking Example projects showing how BOAT can help you generate code @@ -20,6 +20,30 @@ pom + + + + com.backbase.oss + boat-maven-plugin + + + lint + validate + + lint + + + ${project.basedir}/src/main/resources/petstore-breaking.yaml + ${project.basedir}/src/main/resources/output + 5 + + + + + + + + diff --git a/boat-maven-plugin/src/it/example/boat-bay/petstore3/src/main/resource/petstore-breaking.yaml b/boat-maven-plugin/src/it/example/boat-bay/petstore3/src/main/resource/petstore-breaking.yaml new file mode 100644 index 000000000..322020309 --- /dev/null +++ b/boat-maven-plugin/src/it/example/boat-bay/petstore3/src/main/resource/petstore-breaking.yaml @@ -0,0 +1,113 @@ +openapi: "3.0.0" +info: + version: 2.0.0 + title: Swagger Petstore + license: + name: MIT +servers: + - url: http://petstore.swagger.io/v1 +paths: + /new-pets: + get: + summary: List all pets + operationId: listPets + tags: + - pets + parameters: + - name: limit + in: query + description: How many items to return at one time (max 100) + required: false + schema: + type: integer + format: int32 + responses: + '200': + description: A paged array of pets + headers: + x-next: + description: A link to the next page of responses + schema: + type: + content: + application/json: + schema: + $ref: "#/components/schemas/Pets" + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + summary: Create a pet + operationId: createPets + tags: + - pets + responses: + '201': + description: Null response + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /pets/{petId}: + get: + summary: Info for a specific pet + operationId: showPetById + tags: + - pets + parameters: + - name: petId + in: path + required: true + description: The id of the pet to retrieve + schema: + type: string + responses: + '200': + description: Expected response to a valid request + content: + application/json: + schema: + $ref: "#/components/schemas/Pet" + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" +components: + schemas: + Pet: + type: object + required: + - id + - name + properties: + id: + type: integer + format: int64 + name: + type: string + tag: + type: string + new-property: + type: string + Pets: + type: array + items: + $ref: "#/components/schemas/Pet" + Error: + type: object + required: + - code + - message + properties: + code: + type: integer + format: int32 + message: + type: string \ No newline at end of file From 3e3bdcd54921e652a72a03039f46f5fadc9bcf8e Mon Sep 17 00:00:00 2001 From: Sophie Janssens Date: Wed, 27 Jan 2021 13:40:41 +0000 Subject: [PATCH 04/12] updated example projects, attempt at generating boat bay client, doesnt work --- .../pom.xml | 13 +- .../main/resource/petstore-new-breaking.yaml} | 2 +- .../pom.xml | 14 +- .../resources/petstore-new-non-breaking.yaml | 113 ++ .../{petstore2 => lint-petstore}/pom.xml | 11 +- .../src/main/resources/petstore.yaml | 0 .../src/main/resources/petstore.yaml | 0 .../src/it/example/boat-bay/pom.xml | 12 +- .../{petstore4 => validate-petstore}/pom.xml | 9 +- .../src/main/resources/petstore.yaml | 0 .../boat-bay-client.yml | 1044 +++++++++++++++++ .../java-clients/boat-bay-client/pom.xml | 105 ++ .../boat-generate/java-clients/pom.xml | 1 + .../com/backbase/oss/boat/BoatBayRadio.java | 109 ++ .../java/com/backbase/oss/boat/LintMojo.java | 41 +- .../com/backbase/oss/boat/ValidateMojo.java | 21 +- 16 files changed, 1438 insertions(+), 57 deletions(-) rename boat-maven-plugin/src/it/example/boat-bay/{petstore1 => lint-petstore-breaking}/pom.xml (85%) rename boat-maven-plugin/src/it/example/boat-bay/{petstore3/src/main/resource/petstore-breaking.yaml => lint-petstore-breaking/src/main/resource/petstore-new-breaking.yaml} (98%) rename boat-maven-plugin/src/it/example/boat-bay/{petstore3 => lint-petstore-non-breaking}/pom.xml (79%) create mode 100644 boat-maven-plugin/src/it/example/boat-bay/lint-petstore-non-breaking/src/main/resources/petstore-new-non-breaking.yaml rename boat-maven-plugin/src/it/example/boat-bay/{petstore2 => lint-petstore}/pom.xml (83%) rename boat-maven-plugin/src/it/example/boat-bay/{petstore1 => lint-petstore}/src/main/resources/petstore.yaml (100%) delete mode 100644 boat-maven-plugin/src/it/example/boat-bay/petstore2/src/main/resources/petstore.yaml rename boat-maven-plugin/src/it/example/boat-bay/{petstore4 => validate-petstore}/pom.xml (85%) rename boat-maven-plugin/src/it/example/boat-bay/{petstore4 => validate-petstore}/src/main/resources/petstore.yaml (100%) create mode 100644 boat-maven-plugin/src/it/example/boat-generate/java-clients/boat-bay-client/boat-bay-api-client-temp/boat-bay-client.yml create mode 100644 boat-maven-plugin/src/it/example/boat-generate/java-clients/boat-bay-client/pom.xml create mode 100644 boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java diff --git a/boat-maven-plugin/src/it/example/boat-bay/petstore1/pom.xml b/boat-maven-plugin/src/it/example/boat-bay/lint-petstore-breaking/pom.xml similarity index 85% rename from boat-maven-plugin/src/it/example/boat-bay/petstore1/pom.xml rename to boat-maven-plugin/src/it/example/boat-bay/lint-petstore-breaking/pom.xml index 54984f9df..e487a29ea 100644 --- a/boat-maven-plugin/src/it/example/boat-bay/petstore1/pom.xml +++ b/boat-maven-plugin/src/it/example/boat-bay/lint-petstore-breaking/pom.xml @@ -4,19 +4,18 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.backbase.oss.boat.example - example + boat-bay 1.0.0-SNAPSHOT - petstore1 + lint-petstore-breaking - BOAT :: Lint Upload :: Spec + BOAT :: Boat Bay :: Lint Spec Breaking - Example projects showing how BOAT can help you generate code + pom @@ -34,7 +33,7 @@ lint - ${project.basedir}/src/main/resources/petstore.yaml + ${project.basedir}/src/main/resources/petstore-new-breaking.yaml ${project.basedir}/src/main/resources/output 5 @@ -45,4 +44,6 @@ + + diff --git a/boat-maven-plugin/src/it/example/boat-bay/petstore3/src/main/resource/petstore-breaking.yaml b/boat-maven-plugin/src/it/example/boat-bay/lint-petstore-breaking/src/main/resource/petstore-new-breaking.yaml similarity index 98% rename from boat-maven-plugin/src/it/example/boat-bay/petstore3/src/main/resource/petstore-breaking.yaml rename to boat-maven-plugin/src/it/example/boat-bay/lint-petstore-breaking/src/main/resource/petstore-new-breaking.yaml index 322020309..2e252e008 100644 --- a/boat-maven-plugin/src/it/example/boat-bay/petstore3/src/main/resource/petstore-breaking.yaml +++ b/boat-maven-plugin/src/it/example/boat-bay/lint-petstore-breaking/src/main/resource/petstore-new-breaking.yaml @@ -28,7 +28,7 @@ paths: x-next: description: A link to the next page of responses schema: - type: + type: string content: application/json: schema: diff --git a/boat-maven-plugin/src/it/example/boat-bay/petstore3/pom.xml b/boat-maven-plugin/src/it/example/boat-bay/lint-petstore-non-breaking/pom.xml similarity index 79% rename from boat-maven-plugin/src/it/example/boat-bay/petstore3/pom.xml rename to boat-maven-plugin/src/it/example/boat-bay/lint-petstore-non-breaking/pom.xml index 491f4c909..520aaa2c9 100644 --- a/boat-maven-plugin/src/it/example/boat-bay/petstore3/pom.xml +++ b/boat-maven-plugin/src/it/example/boat-bay/lint-petstore-non-breaking/pom.xml @@ -6,20 +6,20 @@ com.backbase.oss.boat.example - example + boat-bay 1.0.0-SNAPSHOT - petstore3 + lint-petstore-non-breaking - BOAT :: Lint Upload :: Spec Breaking + BOAT :: Boat Bay :: Lint Non Breaking Spec - Example projects showing how BOAT can help you generate code + Example project showing the linting of a specification via boat-bay + Using a spec with non breaking changes in petstore pom - @@ -33,7 +33,7 @@ lint - ${project.basedir}/src/main/resources/petstore-breaking.yaml + ${project.basedir}/src/main/resources/petstore-new-non-breaking.yaml ${project.basedir}/src/main/resources/output 5 @@ -44,6 +44,4 @@ - - diff --git a/boat-maven-plugin/src/it/example/boat-bay/lint-petstore-non-breaking/src/main/resources/petstore-new-non-breaking.yaml b/boat-maven-plugin/src/it/example/boat-bay/lint-petstore-non-breaking/src/main/resources/petstore-new-non-breaking.yaml new file mode 100644 index 000000000..9f7ec3683 --- /dev/null +++ b/boat-maven-plugin/src/it/example/boat-bay/lint-petstore-non-breaking/src/main/resources/petstore-new-non-breaking.yaml @@ -0,0 +1,113 @@ +openapi: "3.0.0" +info: + version: 1.1.0 + title: Swagger Petstore + license: + name: MIT +servers: + - url: http://petstore.swagger.io/v1 +paths: + /pets: + get: + summary: List all pets + operationId: listPets + tags: + - pets + parameters: + - name: limit + in: query + description: How many items to return at one time (max 100) + required: false + schema: + type: integer + format: int32 + responses: + '200': + description: A paged array of pets + headers: + x-next: + description: A link to the next page of responses + schema: + type: string + content: + application/json: + schema: + $ref: "#/components/schemas/Pets" + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + summary: Create a pet + operationId: createPets + tags: + - pets + responses: + '201': + description: Null response + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /pets/{petId}: + get: + summary: Info for a specific pet + operationId: showPetById + tags: + - pets + parameters: + - name: petId + in: path + required: true + description: The id of the pet to retrieve + schema: + type: string + responses: + '200': + description: Expected response to a valid request + content: + application/json: + schema: + $ref: "#/components/schemas/Pet" + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" +components: + schemas: + Pet: + type: object + required: + - id + - name + properties: + id: + type: integer + format: int64 + name: + type: string + tag: + type: string + new-property: + type: string + Pets: + type: array + items: + $ref: "#/components/schemas/Pet" + Error: + type: object + required: + - code + - message + properties: + code: + type: integer + format: int32 + message: + type: string \ No newline at end of file diff --git a/boat-maven-plugin/src/it/example/boat-bay/petstore2/pom.xml b/boat-maven-plugin/src/it/example/boat-bay/lint-petstore/pom.xml similarity index 83% rename from boat-maven-plugin/src/it/example/boat-bay/petstore2/pom.xml rename to boat-maven-plugin/src/it/example/boat-bay/lint-petstore/pom.xml index f1cbe6101..b4042f5f3 100644 --- a/boat-maven-plugin/src/it/example/boat-bay/petstore2/pom.xml +++ b/boat-maven-plugin/src/it/example/boat-bay/lint-petstore/pom.xml @@ -4,21 +4,23 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + com.backbase.oss.boat.example - example + boat-bay 1.0.0-SNAPSHOT - petstore2 + lint-petstore - BOAT :: Lint Upload :: Empty Spec + BOAT :: Boat Bay :: Lint Spec - Example projects showing how BOAT can help you generate code + Example project showing the linting of a specification via boat-bay pom + @@ -32,6 +34,7 @@ lint + url ${project.basedir}/src/main/resources/petstore.yaml ${project.basedir}/src/main/resources/output 5 diff --git a/boat-maven-plugin/src/it/example/boat-bay/petstore1/src/main/resources/petstore.yaml b/boat-maven-plugin/src/it/example/boat-bay/lint-petstore/src/main/resources/petstore.yaml similarity index 100% rename from boat-maven-plugin/src/it/example/boat-bay/petstore1/src/main/resources/petstore.yaml rename to boat-maven-plugin/src/it/example/boat-bay/lint-petstore/src/main/resources/petstore.yaml diff --git a/boat-maven-plugin/src/it/example/boat-bay/petstore2/src/main/resources/petstore.yaml b/boat-maven-plugin/src/it/example/boat-bay/petstore2/src/main/resources/petstore.yaml deleted file mode 100644 index e69de29bb..000000000 diff --git a/boat-maven-plugin/src/it/example/boat-bay/pom.xml b/boat-maven-plugin/src/it/example/boat-bay/pom.xml index 53f5403da..e4ea746a7 100644 --- a/boat-maven-plugin/src/it/example/boat-bay/pom.xml +++ b/boat-maven-plugin/src/it/example/boat-bay/pom.xml @@ -12,19 +12,19 @@ boat-bay - BOAT :: Lint Upload + BOAT :: Boat Bay - Example projects showing how BOAT can help you generate code + Example projects showing how BOAT uses Boat bay to help you lint and validate specs pom - petstore1 - petstore2 - petstore3 - petstore4 + lint-petstore + lint-petstore-non-breaking + lint-petstore-breaking + validate-petstore diff --git a/boat-maven-plugin/src/it/example/boat-bay/petstore4/pom.xml b/boat-maven-plugin/src/it/example/boat-bay/validate-petstore/pom.xml similarity index 85% rename from boat-maven-plugin/src/it/example/boat-bay/petstore4/pom.xml rename to boat-maven-plugin/src/it/example/boat-bay/validate-petstore/pom.xml index e4cac3496..4d6a4c185 100644 --- a/boat-maven-plugin/src/it/example/boat-bay/petstore4/pom.xml +++ b/boat-maven-plugin/src/it/example/boat-bay/validate-petstore/pom.xml @@ -7,18 +7,17 @@ com.backbase.oss.boat.example - example + boat-bay 1.0.0-SNAPSHOT - petstore4 + validate-petstore - BOAT :: Lint Upload :: Spec Validate + BOAT :: Boat Bay :: Spec Validate - Example projects showing how BOAT can help you generate code + Example project showing the validation of a specification via boat-bay - pom diff --git a/boat-maven-plugin/src/it/example/boat-bay/petstore4/src/main/resources/petstore.yaml b/boat-maven-plugin/src/it/example/boat-bay/validate-petstore/src/main/resources/petstore.yaml similarity index 100% rename from boat-maven-plugin/src/it/example/boat-bay/petstore4/src/main/resources/petstore.yaml rename to boat-maven-plugin/src/it/example/boat-bay/validate-petstore/src/main/resources/petstore.yaml diff --git a/boat-maven-plugin/src/it/example/boat-generate/java-clients/boat-bay-client/boat-bay-api-client-temp/boat-bay-client.yml b/boat-maven-plugin/src/it/example/boat-generate/java-clients/boat-bay-client/boat-bay-api-client-temp/boat-bay-client.yml new file mode 100644 index 000000000..a7af012c8 --- /dev/null +++ b/boat-maven-plugin/src/it/example/boat-generate/java-clients/boat-bay-client/boat-bay-api-client-temp/boat-bay-client.yml @@ -0,0 +1,1044 @@ +openapi: 3.0.0 +info: + title: Boat Bay Client + description: Endpoints for the boat bay operations + license: + name: Backbase + version: 1.0.0 +servers: +- url: http://boat-bay-server.proto.backbasecloud.com/ +tags: +- name: dashboard +- name: upload-plugin +paths: + /api/boat/portals: + get: + tags: + - dashboard + summary: get list of portals + operationId: getPortals + responses: + "200": + description: boat legacy portal + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/BoatPortal' + /api/boat/portals/{portalKey}/products: + get: + tags: + - dashboard + summary: get products for identified portal + operationId: getPortalProducts + parameters: + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + responses: + "200": + description: list of protals products + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/BoatProduct' + /api/boat/portals/{portalKey}/products/{productKey}/capabilities: + get: + tags: + - dashboard + summary: get Portal Products Capabalities + operationId: getPortalCapabilities + parameters: + - name: pageable + in: query + required: false + style: form + explode: true + schema: + $ref: '#/components/schemas/Pageable' + - name: productKey + in: path + description: product idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + responses: + "200": + description: list of capabilities for product + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/BoatCapability' + /api/boat/portals/{portalKey}/products/{productKey}/services: + get: + tags: + - dashboard + summary: get Portal services for a given product + operationId: getPortalServices + parameters: + - name: pageable + in: query + required: false + style: form + explode: true + schema: + $ref: '#/components/schemas/Pageable' + - name: productKey + in: path + description: product idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + responses: + "200": + description: list of services for product + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/BoatService' + /api/boat/portals/{portalKey}/products/{productKey}/specs: + get: + tags: + - dashboard + summary: get Portal Specs for given product + operationId: getPortalSpecs + parameters: + - name: pageable + in: query + required: false + style: form + explode: true + schema: + $ref: '#/components/schemas/Pageable' + - name: productKey + in: path + description: product idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: capabilityId + in: query + description: capablility idenifier + required: false + style: form + explode: true + schema: + type: string + - name: productReleaseId + in: query + description: product release idenifier + required: false + style: form + explode: true + schema: + type: string + - name: serviceId + in: query + description: service idenifier + required: false + style: form + explode: true + schema: + type: string + - name: grade + in: query + description: grade of spec + required: false + style: form + explode: true + schema: + type: string + - name: backwardsCompatible + in: query + description: backwards compatible indicator + required: false + style: form + explode: true + schema: + type: boolean + - name: changed + in: query + description: changed indicator + required: false + style: form + explode: true + schema: + type: boolean + responses: + "200": + description: list of specs for product + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/BoatSpec' + /api/boat/portals/{portalKey}/products/{productKey}/specs/{specId}/lint-report: + get: + tags: + - dashboard + summary: get Lint Report for spec + operationId: getLintReportForSpec + parameters: + - name: specId + in: path + description: spec idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: productKey + in: path + description: product idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: refresh + in: query + description: refresh idicator + required: false + style: form + explode: true + schema: + type: boolean + responses: + "200": + description: lint report for spec + content: + application/json: + schema: + $ref: '#/components/schemas/BoatLintReport' + /api/boat/portals/{portalKey}/lint-rules: + get: + tags: + - dashboard + summary: get list of lint rules + operationId: getPortalLintRules + parameters: + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + responses: + "200": + description: list of lint rules for portal + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/BoatLintRule' + /api/boat/portals/{portalKey}/products/{productKey}/releases: + get: + tags: + - dashboard + summary: get product releases + operationId: getProductReleases + parameters: + - name: productKey + in: path + description: id of product + required: true + style: simple + explode: false + schema: + type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + responses: + "200": + description: list of product releases for product + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/BoatProductRelease' + /api/boat/portals/{portalKey}/products/{productKey}/releases/{releaseKey}/specs: + get: + tags: + - dashboard + summary: get specs for product release + operationId: getProductReleaseSpecs + parameters: + - name: releaseKey + in: path + description: key for product release + required: true + style: simple + explode: false + schema: + type: string + - name: productKey + in: path + description: id of product + required: true + style: simple + explode: false + schema: + type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + responses: + "200": + description: list of specs for product release + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/BoatSpec' + /api/boat/portals/{portalKey}/lint-rules/{lintRuleId}: + post: + tags: + - dashboard + summary: update lint rule for portal + operationId: updatePortalLintRule + parameters: + - name: lintRuleId + in: path + description: id of portals lint rule + required: true + style: simple + explode: false + schema: + type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/BoatLintRule' + responses: + "200": + description: updated successfuly + content: {} + /api/boat/dashboard: + get: + tags: + - dashboard + summary: get list of boat portal dashboards + operationId: getDashboard + responses: + "200": + description: list of boat portal dashboards + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/BoatPortalDashboard' + /api/boat/dashboard/{projectKey}/{productKey}: + get: + tags: + - dashboard + summary: get product for dashboard project + operationId: getProductDashboard + parameters: + - name: projectKey + in: path + description: project idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: productKey + in: path + description: product idenifier + required: true + style: simple + explode: false + schema: + type: string + responses: + "200": + description: product for dashboard + content: + application/json: + schema: + $ref: '#/components/schemas/BoatProduct' + /api/boat/portals/{portalKey}/products/{productKey}/tags: + get: + tags: + - dashboard + summary: get tags for product + operationId: getProductTags + parameters: + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: productKey + in: path + description: product idenifier + required: true + style: simple + explode: false + schema: + type: string + responses: + "200": + description: list of product tags + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/BoatTag' + ? /api/boat/portals/{portalKey}/products/{productKey}/capabilities/{capabilityKey}/services/{serviceKey}/specs/{specKey}/{version}/download + : get: + tags: + - dashboard + summary: get spec as openapi + operationId: getSpecAsOpenAPI + parameters: + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: productKey + in: path + description: product identifier + required: true + style: simple + explode: false + schema: + type: string + - name: capabilityKey + in: path + description: capability identifier + required: true + style: simple + explode: false + schema: + type: string + - name: serviceKey + in: path + description: service identifier + required: true + style: simple + explode: false + schema: + type: string + - name: specKey + in: path + description: spec identifier + required: true + style: simple + explode: false + schema: + type: string + - name: version + in: path + description: version of spec + required: true + style: simple + explode: false + schema: + type: string + responses: + "200": + description: openApi of spec + headers: + Content-Disposition: + description: name of file + style: simple + explode: false + schema: + type: string + Cache-Control: + style: simple + explode: false + schema: + type: string + Pragma: + style: simple + explode: false + schema: + type: string + Expires: + style: simple + explode: false + schema: + type: string + content: + application/vnd.oai.openapi: + schema: + $ref: '#/components/schemas/Resource' + ? /api/boat/portals/{portalKey}/products/{productKey}/capabilities/{capabilityKey}/services/{serviceKey}/specs/{specKey}/{version} + : get: + tags: + - dashboard + summary: download spec + operationId: downloadSpec + parameters: + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: productKey + in: path + description: product identifier + required: true + style: simple + explode: false + schema: + type: string + - name: capabilityKey + in: path + description: capability identifier + required: true + style: simple + explode: false + schema: + type: string + - name: serviceKey + in: path + description: service identifier + required: true + style: simple + explode: false + schema: + type: string + - name: specKey + in: path + description: spec identifier + required: true + style: simple + explode: false + schema: + type: string + - name: version + in: path + description: version of spec + required: true + style: simple + explode: false + schema: + type: string + responses: + "200": + description: spec with open api + content: + application/json: + schema: + $ref: '#/components/schemas/BoatSpec' + /api/boat/portals/{portalKey}/products/{productKey}/diff-report: + get: + tags: + - lint + summary: get lint report for spec + operationId: getApiChangesForSpec + parameters: + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: productKey + in: path + description: product identifier + required: true + style: simple + explode: false + schema: + type: string + - name: spec1Id + in: query + description: identifies first comparitable api + required: false + style: form + explode: true + schema: + type: string + - name: spec2Id + in: query + description: identifies second comparitable api + required: false + style: form + explode: true + schema: + type: string + responses: + "200": + description: changed openApi + content: + application/json: + schema: + $ref: '#/components/schemas/ChangedOpenApiObject' + /api/boat/portals/{portalKey}/products/{productKey}/diff-report.html: + get: + tags: + - lint + summary: get lint report for spec as html + operationId: getLintReportForSpecAsHtml + parameters: + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: productKey + in: path + description: product identifier + required: true + style: simple + explode: false + schema: + type: string + - name: spec1Id + in: query + description: identifies first comparitable api + required: false + style: form + explode: true + schema: + type: string + - name: spec2Id + in: query + description: identifies second comparitable api + required: false + style: form + explode: true + schema: + type: string + responses: + "200": + description: changed openApi as html + content: + application/json: + schema: + type: string + /api/boat/boat-maven-plugin/{sourceId}/upload: + put: + tags: + - upload-plugin + summary: upload and lint specs + operationId: uploadSpec + parameters: + - name: sourceId + in: path + description: source idenifier + required: true + style: simple + explode: false + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/upload-request-body' + required: true + responses: + "200": + description: list of lint reports for specs + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/BoatLintReport' +components: + schemas: + BoatPortal: + type: object + properties: + id: + type: number + key: + type: string + name: + type: string + content: + type: string + createdOn: + $ref: '#/components/schemas/LocalDateTime' + createdBy: + type: string + BoatProduct: + type: object + properties: + portalKey: + type: string + portalName: + type: string + id: + type: number + key: + type: string + name: + type: string + content: + type: string + createdOn: + $ref: '#/components/schemas/LocalDateTime' + createdBy: + type: string + lastLintReport: + $ref: '#/components/schemas/BoatLintReport' + statistics: + $ref: '#/components/schemas/BoatStatistics' + jiraProjectId: + type: string + Pageable: + type: object + properties: + page: + type: integer + size: + type: integer + description: minimal Pageable query parameters + BoatCapability: + type: object + properties: + id: + type: number + key: + type: string + name: + type: string + content: + type: string + createdOn: + $ref: '#/components/schemas/LocalDateTime' + createdBy: + type: string + lastLintReport: + $ref: '#/components/schemas/BoatLintReport' + statistics: + $ref: '#/components/schemas/BoatStatistics' + BoatService: + type: object + properties: + key: + type: string + name: + type: string + description: + type: string + icon: + type: string + color: + type: string + createdOn: + $ref: '#/components/schemas/LocalDateTime' + createdBy: + type: string + statistics: + $ref: '#/components/schemas/BoatStatistics' + BoatSpec: + type: object + properties: + id: + type: number + key: + type: string + name: + type: string + title: + type: string + description: + type: string + icon: + type: string + version: + type: string + grade: + type: string + createdOn: + $ref: '#/components/schemas/LocalDateTime' + createdBy: + type: string + statistics: + $ref: '#/components/schemas/BoatStatistics' + backwardsCompatible: + type: boolean + changes: + $ref: '#/components/schemas/Changes' + capability: + $ref: '#/components/schemas/BoatCapability' + serviceDefinition: + $ref: '#/components/schemas/BoatService' + openApi: + type: string + BoatLintReport: + type: object + properties: + id: + type: number + spec: + $ref: '#/components/schemas/BoatSpec' + name: + type: string + passed: + type: boolean + lintedOn: + $ref: '#/components/schemas/LocalDateTime' + openApi: + type: string + version: + type: string + grade: + type: string + violations: + type: array + items: + $ref: '#/components/schemas/BoatViolation' + hasViolations: + type: boolean + BoatLintRule: + type: object + properties: + id: + type: number + ruleId: + type: string + enabled: + type: boolean + title: + type: string + ruleSet: + type: string + severity: + $ref: '#/components/schemas/Severity' + url: + type: string + format: uri + BoatProductRelease: + type: object + properties: + id: + type: number + key: + type: string + name: + type: string + version: + type: string + releaseDate: + $ref: '#/components/schemas/LocalDateTime' + BoatPortalDashboard: + type: object + properties: + portalId: + type: string + portalKey: + type: string + portalName: + type: string + productId: + type: string + productKey: + type: string + productName: + type: string + numberOfServices: + type: integer + format: int64 + numberOfCapabilities: + type: integer + format: int64 + productDescription: + type: string + lastLintReport: + $ref: '#/components/schemas/BoatLintReport' + statistics: + $ref: '#/components/schemas/BoatStatistics' + BoatTag: + type: object + properties: + name: + type: string + description: + type: string + hide: + type: boolean + color: + type: string + numberOfOccurrences: + type: integer + Resource: + type: array + items: + type: string + format: byte + ChangedOpenApiObject: + type: object + upload-request-body: + type: object + properties: + specs: + type: array + items: + $ref: '#/components/schemas/UploadSpec' + location: + type: string + projectId: + type: string + artifactId: + type: string + version: + type: string + LocalDateTime: + type: string + format: date-time + BoatStatistics: + type: object + properties: + updatedOn: + $ref: '#/components/schemas/LocalDateTime' + mustViolationsCount: + type: integer + format: int64 + shouldViolationsCount: + type: integer + format: int64 + mayViolationsCount: + type: integer + format: int64 + hintViolationsCount: + type: integer + format: int64 + Changes: + type: string + enum: + - NOT_APPLICABLE + - ERROR_COMPARING + - UNCHANGED + - COMPATIBLE + - BREAKING + BoatViolation: + type: object + properties: + rule: + $ref: '#/components/schemas/BoatLintRule' + description: + type: string + severity: + $ref: '#/components/schemas/Severity' + lines: + $ref: '#/components/schemas/IntRange' + pointer: + type: string + Severity: + type: string + enum: + - MUST + - SHOULD + - MAY + - HINT + UploadSpec: + type: object + properties: + fileName: + type: string + openApi: + type: string + key: + type: string + name: + type: string + IntRange: + type: object + properties: + start: + type: integer + endInclusive: + type: integer + examples: {} diff --git a/boat-maven-plugin/src/it/example/boat-generate/java-clients/boat-bay-client/pom.xml b/boat-maven-plugin/src/it/example/boat-generate/java-clients/boat-bay-client/pom.xml new file mode 100644 index 000000000..4a474f7df --- /dev/null +++ b/boat-maven-plugin/src/it/example/boat-generate/java-clients/boat-bay-client/pom.xml @@ -0,0 +1,105 @@ + + + 4.0.0 + + + com.backbase.oss.boat.bay + java-clients + 0.0.1-SNAPSHOT + + + boat-bay-client + + BOAT :: Generate :: Boat Bay Client + + jar + + + ApiClient.java,BeanValidationException.java,RFC3339DateFormat.java,ServerConfiguration.java,ServerVariable.java,StringUtil.java,Authentication.java,HttpBasicAuth.java,HttpBearerAuth.java,ApiKeyAuth.java,ApiException.java,Pair.java + 0.2.1 + + + + + io.swagger + swagger-annotations + + + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + + org.openapitools + jackson-databind-nullable + ${jackson-databind-nullable-version} + + + + com.google.code.findbugs + jsr305 + + + org.springframework.data + spring-data-commons + + + + + + + com.backbase.oss + boat-maven-plugin + + + generate-webclient-embedded + generate-sources + + generate + + + ${project.basedir}/boat-bay-api-client-temp/boat-bay-client.yml + java + native + + java8 + + com.backbase.oss.boat.bay.client.model + com.backbase.oss.boat.bay.client.api + false + false + false + false + true + + IntRange = kotlin.ranges.IntRange + + + LocalDateTime = java.time.LocalDateTime + Pageable = org.springframework.data.domain.Pageable + + ${boat-maven-plugin.supportingFilesToGenerate} + + + + + + + + + + diff --git a/boat-maven-plugin/src/it/example/boat-generate/java-clients/pom.xml b/boat-maven-plugin/src/it/example/boat-generate/java-clients/pom.xml index 79f7b2a49..86d52b218 100644 --- a/boat-maven-plugin/src/it/example/boat-generate/java-clients/pom.xml +++ b/boat-maven-plugin/src/it/example/boat-generate/java-clients/pom.xml @@ -21,6 +21,7 @@ pom + boat-bay-client java rest-template-embedded webclient-embedded diff --git a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java new file mode 100644 index 000000000..600e99ee0 --- /dev/null +++ b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java @@ -0,0 +1,109 @@ +package com.backbase.oss.boat; + +import com.backbase.oss.boat.bay.client.ApiClient; +import com.backbase.oss.boat.bay.client.ApiException; +import com.backbase.oss.boat.bay.client.api.UploadPluginApi; +import com.backbase.oss.boat.bay.client.model.BoatLintReport; +import com.backbase.oss.boat.bay.client.model.UploadRequestBody; +import com.backbase.oss.boat.bay.client.model.UploadSpec; +import com.backbase.oss.boat.loader.OpenAPILoader; +import io.swagger.v3.oas.models.OpenAPI; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.io.IOUtils; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProject; + +import java.io.File; +import java.nio.charset.Charset; +import java.time.Duration; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +@Slf4j +public class BoatBayRadio { + + @Parameter(name = "readTimeout", defaultValue = "null") + public Duration readTimeout; + + private UploadPluginApi boatbayUploadSpecClient; + private File inputSpec; + private File output; + protected MavenProject project; + + public BoatBayRadio(File inputSpec, File output, MavenProject project) { + this.project = project; + this.output = output; + this.inputSpec = inputSpec; + this.boatbayUploadSpecClient = new UploadPluginApi(new ApiClient().setReadTimeout(readTimeout));; + } + + + public List upload(String sourceId ) throws ApiException { + + if (sourceId.isEmpty()){ + throw new RuntimeException("Source must be set up first"); + } + try { + return boatbayUploadSpecClient.uploadSpec(sourceId, createRequestBody()); + } catch (Exception e) { + throw new ApiException(e.getMessage()); + } + + } + + private UploadRequestBody createRequestBody(){ + UploadRequestBody requestBody = new UploadRequestBody(); + try { + requestBody.setSpecs(getSpecs()); + }catch (Exception e){ + throw new RuntimeException("unable to load specs", e); + } + + requestBody.location(project.getBasedir().toPath().resolve(inputSpec.toPath()).toString()); + if (output != null){ + requestBody.location(output.getParentFile().getPath()); + } + + requestBody.projectId(project.getGroupId()); + requestBody.setArtifactId(project.getArtifactId()); + requestBody.version(project.getVersion()); + + return requestBody; + } + + private List getSpecs() throws MojoExecutionException { + File[] inputFiles; + if (inputSpec.isDirectory()) { + inputFiles = inputSpec.listFiles(pathname -> pathname.getName().endsWith(".yaml")); + if (inputFiles == null || inputFiles.length == 0) { + throw new MojoExecutionException("No OpenAPI specs found in: " + inputSpec); + } + log.info("Found " + inputFiles.length + " specs to lint."); + } else { + inputFiles = new File[]{inputSpec}; + } + + List specs = Arrays.stream(inputFiles).map(this::mapToUploadSpec).collect(Collectors.toList()); + return specs; + } + + private UploadSpec mapToUploadSpec(File spec) { + OpenAPI openAPI; + try { + String contents = IOUtils.toString(spec.toURI(), Charset.defaultCharset()); + openAPI= OpenAPILoader.parse(contents); + }catch (Exception e){ + throw new RuntimeException("unable to read api files: "+e.getMessage()); + } + + UploadSpec uploadSpec = new UploadSpec(); + uploadSpec.fileName(spec.getName()); + uploadSpec.openApi(openAPI.getOpenapi()); + uploadSpec.key(spec.getName().substring(0, spec.getName().lastIndexOf('-'))); + uploadSpec.name(spec.getName()); + return uploadSpec; + } + +} diff --git a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/LintMojo.java b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/LintMojo.java index 660834915..b9d4060ee 100644 --- a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/LintMojo.java +++ b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/LintMojo.java @@ -1,18 +1,14 @@ package com.backbase.oss.boat; import com.backbase.oss.boat.bay.client.ApiException; -import com.backbase.oss.boat.bay.client.api.UploadPluginApi; -import com.backbase.oss.boat.loader.OpenAPILoader; -import com.backbase.oss.boat.loader.OpenAPILoaderException; import com.backbase.oss.boat.quay.model.BoatLintReport; import com.backbase.oss.codegen.lint.BoatLintConfig; import com.backbase.oss.codegen.lint.BoatLintGenerator; import java.io.File; -import java.io.IOException; import java.net.URL; import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -20,6 +16,7 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.project.MavenProject; +import sun.tools.java.Environment; @SuppressWarnings("FieldMayBeFinal") @Mojo(name = "lint", requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true) @@ -44,27 +41,32 @@ public class LintMojo extends AbstractLintMojo { @Parameter(readonly = true, required = true, defaultValue = "${project}") protected MavenProject project; - @Parameter(name = "sourceId") + @Parameter(name = "boatBayUrl", defaultValue = "hjhb", property = "boat.maven.plugin.lint.boatBayUrl") + private String boatBayUrl; + + @Parameter(name = "sourceId", defaultValue = "") private String sourceId; - private UploadLint boatBaySpecUpload; + private BoatBayRadio boatBayRadio; @Override public void execute() throws MojoExecutionException, MojoFailureException { - boolean boatbay = false; - List boatLintReports = null; try { - -// if(boatbay){ -// new UploadLint(inputSpec,output,project).upload(sourceId); -// } - boatLintReports = lint(); - } catch (MojoExecutionException e) { + if (!sourceId.isEmpty() + || !System.getenv("boatBayUrl").isEmpty() + || System.getenv("boatBayUrl") != null + || !boatBayUrl.isEmpty()) { + new BoatBayRadio(inputSpec,output,project).upload(sourceId); + // System.getenv().containsKey("boatBayUrl"); + }else { + boatLintReports = lint(); + } + } catch (MojoExecutionException | ApiException e) { if (failOnWarning) { - throw e; + throw new MojoExecutionException(e.getMessage()); } } if (boatLintReports == null) { @@ -116,8 +118,9 @@ private File getOutput() { } + public void setSourceId(String sourceId){ this.sourceId = sourceId; } - public void setWriteLintReport(boolean writeLintReport) { - this.writeLintReport = writeLintReport; - } + public void setBoatBayUrl(String boatBayUrl){this.boatBayUrl = boatBayUrl;} + + public void setWriteLintReport(boolean writeLintReport) { this.writeLintReport = writeLintReport; } } diff --git a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/ValidateMojo.java b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/ValidateMojo.java index b49076bea..85f74edef 100644 --- a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/ValidateMojo.java +++ b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/ValidateMojo.java @@ -1,7 +1,5 @@ package com.backbase.oss.boat; -import com.backbase.oss.boat.bay.client.ApiClient; -import com.backbase.oss.boat.bay.client.api.UploadPluginApi; import com.backbase.oss.boat.serializer.SerializerUtils; import io.swagger.parser.OpenAPIParser; import io.swagger.v3.parser.core.models.ParseOptions; @@ -18,7 +16,6 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.project.MavenProject; -import org.springframework.beans.factory.annotation.Autowired; /** * Validates OpenAPI specs. @@ -35,15 +32,20 @@ public class ValidateMojo extends AbstractMojo { @Parameter(readonly = true, required = true, defaultValue = "${project}") protected MavenProject project; -/// cant get it to be sent in source pom flile ??? - @Parameter(name = "sourceId", defaultValue = "", property = "inputSpec") +/// cant get it to be sent in source pom file ??? + @Parameter(name = "sourceId", defaultValue = "", property = "boat.maven.plugin.sourceId") private String sourceId; - private UploadLint boatbayUploadSpecClient; + @Parameter(name = "boatBayUrl", defaultValue = "", property = "boat.maven.plugin.lint.boatBayUrl") + private String boatBayUrl; + + private BoatBayRadio boatbayUploadSpecClient; public void setInput(File input) { this.input = input; } + public void setSourceId(String sourceId){this.sourceId = sourceId;} + public void setBoatBayUrl(String boatBayUrl){this.boatBayUrl = boatBayUrl;} public void setFailOnWarning(boolean failOnWarning) { this.failOnWarning= failOnWarning; } @@ -66,8 +68,11 @@ public void execute() throws MojoFailureException { } } else { validate(input); - if (false){ - new UploadLint(input,null,project).upload(sourceId); + if (!sourceId.isEmpty() + || !System.getenv("boatBayUrl").isEmpty() + || System.getenv("boatBayUrl") != null + || !boatBayUrl.isEmpty()){ + new BoatBayRadio(input,null,project).upload(sourceId); } } } From 712bd35a62edf57435fe0cdf2209fbfaef521ff6 Mon Sep 17 00:00:00 2001 From: Sophie Janssens Date: Wed, 27 Jan 2021 14:24:06 +0000 Subject: [PATCH 05/12] generates boat bay client api in baot maven plugin project --- boat-maven-plugin/pom.xml | 87 +- .../boat-bay-client.yaml | 1044 +++++++++++++++++ 2 files changed, 1128 insertions(+), 3 deletions(-) create mode 100644 boat-maven-plugin/src/main/resources/boat-bay-api-client-temp/boat-bay-client.yaml diff --git a/boat-maven-plugin/pom.xml b/boat-maven-plugin/pom.xml index bccf724f6..fd4c83532 100644 --- a/boat-maven-plugin/pom.xml +++ b/boat-maven-plugin/pom.xml @@ -15,6 +15,11 @@ Open API Converter + + ApiClient.java,BeanValidationException.java,RFC3339DateFormat.java,ServerConfiguration.java,ServerVariable.java,StringUtil.java,Authentication.java,HttpBasicAuth.java,HttpBearerAuth.java,ApiKeyAuth.java,ApiException.java,Pair.java + 0.2.1 + 1.6.2 + 3.6.0 src/main/java/com/backbase/oss/boat/GenerateMojo.java, @@ -127,12 +132,47 @@ test + - com.backbase.oss.boat.bay - boat-bay-client - 0.0.1-SNAPSHOT + io.swagger + swagger-annotations + ${swagger-annotations.version} + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + + org.openapitools + jackson-databind-nullable + ${jackson-databind-nullable-version} + + + + com.google.code.findbugs + jsr305 + + + org.springframework.data + spring-data-commons + 2.4.2 + + + @@ -148,6 +188,45 @@ maven-plugin-plugin + + com.backbase.oss + boat-maven-plugin + 0.13.0 + + + generate-webclient-embedded + generate-sources + + generate + + + ${project.basedir}/src/main/resources/boat-bay-api-client-temp/boat-bay-client.yaml + ${project.basedir}/target/generated-sources + java + native + + java8 + + com.backbase.oss.boat.bay.client.model + com.backbase.oss.boat.bay.client.api + false + false + false + false + true + + IntRange = kotlin.ranges.IntRange + + + LocalDateTime = java.time.LocalDateTime + Pageable = org.springframework.data.domain.Pageable + + ${boat-maven-plugin.supportingFilesToGenerate} + + + + + org.apache.maven.plugins maven-compiler-plugin @@ -221,6 +300,8 @@ + + org.apache.maven.plugins maven-invoker-plugin diff --git a/boat-maven-plugin/src/main/resources/boat-bay-api-client-temp/boat-bay-client.yaml b/boat-maven-plugin/src/main/resources/boat-bay-api-client-temp/boat-bay-client.yaml new file mode 100644 index 000000000..a7af012c8 --- /dev/null +++ b/boat-maven-plugin/src/main/resources/boat-bay-api-client-temp/boat-bay-client.yaml @@ -0,0 +1,1044 @@ +openapi: 3.0.0 +info: + title: Boat Bay Client + description: Endpoints for the boat bay operations + license: + name: Backbase + version: 1.0.0 +servers: +- url: http://boat-bay-server.proto.backbasecloud.com/ +tags: +- name: dashboard +- name: upload-plugin +paths: + /api/boat/portals: + get: + tags: + - dashboard + summary: get list of portals + operationId: getPortals + responses: + "200": + description: boat legacy portal + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/BoatPortal' + /api/boat/portals/{portalKey}/products: + get: + tags: + - dashboard + summary: get products for identified portal + operationId: getPortalProducts + parameters: + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + responses: + "200": + description: list of protals products + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/BoatProduct' + /api/boat/portals/{portalKey}/products/{productKey}/capabilities: + get: + tags: + - dashboard + summary: get Portal Products Capabalities + operationId: getPortalCapabilities + parameters: + - name: pageable + in: query + required: false + style: form + explode: true + schema: + $ref: '#/components/schemas/Pageable' + - name: productKey + in: path + description: product idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + responses: + "200": + description: list of capabilities for product + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/BoatCapability' + /api/boat/portals/{portalKey}/products/{productKey}/services: + get: + tags: + - dashboard + summary: get Portal services for a given product + operationId: getPortalServices + parameters: + - name: pageable + in: query + required: false + style: form + explode: true + schema: + $ref: '#/components/schemas/Pageable' + - name: productKey + in: path + description: product idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + responses: + "200": + description: list of services for product + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/BoatService' + /api/boat/portals/{portalKey}/products/{productKey}/specs: + get: + tags: + - dashboard + summary: get Portal Specs for given product + operationId: getPortalSpecs + parameters: + - name: pageable + in: query + required: false + style: form + explode: true + schema: + $ref: '#/components/schemas/Pageable' + - name: productKey + in: path + description: product idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: capabilityId + in: query + description: capablility idenifier + required: false + style: form + explode: true + schema: + type: string + - name: productReleaseId + in: query + description: product release idenifier + required: false + style: form + explode: true + schema: + type: string + - name: serviceId + in: query + description: service idenifier + required: false + style: form + explode: true + schema: + type: string + - name: grade + in: query + description: grade of spec + required: false + style: form + explode: true + schema: + type: string + - name: backwardsCompatible + in: query + description: backwards compatible indicator + required: false + style: form + explode: true + schema: + type: boolean + - name: changed + in: query + description: changed indicator + required: false + style: form + explode: true + schema: + type: boolean + responses: + "200": + description: list of specs for product + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/BoatSpec' + /api/boat/portals/{portalKey}/products/{productKey}/specs/{specId}/lint-report: + get: + tags: + - dashboard + summary: get Lint Report for spec + operationId: getLintReportForSpec + parameters: + - name: specId + in: path + description: spec idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: productKey + in: path + description: product idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: refresh + in: query + description: refresh idicator + required: false + style: form + explode: true + schema: + type: boolean + responses: + "200": + description: lint report for spec + content: + application/json: + schema: + $ref: '#/components/schemas/BoatLintReport' + /api/boat/portals/{portalKey}/lint-rules: + get: + tags: + - dashboard + summary: get list of lint rules + operationId: getPortalLintRules + parameters: + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + responses: + "200": + description: list of lint rules for portal + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/BoatLintRule' + /api/boat/portals/{portalKey}/products/{productKey}/releases: + get: + tags: + - dashboard + summary: get product releases + operationId: getProductReleases + parameters: + - name: productKey + in: path + description: id of product + required: true + style: simple + explode: false + schema: + type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + responses: + "200": + description: list of product releases for product + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/BoatProductRelease' + /api/boat/portals/{portalKey}/products/{productKey}/releases/{releaseKey}/specs: + get: + tags: + - dashboard + summary: get specs for product release + operationId: getProductReleaseSpecs + parameters: + - name: releaseKey + in: path + description: key for product release + required: true + style: simple + explode: false + schema: + type: string + - name: productKey + in: path + description: id of product + required: true + style: simple + explode: false + schema: + type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + responses: + "200": + description: list of specs for product release + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/BoatSpec' + /api/boat/portals/{portalKey}/lint-rules/{lintRuleId}: + post: + tags: + - dashboard + summary: update lint rule for portal + operationId: updatePortalLintRule + parameters: + - name: lintRuleId + in: path + description: id of portals lint rule + required: true + style: simple + explode: false + schema: + type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/BoatLintRule' + responses: + "200": + description: updated successfuly + content: {} + /api/boat/dashboard: + get: + tags: + - dashboard + summary: get list of boat portal dashboards + operationId: getDashboard + responses: + "200": + description: list of boat portal dashboards + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/BoatPortalDashboard' + /api/boat/dashboard/{projectKey}/{productKey}: + get: + tags: + - dashboard + summary: get product for dashboard project + operationId: getProductDashboard + parameters: + - name: projectKey + in: path + description: project idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: productKey + in: path + description: product idenifier + required: true + style: simple + explode: false + schema: + type: string + responses: + "200": + description: product for dashboard + content: + application/json: + schema: + $ref: '#/components/schemas/BoatProduct' + /api/boat/portals/{portalKey}/products/{productKey}/tags: + get: + tags: + - dashboard + summary: get tags for product + operationId: getProductTags + parameters: + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: productKey + in: path + description: product idenifier + required: true + style: simple + explode: false + schema: + type: string + responses: + "200": + description: list of product tags + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/BoatTag' + ? /api/boat/portals/{portalKey}/products/{productKey}/capabilities/{capabilityKey}/services/{serviceKey}/specs/{specKey}/{version}/download + : get: + tags: + - dashboard + summary: get spec as openapi + operationId: getSpecAsOpenAPI + parameters: + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: productKey + in: path + description: product identifier + required: true + style: simple + explode: false + schema: + type: string + - name: capabilityKey + in: path + description: capability identifier + required: true + style: simple + explode: false + schema: + type: string + - name: serviceKey + in: path + description: service identifier + required: true + style: simple + explode: false + schema: + type: string + - name: specKey + in: path + description: spec identifier + required: true + style: simple + explode: false + schema: + type: string + - name: version + in: path + description: version of spec + required: true + style: simple + explode: false + schema: + type: string + responses: + "200": + description: openApi of spec + headers: + Content-Disposition: + description: name of file + style: simple + explode: false + schema: + type: string + Cache-Control: + style: simple + explode: false + schema: + type: string + Pragma: + style: simple + explode: false + schema: + type: string + Expires: + style: simple + explode: false + schema: + type: string + content: + application/vnd.oai.openapi: + schema: + $ref: '#/components/schemas/Resource' + ? /api/boat/portals/{portalKey}/products/{productKey}/capabilities/{capabilityKey}/services/{serviceKey}/specs/{specKey}/{version} + : get: + tags: + - dashboard + summary: download spec + operationId: downloadSpec + parameters: + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: productKey + in: path + description: product identifier + required: true + style: simple + explode: false + schema: + type: string + - name: capabilityKey + in: path + description: capability identifier + required: true + style: simple + explode: false + schema: + type: string + - name: serviceKey + in: path + description: service identifier + required: true + style: simple + explode: false + schema: + type: string + - name: specKey + in: path + description: spec identifier + required: true + style: simple + explode: false + schema: + type: string + - name: version + in: path + description: version of spec + required: true + style: simple + explode: false + schema: + type: string + responses: + "200": + description: spec with open api + content: + application/json: + schema: + $ref: '#/components/schemas/BoatSpec' + /api/boat/portals/{portalKey}/products/{productKey}/diff-report: + get: + tags: + - lint + summary: get lint report for spec + operationId: getApiChangesForSpec + parameters: + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: productKey + in: path + description: product identifier + required: true + style: simple + explode: false + schema: + type: string + - name: spec1Id + in: query + description: identifies first comparitable api + required: false + style: form + explode: true + schema: + type: string + - name: spec2Id + in: query + description: identifies second comparitable api + required: false + style: form + explode: true + schema: + type: string + responses: + "200": + description: changed openApi + content: + application/json: + schema: + $ref: '#/components/schemas/ChangedOpenApiObject' + /api/boat/portals/{portalKey}/products/{productKey}/diff-report.html: + get: + tags: + - lint + summary: get lint report for spec as html + operationId: getLintReportForSpecAsHtml + parameters: + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: productKey + in: path + description: product identifier + required: true + style: simple + explode: false + schema: + type: string + - name: spec1Id + in: query + description: identifies first comparitable api + required: false + style: form + explode: true + schema: + type: string + - name: spec2Id + in: query + description: identifies second comparitable api + required: false + style: form + explode: true + schema: + type: string + responses: + "200": + description: changed openApi as html + content: + application/json: + schema: + type: string + /api/boat/boat-maven-plugin/{sourceId}/upload: + put: + tags: + - upload-plugin + summary: upload and lint specs + operationId: uploadSpec + parameters: + - name: sourceId + in: path + description: source idenifier + required: true + style: simple + explode: false + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/upload-request-body' + required: true + responses: + "200": + description: list of lint reports for specs + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/BoatLintReport' +components: + schemas: + BoatPortal: + type: object + properties: + id: + type: number + key: + type: string + name: + type: string + content: + type: string + createdOn: + $ref: '#/components/schemas/LocalDateTime' + createdBy: + type: string + BoatProduct: + type: object + properties: + portalKey: + type: string + portalName: + type: string + id: + type: number + key: + type: string + name: + type: string + content: + type: string + createdOn: + $ref: '#/components/schemas/LocalDateTime' + createdBy: + type: string + lastLintReport: + $ref: '#/components/schemas/BoatLintReport' + statistics: + $ref: '#/components/schemas/BoatStatistics' + jiraProjectId: + type: string + Pageable: + type: object + properties: + page: + type: integer + size: + type: integer + description: minimal Pageable query parameters + BoatCapability: + type: object + properties: + id: + type: number + key: + type: string + name: + type: string + content: + type: string + createdOn: + $ref: '#/components/schemas/LocalDateTime' + createdBy: + type: string + lastLintReport: + $ref: '#/components/schemas/BoatLintReport' + statistics: + $ref: '#/components/schemas/BoatStatistics' + BoatService: + type: object + properties: + key: + type: string + name: + type: string + description: + type: string + icon: + type: string + color: + type: string + createdOn: + $ref: '#/components/schemas/LocalDateTime' + createdBy: + type: string + statistics: + $ref: '#/components/schemas/BoatStatistics' + BoatSpec: + type: object + properties: + id: + type: number + key: + type: string + name: + type: string + title: + type: string + description: + type: string + icon: + type: string + version: + type: string + grade: + type: string + createdOn: + $ref: '#/components/schemas/LocalDateTime' + createdBy: + type: string + statistics: + $ref: '#/components/schemas/BoatStatistics' + backwardsCompatible: + type: boolean + changes: + $ref: '#/components/schemas/Changes' + capability: + $ref: '#/components/schemas/BoatCapability' + serviceDefinition: + $ref: '#/components/schemas/BoatService' + openApi: + type: string + BoatLintReport: + type: object + properties: + id: + type: number + spec: + $ref: '#/components/schemas/BoatSpec' + name: + type: string + passed: + type: boolean + lintedOn: + $ref: '#/components/schemas/LocalDateTime' + openApi: + type: string + version: + type: string + grade: + type: string + violations: + type: array + items: + $ref: '#/components/schemas/BoatViolation' + hasViolations: + type: boolean + BoatLintRule: + type: object + properties: + id: + type: number + ruleId: + type: string + enabled: + type: boolean + title: + type: string + ruleSet: + type: string + severity: + $ref: '#/components/schemas/Severity' + url: + type: string + format: uri + BoatProductRelease: + type: object + properties: + id: + type: number + key: + type: string + name: + type: string + version: + type: string + releaseDate: + $ref: '#/components/schemas/LocalDateTime' + BoatPortalDashboard: + type: object + properties: + portalId: + type: string + portalKey: + type: string + portalName: + type: string + productId: + type: string + productKey: + type: string + productName: + type: string + numberOfServices: + type: integer + format: int64 + numberOfCapabilities: + type: integer + format: int64 + productDescription: + type: string + lastLintReport: + $ref: '#/components/schemas/BoatLintReport' + statistics: + $ref: '#/components/schemas/BoatStatistics' + BoatTag: + type: object + properties: + name: + type: string + description: + type: string + hide: + type: boolean + color: + type: string + numberOfOccurrences: + type: integer + Resource: + type: array + items: + type: string + format: byte + ChangedOpenApiObject: + type: object + upload-request-body: + type: object + properties: + specs: + type: array + items: + $ref: '#/components/schemas/UploadSpec' + location: + type: string + projectId: + type: string + artifactId: + type: string + version: + type: string + LocalDateTime: + type: string + format: date-time + BoatStatistics: + type: object + properties: + updatedOn: + $ref: '#/components/schemas/LocalDateTime' + mustViolationsCount: + type: integer + format: int64 + shouldViolationsCount: + type: integer + format: int64 + mayViolationsCount: + type: integer + format: int64 + hintViolationsCount: + type: integer + format: int64 + Changes: + type: string + enum: + - NOT_APPLICABLE + - ERROR_COMPARING + - UNCHANGED + - COMPATIBLE + - BREAKING + BoatViolation: + type: object + properties: + rule: + $ref: '#/components/schemas/BoatLintRule' + description: + type: string + severity: + $ref: '#/components/schemas/Severity' + lines: + $ref: '#/components/schemas/IntRange' + pointer: + type: string + Severity: + type: string + enum: + - MUST + - SHOULD + - MAY + - HINT + UploadSpec: + type: object + properties: + fileName: + type: string + openApi: + type: string + key: + type: string + name: + type: string + IntRange: + type: object + properties: + start: + type: integer + endInclusive: + type: integer + examples: {} From af5f18b149b6b318ff04caab4114dae88aa06781 Mon Sep 17 00:00:00 2001 From: Sophie Janssens Date: Tue, 2 Mar 2021 12:39:56 +0000 Subject: [PATCH 06/12] working, possibly final bay-bay-feature, link to lint report needs to be checked --- boat-maven-plugin/pom.xml | 94 +- .../com/backbase/oss/boat/BoatBayRadio.java | 181 +++- .../java/com/backbase/oss/boat/LintMojo.java | 23 +- .../com/backbase/oss/boat/ValidateMojo.java | 6 - .../boat-bay-client.yaml | 927 +++++++++--------- .../com/backbase/oss/boat/LintMojoTests.java | 17 + 6 files changed, 722 insertions(+), 526 deletions(-) diff --git a/boat-maven-plugin/pom.xml b/boat-maven-plugin/pom.xml index fd4c83532..1fcff4dd4 100644 --- a/boat-maven-plugin/pom.xml +++ b/boat-maven-plugin/pom.xml @@ -171,8 +171,59 @@ spring-data-commons 2.4.2 + + com.squareup.okhttp3 + okhttp + 3.14.2 + + + io.gsonfire + gson-fire + 1.8.5 + + + com.squareup.okhttp3 + logging-interceptor + 3.8.1 + + + org.springframework + spring-expression + 5.2.5.RELEASE + + + junit + junit + 4.13.1 + compile + + - + + io.github.openfeign + feign-okhttp + 10.11 + + + io.github.openfeign + feign-gson + 10.11 + + + io.github.openfeign + feign-slf4j + 10.11 + + + io.github.openfeign.form + feign-form + 3.8.0 + + + io.github.openfeign + feign-jackson + 9.3.1 + @@ -187,46 +238,51 @@ org.apache.maven.plugins maven-plugin-plugin - - com.backbase.oss - boat-maven-plugin - 0.13.0 + org.openapitools + openapi-generator-maven-plugin + 5.0.0 - generate-webclient-embedded - generate-sources generate ${project.basedir}/src/main/resources/boat-bay-api-client-temp/boat-bay-client.yaml - ${project.basedir}/target/generated-sources java - native - java8 + true + ${boat-maven-plugin.supportingFilesToGenerate} + com.backbase.oss.boat.bay.client.model + com.backbase.oss.boat.bay.client.api + ${project.basedir}/target/generated-sources + false + feign + false + false + false + true + java8-localdatetime + src/gen/java/main - com.backbase.oss.boat.bay.client.model - com.backbase.oss.boat.bay.client.api - false - false - false - false - true - IntRange = kotlin.ranges.IntRange + JsonPointer = com.fasterxml.jackson.core.JsonPointer + LocalDateTime = java.time.LocalDateTime + org.joda.time = java.time.LocalDateTime + + JsonPointer = com.fasterxml.jackson.core.JsonPointer LocalDateTime = java.time.LocalDateTime Pageable = org.springframework.data.domain.Pageable + IntRange = kotlin.ranges.IntRange - ${boat-maven-plugin.supportingFilesToGenerate} + org.apache.maven.plugins maven-compiler-plugin diff --git a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java index 600e99ee0..9df684105 100644 --- a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java +++ b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java @@ -1,22 +1,26 @@ package com.backbase.oss.boat; import com.backbase.oss.boat.bay.client.ApiClient; -import com.backbase.oss.boat.bay.client.ApiException; import com.backbase.oss.boat.bay.client.api.UploadPluginApi; -import com.backbase.oss.boat.bay.client.model.BoatLintReport; -import com.backbase.oss.boat.bay.client.model.UploadRequestBody; -import com.backbase.oss.boat.bay.client.model.UploadSpec; +import com.backbase.oss.boat.bay.client.model.*; import com.backbase.oss.boat.loader.OpenAPILoader; import io.swagger.v3.oas.models.OpenAPI; +import kotlin.ranges.IntRange; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.IOUtils; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; +import org.jetbrains.annotations.NotNull; +import org.springframework.expression.Expression; +import org.springframework.expression.ExpressionParser; +import org.springframework.expression.spel.standard.SpelExpressionParser; +import org.zalando.zally.rule.api.Severity; +import org.zalando.zally.rule.api.Violation; import java.io.File; import java.nio.charset.Charset; -import java.time.Duration; +import java.nio.file.Path; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; @@ -25,46 +29,138 @@ public class BoatBayRadio { @Parameter(name = "readTimeout", defaultValue = "null") - public Duration readTimeout; + public Integer readTimeout; - private UploadPluginApi boatbayUploadSpecClient; - private File inputSpec; - private File output; + private final UploadPluginApi boatbayUploadSpecClient; + private final File inputSpec; + private final File output; + private String clientBasePath; protected MavenProject project; - public BoatBayRadio(File inputSpec, File output, MavenProject project) { + + public BoatBayRadio(File inputSpec, File output, MavenProject project, String clientBasePath) { this.project = project; this.output = output; this.inputSpec = inputSpec; - this.boatbayUploadSpecClient = new UploadPluginApi(new ApiClient().setReadTimeout(readTimeout));; + this.clientBasePath = clientBasePath; + + if (System.getenv().containsKey("BOAT_BAY_SERVER_URL")) + this.clientBasePath= System.getenv("BOAT_BAY_SERVER_URL"); + + boatbayUploadSpecClient = configureApiClient(this.clientBasePath).buildClient(UploadPluginApi.class); } + private ApiClient configureApiClient(String clientBasePath){ - public List upload(String sourceId ) throws ApiException { + if (readTimeout == null) + return new ApiClient().setBasePath(clientBasePath); + + return new ApiClient().setBasePath(clientBasePath); + } + + + public List upload(String sourceId ) { + log.debug("uploading specs for source : {}" , sourceId); + + List boatLintReports = boatbayUploadSpecClient.uploadSpec(sourceId, createRequestBody()); + + log.info("\nSpecs linted.Lint reports can be found at:"); + + List lintReports= boatLintReports.stream() + .map(this::mapBoatBayLintToBoatLint) + .collect(Collectors.toList()); + + return lintReports; + } + + + private com.backbase.oss.boat.quay.model.BoatLintReport mapBoatBayLintToBoatLint(BoatLintReport bayLintReport){ + com.backbase.oss.boat.quay.model.BoatLintReport lintReport = new com.backbase.oss.boat.quay.model.BoatLintReport(); + + lintReport.setOpenApi(bayLintReport.getOpenApi()); + lintReport.setVersion(bayLintReport.getVersion()); + lintReport.setTitle(bayLintReport.getName()); + lintReport.setAvailableRules(bayLintReport.getViolations().stream().map(BoatViolation::getRule).map(this::mapRule).collect(Collectors.toList())); + lintReport.setViolations(bayLintReport.getViolations().stream().map(this::mapViolation).collect(Collectors.toList())); + lintReport.setFilePath(getFilePath(bayLintReport.getSpec().getName())); + + //link to lint report may need updating before release + log.info("\n\tSpec {}: {}/lint-report/{}/view", + bayLintReport.getSpec().getName(), + clientBasePath, + bayLintReport.getId()); + + return lintReport; + } + + + private String getFilePath(String fileName) { + File inputFile = inputSpec.toPath().resolve(fileName).toFile(); + File workingDirectory = new File("."); + Path relativize; - if (sourceId.isEmpty()){ - throw new RuntimeException("Source must be set up first"); - } try { - return boatbayUploadSpecClient.uploadSpec(sourceId, createRequestBody()); - } catch (Exception e) { - throw new ApiException(e.getMessage()); + relativize = workingDirectory.toPath().relativize(inputFile.toPath()); + } catch (RuntimeException exception) { + log.warn("Failed to get relative path for: {} in working directory: {}", inputFile, workingDirectory); + return inputFile.toString(); } + return relativize.toString(); + } + + + private com.backbase.oss.boat.quay.model.BoatLintRule mapRule(BoatLintRule boatRule){ + com.backbase.oss.boat.quay.model.BoatLintRule boatLintRule = new com.backbase.oss.boat.quay.model.BoatLintRule(); + + boatLintRule.setTitle(boatRule.getTitle()); + boatLintRule.setRuleSet(boatRule.getRuleSet()); + boatLintRule.setIgnored(!boatRule.getEnabled()); + boatLintRule.setUrl(boatRule.getUrl()); + boatLintRule.setSeverity(mapSeverity(boatRule.getSeverity())); + + return boatLintRule; + } + + + private com.backbase.oss.boat.quay.model.BoatViolation mapViolation(BoatViolation boatViolation){ + com.backbase.oss.boat.quay.model.BoatViolation violation = new com.backbase.oss.boat.quay.model.BoatViolation(); + + violation.setDescription(boatViolation.getDescription()); + violation.setRule(mapRule(boatViolation.getRule())); + violation.setSeverity(mapSeverity(boatViolation.getSeverity())); + violation.setLines(boatViolation.getLines()); + violation.setPointer(boatViolation.getPointer()); + + return violation; + } + +// private IntRange mapRange(com.backbase.oss.boat.bay.client.model.IntRange range){ +// +// if (range.getEndInclusive()==null){ +// return new IntRange(range.getStart(),range.getStart()); +// } +// return new IntRange(range.getStart(),range.getEndInclusive()); +// } + + private Severity mapSeverity(com.backbase.oss.boat.bay.client.model.Severity boatSeverity){ + return Severity.valueOf(boatSeverity.getValue()); } + private UploadRequestBody createRequestBody(){ UploadRequestBody requestBody = new UploadRequestBody(); + try { requestBody.setSpecs(getSpecs()); }catch (Exception e){ throw new RuntimeException("unable to load specs", e); } - requestBody.location(project.getBasedir().toPath().resolve(inputSpec.toPath()).toString()); - if (output != null){ - requestBody.location(output.getParentFile().getPath()); - } + requestBody.location(output.getParentFile().getPath()); + + if (output == null) + requestBody.location(new File("./target/boat-bay-lint").getAbsolutePath()); requestBody.projectId(project.getGroupId()); requestBody.setArtifactId(project.getArtifactId()); @@ -75,35 +171,62 @@ private UploadRequestBody createRequestBody(){ private List getSpecs() throws MojoExecutionException { File[] inputFiles; + if (inputSpec.isDirectory()) { inputFiles = inputSpec.listFiles(pathname -> pathname.getName().endsWith(".yaml")); - if (inputFiles == null || inputFiles.length == 0) { + + if (inputFiles == null || inputFiles.length == 0) throw new MojoExecutionException("No OpenAPI specs found in: " + inputSpec); - } + + log.info("Found " + inputFiles.length + " specs to lint."); } else { inputFiles = new File[]{inputSpec}; } - List specs = Arrays.stream(inputFiles).map(this::mapToUploadSpec).collect(Collectors.toList()); - return specs; + return Arrays.stream(inputFiles).map(this::mapToUploadSpec).collect(Collectors.toList()); } private UploadSpec mapToUploadSpec(File spec) { OpenAPI openAPI; + String contents; + try { - String contents = IOUtils.toString(spec.toURI(), Charset.defaultCharset()); + + contents = IOUtils.toString(spec.toURI(), Charset.defaultCharset()); openAPI= OpenAPILoader.parse(contents); + }catch (Exception e){ throw new RuntimeException("unable to read api files: "+e.getMessage()); } UploadSpec uploadSpec = new UploadSpec(); uploadSpec.fileName(spec.getName()); - uploadSpec.openApi(openAPI.getOpenapi()); - uploadSpec.key(spec.getName().substring(0, spec.getName().lastIndexOf('-'))); + + uploadSpec.openApi(contents); + + log.debug("uploading api {} with contents {}", spec.getName(),openAPI.getOpenapi()); + + uploadSpec.key(getSpecKey(spec)); uploadSpec.name(spec.getName()); + return uploadSpec; } + private String getSpecKey(File spec){ + String key; + String spEL; + ExpressionParser parser = new SpelExpressionParser(); + + if(spec.getName().contains("-")){ + spEL = "name.substring(0,name.lastIndexOf('-'))"; + }else + spEL = "name.substring(0,name.lastIndexOf('.'))"; + + Expression value = parser.parseExpression(spEL); + key = value.getValue(spec, String.class); + + return key; + } + } diff --git a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/LintMojo.java b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/LintMojo.java index b9d4060ee..befff76d5 100644 --- a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/LintMojo.java +++ b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/LintMojo.java @@ -1,14 +1,11 @@ package com.backbase.oss.boat; -import com.backbase.oss.boat.bay.client.ApiException; import com.backbase.oss.boat.quay.model.BoatLintReport; import com.backbase.oss.codegen.lint.BoatLintConfig; import com.backbase.oss.codegen.lint.BoatLintGenerator; import java.io.File; -import java.net.URL; import java.util.List; -import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -16,7 +13,6 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.project.MavenProject; -import sun.tools.java.Environment; @SuppressWarnings("FieldMayBeFinal") @Mojo(name = "lint", requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true) @@ -44,8 +40,8 @@ public class LintMojo extends AbstractLintMojo { @Parameter(name = "boatBayUrl", defaultValue = "hjhb", property = "boat.maven.plugin.lint.boatBayUrl") private String boatBayUrl; - @Parameter(name = "sourceId", defaultValue = "") - private String sourceId; + @Parameter(name = "sourceKey", defaultValue = "") + private String sourceKey; private BoatBayRadio boatBayRadio; @@ -55,16 +51,14 @@ public void execute() throws MojoExecutionException, MojoFailureException { List boatLintReports = null; try { - if (!sourceId.isEmpty() - || !System.getenv("boatBayUrl").isEmpty() - || System.getenv("boatBayUrl") != null - || !boatBayUrl.isEmpty()) { - new BoatBayRadio(inputSpec,output,project).upload(sourceId); - // System.getenv().containsKey("boatBayUrl"); + if (!sourceKey.isEmpty() + && (System.getenv().containsKey("boatBayUrl") + || !boatBayUrl.isEmpty())) { + boatLintReports = new BoatBayRadio(inputSpec,output,project, boatBayUrl).upload(sourceKey); }else { boatLintReports = lint(); } - } catch (MojoExecutionException | ApiException e) { + } catch (MojoExecutionException e) { if (failOnWarning) { throw new MojoExecutionException(e.getMessage()); } @@ -94,6 +88,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { throw new MojoFailureException("Linting " + inputSpec + " failed. Please correct the found issues and try again"); } + } private void generateLintReport(boolean isSingleLint, BoatLintReport report) { @@ -118,7 +113,7 @@ private File getOutput() { } - public void setSourceId(String sourceId){ this.sourceId = sourceId; } + public void setSourceKey(String sourceKey){ this.sourceKey = sourceKey; } public void setBoatBayUrl(String boatBayUrl){this.boatBayUrl = boatBayUrl;} diff --git a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/ValidateMojo.java b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/ValidateMojo.java index 85f74edef..e534c1191 100644 --- a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/ValidateMojo.java +++ b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/ValidateMojo.java @@ -68,12 +68,6 @@ public void execute() throws MojoFailureException { } } else { validate(input); - if (!sourceId.isEmpty() - || !System.getenv("boatBayUrl").isEmpty() - || System.getenv("boatBayUrl") != null - || !boatBayUrl.isEmpty()){ - new BoatBayRadio(input,null,project).upload(sourceId); - } } } diff --git a/boat-maven-plugin/src/main/resources/boat-bay-api-client-temp/boat-bay-client.yaml b/boat-maven-plugin/src/main/resources/boat-bay-api-client-temp/boat-bay-client.yaml index a7af012c8..055e230aa 100644 --- a/boat-maven-plugin/src/main/resources/boat-bay-api-client-temp/boat-bay-client.yaml +++ b/boat-maven-plugin/src/main/resources/boat-bay-api-client-temp/boat-bay-client.yaml @@ -6,15 +6,18 @@ info: name: Backbase version: 1.0.0 servers: -- url: http://boat-bay-server.proto.backbasecloud.com/ + - url: http://localhost:8080 + description: test server + - url: http://boat-bay-server.proto.backbasecloud.com/ + description: production server tags: -- name: dashboard -- name: upload-plugin + - name: dashboard + - name: upload-plugin paths: /api/boat/portals: get: tags: - - dashboard + - dashboard summary: get list of portals operationId: getPortals responses: @@ -29,18 +32,18 @@ paths: /api/boat/portals/{portalKey}/products: get: tags: - - dashboard + - dashboard summary: get products for identified portal operationId: getPortalProducts parameters: - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string responses: "200": description: list of protals products @@ -53,33 +56,33 @@ paths: /api/boat/portals/{portalKey}/products/{productKey}/capabilities: get: tags: - - dashboard + - dashboard summary: get Portal Products Capabalities operationId: getPortalCapabilities parameters: - - name: pageable - in: query - required: false - style: form - explode: true - schema: - $ref: '#/components/schemas/Pageable' - - name: productKey - in: path - description: product idenifier - required: true - style: simple - explode: false - schema: - type: string - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string + - name: pageable + in: query + required: false + style: form + explode: true + schema: + $ref: '#/components/schemas/Pageable' + - name: productKey + in: path + description: product idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string responses: "200": description: list of capabilities for product @@ -92,33 +95,33 @@ paths: /api/boat/portals/{portalKey}/products/{productKey}/services: get: tags: - - dashboard + - dashboard summary: get Portal services for a given product operationId: getPortalServices parameters: - - name: pageable - in: query - required: false - style: form - explode: true - schema: - $ref: '#/components/schemas/Pageable' - - name: productKey - in: path - description: product idenifier - required: true - style: simple - explode: false - schema: - type: string - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string + - name: pageable + in: query + required: false + style: form + explode: true + schema: + $ref: '#/components/schemas/Pageable' + - name: productKey + in: path + description: product idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string responses: "200": description: list of services for product @@ -131,81 +134,85 @@ paths: /api/boat/portals/{portalKey}/products/{productKey}/specs: get: tags: - - dashboard + - dashboard summary: get Portal Specs for given product operationId: getPortalSpecs parameters: - - name: pageable - in: query - required: false - style: form - explode: true - schema: - $ref: '#/components/schemas/Pageable' - - name: productKey - in: path - description: product idenifier - required: true - style: simple - explode: false - schema: - type: string - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string - - name: capabilityId - in: query - description: capablility idenifier - required: false - style: form - explode: true - schema: - type: string - - name: productReleaseId - in: query - description: product release idenifier - required: false - style: form - explode: true - schema: - type: string - - name: serviceId - in: query - description: service idenifier - required: false - style: form - explode: true - schema: - type: string - - name: grade - in: query - description: grade of spec - required: false - style: form - explode: true - schema: - type: string - - name: backwardsCompatible - in: query - description: backwards compatible indicator - required: false - style: form - explode: true - schema: - type: boolean - - name: changed - in: query - description: changed indicator - required: false - style: form - explode: true - schema: - type: boolean + - name: pageable + in: query + required: false + style: form + explode: true + schema: + $ref: '#/components/schemas/Pageable' + - name: productKey + in: path + description: product idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: capability + in: query + description: capablility idenifier + required: false + style: form + explode: true + schema: + type: array + items: + type: string + - name: release + in: query + description: product release idenifier + required: false + style: form + explode: true + schema: + type: string + - name: service + in: query + description: service idenifier + required: false + style: form + explode: true + schema: + type: array + items: + type: string + - name: grade + in: query + description: grade of spec + required: false + style: form + explode: true + schema: + type: string + - name: backwardsCompatible + in: query + description: backwards compatible indicator + required: false + style: form + explode: true + schema: + type: boolean + - name: changed + in: query + description: changed indicator + required: false + style: form + explode: true + schema: + type: boolean responses: "200": description: list of specs for product @@ -218,42 +225,42 @@ paths: /api/boat/portals/{portalKey}/products/{productKey}/specs/{specId}/lint-report: get: tags: - - dashboard + - dashboard summary: get Lint Report for spec operationId: getLintReportForSpec parameters: - - name: specId - in: path - description: spec idenifier - required: true - style: simple - explode: false - schema: - type: string - - name: productKey - in: path - description: product idenifier - required: true - style: simple - explode: false - schema: - type: string - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string - - name: refresh - in: query - description: refresh idicator - required: false - style: form - explode: true - schema: - type: boolean + - name: specId + in: path + description: spec idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: productKey + in: path + description: product idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: refresh + in: query + description: refresh idicator + required: false + style: form + explode: true + schema: + type: boolean responses: "200": description: lint report for spec @@ -264,18 +271,18 @@ paths: /api/boat/portals/{portalKey}/lint-rules: get: tags: - - dashboard + - dashboard summary: get list of lint rules operationId: getPortalLintRules parameters: - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string responses: "200": description: list of lint rules for portal @@ -288,26 +295,26 @@ paths: /api/boat/portals/{portalKey}/products/{productKey}/releases: get: tags: - - dashboard + - dashboard summary: get product releases operationId: getProductReleases parameters: - - name: productKey - in: path - description: id of product - required: true - style: simple - explode: false - schema: - type: string - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string + - name: productKey + in: path + description: id of product + required: true + style: simple + explode: false + schema: + type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string responses: "200": description: list of product releases for product @@ -320,34 +327,34 @@ paths: /api/boat/portals/{portalKey}/products/{productKey}/releases/{releaseKey}/specs: get: tags: - - dashboard + - dashboard summary: get specs for product release operationId: getProductReleaseSpecs parameters: - - name: releaseKey - in: path - description: key for product release - required: true - style: simple - explode: false - schema: - type: string - - name: productKey - in: path - description: id of product - required: true - style: simple - explode: false - schema: - type: string - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string + - name: releaseKey + in: path + description: key for product release + required: true + style: simple + explode: false + schema: + type: string + - name: productKey + in: path + description: id of product + required: true + style: simple + explode: false + schema: + type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string responses: "200": description: list of specs for product release @@ -360,26 +367,26 @@ paths: /api/boat/portals/{portalKey}/lint-rules/{lintRuleId}: post: tags: - - dashboard + - dashboard summary: update lint rule for portal operationId: updatePortalLintRule parameters: - - name: lintRuleId - in: path - description: id of portals lint rule - required: true - style: simple - explode: false - schema: - type: string - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string + - name: lintRuleId + in: path + description: id of portals lint rule + required: true + style: simple + explode: false + schema: + type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string requestBody: content: application/json: @@ -392,7 +399,7 @@ paths: /api/boat/dashboard: get: tags: - - dashboard + - dashboard summary: get list of boat portal dashboards operationId: getDashboard responses: @@ -407,26 +414,26 @@ paths: /api/boat/dashboard/{projectKey}/{productKey}: get: tags: - - dashboard + - dashboard summary: get product for dashboard project operationId: getProductDashboard parameters: - - name: projectKey - in: path - description: project idenifier - required: true - style: simple - explode: false - schema: - type: string - - name: productKey - in: path - description: product idenifier - required: true - style: simple - explode: false - schema: - type: string + - name: projectKey + in: path + description: project idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: productKey + in: path + description: product idenifier + required: true + style: simple + explode: false + schema: + type: string responses: "200": description: product for dashboard @@ -437,26 +444,26 @@ paths: /api/boat/portals/{portalKey}/products/{productKey}/tags: get: tags: - - dashboard + - dashboard summary: get tags for product operationId: getProductTags parameters: - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string - - name: productKey - in: path - description: product idenifier - required: true - style: simple - explode: false - schema: - type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: productKey + in: path + description: product idenifier + required: true + style: simple + explode: false + schema: + type: string responses: "200": description: list of product tags @@ -466,61 +473,61 @@ paths: type: array items: $ref: '#/components/schemas/BoatTag' - ? /api/boat/portals/{portalKey}/products/{productKey}/capabilities/{capabilityKey}/services/{serviceKey}/specs/{specKey}/{version}/download - : get: + /api/boat/portals/{portalKey}/products/{productKey}/capabilities/{capabilityKey}/services/{serviceKey}/specs/{specKey}/{version}/download: + get: tags: - - dashboard + - dashboard summary: get spec as openapi operationId: getSpecAsOpenAPI parameters: - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string - - name: productKey - in: path - description: product identifier - required: true - style: simple - explode: false - schema: - type: string - - name: capabilityKey - in: path - description: capability identifier - required: true - style: simple - explode: false - schema: - type: string - - name: serviceKey - in: path - description: service identifier - required: true - style: simple - explode: false - schema: - type: string - - name: specKey - in: path - description: spec identifier - required: true - style: simple - explode: false - schema: - type: string - - name: version - in: path - description: version of spec - required: true - style: simple - explode: false - schema: - type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: productKey + in: path + description: product identifier + required: true + style: simple + explode: false + schema: + type: string + - name: capabilityKey + in: path + description: capability identifier + required: true + style: simple + explode: false + schema: + type: string + - name: serviceKey + in: path + description: service identifier + required: true + style: simple + explode: false + schema: + type: string + - name: specKey + in: path + description: spec identifier + required: true + style: simple + explode: false + schema: + type: string + - name: version + in: path + description: version of spec + required: true + style: simple + explode: false + schema: + type: string responses: "200": description: openApi of spec @@ -550,61 +557,61 @@ paths: application/vnd.oai.openapi: schema: $ref: '#/components/schemas/Resource' - ? /api/boat/portals/{portalKey}/products/{productKey}/capabilities/{capabilityKey}/services/{serviceKey}/specs/{specKey}/{version} - : get: + /api/boat/portals/{portalKey}/products/{productKey}/capabilities/{capabilityKey}/services/{serviceKey}/specs/{specKey}/{version}: + get: tags: - - dashboard + - dashboard summary: download spec operationId: downloadSpec parameters: - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string - - name: productKey - in: path - description: product identifier - required: true - style: simple - explode: false - schema: - type: string - - name: capabilityKey - in: path - description: capability identifier - required: true - style: simple - explode: false - schema: - type: string - - name: serviceKey - in: path - description: service identifier - required: true - style: simple - explode: false - schema: - type: string - - name: specKey - in: path - description: spec identifier - required: true - style: simple - explode: false - schema: - type: string - - name: version - in: path - description: version of spec - required: true - style: simple - explode: false - schema: - type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: productKey + in: path + description: product identifier + required: true + style: simple + explode: false + schema: + type: string + - name: capabilityKey + in: path + description: capability identifier + required: true + style: simple + explode: false + schema: + type: string + - name: serviceKey + in: path + description: service identifier + required: true + style: simple + explode: false + schema: + type: string + - name: specKey + in: path + description: spec identifier + required: true + style: simple + explode: false + schema: + type: string + - name: version + in: path + description: version of spec + required: true + style: simple + explode: false + schema: + type: string responses: "200": description: spec with open api @@ -615,42 +622,42 @@ paths: /api/boat/portals/{portalKey}/products/{productKey}/diff-report: get: tags: - - lint + - lint summary: get lint report for spec operationId: getApiChangesForSpec parameters: - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string - - name: productKey - in: path - description: product identifier - required: true - style: simple - explode: false - schema: - type: string - - name: spec1Id - in: query - description: identifies first comparitable api - required: false - style: form - explode: true - schema: - type: string - - name: spec2Id - in: query - description: identifies second comparitable api - required: false - style: form - explode: true - schema: - type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: productKey + in: path + description: product identifier + required: true + style: simple + explode: false + schema: + type: string + - name: spec1Id + in: query + description: identifies first comparitable api + required: false + style: form + explode: true + schema: + type: string + - name: spec2Id + in: query + description: identifies second comparitable api + required: false + style: form + explode: true + schema: + type: string responses: "200": description: changed openApi @@ -661,42 +668,42 @@ paths: /api/boat/portals/{portalKey}/products/{productKey}/diff-report.html: get: tags: - - lint + - lint summary: get lint report for spec as html operationId: getLintReportForSpecAsHtml parameters: - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string - - name: productKey - in: path - description: product identifier - required: true - style: simple - explode: false - schema: - type: string - - name: spec1Id - in: query - description: identifies first comparitable api - required: false - style: form - explode: true - schema: - type: string - - name: spec2Id - in: query - description: identifies second comparitable api - required: false - style: form - explode: true - schema: - type: string + - name: portalKey + in: path + description: portal idenifier + required: true + style: simple + explode: false + schema: + type: string + - name: productKey + in: path + description: product identifier + required: true + style: simple + explode: false + schema: + type: string + - name: spec1Id + in: query + description: identifies first comparitable api + required: false + style: form + explode: true + schema: + type: string + - name: spec2Id + in: query + description: identifies second comparitable api + required: false + style: form + explode: true + schema: + type: string responses: "200": description: changed openApi as html @@ -704,21 +711,21 @@ paths: application/json: schema: type: string - /api/boat/boat-maven-plugin/{sourceId}/upload: - put: + /api/boat/boat-maven-plugin/{sourceKey}/upload: + post: tags: - - upload-plugin + - upload-plugin summary: upload and lint specs operationId: uploadSpec parameters: - - name: sourceId - in: path - description: source idenifier - required: true - style: simple - explode: false - schema: - type: string + - name: sourceKey + in: path + description: source idenifier + required: true + style: simple + explode: false + schema: + type: string requestBody: content: application/json: @@ -799,6 +806,10 @@ components: $ref: '#/components/schemas/LocalDateTime' createdBy: type: string + services: + type: array + items: + $ref: '#/components/schemas/BoatService' lastLintReport: $ref: '#/components/schemas/BoatLintReport' statistics: @@ -998,11 +1009,11 @@ components: Changes: type: string enum: - - NOT_APPLICABLE - - ERROR_COMPARING - - UNCHANGED - - COMPATIBLE - - BREAKING + - NOT_APPLICABLE + - ERROR_COMPARING + - UNCHANGED + - COMPATIBLE + - BREAKING BoatViolation: type: object properties: @@ -1015,14 +1026,14 @@ components: lines: $ref: '#/components/schemas/IntRange' pointer: - type: string + type: JsonPointer Severity: type: string enum: - - MUST - - SHOULD - - MAY - - HINT + - MUST + - SHOULD + - MAY + - HINT UploadSpec: type: object properties: diff --git a/boat-maven-plugin/src/test/java/com/backbase/oss/boat/LintMojoTests.java b/boat-maven-plugin/src/test/java/com/backbase/oss/boat/LintMojoTests.java index 5890d3452..b9c25b096 100644 --- a/boat-maven-plugin/src/test/java/com/backbase/oss/boat/LintMojoTests.java +++ b/boat-maven-plugin/src/test/java/com/backbase/oss/boat/LintMojoTests.java @@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.project.MavenProject; import org.assertj.core.util.Arrays; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import org.junit.jupiter.api.Test; @@ -85,6 +86,22 @@ void testExceptionsWithInvalidFile() { assertDoesNotThrow(lintMojo::execute); } + @Test + void testLintUpload() throws MojoFailureException, MojoExecutionException { + LintMojo lintMojo = new LintMojo(); + lintMojo.project = new MavenProject(); + lintMojo.project.setGroupId("repo.backbase.com"); + lintMojo.project.setArtifactId("petstore"); + lintMojo.project.setVersion("1.0.0"); + lintMojo.project.setFile(getFile("/oas-examples")); + lintMojo.setSourceKey("repo-petstore"); + lintMojo.setBoatBayUrl("http://localhost:8080"); + lintMojo.output= new File("/Users/sophiej/Documents/Projects/opensauce/fresh-water-boat/backbase-openapi-tools/boat-maven-plugin/src/test/resources/upload-reports"); + lintMojo.setIgnoreRules(Arrays.array("219", "105", "104", "151", "134", "115")); + lintMojo.setInput(getFile("/oas-examples/petstore.yaml")); + lintMojo.setFailOnWarning(false); + lintMojo.execute(); + } private File getFile(String fileName) { From 59ee0efd52f222654308ab58a374d7de2f26089d Mon Sep 17 00:00:00 2001 From: Sophie Janssens Date: Sat, 6 Mar 2021 19:54:29 +0000 Subject: [PATCH 07/12] fixed issue with IntRange --- boat-maven-plugin/pom.xml | 2 +- .../java/com/backbase/oss/boat/BoatBayRadio.java | 16 ++++++++-------- .../java/com/backbase/oss/boat/LintMojo.java | 6 +++--- .../java/com/backbase/oss/boat/ValidateMojo.java | 11 +---------- 4 files changed, 13 insertions(+), 22 deletions(-) diff --git a/boat-maven-plugin/pom.xml b/boat-maven-plugin/pom.xml index 1fcff4dd4..0696afa41 100644 --- a/boat-maven-plugin/pom.xml +++ b/boat-maven-plugin/pom.xml @@ -275,7 +275,7 @@ JsonPointer = com.fasterxml.jackson.core.JsonPointer LocalDateTime = java.time.LocalDateTime Pageable = org.springframework.data.domain.Pageable - IntRange = kotlin.ranges.IntRange + diff --git a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java index 9df684105..75e51cc9d 100644 --- a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java +++ b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java @@ -129,19 +129,19 @@ private com.backbase.oss.boat.quay.model.BoatViolation mapViolation(BoatViolatio violation.setDescription(boatViolation.getDescription()); violation.setRule(mapRule(boatViolation.getRule())); violation.setSeverity(mapSeverity(boatViolation.getSeverity())); - violation.setLines(boatViolation.getLines()); + violation.setLines(mapRange(boatViolation.getLines())); violation.setPointer(boatViolation.getPointer()); return violation; } -// private IntRange mapRange(com.backbase.oss.boat.bay.client.model.IntRange range){ -// -// if (range.getEndInclusive()==null){ -// return new IntRange(range.getStart(),range.getStart()); -// } -// return new IntRange(range.getStart(),range.getEndInclusive()); -// } + private IntRange mapRange(com.backbase.oss.boat.bay.client.model.IntRange range){ + + if (range.getEndInclusive()==null){ + return new IntRange(range.getStart(),range.getStart()); + } + return new IntRange(range.getStart(),range.getEndInclusive()); + } private Severity mapSeverity(com.backbase.oss.boat.bay.client.model.Severity boatSeverity){ return Severity.valueOf(boatSeverity.getValue()); diff --git a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/LintMojo.java b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/LintMojo.java index befff76d5..d87340c10 100644 --- a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/LintMojo.java +++ b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/LintMojo.java @@ -37,10 +37,10 @@ public class LintMojo extends AbstractLintMojo { @Parameter(readonly = true, required = true, defaultValue = "${project}") protected MavenProject project; - @Parameter(name = "boatBayUrl", defaultValue = "hjhb", property = "boat.maven.plugin.lint.boatBayUrl") + @Parameter(name = "boatBayUrl", property = "boat.maven.plugin.lint.boatBayUrl") private String boatBayUrl; - @Parameter(name = "sourceKey", defaultValue = "") + @Parameter(name = "sourceKey") private String sourceKey; private BoatBayRadio boatBayRadio; @@ -51,7 +51,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { List boatLintReports = null; try { - if (!sourceKey.isEmpty() + if (sourceKey != null && (System.getenv().containsKey("boatBayUrl") || !boatBayUrl.isEmpty())) { boatLintReports = new BoatBayRadio(inputSpec,output,project, boatBayUrl).upload(sourceKey); diff --git a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/ValidateMojo.java b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/ValidateMojo.java index e534c1191..8f3f766b4 100644 --- a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/ValidateMojo.java +++ b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/ValidateMojo.java @@ -32,20 +32,11 @@ public class ValidateMojo extends AbstractMojo { @Parameter(readonly = true, required = true, defaultValue = "${project}") protected MavenProject project; -/// cant get it to be sent in source pom file ??? - @Parameter(name = "sourceId", defaultValue = "", property = "boat.maven.plugin.sourceId") - private String sourceId; - - @Parameter(name = "boatBayUrl", defaultValue = "", property = "boat.maven.plugin.lint.boatBayUrl") - private String boatBayUrl; - - private BoatBayRadio boatbayUploadSpecClient; public void setInput(File input) { this.input = input; } - public void setSourceId(String sourceId){this.sourceId = sourceId;} - public void setBoatBayUrl(String boatBayUrl){this.boatBayUrl = boatBayUrl;} + public void setFailOnWarning(boolean failOnWarning) { this.failOnWarning= failOnWarning; } From 68bd0c08bf5fae7d932b32cc611e3eeab3c5ba2e Mon Sep 17 00:00:00 2001 From: Sophie Janssens Date: Tue, 9 Mar 2021 10:33:10 +0000 Subject: [PATCH 08/12] updated it examples for boat bay --- boat-maven-plugin/README.md | 16 +- .../boat-bay/lint-petstore-breaking/pom.xml | 3 +- .../lint-petstore-non-breaking/pom.xml | 3 +- .../it/example/boat-bay/lint-petstore/pom.xml | 3 +- .../src/it/example/boat-bay/pom.xml | 1 - .../boat-bay/validate-petstore/pom.xml | 46 - .../src/main/resources/petstore.yaml | 138 --- .../boat-bay-client.yml | 1044 ----------------- .../java-clients/boat-bay-client/pom.xml | 105 -- .../boat-generate/java-clients/pom.xml | 1 - .../com/backbase/oss/boat/BoatBayRadio.java | 6 +- 11 files changed, 24 insertions(+), 1342 deletions(-) delete mode 100644 boat-maven-plugin/src/it/example/boat-bay/validate-petstore/pom.xml delete mode 100644 boat-maven-plugin/src/it/example/boat-bay/validate-petstore/src/main/resources/petstore.yaml delete mode 100644 boat-maven-plugin/src/it/example/boat-generate/java-clients/boat-bay-client/boat-bay-api-client-temp/boat-bay-client.yml delete mode 100644 boat-maven-plugin/src/it/example/boat-generate/java-clients/boat-bay-client/pom.xml diff --git a/boat-maven-plugin/README.md b/boat-maven-plugin/README.md index b3ab2938f..87b588a00 100644 --- a/boat-maven-plugin/README.md +++ b/boat-maven-plugin/README.md @@ -158,7 +158,21 @@ The `boat` plugin has multiple goals: writeLintReport (Default: true) Set this to true to generate lint report. - + + sourceKey + Required: false + Set this to the SourceKey for the spec being + linted. This should be set to upload spec and lint via BoatBay. + To find out how to set up a source go to BoatBay project. + + boatBayUrl + Required: false + Set to url for boat bay server, options for this are, "http://localhost:8080" to run locally for testing + purposes and https://boat-bay.proto.backbasecloud.com/ for deployment + Optionally this can be set as an enviroment variable under the key BOAT_BAY_SERVER_URL. To set this as an + enviroment variable use the command export BOAT_BAY_SERVER_URL=http://localhost:8080, or the property + may be added to the config setting of boat-maven-plugin (in the run configuration options). + Example: ``` diff --git a/boat-maven-plugin/src/it/example/boat-bay/lint-petstore-breaking/pom.xml b/boat-maven-plugin/src/it/example/boat-bay/lint-petstore-breaking/pom.xml index e487a29ea..1eb8d3419 100644 --- a/boat-maven-plugin/src/it/example/boat-bay/lint-petstore-breaking/pom.xml +++ b/boat-maven-plugin/src/it/example/boat-bay/lint-petstore-breaking/pom.xml @@ -35,7 +35,8 @@ ${project.basedir}/src/main/resources/petstore-new-breaking.yaml ${project.basedir}/src/main/resources/output - 5 + repo-petstore + http://localhost:8080 diff --git a/boat-maven-plugin/src/it/example/boat-bay/lint-petstore-non-breaking/pom.xml b/boat-maven-plugin/src/it/example/boat-bay/lint-petstore-non-breaking/pom.xml index 520aaa2c9..62bd90bed 100644 --- a/boat-maven-plugin/src/it/example/boat-bay/lint-petstore-non-breaking/pom.xml +++ b/boat-maven-plugin/src/it/example/boat-bay/lint-petstore-non-breaking/pom.xml @@ -35,7 +35,8 @@ ${project.basedir}/src/main/resources/petstore-new-non-breaking.yaml ${project.basedir}/src/main/resources/output - 5 + repo-petstore + http://localhost:8080 diff --git a/boat-maven-plugin/src/it/example/boat-bay/lint-petstore/pom.xml b/boat-maven-plugin/src/it/example/boat-bay/lint-petstore/pom.xml index b4042f5f3..573e60865 100644 --- a/boat-maven-plugin/src/it/example/boat-bay/lint-petstore/pom.xml +++ b/boat-maven-plugin/src/it/example/boat-bay/lint-petstore/pom.xml @@ -37,7 +37,8 @@ url ${project.basedir}/src/main/resources/petstore.yaml ${project.basedir}/src/main/resources/output - 5 + repo-petstore + http://localhost:8080 diff --git a/boat-maven-plugin/src/it/example/boat-bay/pom.xml b/boat-maven-plugin/src/it/example/boat-bay/pom.xml index e4ea746a7..5509af49e 100644 --- a/boat-maven-plugin/src/it/example/boat-bay/pom.xml +++ b/boat-maven-plugin/src/it/example/boat-bay/pom.xml @@ -24,7 +24,6 @@ lint-petstore lint-petstore-non-breaking lint-petstore-breaking - validate-petstore diff --git a/boat-maven-plugin/src/it/example/boat-bay/validate-petstore/pom.xml b/boat-maven-plugin/src/it/example/boat-bay/validate-petstore/pom.xml deleted file mode 100644 index 4d6a4c185..000000000 --- a/boat-maven-plugin/src/it/example/boat-bay/validate-petstore/pom.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - 4.0.0 - - - - com.backbase.oss.boat.example - boat-bay - 1.0.0-SNAPSHOT - - - validate-petstore - - BOAT :: Boat Bay :: Spec Validate - - - Example project showing the validation of a specification via boat-bay - - pom - - - - - com.backbase.oss - boat-maven-plugin - - - validate - validate - - validate - - - true - ${project.basedir}/src/main/resources/petstore.yaml - - - - - - - - - diff --git a/boat-maven-plugin/src/it/example/boat-bay/validate-petstore/src/main/resources/petstore.yaml b/boat-maven-plugin/src/it/example/boat-bay/validate-petstore/src/main/resources/petstore.yaml deleted file mode 100644 index 137eaff93..000000000 --- a/boat-maven-plugin/src/it/example/boat-bay/validate-petstore/src/main/resources/petstore.yaml +++ /dev/null @@ -1,138 +0,0 @@ -openapi: "3.0.0" -info: - version: 1.0.0 - title: Swagger Petstore - license: - name: MIT -servers: - - url: http://petstore.swagger.io/v1 -paths: - /pets: - get: - summary: List all pets - operationId: listPets - tags: - - pets - parameters: - - name: limit - in: query - description: How many items to return at one time (max 100) - required: false - schema: - type: integer - format: int32 - responses: - '200': - description: A paged array of pets - headers: - x-next: - description: A link to the next page of responses - schema: - type: string - content: - application/json: - schema: - $ref: "#/components/schemas/Pets" - text/csv: - schema: - type: string - 500: - content: - application/json: - schema: - $ref: '#/components/schemas/InternalServerError' - description: InternalServerError - default: - description: unexpected error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - post: - summary: Create a pet - operationId: createPets - tags: - - pets - responses: - '201': - description: Null response - default: - description: unexpected error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /pets/{petId}: - get: - summary: Info for a specific pet - operationId: showPetById - tags: - - pets - parameters: - - name: petId - in: path - required: true - description: The id of the pet to retrieve - schema: - type: string - responses: - '200': - description: Expected response to a valid request - content: - application/json: - schema: - $ref: "#/components/schemas/Pet" - default: - description: unexpected error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /no-schema: - get: - summary: No Schema - operationId: getNoSchema - tags: - - pets - responses: - 200: - description: A response that does not specify a schema - content: - application/json: {} -components: - schemas: - Pet: - type: object - required: - - id - - name - properties: - id: - type: integer - format: int64 - name: - type: string - tag: - type: string - Pets: - type: array - items: - $ref: "#/components/schemas/Pet" - Error: - type: object - required: - - code - - message - properties: - code: - type: integer - format: int32 - message: - type: string - InternalServerError: - type: object - required: - - message - properties: - message: - type: string \ No newline at end of file diff --git a/boat-maven-plugin/src/it/example/boat-generate/java-clients/boat-bay-client/boat-bay-api-client-temp/boat-bay-client.yml b/boat-maven-plugin/src/it/example/boat-generate/java-clients/boat-bay-client/boat-bay-api-client-temp/boat-bay-client.yml deleted file mode 100644 index a7af012c8..000000000 --- a/boat-maven-plugin/src/it/example/boat-generate/java-clients/boat-bay-client/boat-bay-api-client-temp/boat-bay-client.yml +++ /dev/null @@ -1,1044 +0,0 @@ -openapi: 3.0.0 -info: - title: Boat Bay Client - description: Endpoints for the boat bay operations - license: - name: Backbase - version: 1.0.0 -servers: -- url: http://boat-bay-server.proto.backbasecloud.com/ -tags: -- name: dashboard -- name: upload-plugin -paths: - /api/boat/portals: - get: - tags: - - dashboard - summary: get list of portals - operationId: getPortals - responses: - "200": - description: boat legacy portal - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/BoatPortal' - /api/boat/portals/{portalKey}/products: - get: - tags: - - dashboard - summary: get products for identified portal - operationId: getPortalProducts - parameters: - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string - responses: - "200": - description: list of protals products - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/BoatProduct' - /api/boat/portals/{portalKey}/products/{productKey}/capabilities: - get: - tags: - - dashboard - summary: get Portal Products Capabalities - operationId: getPortalCapabilities - parameters: - - name: pageable - in: query - required: false - style: form - explode: true - schema: - $ref: '#/components/schemas/Pageable' - - name: productKey - in: path - description: product idenifier - required: true - style: simple - explode: false - schema: - type: string - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string - responses: - "200": - description: list of capabilities for product - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/BoatCapability' - /api/boat/portals/{portalKey}/products/{productKey}/services: - get: - tags: - - dashboard - summary: get Portal services for a given product - operationId: getPortalServices - parameters: - - name: pageable - in: query - required: false - style: form - explode: true - schema: - $ref: '#/components/schemas/Pageable' - - name: productKey - in: path - description: product idenifier - required: true - style: simple - explode: false - schema: - type: string - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string - responses: - "200": - description: list of services for product - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/BoatService' - /api/boat/portals/{portalKey}/products/{productKey}/specs: - get: - tags: - - dashboard - summary: get Portal Specs for given product - operationId: getPortalSpecs - parameters: - - name: pageable - in: query - required: false - style: form - explode: true - schema: - $ref: '#/components/schemas/Pageable' - - name: productKey - in: path - description: product idenifier - required: true - style: simple - explode: false - schema: - type: string - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string - - name: capabilityId - in: query - description: capablility idenifier - required: false - style: form - explode: true - schema: - type: string - - name: productReleaseId - in: query - description: product release idenifier - required: false - style: form - explode: true - schema: - type: string - - name: serviceId - in: query - description: service idenifier - required: false - style: form - explode: true - schema: - type: string - - name: grade - in: query - description: grade of spec - required: false - style: form - explode: true - schema: - type: string - - name: backwardsCompatible - in: query - description: backwards compatible indicator - required: false - style: form - explode: true - schema: - type: boolean - - name: changed - in: query - description: changed indicator - required: false - style: form - explode: true - schema: - type: boolean - responses: - "200": - description: list of specs for product - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/BoatSpec' - /api/boat/portals/{portalKey}/products/{productKey}/specs/{specId}/lint-report: - get: - tags: - - dashboard - summary: get Lint Report for spec - operationId: getLintReportForSpec - parameters: - - name: specId - in: path - description: spec idenifier - required: true - style: simple - explode: false - schema: - type: string - - name: productKey - in: path - description: product idenifier - required: true - style: simple - explode: false - schema: - type: string - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string - - name: refresh - in: query - description: refresh idicator - required: false - style: form - explode: true - schema: - type: boolean - responses: - "200": - description: lint report for spec - content: - application/json: - schema: - $ref: '#/components/schemas/BoatLintReport' - /api/boat/portals/{portalKey}/lint-rules: - get: - tags: - - dashboard - summary: get list of lint rules - operationId: getPortalLintRules - parameters: - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string - responses: - "200": - description: list of lint rules for portal - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/BoatLintRule' - /api/boat/portals/{portalKey}/products/{productKey}/releases: - get: - tags: - - dashboard - summary: get product releases - operationId: getProductReleases - parameters: - - name: productKey - in: path - description: id of product - required: true - style: simple - explode: false - schema: - type: string - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string - responses: - "200": - description: list of product releases for product - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/BoatProductRelease' - /api/boat/portals/{portalKey}/products/{productKey}/releases/{releaseKey}/specs: - get: - tags: - - dashboard - summary: get specs for product release - operationId: getProductReleaseSpecs - parameters: - - name: releaseKey - in: path - description: key for product release - required: true - style: simple - explode: false - schema: - type: string - - name: productKey - in: path - description: id of product - required: true - style: simple - explode: false - schema: - type: string - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string - responses: - "200": - description: list of specs for product release - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/BoatSpec' - /api/boat/portals/{portalKey}/lint-rules/{lintRuleId}: - post: - tags: - - dashboard - summary: update lint rule for portal - operationId: updatePortalLintRule - parameters: - - name: lintRuleId - in: path - description: id of portals lint rule - required: true - style: simple - explode: false - schema: - type: string - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/BoatLintRule' - responses: - "200": - description: updated successfuly - content: {} - /api/boat/dashboard: - get: - tags: - - dashboard - summary: get list of boat portal dashboards - operationId: getDashboard - responses: - "200": - description: list of boat portal dashboards - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/BoatPortalDashboard' - /api/boat/dashboard/{projectKey}/{productKey}: - get: - tags: - - dashboard - summary: get product for dashboard project - operationId: getProductDashboard - parameters: - - name: projectKey - in: path - description: project idenifier - required: true - style: simple - explode: false - schema: - type: string - - name: productKey - in: path - description: product idenifier - required: true - style: simple - explode: false - schema: - type: string - responses: - "200": - description: product for dashboard - content: - application/json: - schema: - $ref: '#/components/schemas/BoatProduct' - /api/boat/portals/{portalKey}/products/{productKey}/tags: - get: - tags: - - dashboard - summary: get tags for product - operationId: getProductTags - parameters: - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string - - name: productKey - in: path - description: product idenifier - required: true - style: simple - explode: false - schema: - type: string - responses: - "200": - description: list of product tags - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/BoatTag' - ? /api/boat/portals/{portalKey}/products/{productKey}/capabilities/{capabilityKey}/services/{serviceKey}/specs/{specKey}/{version}/download - : get: - tags: - - dashboard - summary: get spec as openapi - operationId: getSpecAsOpenAPI - parameters: - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string - - name: productKey - in: path - description: product identifier - required: true - style: simple - explode: false - schema: - type: string - - name: capabilityKey - in: path - description: capability identifier - required: true - style: simple - explode: false - schema: - type: string - - name: serviceKey - in: path - description: service identifier - required: true - style: simple - explode: false - schema: - type: string - - name: specKey - in: path - description: spec identifier - required: true - style: simple - explode: false - schema: - type: string - - name: version - in: path - description: version of spec - required: true - style: simple - explode: false - schema: - type: string - responses: - "200": - description: openApi of spec - headers: - Content-Disposition: - description: name of file - style: simple - explode: false - schema: - type: string - Cache-Control: - style: simple - explode: false - schema: - type: string - Pragma: - style: simple - explode: false - schema: - type: string - Expires: - style: simple - explode: false - schema: - type: string - content: - application/vnd.oai.openapi: - schema: - $ref: '#/components/schemas/Resource' - ? /api/boat/portals/{portalKey}/products/{productKey}/capabilities/{capabilityKey}/services/{serviceKey}/specs/{specKey}/{version} - : get: - tags: - - dashboard - summary: download spec - operationId: downloadSpec - parameters: - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string - - name: productKey - in: path - description: product identifier - required: true - style: simple - explode: false - schema: - type: string - - name: capabilityKey - in: path - description: capability identifier - required: true - style: simple - explode: false - schema: - type: string - - name: serviceKey - in: path - description: service identifier - required: true - style: simple - explode: false - schema: - type: string - - name: specKey - in: path - description: spec identifier - required: true - style: simple - explode: false - schema: - type: string - - name: version - in: path - description: version of spec - required: true - style: simple - explode: false - schema: - type: string - responses: - "200": - description: spec with open api - content: - application/json: - schema: - $ref: '#/components/schemas/BoatSpec' - /api/boat/portals/{portalKey}/products/{productKey}/diff-report: - get: - tags: - - lint - summary: get lint report for spec - operationId: getApiChangesForSpec - parameters: - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string - - name: productKey - in: path - description: product identifier - required: true - style: simple - explode: false - schema: - type: string - - name: spec1Id - in: query - description: identifies first comparitable api - required: false - style: form - explode: true - schema: - type: string - - name: spec2Id - in: query - description: identifies second comparitable api - required: false - style: form - explode: true - schema: - type: string - responses: - "200": - description: changed openApi - content: - application/json: - schema: - $ref: '#/components/schemas/ChangedOpenApiObject' - /api/boat/portals/{portalKey}/products/{productKey}/diff-report.html: - get: - tags: - - lint - summary: get lint report for spec as html - operationId: getLintReportForSpecAsHtml - parameters: - - name: portalKey - in: path - description: portal idenifier - required: true - style: simple - explode: false - schema: - type: string - - name: productKey - in: path - description: product identifier - required: true - style: simple - explode: false - schema: - type: string - - name: spec1Id - in: query - description: identifies first comparitable api - required: false - style: form - explode: true - schema: - type: string - - name: spec2Id - in: query - description: identifies second comparitable api - required: false - style: form - explode: true - schema: - type: string - responses: - "200": - description: changed openApi as html - content: - application/json: - schema: - type: string - /api/boat/boat-maven-plugin/{sourceId}/upload: - put: - tags: - - upload-plugin - summary: upload and lint specs - operationId: uploadSpec - parameters: - - name: sourceId - in: path - description: source idenifier - required: true - style: simple - explode: false - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/upload-request-body' - required: true - responses: - "200": - description: list of lint reports for specs - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/BoatLintReport' -components: - schemas: - BoatPortal: - type: object - properties: - id: - type: number - key: - type: string - name: - type: string - content: - type: string - createdOn: - $ref: '#/components/schemas/LocalDateTime' - createdBy: - type: string - BoatProduct: - type: object - properties: - portalKey: - type: string - portalName: - type: string - id: - type: number - key: - type: string - name: - type: string - content: - type: string - createdOn: - $ref: '#/components/schemas/LocalDateTime' - createdBy: - type: string - lastLintReport: - $ref: '#/components/schemas/BoatLintReport' - statistics: - $ref: '#/components/schemas/BoatStatistics' - jiraProjectId: - type: string - Pageable: - type: object - properties: - page: - type: integer - size: - type: integer - description: minimal Pageable query parameters - BoatCapability: - type: object - properties: - id: - type: number - key: - type: string - name: - type: string - content: - type: string - createdOn: - $ref: '#/components/schemas/LocalDateTime' - createdBy: - type: string - lastLintReport: - $ref: '#/components/schemas/BoatLintReport' - statistics: - $ref: '#/components/schemas/BoatStatistics' - BoatService: - type: object - properties: - key: - type: string - name: - type: string - description: - type: string - icon: - type: string - color: - type: string - createdOn: - $ref: '#/components/schemas/LocalDateTime' - createdBy: - type: string - statistics: - $ref: '#/components/schemas/BoatStatistics' - BoatSpec: - type: object - properties: - id: - type: number - key: - type: string - name: - type: string - title: - type: string - description: - type: string - icon: - type: string - version: - type: string - grade: - type: string - createdOn: - $ref: '#/components/schemas/LocalDateTime' - createdBy: - type: string - statistics: - $ref: '#/components/schemas/BoatStatistics' - backwardsCompatible: - type: boolean - changes: - $ref: '#/components/schemas/Changes' - capability: - $ref: '#/components/schemas/BoatCapability' - serviceDefinition: - $ref: '#/components/schemas/BoatService' - openApi: - type: string - BoatLintReport: - type: object - properties: - id: - type: number - spec: - $ref: '#/components/schemas/BoatSpec' - name: - type: string - passed: - type: boolean - lintedOn: - $ref: '#/components/schemas/LocalDateTime' - openApi: - type: string - version: - type: string - grade: - type: string - violations: - type: array - items: - $ref: '#/components/schemas/BoatViolation' - hasViolations: - type: boolean - BoatLintRule: - type: object - properties: - id: - type: number - ruleId: - type: string - enabled: - type: boolean - title: - type: string - ruleSet: - type: string - severity: - $ref: '#/components/schemas/Severity' - url: - type: string - format: uri - BoatProductRelease: - type: object - properties: - id: - type: number - key: - type: string - name: - type: string - version: - type: string - releaseDate: - $ref: '#/components/schemas/LocalDateTime' - BoatPortalDashboard: - type: object - properties: - portalId: - type: string - portalKey: - type: string - portalName: - type: string - productId: - type: string - productKey: - type: string - productName: - type: string - numberOfServices: - type: integer - format: int64 - numberOfCapabilities: - type: integer - format: int64 - productDescription: - type: string - lastLintReport: - $ref: '#/components/schemas/BoatLintReport' - statistics: - $ref: '#/components/schemas/BoatStatistics' - BoatTag: - type: object - properties: - name: - type: string - description: - type: string - hide: - type: boolean - color: - type: string - numberOfOccurrences: - type: integer - Resource: - type: array - items: - type: string - format: byte - ChangedOpenApiObject: - type: object - upload-request-body: - type: object - properties: - specs: - type: array - items: - $ref: '#/components/schemas/UploadSpec' - location: - type: string - projectId: - type: string - artifactId: - type: string - version: - type: string - LocalDateTime: - type: string - format: date-time - BoatStatistics: - type: object - properties: - updatedOn: - $ref: '#/components/schemas/LocalDateTime' - mustViolationsCount: - type: integer - format: int64 - shouldViolationsCount: - type: integer - format: int64 - mayViolationsCount: - type: integer - format: int64 - hintViolationsCount: - type: integer - format: int64 - Changes: - type: string - enum: - - NOT_APPLICABLE - - ERROR_COMPARING - - UNCHANGED - - COMPATIBLE - - BREAKING - BoatViolation: - type: object - properties: - rule: - $ref: '#/components/schemas/BoatLintRule' - description: - type: string - severity: - $ref: '#/components/schemas/Severity' - lines: - $ref: '#/components/schemas/IntRange' - pointer: - type: string - Severity: - type: string - enum: - - MUST - - SHOULD - - MAY - - HINT - UploadSpec: - type: object - properties: - fileName: - type: string - openApi: - type: string - key: - type: string - name: - type: string - IntRange: - type: object - properties: - start: - type: integer - endInclusive: - type: integer - examples: {} diff --git a/boat-maven-plugin/src/it/example/boat-generate/java-clients/boat-bay-client/pom.xml b/boat-maven-plugin/src/it/example/boat-generate/java-clients/boat-bay-client/pom.xml deleted file mode 100644 index 4a474f7df..000000000 --- a/boat-maven-plugin/src/it/example/boat-generate/java-clients/boat-bay-client/pom.xml +++ /dev/null @@ -1,105 +0,0 @@ - - - 4.0.0 - - - com.backbase.oss.boat.bay - java-clients - 0.0.1-SNAPSHOT - - - boat-bay-client - - BOAT :: Generate :: Boat Bay Client - - jar - - - ApiClient.java,BeanValidationException.java,RFC3339DateFormat.java,ServerConfiguration.java,ServerVariable.java,StringUtil.java,Authentication.java,HttpBasicAuth.java,HttpBearerAuth.java,ApiKeyAuth.java,ApiException.java,Pair.java - 0.2.1 - - - - - io.swagger - swagger-annotations - - - - - com.fasterxml.jackson.core - jackson-core - - - com.fasterxml.jackson.core - jackson-annotations - - - com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.datatype - jackson-datatype-jsr310 - - - org.openapitools - jackson-databind-nullable - ${jackson-databind-nullable-version} - - - - com.google.code.findbugs - jsr305 - - - org.springframework.data - spring-data-commons - - - - - - - com.backbase.oss - boat-maven-plugin - - - generate-webclient-embedded - generate-sources - - generate - - - ${project.basedir}/boat-bay-api-client-temp/boat-bay-client.yml - java - native - - java8 - - com.backbase.oss.boat.bay.client.model - com.backbase.oss.boat.bay.client.api - false - false - false - false - true - - IntRange = kotlin.ranges.IntRange - - - LocalDateTime = java.time.LocalDateTime - Pageable = org.springframework.data.domain.Pageable - - ${boat-maven-plugin.supportingFilesToGenerate} - - - - - - - - - - diff --git a/boat-maven-plugin/src/it/example/boat-generate/java-clients/pom.xml b/boat-maven-plugin/src/it/example/boat-generate/java-clients/pom.xml index 86d52b218..79f7b2a49 100644 --- a/boat-maven-plugin/src/it/example/boat-generate/java-clients/pom.xml +++ b/boat-maven-plugin/src/it/example/boat-generate/java-clients/pom.xml @@ -21,7 +21,6 @@ pom - boat-bay-client java rest-template-embedded webclient-embedded diff --git a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java index 75e51cc9d..c334ecce9 100644 --- a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java +++ b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java @@ -11,12 +11,10 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; -import org.jetbrains.annotations.NotNull; import org.springframework.expression.Expression; import org.springframework.expression.ExpressionParser; import org.springframework.expression.spel.standard.SpelExpressionParser; import org.zalando.zally.rule.api.Severity; -import org.zalando.zally.rule.api.Violation; import java.io.File; import java.nio.charset.Charset; @@ -84,7 +82,9 @@ private com.backbase.oss.boat.quay.model.BoatLintReport mapBoatBayLintToBoatLint lintReport.setViolations(bayLintReport.getViolations().stream().map(this::mapViolation).collect(Collectors.toList())); lintReport.setFilePath(getFilePath(bayLintReport.getSpec().getName())); - //link to lint report may need updating before release + //link to lint report may need updating before release should perhaps + //be something like this: (link to html lint file) + // http://localhost:63342/backbase-openapi-tools/lint-petstore/output/index.html?_ijt=bh276c3tslp8dkol056oq0h116 log.info("\n\tSpec {}: {}/lint-report/{}/view", bayLintReport.getSpec().getName(), clientBasePath, From 714d27222183da353e68c3fc0dbb49399b027359 Mon Sep 17 00:00:00 2001 From: Sophie Janssens Date: Mon, 15 Mar 2021 10:27:43 +0000 Subject: [PATCH 09/12] Fix: edited comment --- .../src/main/java/com/backbase/oss/boat/BoatBayRadio.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java index c334ecce9..288dc187c 100644 --- a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java +++ b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java @@ -83,8 +83,9 @@ private com.backbase.oss.boat.quay.model.BoatLintReport mapBoatBayLintToBoatLint lintReport.setFilePath(getFilePath(bayLintReport.getSpec().getName())); //link to lint report may need updating before release should perhaps - //be something like this: (link to html lint file) - // http://localhost:63342/backbase-openapi-tools/lint-petstore/output/index.html?_ijt=bh276c3tslp8dkol056oq0h116 + //this link structure is for testing + //be something like this: + // https://boat-bay.proto.backbasecloud.com/lint-reports/repo/digital-banking/lint-report/167 log.info("\n\tSpec {}: {}/lint-report/{}/view", bayLintReport.getSpec().getName(), clientBasePath, From 6b0fc46725202a433004146fb0b96fb66b4b43b7 Mon Sep 17 00:00:00 2001 From: Sophie Janssens Date: Mon, 26 Jul 2021 20:50:06 +0200 Subject: [PATCH 10/12] Feature: boat bay uploads spec through lint mojo --- boat-maven-plugin/pom.xml | 22 +- .../it/example/boat-bay/lint-petstore/pom.xml | 2 +- .../{petstore.yaml => petstore-v2.0.0.yaml} | 0 .../src/it/example/boat-generate/pom.xml | 2 +- boat-maven-plugin/src/it/example/pom.xml | 1 - .../com/backbase/oss/boat/BoatBayRadio.java | 96 +--- .../java/com/backbase/oss/boat/LintMojo.java | 13 +- .../oss/boat/mapper/LintReportMapper.java | 15 + .../boat-bay-client-api.yaml | 322 +++++++++++++ .../com/backbase/oss/boat/BoatRadioTests.java | 48 ++ .../backbase/oss/boat/GenerateMojoTests.java | 2 +- .../com/backbase/oss/boat/GeneratorTests.java | 4 - .../com/backbase/oss/boat/LintMojoTests.java | 17 - .../mock-upload-request-response.json | 426 ++++++++++++++++++ .../oas-examples/petstore-v1.0.0.yaml | 138 ++++++ 15 files changed, 998 insertions(+), 110 deletions(-) rename boat-maven-plugin/src/it/example/boat-bay/lint-petstore/src/main/resources/{petstore.yaml => petstore-v2.0.0.yaml} (100%) create mode 100644 boat-maven-plugin/src/main/java/com/backbase/oss/boat/mapper/LintReportMapper.java create mode 100644 boat-maven-plugin/src/main/resources/boat-bay-api-client-temp/boat-bay-client-api.yaml create mode 100644 boat-maven-plugin/src/test/java/com/backbase/oss/boat/BoatRadioTests.java create mode 100644 boat-maven-plugin/src/test/resources/boat-bay-mock-server/mock-upload-request-response.json create mode 100644 boat-maven-plugin/src/test/resources/oas-examples/petstore-v1.0.0.yaml diff --git a/boat-maven-plugin/pom.xml b/boat-maven-plugin/pom.xml index ba8ab7fa1..18dbe4ba5 100644 --- a/boat-maven-plugin/pom.xml +++ b/boat-maven-plugin/pom.xml @@ -20,7 +20,7 @@ ApiClient.java,BeanValidationException.java,RFC3339DateFormat.java,ServerConfiguration.java,ServerVariable.java,StringUtil.java,Authentication.java,HttpBasicAuth.java,HttpBearerAuth.java,ApiKeyAuth.java,ApiException.java,Pair.java 0.2.1 1.6.2 - + 3.6.0 src/main/java/com/backbase/oss/boat/GenerateMojo.java, @@ -62,7 +62,11 @@ org.apache.commons commons-collections4 - + + com.backbase.buildingblocks + service-sdk-starter-mapping + 13.0.0-cr.18 + org.apache.maven @@ -81,12 +85,17 @@ org.apache.maven.shared maven-common-artifact-filters - + + org.springframework + spring-context + 4.0.6.RELEASE + org.sonatype.plexus plexus-build-api 0.0.7 + org.codehaus.plexus plexus-io @@ -206,6 +215,11 @@ 4.13.1 compile + + org.mock-server + mockserver-netty + 5.11.1 + @@ -257,7 +271,7 @@ generate - ${project.basedir}/src/main/resources/boat-bay-api-client-temp/boat-bay-client.yaml + ${project.basedir}/src/main/resources/boat-bay-api-client-temp/boat-bay-client-api.yaml java true diff --git a/boat-maven-plugin/src/it/example/boat-bay/lint-petstore/pom.xml b/boat-maven-plugin/src/it/example/boat-bay/lint-petstore/pom.xml index 573e60865..22ad5e6c8 100644 --- a/boat-maven-plugin/src/it/example/boat-bay/lint-petstore/pom.xml +++ b/boat-maven-plugin/src/it/example/boat-bay/lint-petstore/pom.xml @@ -35,7 +35,7 @@ url - ${project.basedir}/src/main/resources/petstore.yaml + ${project.basedir}/src/main/resources/petstore-v2.0.0.yaml ${project.basedir}/src/main/resources/output repo-petstore http://localhost:8080 diff --git a/boat-maven-plugin/src/it/example/boat-bay/lint-petstore/src/main/resources/petstore.yaml b/boat-maven-plugin/src/it/example/boat-bay/lint-petstore/src/main/resources/petstore-v2.0.0.yaml similarity index 100% rename from boat-maven-plugin/src/it/example/boat-bay/lint-petstore/src/main/resources/petstore.yaml rename to boat-maven-plugin/src/it/example/boat-bay/lint-petstore/src/main/resources/petstore-v2.0.0.yaml diff --git a/boat-maven-plugin/src/it/example/boat-generate/pom.xml b/boat-maven-plugin/src/it/example/boat-generate/pom.xml index 63fbcf268..e74c5d361 100644 --- a/boat-maven-plugin/src/it/example/boat-generate/pom.xml +++ b/boat-maven-plugin/src/it/example/boat-generate/pom.xml @@ -22,7 +22,7 @@ angular - java-clients + java-server diff --git a/boat-maven-plugin/src/it/example/pom.xml b/boat-maven-plugin/src/it/example/pom.xml index 8359658bd..58f0aa68f 100644 --- a/boat-maven-plugin/src/it/example/pom.xml +++ b/boat-maven-plugin/src/it/example/pom.xml @@ -42,7 +42,6 @@ boat-multiple-executions boat-artifact-input - boat-bay boat-doc boat-export boat-generate diff --git a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java index 288dc187c..5655ce926 100644 --- a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java +++ b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java @@ -4,6 +4,9 @@ import com.backbase.oss.boat.bay.client.api.UploadPluginApi; import com.backbase.oss.boat.bay.client.model.*; import com.backbase.oss.boat.loader.OpenAPILoader; +import com.backbase.oss.boat.mapper.LintReportMapperImpl; +import com.fasterxml.jackson.databind.introspect.TypeResolutionContext.Basic; +import feign.auth.BasicAuthRequestInterceptor; import io.swagger.v3.oas.models.OpenAPI; import kotlin.ranges.IntRange; import lombok.extern.slf4j.Slf4j; @@ -31,14 +34,14 @@ public class BoatBayRadio { private final UploadPluginApi boatbayUploadSpecClient; private final File inputSpec; - private final File output; private String clientBasePath; + private LintReportMapperImpl reportMapper; protected MavenProject project; - public BoatBayRadio(File inputSpec, File output, MavenProject project, String clientBasePath) { + public BoatBayRadio(File inputSpec, MavenProject project, String clientBasePath) { this.project = project; - this.output = output; + this.reportMapper = new LintReportMapperImpl(); this.inputSpec = inputSpec; this.clientBasePath = clientBasePath; @@ -50,17 +53,21 @@ public BoatBayRadio(File inputSpec, File output, MavenProject project, String cl private ApiClient configureApiClient(String clientBasePath){ - if (readTimeout == null) - return new ApiClient().setBasePath(clientBasePath); + if (readTimeout == null){ + BasicAuthRequestInterceptor basicAuthRequestInterceptor = new BasicAuthRequestInterceptor("admin","admin"); + ApiClient apiClient = new ApiClient().setBasePath(clientBasePath); + apiClient.addAuthorization("Basic",basicAuthRequestInterceptor); + return apiClient; + } return new ApiClient().setBasePath(clientBasePath); } + public List upload(String sourceKey ) { + log.debug("uploading specs for source : {}" , sourceKey); - public List upload(String sourceId ) { - log.debug("uploading specs for source : {}" , sourceId); - List boatLintReports = boatbayUploadSpecClient.uploadSpec(sourceId, createRequestBody()); + List boatLintReports = boatbayUploadSpecClient.uploadSpec(sourceKey, createRequestBody()); log.info("\nSpecs linted.Lint reports can be found at:"); @@ -73,20 +80,15 @@ public List upload(String sourc private com.backbase.oss.boat.quay.model.BoatLintReport mapBoatBayLintToBoatLint(BoatLintReport bayLintReport){ - com.backbase.oss.boat.quay.model.BoatLintReport lintReport = new com.backbase.oss.boat.quay.model.BoatLintReport(); - lintReport.setOpenApi(bayLintReport.getOpenApi()); - lintReport.setVersion(bayLintReport.getVersion()); - lintReport.setTitle(bayLintReport.getName()); - lintReport.setAvailableRules(bayLintReport.getViolations().stream().map(BoatViolation::getRule).map(this::mapRule).collect(Collectors.toList())); - lintReport.setViolations(bayLintReport.getViolations().stream().map(this::mapViolation).collect(Collectors.toList())); - lintReport.setFilePath(getFilePath(bayLintReport.getSpec().getName())); + com.backbase.oss.boat.quay.model.BoatLintReport lintReport = reportMapper.bayReportToBoatReport(bayLintReport); + lintReport.setFilePath(getFilePath(lintReport.getFilePath())); //link to lint report may need updating before release should perhaps //this link structure is for testing //be something like this: // https://boat-bay.proto.backbasecloud.com/lint-reports/repo/digital-banking/lint-report/167 - log.info("\n\tSpec {}: {}/lint-report/{}/view", + log.info("\n\tSpec {}: {}lint-report/{}/view", bayLintReport.getSpec().getName(), clientBasePath, bayLintReport.getId()); @@ -94,7 +96,6 @@ private com.backbase.oss.boat.quay.model.BoatLintReport mapBoatBayLintToBoatLint return lintReport; } - private String getFilePath(String fileName) { File inputFile = inputSpec.toPath().resolve(fileName).toFile(); File workingDirectory = new File("."); @@ -111,44 +112,6 @@ private String getFilePath(String fileName) { } - private com.backbase.oss.boat.quay.model.BoatLintRule mapRule(BoatLintRule boatRule){ - com.backbase.oss.boat.quay.model.BoatLintRule boatLintRule = new com.backbase.oss.boat.quay.model.BoatLintRule(); - - boatLintRule.setTitle(boatRule.getTitle()); - boatLintRule.setRuleSet(boatRule.getRuleSet()); - boatLintRule.setIgnored(!boatRule.getEnabled()); - boatLintRule.setUrl(boatRule.getUrl()); - boatLintRule.setSeverity(mapSeverity(boatRule.getSeverity())); - - return boatLintRule; - } - - - private com.backbase.oss.boat.quay.model.BoatViolation mapViolation(BoatViolation boatViolation){ - com.backbase.oss.boat.quay.model.BoatViolation violation = new com.backbase.oss.boat.quay.model.BoatViolation(); - - violation.setDescription(boatViolation.getDescription()); - violation.setRule(mapRule(boatViolation.getRule())); - violation.setSeverity(mapSeverity(boatViolation.getSeverity())); - violation.setLines(mapRange(boatViolation.getLines())); - violation.setPointer(boatViolation.getPointer()); - - return violation; - } - - private IntRange mapRange(com.backbase.oss.boat.bay.client.model.IntRange range){ - - if (range.getEndInclusive()==null){ - return new IntRange(range.getStart(),range.getStart()); - } - return new IntRange(range.getStart(),range.getEndInclusive()); - } - - private Severity mapSeverity(com.backbase.oss.boat.bay.client.model.Severity boatSeverity){ - return Severity.valueOf(boatSeverity.getValue()); - } - - private UploadRequestBody createRequestBody(){ UploadRequestBody requestBody = new UploadRequestBody(); @@ -158,11 +121,6 @@ private UploadRequestBody createRequestBody(){ throw new RuntimeException("unable to load specs", e); } - requestBody.location(output.getParentFile().getPath()); - - if (output == null) - requestBody.location(new File("./target/boat-bay-lint").getAbsolutePath()); - requestBody.projectId(project.getGroupId()); requestBody.setArtifactId(project.getArtifactId()); requestBody.version(project.getVersion()); @@ -203,31 +161,15 @@ private UploadSpec mapToUploadSpec(File spec) { UploadSpec uploadSpec = new UploadSpec(); uploadSpec.fileName(spec.getName()); - + uploadSpec.version(openAPI.getInfo().getVersion()); uploadSpec.openApi(contents); log.debug("uploading api {} with contents {}", spec.getName(),openAPI.getOpenapi()); - uploadSpec.key(getSpecKey(spec)); uploadSpec.name(spec.getName()); return uploadSpec; } - private String getSpecKey(File spec){ - String key; - String spEL; - ExpressionParser parser = new SpelExpressionParser(); - - if(spec.getName().contains("-")){ - spEL = "name.substring(0,name.lastIndexOf('-'))"; - }else - spEL = "name.substring(0,name.lastIndexOf('.'))"; - - Expression value = parser.parseExpression(spEL); - key = value.getValue(spec, String.class); - - return key; - } } diff --git a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/LintMojo.java b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/LintMojo.java index d87340c10..ba56124de 100644 --- a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/LintMojo.java +++ b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/LintMojo.java @@ -37,13 +37,12 @@ public class LintMojo extends AbstractLintMojo { @Parameter(readonly = true, required = true, defaultValue = "${project}") protected MavenProject project; - @Parameter(name = "boatBayUrl", property = "boat.maven.plugin.lint.boatBayUrl") + @Parameter(name = "boatBayUrl", property = "boat.maven.plugin.lint.boatBayUrl", defaultValue ="") private String boatBayUrl; @Parameter(name = "sourceKey") private String sourceKey; - private BoatBayRadio boatBayRadio; @Override public void execute() throws MojoExecutionException, MojoFailureException { @@ -52,9 +51,9 @@ public void execute() throws MojoExecutionException, MojoFailureException { List boatLintReports = null; try { if (sourceKey != null - && (System.getenv().containsKey("boatBayUrl") + && (System.getenv().containsKey("BOAT_BAY_SERVER_URL") || !boatBayUrl.isEmpty())) { - boatLintReports = new BoatBayRadio(inputSpec,output,project, boatBayUrl).upload(sourceKey); + boatLintReports = new BoatBayRadio(getInput(),project, boatBayUrl).upload(sourceKey); }else { boatLintReports = lint(); } @@ -112,6 +111,12 @@ private File getOutput() { return this.output; } + public File getInput(){ + if(input==null){ + input = new File(inputSpec); + } + return input; + } public void setSourceKey(String sourceKey){ this.sourceKey = sourceKey; } diff --git a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/mapper/LintReportMapper.java b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/mapper/LintReportMapper.java new file mode 100644 index 000000000..715909be4 --- /dev/null +++ b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/mapper/LintReportMapper.java @@ -0,0 +1,15 @@ +package com.backbase.oss.boat.mapper; +import com.backbase.oss.boat.quay.model.BoatLintReport; +import com.fasterxml.jackson.core.JsonPointer; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; + +@Mapper(componentModel = "spring") +public interface LintReportMapper { + + @Mapping(target = "title", source = "name") + @Mapping(target = "filePath", source = "spec.name") +// @Mapping(target = "availableRules", source = "") + BoatLintReport bayReportToBoatReport(com.backbase.oss.boat.bay.client.model.BoatLintReport bayReport); + +} diff --git a/boat-maven-plugin/src/main/resources/boat-bay-api-client-temp/boat-bay-client-api.yaml b/boat-maven-plugin/src/main/resources/boat-bay-api-client-temp/boat-bay-client-api.yaml new file mode 100644 index 000000000..b386c1186 --- /dev/null +++ b/boat-maven-plugin/src/main/resources/boat-bay-api-client-temp/boat-bay-client-api.yaml @@ -0,0 +1,322 @@ +openapi: 3.0.0 +info: + title: Boat Bay Upload Server + description: Endpoints for uploading Specs to boat bay + license: + name: Backbase + version: 1.0.0 +servers: +- url: http://boat-bay-server.proto.backbasecloud.com/ +tags: +- name: upload-plugin +paths: + /api/boat/boat-maven-plugin/{sourceKey}/upload: + post: + tags: + - upload-plugin + summary: upload and lint specs + operationId: uploadSpec + parameters: + - name: sourceKey + in: path + description: source identifier + required: true + style: simple + explode: false + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UploadRequestBody' + required: true + responses: + "200": + description: list of lint reports for specs + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/BoatLintReport' +components: + schemas: + BoatProduct: + type: object + properties: + portalKey: + type: string + portalName: + type: string + id: + type: integer + format: int64 + key: + type: string + name: + type: string + content: + type: string + createdOn: + $ref: '#/components/schemas/LocalDateTime' + createdBy: + type: string + lastLintReport: + $ref: '#/components/schemas/BoatLintReport' + statistics: + $ref: '#/components/schemas/BoatStatistics' + jiraProjectId: + type: string + BoatCapability: + type: object + properties: + id: + type: integer + format: int64 + key: + type: string + name: + type: string + content: + type: string + createdOn: + $ref: '#/components/schemas/LocalDateTime' + createdBy: + type: string + services: + type: array + items: + $ref: '#/components/schemas/BoatService' + lastLintReport: + $ref: '#/components/schemas/BoatLintReport' + statistics: + $ref: '#/components/schemas/BoatStatistics' + BoatService: + type: object + properties: + key: + type: string + name: + type: string + description: + type: string + icon: + type: string + color: + type: string + createdOn: + $ref: '#/components/schemas/LocalDateTime' + createdBy: + type: string + statistics: + $ref: '#/components/schemas/BoatStatistics' + capability: + $ref: '#/components/schemas/BoatCapability' + BoatSpec: + type: object + properties: + id: + type: integer + format: int64 + key: + type: string + name: + type: string + title: + type: string + description: + type: string + icon: + type: string + version: + type: string + grade: + type: string + createdOn: + $ref: '#/components/schemas/LocalDateTime' + createdBy: + type: string + statistics: + $ref: '#/components/schemas/BoatStatistics' + backwardsCompatible: + type: boolean + changes: + $ref: '#/components/schemas/Changes' + capability: + $ref: '#/components/schemas/BoatCapability' + serviceDefinition: + $ref: '#/components/schemas/BoatService' + openApi: + type: string + BoatLintReport: + type: object + properties: + id: + type: integer + format: int64 + spec: + $ref: '#/components/schemas/BoatSpec' + name: + type: string + passed: + type: boolean + lintedOn: + $ref: '#/components/schemas/LocalDateTime' + openApi: + type: string + version: + type: string + grade: + type: string + violations: + type: array + items: + $ref: '#/components/schemas/BoatViolation' + hasViolations: + type: boolean + BoatLintRule: + type: object + properties: + id: + type: integer + format: int64 + ruleId: + type: string + enabled: + type: boolean + title: + type: string + ruleSet: + type: string + severity: + $ref: '#/components/schemas/Severity' + url: + type: string + format: uri + BoatProductRelease: + type: object + properties: + id: + type: integer + format: int64 + key: + type: string + name: + type: string + version: + type: string + releaseDate: + $ref: '#/components/schemas/LocalDateTime' + Resource: + type: array + items: + type: string + format: byte + ChangedOpenApiObject: + type: object + UploadRequestBody: + type: object + properties: + specs: + type: array + items: + $ref: '#/components/schemas/UploadSpec' + projectId: + type: string + nullable: false + minLength: 1 + artifactId: + type: string + nullable: false + minLength: 1 + version: + type: string + nullable: false + minLength: 1 + LocalDateTime: + type: string + format: date-time + BoatStatistics: + type: object + properties: + updatedOn: + $ref: '#/components/schemas/LocalDateTime' + mustViolationsCount: + type: integer + format: int64 + shouldViolationsCount: + type: integer + format: int64 + mayViolationsCount: + type: integer + format: int64 + hintViolationsCount: + type: integer + format: int64 + Changes: + type: string + enum: + - INVALID_VERSION + - NOT_APPLICABLE + - ERROR_COMPARING + - UNCHANGED + - COMPATIBLE + - BREAKING + BoatViolation: + type: object + properties: + rule: + $ref: '#/components/schemas/BoatLintRule' + description: + type: string + severity: + $ref: '#/components/schemas/Severity' + lines: + $ref: '#/components/schemas/IntRange' + pointer: + $ref: '#/components/schemas/JsonPointer' + Severity: + type: string + enum: + - MUST + - SHOULD + - MAY + - HINT + UploadSpec: + type: object + properties: + fileName: + type: string + openApi: + type: string + name: + type: string + version: + type: string + JsonPointer: + type: object + properties: + separator: + type: string + default: / + EMPTY: + type: JsonPointer + _nextSegment: + type: JsonPointer + _head: + type: JsonPointer + _asString: + type: string + _matchingPropertyName: + type: string + _matchingElementIndex: + type: int + IntRange: + type: object + properties: + start: + type: integer + endInclusive: + type: integer + examples: {} diff --git a/boat-maven-plugin/src/test/java/com/backbase/oss/boat/BoatRadioTests.java b/boat-maven-plugin/src/test/java/com/backbase/oss/boat/BoatRadioTests.java new file mode 100644 index 000000000..86fd5e1b4 --- /dev/null +++ b/boat-maven-plugin/src/test/java/com/backbase/oss/boat/BoatRadioTests.java @@ -0,0 +1,48 @@ +package com.backbase.oss.boat; + +import static org.mockserver.integration.ClientAndServer.startClientAndServer; + +import java.io.File; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.project.MavenProject; +import org.assertj.core.util.Arrays; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockserver.configuration.ConfigurationProperties; +import org.mockserver.integration.ClientAndServer; + +public class BoatRadioTests { + private ClientAndServer boatBayMockServer; + private final String sourcekey = "repo-petstore"; + + @BeforeEach + public void setUp(){ + String initializationJsonPath = getClass().getResource("/boat-bay-mock-server/mock-upload-request-response.json").getPath(); + ConfigurationProperties.initializationJsonPath(initializationJsonPath); + boatBayMockServer = startClientAndServer(8080); + + + } + @Test + void testLintUpload() throws MojoFailureException, MojoExecutionException { + + LintMojo lintMojo = new LintMojo(); + lintMojo.project = new MavenProject(); + lintMojo.project.setGroupId("repo.backbase.com"); + lintMojo.project.setArtifactId("petstore"); + lintMojo.project.setVersion("1.0.0-SNAPSHOT"); + lintMojo.project.setFile(getFile("/oas-examples")); + lintMojo.setSourceKey(sourcekey); + lintMojo.setBoatBayUrl("http://localhost:8080/"); + lintMojo.output= new File("/Users/sophiej/Documents/Projects/opensauce/fresh-water-boat/backbase-openapi-tools/boat-maven-plugin/src/test/resources/upload-reports"); + lintMojo.setIgnoreRules(Arrays.array("219", "105", "104", "151", "134", "115")); + lintMojo.setInput(getFile("/oas-examples/petstore-v1.0.0.yaml")); + lintMojo.setFailOnWarning(false); + lintMojo.execute(); + } + private File getFile(String fileName) { + return new File(getClass().getResource(fileName).getFile()); + } + +} diff --git a/boat-maven-plugin/src/test/java/com/backbase/oss/boat/GenerateMojoTests.java b/boat-maven-plugin/src/test/java/com/backbase/oss/boat/GenerateMojoTests.java index 31457400a..b009814c7 100644 --- a/boat-maven-plugin/src/test/java/com/backbase/oss/boat/GenerateMojoTests.java +++ b/boat-maven-plugin/src/test/java/com/backbase/oss/boat/GenerateMojoTests.java @@ -94,7 +94,7 @@ void useJavaBoatForWebClientEmbedded() throws MojoExecutionException, MojoFailur private T configure(T mojo, String generatorName) { mojo.buildContext = buildContext; mojo.project = project; - mojo.inputSpec = "src/test/resources/oas-examples/petstore.yaml"; + mojo.inputSpec = "src/test/resources/oas-examples/petstore-v1.0.0.yaml"; mojo.output = new File("target/generate-mojo-tests"); mojo.generatorName = generatorName; diff --git a/boat-maven-plugin/src/test/java/com/backbase/oss/boat/GeneratorTests.java b/boat-maven-plugin/src/test/java/com/backbase/oss/boat/GeneratorTests.java index 839e21df8..00d23f2ab 100644 --- a/boat-maven-plugin/src/test/java/com/backbase/oss/boat/GeneratorTests.java +++ b/boat-maven-plugin/src/test/java/com/backbase/oss/boat/GeneratorTests.java @@ -5,14 +5,10 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.project.MavenProject; -import org.apache.maven.shared.invoker.*; import org.codehaus.plexus.logging.console.ConsoleLogger; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.CsvSource; -import org.junit.jupiter.params.provider.ValueSource; import org.sonatype.plexus.build.incremental.DefaultBuildContext; import java.io.File; import java.util.*; diff --git a/boat-maven-plugin/src/test/java/com/backbase/oss/boat/LintMojoTests.java b/boat-maven-plugin/src/test/java/com/backbase/oss/boat/LintMojoTests.java index dc553c914..16e609f37 100644 --- a/boat-maven-plugin/src/test/java/com/backbase/oss/boat/LintMojoTests.java +++ b/boat-maven-plugin/src/test/java/com/backbase/oss/boat/LintMojoTests.java @@ -86,23 +86,6 @@ void testExceptionsWithInvalidFile() { assertDoesNotThrow(lintMojo::execute); } - @Test - void testLintUpload() throws MojoFailureException, MojoExecutionException { - LintMojo lintMojo = new LintMojo(); - lintMojo.project = new MavenProject(); - lintMojo.project.setGroupId("repo.backbase.com"); - lintMojo.project.setArtifactId("petstore"); - lintMojo.project.setVersion("1.0.0"); - lintMojo.project.setFile(getFile("/oas-examples")); - lintMojo.setSourceKey("repo-petstore"); - lintMojo.setBoatBayUrl("http://localhost:8080"); - lintMojo.output= new File("/Users/sophiej/Documents/Projects/opensauce/fresh-water-boat/backbase-openapi-tools/boat-maven-plugin/src/test/resources/upload-reports"); - lintMojo.setIgnoreRules(Arrays.array("219", "105", "104", "151", "134", "115")); - lintMojo.setInput(getFile("/oas-examples/petstore.yaml")); - lintMojo.setFailOnWarning(false); - lintMojo.execute(); - } - private File getFile(String fileName) { return new File(getClass().getResource(fileName).getFile()); diff --git a/boat-maven-plugin/src/test/resources/boat-bay-mock-server/mock-upload-request-response.json b/boat-maven-plugin/src/test/resources/boat-bay-mock-server/mock-upload-request-response.json new file mode 100644 index 000000000..7fa8779de --- /dev/null +++ b/boat-maven-plugin/src/test/resources/boat-bay-mock-server/mock-upload-request-response.json @@ -0,0 +1,426 @@ +[ + { + "httpRequest": { + "method": "POST", + "path": "/api/boat/boat-maven-plugin/repo-petstore/upload" + }, + "httpResponse": { + "statusCode": 200, + "body": [ + { + "id": 2, + "spec": { + "id": 1, + "key": "petstore", + "name": "petstore-v1.0.0.yaml", + "title": "Swagger Petstore", + "version": "1.0.0", + "createdOn": "2021-11-17T14:45:10Z", + "createdBy": "MavenPluginUpload", + "changes": "NOT_APPLICABLE", + "capability": { + "id": 1, + "key": "backbase-com", + "name": "backbase-com" + }, + "serviceDefinition": { + "key": "petstore", + "name": "petstore", + "capability": { + "id": 1, + "key": "backbase-com", + "name": "backbase-com" + } + } + }, + "name": "petstore-v1.0.0.yaml", + "lintedOn": "2021-11-17T14:50:10Z", + "openApi": "openapi: \"3.0.0\"\ninfo:\n version: 1.0.0\n title: Swagger Petstore\n license:\n name: MIT\nservers:\n - url: http://petstore.swagger.io/v1\npaths:\n /pets:\n get:\n summary: List all pets\n operationId: listPets\n tags:\n - pets\n parameters:\n - name: limit\n in: query\n description: How many items to return at one time (max 100)\n required: false\n schema:\n type: integer\n format: int32\n responses:\n \u0027200\u0027:\n description: A paged array of pets\n headers:\n x-next:\n description: A link to the next page of responses\n schema:\n type: string\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/Pets\"\n text/csv:\n schema:\n type: string\n 500:\n content:\n application/json:\n schema:\n $ref: \u0027#/components/schemas/InternalServerError\u0027\n description: InternalServerError\n default:\n description: unexpected error\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/Error\"\n post:\n summary: Create a pet\n operationId: createPets\n tags:\n - pets\n responses:\n \u0027201\u0027:\n description: Null response\n default:\n description: unexpected error\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/Error\"\n /pets/{petId}:\n get:\n summary: Info for a specific pet\n operationId: showPetById\n tags:\n - pets\n parameters:\n - name: petId\n in: path\n required: true\n description: The id of the pet to retrieve\n schema:\n type: string\n responses:\n \u0027200\u0027:\n description: Expected response to a valid request\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/Pet\"\n default:\n description: unexpected error\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/Error\"\n /no-schema:\n get:\n summary: No Schema\n operationId: getNoSchema\n tags:\n - pets\n responses:\n 200:\n description: A response that does not specify a schema\n content:\n application/json: {}\ncomponents:\n schemas:\n Pet:\n type: object\n required:\n - id\n - name\n properties:\n id:\n type: integer\n format: int64\n name:\n type: string\n tag:\n type: string\n Pets:\n type: array\n items:\n $ref: \"#/components/schemas/Pet\"\n Error:\n type: object\n required:\n - code\n - message\n properties:\n code:\n type: integer\n format: int32\n message:\n type: string\n InternalServerError:\n type: object\n required:\n - message\n properties:\n message:\n type: string", + "version": "1.0.0", + "grade": "F", + "violations": [ + { + "rule": { + "id": 21, + "ruleId": "B007", + "enabled": true, + "title": "Check prefix for paths", + "ruleSet": "BoatRuleSet", + "severity": "MUST", + "url": "https://backbase.github.io/backbase-openapi-tools/rules.md#b007-check-prefix-for-paths" + }, + "description": "Incorrect path prefix: pets. Correct values are [client-api, service-api, integration-api]", + "severity": "MUST", + "lines": { + "first": 10, + "last": 65, + "step": 1 + }, + "pointer": { + "_nextSegment": { + "_nextSegment": { + "_asString": "", + "_matchingPropertyName": "", + "_matchingElementIndex": -1 + }, + "_asString": "/~1pets", + "_matchingPropertyName": "/pets", + "_matchingElementIndex": -1 + }, + "_asString": "/paths/~1pets", + "_matchingPropertyName": "paths", + "_matchingElementIndex": -1 + } + }, + { + "rule": { + "id": 20, + "ruleId": "B006", + "enabled": true, + "title": "Check info block description format.", + "ruleSet": "BoatRuleSet", + "severity": "MUST", + "url": "https://backbase.github.io/backbase-openapi-tools/rules.md#b006-check-info-block-description-format-" + }, + "description": "description is a required value", + "severity": "MUST", + "lines": { + "first": 1, + "last": 1, + "step": 1 + }, + "pointer": { + "_nextSegment": { + "_nextSegment": { + "_nextSegment": { + "_asString": "", + "_matchingPropertyName": "", + "_matchingElementIndex": -1 + }, + "_asString": "/description", + "_matchingPropertyName": "description", + "_matchingElementIndex": -1 + }, + "_asString": "/info/description", + "_matchingPropertyName": "info", + "_matchingElementIndex": -1 + }, + "_asString": "/openapi/info/description", + "_matchingPropertyName": "openapi", + "_matchingElementIndex": -1 + } + }, + { + "rule": { + "id": 13, + "ruleId": "B008", + "enabled": true, + "title": "Check x-icon value in the info block", + "ruleSet": "BoatRuleSet", + "severity": "SHOULD", + "url": "https://backbase.github.io/backbase-openapi-tools/rules.md#b008-check-x-icon-value-in-the-info-block" + }, + "description": "x-icon should be provided in the info block with the assigned value for the API", + "severity": "SHOULD", + "lines": { + "first": 1, + "last": 1, + "step": 1 + }, + "pointer": { + "_nextSegment": { + "_nextSegment": { + "_nextSegment": { + "_asString": "", + "_matchingPropertyName": "", + "_matchingElementIndex": -1 + }, + "_asString": "/x-icon", + "_matchingPropertyName": "x-icon", + "_matchingElementIndex": -1 + }, + "_asString": "/info/x-icon", + "_matchingPropertyName": "info", + "_matchingElementIndex": -1 + }, + "_asString": "/openapi/info/x-icon", + "_matchingPropertyName": "openapi", + "_matchingElementIndex": -1 + } + }, + { + "rule": { + "id": 18, + "ruleId": "B004", + "enabled": true, + "title": "Check info block tags allowed.", + "ruleSet": "BoatRuleSet", + "severity": "MUST", + "url": "https://backbase.github.io/backbase-openapi-tools/rules.md#b004-check-info-block-tags-allowed-" + }, + "description": "tags are required", + "severity": "MUST", + "lines": { + "first": 1, + "last": 1, + "step": 1 + }, + "pointer": { + "_nextSegment": { + "_nextSegment": { + "_nextSegment": { + "_asString": "", + "_matchingPropertyName": "", + "_matchingElementIndex": -1 + }, + "_asString": "/tags", + "_matchingPropertyName": "tags", + "_matchingElementIndex": -1 + }, + "_asString": "/info/tags", + "_matchingPropertyName": "info", + "_matchingElementIndex": -1 + }, + "_asString": "/openapi/info/tags", + "_matchingPropertyName": "openapi", + "_matchingElementIndex": -1 + } + }, + { + "rule": { + "id": 15, + "ruleId": "B001", + "enabled": true, + "title": "No license information allowed.", + "ruleSet": "BoatRuleSet", + "severity": "MUST", + "url": "https://backbase.github.io/backbase-openapi-tools/rules.md#b001-no-license-information-allowed-" + }, + "description": "OpenAPI must not contain a license because it\u0027s covered by the License Agreement we already negotiate with customers. ", + "severity": "MUST", + "lines": { + "first": 1, + "last": 1, + "step": 1 + }, + "pointer": { + "_nextSegment": { + "_nextSegment": { + "_nextSegment": { + "_asString": "", + "_matchingPropertyName": "", + "_matchingElementIndex": -1 + }, + "_asString": "/version", + "_matchingPropertyName": "version", + "_matchingElementIndex": -1 + }, + "_asString": "/info/version", + "_matchingPropertyName": "info", + "_matchingElementIndex": -1 + }, + "_asString": "/openapi/info/version", + "_matchingPropertyName": "openapi", + "_matchingElementIndex": -1 + } + }, + { + "rule": { + "id": 23, + "ruleId": "M0012", + "enabled": true, + "title": "Open API Version must be set to the correct version", + "ruleSet": "BoatRuleSet", + "severity": "MUST", + "url": "https://backbase.github.io/backbase-openapi-tools/rules.md#m0012-open-api-version-must-be-set-to-the-correct-version" + }, + "description": "OpenAPI specification version must be [3.0.3, 3.0.4]. It\u0027s now set to `3.0.0`", + "severity": "MUST", + "lines": { + "first": 1, + "last": 1, + "step": 1 + }, + "pointer": { + "_nextSegment": { + "_asString": "", + "_matchingPropertyName": "", + "_matchingElementIndex": -1 + }, + "_asString": "/openapi", + "_matchingPropertyName": "openapi", + "_matchingElementIndex": -1 + } + }, + { + "rule": { + "id": 21, + "ruleId": "B007", + "enabled": true, + "title": "Check prefix for paths", + "ruleSet": "BoatRuleSet", + "severity": "MUST", + "url": "https://backbase.github.io/backbase-openapi-tools/rules.md#b007-check-prefix-for-paths" + }, + "description": "Incorrect path prefix: pets. Correct values are [client-api, service-api, integration-api]", + "severity": "MUST", + "lines": { + "first": 65, + "last": 91, + "step": 1 + }, + "pointer": { + "_nextSegment": { + "_nextSegment": { + "_asString": "", + "_matchingPropertyName": "", + "_matchingElementIndex": -1 + }, + "_asString": "/~1pets~1{petId}", + "_matchingPropertyName": "/pets/{petId}", + "_matchingElementIndex": -1 + }, + "_asString": "/paths/~1pets~1{petId}", + "_matchingPropertyName": "paths", + "_matchingElementIndex": -1 + } + }, + { + "rule": { + "id": 21, + "ruleId": "B007", + "enabled": true, + "title": "Check prefix for paths", + "ruleSet": "BoatRuleSet", + "severity": "MUST", + "url": "https://backbase.github.io/backbase-openapi-tools/rules.md#b007-check-prefix-for-paths" + }, + "description": "Incorrect path prefix: no-schema. Correct values are [client-api, service-api, integration-api]", + "severity": "MUST", + "lines": { + "first": 91, + "last": 102, + "step": 1 + }, + "pointer": { + "_nextSegment": { + "_nextSegment": { + "_asString": "", + "_matchingPropertyName": "", + "_matchingElementIndex": -1 + }, + "_asString": "/~1no-schema", + "_matchingPropertyName": "/no-schema", + "_matchingElementIndex": -1 + }, + "_asString": "/paths/~1no-schema", + "_matchingPropertyName": "paths", + "_matchingElementIndex": -1 + } + }, + { + "rule": { + "id": 22, + "ruleId": "B009", + "enabled": true, + "title": "Check prefix for paths should contain version.", + "ruleSet": "BoatRuleSet", + "severity": "MUST", + "url": "https://backbase.github.io/backbase-openapi-tools/rules.md#b009-check-prefix-for-paths-should-contain-version-" + }, + "description": "URL should contain version number", + "severity": "MUST", + "lines": { + "first": 10, + "last": 65, + "step": 1 + }, + "pointer": { + "_nextSegment": { + "_nextSegment": { + "_asString": "", + "_matchingPropertyName": "", + "_matchingElementIndex": -1 + }, + "_asString": "/~1pets", + "_matchingPropertyName": "/pets", + "_matchingElementIndex": -1 + }, + "_asString": "/paths/~1pets", + "_matchingPropertyName": "paths", + "_matchingElementIndex": -1 + } + }, + { + "rule": { + "id": 22, + "ruleId": "B009", + "enabled": true, + "title": "Check prefix for paths should contain version.", + "ruleSet": "BoatRuleSet", + "severity": "MUST", + "url": "https://backbase.github.io/backbase-openapi-tools/rules.md#b009-check-prefix-for-paths-should-contain-version-" + }, + "description": "URL should contain version number", + "severity": "MUST", + "lines": { + "first": 65, + "last": 91, + "step": 1 + }, + "pointer": { + "_nextSegment": { + "_nextSegment": { + "_asString": "", + "_matchingPropertyName": "", + "_matchingElementIndex": -1 + }, + "_asString": "/~1pets~1{petId}", + "_matchingPropertyName": "/pets/{petId}", + "_matchingElementIndex": -1 + }, + "_asString": "/paths/~1pets~1{petId}", + "_matchingPropertyName": "paths", + "_matchingElementIndex": -1 + } + }, + { + "rule": { + "id": 22, + "ruleId": "B009", + "enabled": true, + "title": "Check prefix for paths should contain version.", + "ruleSet": "BoatRuleSet", + "severity": "MUST", + "url": "https://backbase.github.io/backbase-openapi-tools/rules.md#b009-check-prefix-for-paths-should-contain-version-" + }, + "description": "URL should contain version number", + "severity": "MUST", + "lines": { + "first": 91, + "last": 102, + "step": 1 + }, + "pointer": { + "_nextSegment": { + "_nextSegment": { + "_asString": "", + "_matchingPropertyName": "", + "_matchingElementIndex": -1 + }, + "_asString": "/~1no-schema", + "_matchingPropertyName": "/no-schema", + "_matchingElementIndex": -1 + }, + "_asString": "/paths/~1no-schema", + "_matchingPropertyName": "paths", + "_matchingElementIndex": -1 + } + } + ] + } + ] + + } + } +] \ No newline at end of file diff --git a/boat-maven-plugin/src/test/resources/oas-examples/petstore-v1.0.0.yaml b/boat-maven-plugin/src/test/resources/oas-examples/petstore-v1.0.0.yaml new file mode 100644 index 000000000..137eaff93 --- /dev/null +++ b/boat-maven-plugin/src/test/resources/oas-examples/petstore-v1.0.0.yaml @@ -0,0 +1,138 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: Swagger Petstore + license: + name: MIT +servers: + - url: http://petstore.swagger.io/v1 +paths: + /pets: + get: + summary: List all pets + operationId: listPets + tags: + - pets + parameters: + - name: limit + in: query + description: How many items to return at one time (max 100) + required: false + schema: + type: integer + format: int32 + responses: + '200': + description: A paged array of pets + headers: + x-next: + description: A link to the next page of responses + schema: + type: string + content: + application/json: + schema: + $ref: "#/components/schemas/Pets" + text/csv: + schema: + type: string + 500: + content: + application/json: + schema: + $ref: '#/components/schemas/InternalServerError' + description: InternalServerError + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + summary: Create a pet + operationId: createPets + tags: + - pets + responses: + '201': + description: Null response + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /pets/{petId}: + get: + summary: Info for a specific pet + operationId: showPetById + tags: + - pets + parameters: + - name: petId + in: path + required: true + description: The id of the pet to retrieve + schema: + type: string + responses: + '200': + description: Expected response to a valid request + content: + application/json: + schema: + $ref: "#/components/schemas/Pet" + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /no-schema: + get: + summary: No Schema + operationId: getNoSchema + tags: + - pets + responses: + 200: + description: A response that does not specify a schema + content: + application/json: {} +components: + schemas: + Pet: + type: object + required: + - id + - name + properties: + id: + type: integer + format: int64 + name: + type: string + tag: + type: string + Pets: + type: array + items: + $ref: "#/components/schemas/Pet" + Error: + type: object + required: + - code + - message + properties: + code: + type: integer + format: int32 + message: + type: string + InternalServerError: + type: object + required: + - message + properties: + message: + type: string \ No newline at end of file From 1b1a78a28696d451a6a4eddbbed95933fd678f7b Mon Sep 17 00:00:00 2001 From: Sophie Janssens Date: Mon, 26 Jul 2021 23:23:22 +0200 Subject: [PATCH 11/12] fix: got rid of ssdk dependency --- boat-maven-plugin/pom.xml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/boat-maven-plugin/pom.xml b/boat-maven-plugin/pom.xml index 18dbe4ba5..61026c46a 100644 --- a/boat-maven-plugin/pom.xml +++ b/boat-maven-plugin/pom.xml @@ -28,6 +28,8 @@ ${basedir}/../${aggregate.report.dir} + 1.4.2.Final + reuseReports ${project.basedir}/target/jacoco-it.exec @@ -63,9 +65,15 @@ commons-collections4 - com.backbase.buildingblocks - service-sdk-starter-mapping - 13.0.0-cr.18 + org.mapstruct + mapstruct + ${org.mapstruct.version} + + + org.mapstruct + mapstruct-processor + ${org.mapstruct.version} + compile From 7fddda583f6e2c44a992f60ddbdeffc01b101478 Mon Sep 17 00:00:00 2001 From: Sophie Janssens Date: Wed, 28 Jul 2021 22:40:31 +0200 Subject: [PATCH 12/12] fix: got rid authorisation --- .../src/main/java/com/backbase/oss/boat/BoatBayRadio.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java index 5655ce926..82fedbad0 100644 --- a/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java +++ b/boat-maven-plugin/src/main/java/com/backbase/oss/boat/BoatBayRadio.java @@ -56,7 +56,7 @@ private ApiClient configureApiClient(String clientBasePath){ if (readTimeout == null){ BasicAuthRequestInterceptor basicAuthRequestInterceptor = new BasicAuthRequestInterceptor("admin","admin"); ApiClient apiClient = new ApiClient().setBasePath(clientBasePath); - apiClient.addAuthorization("Basic",basicAuthRequestInterceptor); +// apiClient.addAuthorization("Basic",basicAuthRequestInterceptor); return apiClient; }