From 477d62c5c54d0b0f99822d2bbd87b85c7556205d Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Tue, 1 Jun 2021 07:40:48 +0000 Subject: [PATCH 01/27] [version bump] new dev version --- boat-engine/pom.xml | 2 +- boat-maven-plugin/pom.xml | 2 +- boat-quay/boat-quay-lint/pom.xml | 2 +- boat-quay/boat-quay-rules/pom.xml | 2 +- boat-quay/pom.xml | 2 +- boat-scaffold/pom.xml | 4 ++-- boat-terminal/pom.xml | 2 +- boat-trail-resources/pom.xml | 2 +- pom.xml | 2 +- tests/pom.xml | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/boat-engine/pom.xml b/boat-engine/pom.xml index d2db98496..7b72c7e2b 100644 --- a/boat-engine/pom.xml +++ b/boat-engine/pom.xml @@ -5,7 +5,7 @@ com.backbase.oss backbase-openapi-tools - 0.14.3-SNAPSHOT + 0.14.4-SNAPSHOT boat-engine jar diff --git a/boat-maven-plugin/pom.xml b/boat-maven-plugin/pom.xml index baa0b2ae5..84c671601 100644 --- a/boat-maven-plugin/pom.xml +++ b/boat-maven-plugin/pom.xml @@ -6,7 +6,7 @@ com.backbase.oss backbase-openapi-tools - 0.14.3-SNAPSHOT + 0.14.4-SNAPSHOT boat-maven-plugin diff --git a/boat-quay/boat-quay-lint/pom.xml b/boat-quay/boat-quay-lint/pom.xml index b18781a9d..3967741b5 100644 --- a/boat-quay/boat-quay-lint/pom.xml +++ b/boat-quay/boat-quay-lint/pom.xml @@ -5,7 +5,7 @@ com.backbase.oss boat-quay - 0.14.3-SNAPSHOT + 0.14.4-SNAPSHOT boat-quay-lint jar diff --git a/boat-quay/boat-quay-rules/pom.xml b/boat-quay/boat-quay-rules/pom.xml index 8424d350b..2d13fd3d5 100644 --- a/boat-quay/boat-quay-rules/pom.xml +++ b/boat-quay/boat-quay-rules/pom.xml @@ -5,7 +5,7 @@ com.backbase.oss boat-quay - 0.14.3-SNAPSHOT + 0.14.4-SNAPSHOT boat-quay-rules jar diff --git a/boat-quay/pom.xml b/boat-quay/pom.xml index b422ff5a5..dcf02d835 100644 --- a/boat-quay/pom.xml +++ b/boat-quay/pom.xml @@ -5,7 +5,7 @@ com.backbase.oss backbase-openapi-tools - 0.14.3-SNAPSHOT + 0.14.4-SNAPSHOT diff --git a/boat-scaffold/pom.xml b/boat-scaffold/pom.xml index afe6339a3..f195aca86 100644 --- a/boat-scaffold/pom.xml +++ b/boat-scaffold/pom.xml @@ -5,7 +5,7 @@ com.backbase.oss backbase-openapi-tools - 0.14.3-SNAPSHOT + 0.14.4-SNAPSHOT boat-scaffold @@ -86,7 +86,7 @@ com.backbase.oss boat-trail-resources - 0.14.3-SNAPSHOT + 0.14.4-SNAPSHOT test diff --git a/boat-terminal/pom.xml b/boat-terminal/pom.xml index edc035544..9dd36d1ef 100644 --- a/boat-terminal/pom.xml +++ b/boat-terminal/pom.xml @@ -5,7 +5,7 @@ com.backbase.oss backbase-openapi-tools - 0.14.3-SNAPSHOT + 0.14.4-SNAPSHOT boat-terminal diff --git a/boat-trail-resources/pom.xml b/boat-trail-resources/pom.xml index 88527418d..7fa10780d 100644 --- a/boat-trail-resources/pom.xml +++ b/boat-trail-resources/pom.xml @@ -5,7 +5,7 @@ com.backbase.oss backbase-openapi-tools - 0.14.3-SNAPSHOT + 0.14.4-SNAPSHOT boat-trail-resources diff --git a/pom.xml b/pom.xml index ebc174223..afc95bd36 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.backbase.oss backbase-openapi-tools - 0.14.3-SNAPSHOT + 0.14.4-SNAPSHOT pom Backbase Open Api Tools will help you converting RAML to OpenAPI plus many more diff --git a/tests/pom.xml b/tests/pom.xml index 9f52738f6..f29078c87 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -5,7 +5,7 @@ com.backbase.oss backbase-openapi-tools - 0.14.3-SNAPSHOT + 0.14.4-SNAPSHOT tests From ec4b07f87c1e345b0e8b66954d4b0afbf8e18ede Mon Sep 17 00:00:00 2001 From: Sophie Janssens Date: Wed, 2 Jun 2021 13:26:15 +0200 Subject: [PATCH 02/27] Fix: added documentation for artifact input feature --- boat-maven-plugin/README.md | 59 +++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 3 deletions(-) diff --git a/boat-maven-plugin/README.md b/boat-maven-plugin/README.md index baa931737..0d01cbd92 100644 --- a/boat-maven-plugin/README.md +++ b/boat-maven-plugin/README.md @@ -23,6 +23,8 @@ defined on openapi-generator-maven-plugin can be applied here too. Boat maven plugin uses slightly modified templates for html, java and webclient that help generate specs and clients that work best in a Backbase projects. +All inputSpec parameters for this goal may additionally be configured as an artifact. See [Example inputMavenArtifact parameter](#example-inputMavenArtifact-parameter) or integration tests for examples. + ## boat:generate-spring-boot-embedded Same with `generate` but with opinionated defaults for Spring @@ -152,7 +154,11 @@ Available parameters: inputSpec Required: true Input spec directory or file. - + Optionaly inputMavenArtifact parameter can be used instead to configure an artifact input. + + inputMavenArtifact + Input spec artifact + output (Default: ${project.build.directory}/boat-lint-reports) Output directory for lint reports. @@ -171,12 +177,15 @@ Example: ${ignored-lint-rules} true + +To see details and an example of inputMavenArtifact: + [Example inputMavenArtifact parameter](#example-inputMavenArtifact-parameter) To see details about this goal: mvn help:describe -DgroupId=com.backbase.oss -DartifactId=boat-maven-plugin -Dgoal=lint -Ddetail` - - + + ## boat:bundle Bundles a spec by resolving external references. @@ -321,3 +330,47 @@ Configuration example ``` + +## Example inputMavenArtifact parameter + +Example: + +```$xml + + com.backbase.oss.boat.example + openapi-zips + 1.0.0-SNAPSHOT + api + zip + presentation-client-api/openapi.yaml + +``` + +Parameters: + + groupId + Required: true + Input artifacts groupId + artifactId + Required: true + Input artifacts artifactId + version + Required: true + Input artifacts version + classifier + Required: true + Input artifacts classifier (must be api) + type + Required: true + Input artifacts type (must be zip) + fileName + Required: true + directory or file in artifact to be processed by goal + + +This parameter is available as a replacement for the inputSpec parameter in goals [generate](#boat:generate) and [lint](#boat:lint). + +It downloads a copy of the artifact if it is not already present, and uses a specified spec (or directory of specs) +from the artifact as the inputSpec for the goal. + +More examples can be found in integration tests. \ No newline at end of file From cbc6b61db6f4354b88d8d79b6102386655f11b78 Mon Sep 17 00:00:00 2001 From: Sophie Janssens Date: Mon, 7 Jun 2021 14:24:47 +0200 Subject: [PATCH 03/27] Fix: link to relevant it tests for config examples --- boat-maven-plugin/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boat-maven-plugin/README.md b/boat-maven-plugin/README.md index 0d01cbd92..0e340c274 100644 --- a/boat-maven-plugin/README.md +++ b/boat-maven-plugin/README.md @@ -23,7 +23,7 @@ defined on openapi-generator-maven-plugin can be applied here too. Boat maven plugin uses slightly modified templates for html, java and webclient that help generate specs and clients that work best in a Backbase projects. -All inputSpec parameters for this goal may additionally be configured as an artifact. See [Example inputMavenArtifact parameter](#example-inputMavenArtifact-parameter) or integration tests for examples. +All inputSpec parameters for this goal may additionally be configured as an artifact. See [Example inputMavenArtifact parameter](#example-inputMavenArtifact-parameter) or [integration tests](https://github.com/Backbase/backbase-openapi-tools/tree/main/boat-maven-plugin/src/it/example/boat-artifact-input) for examples. ## boat:generate-spring-boot-embedded From e403af91109179ae69a1246f31f83934846ca143 Mon Sep 17 00:00:00 2001 From: Bart Veenstra Date: Mon, 14 Jun 2021 18:00:14 +0200 Subject: [PATCH 04/27] BOAT MARINA. Multiple Docs --- .../oss/codegen/BoatDefaultGenerator.java | 6 + .../oss/codegen/BoatStaticDocsGenerator.java | 190 + .../oss/codegen/doc/BoatDocsGenerator.java | 158 +- .../oss/codegen/marina/BoatMarinaConfig.java | 4 + .../codegen/marina/BoatMarinaGenerator.java | 77 + .../org.openapitools.codegen.CodegenConfig | 1 + .../templates/boat-marina/api.js.mustache | 6 + .../templates/boat-marina/backbase-logo.svg | 33 + .../boat-marina/css/jsonschemaview.css | 210 + .../boat-marina/css/jsontreeviewer.css | 165 + .../templates/boat-marina/css/prettify.css | 101 + .../templates/boat-marina/css/response.css | 89 + .../main/templates/boat-marina/css/styles.css | 874 + .../templates/boat-marina/header.mustache | 10 + .../templates/boat-marina/index.js.mustache | 30 + .../main/templates/boat-marina/index.mustache | 413 + .../boat-marina/js/json_stringify_safe.js | 25 + .../templates/boat-marina/js/jsonformatter.js | 961 + .../boat-marina/js/jsonschema-ref-parser.js | 17780 ++++++++++++++++ .../boat-marina/js/jsonschemamergeallof.js | 7531 +++++++ .../boat-marina/js/jsonschemaview.js | 817 + .../boat-marina/js/jsontreeviewer.js | 819 + .../main/templates/boat-marina/js/marked.js | 6 + .../main/templates/boat-marina/js/prettify.js | 30 + .../templates/boat-marina/js/webfontloader.js | 17 + .../boat-marina/licenseInfo.mustache | 11 + .../templates/boat-marina/model.js.mustache | 1 + .../main/templates/boat-marina/param.mustache | 71 + .../templates/boat-marina/paramB.mustache | 93 + .../templates/boat-marina/response.mustache | 116 + .../templates/boat-marina/sidenav.mustache | 65 + .../oss/codegen/doc/BoatDocsTest.java | 11 +- .../oss/codegen/marina/BoatMarinaTest.java | 84 + 33 files changed, 30642 insertions(+), 163 deletions(-) create mode 100644 boat-scaffold/src/main/java/com/backbase/oss/codegen/BoatDefaultGenerator.java create mode 100644 boat-scaffold/src/main/java/com/backbase/oss/codegen/BoatStaticDocsGenerator.java create mode 100644 boat-scaffold/src/main/java/com/backbase/oss/codegen/marina/BoatMarinaConfig.java create mode 100644 boat-scaffold/src/main/java/com/backbase/oss/codegen/marina/BoatMarinaGenerator.java create mode 100644 boat-scaffold/src/main/templates/boat-marina/api.js.mustache create mode 100644 boat-scaffold/src/main/templates/boat-marina/backbase-logo.svg create mode 100644 boat-scaffold/src/main/templates/boat-marina/css/jsonschemaview.css create mode 100644 boat-scaffold/src/main/templates/boat-marina/css/jsontreeviewer.css create mode 100644 boat-scaffold/src/main/templates/boat-marina/css/prettify.css create mode 100644 boat-scaffold/src/main/templates/boat-marina/css/response.css create mode 100644 boat-scaffold/src/main/templates/boat-marina/css/styles.css create mode 100644 boat-scaffold/src/main/templates/boat-marina/header.mustache create mode 100644 boat-scaffold/src/main/templates/boat-marina/index.js.mustache create mode 100644 boat-scaffold/src/main/templates/boat-marina/index.mustache create mode 100644 boat-scaffold/src/main/templates/boat-marina/js/json_stringify_safe.js create mode 100644 boat-scaffold/src/main/templates/boat-marina/js/jsonformatter.js create mode 100644 boat-scaffold/src/main/templates/boat-marina/js/jsonschema-ref-parser.js create mode 100644 boat-scaffold/src/main/templates/boat-marina/js/jsonschemamergeallof.js create mode 100644 boat-scaffold/src/main/templates/boat-marina/js/jsonschemaview.js create mode 100644 boat-scaffold/src/main/templates/boat-marina/js/jsontreeviewer.js create mode 100644 boat-scaffold/src/main/templates/boat-marina/js/marked.js create mode 100644 boat-scaffold/src/main/templates/boat-marina/js/prettify.js create mode 100644 boat-scaffold/src/main/templates/boat-marina/js/webfontloader.js create mode 100644 boat-scaffold/src/main/templates/boat-marina/licenseInfo.mustache create mode 100644 boat-scaffold/src/main/templates/boat-marina/model.js.mustache create mode 100644 boat-scaffold/src/main/templates/boat-marina/param.mustache create mode 100644 boat-scaffold/src/main/templates/boat-marina/paramB.mustache create mode 100644 boat-scaffold/src/main/templates/boat-marina/response.mustache create mode 100644 boat-scaffold/src/main/templates/boat-marina/sidenav.mustache create mode 100644 boat-scaffold/src/test/java/com/backbase/oss/codegen/marina/BoatMarinaTest.java diff --git a/boat-scaffold/src/main/java/com/backbase/oss/codegen/BoatDefaultGenerator.java b/boat-scaffold/src/main/java/com/backbase/oss/codegen/BoatDefaultGenerator.java new file mode 100644 index 000000000..956e8e00d --- /dev/null +++ b/boat-scaffold/src/main/java/com/backbase/oss/codegen/BoatDefaultGenerator.java @@ -0,0 +1,6 @@ +package com.backbase.oss.codegen; + +import org.openapitools.codegen.DefaultGenerator; + +public class BoatDefaultGenerator extends DefaultGenerator { +} diff --git a/boat-scaffold/src/main/java/com/backbase/oss/codegen/BoatStaticDocsGenerator.java b/boat-scaffold/src/main/java/com/backbase/oss/codegen/BoatStaticDocsGenerator.java new file mode 100644 index 000000000..8d2f95425 --- /dev/null +++ b/boat-scaffold/src/main/java/com/backbase/oss/codegen/BoatStaticDocsGenerator.java @@ -0,0 +1,190 @@ +package com.backbase.oss.codegen; + +import com.backbase.oss.codegen.doc.BoatCodegenParameter; +import com.backbase.oss.codegen.doc.BoatCodegenResponse; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectReader; +import com.fasterxml.jackson.databind.node.ArrayNode; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.media.Schema; +import io.swagger.v3.oas.models.parameters.Parameter; +import io.swagger.v3.oas.models.parameters.RequestBody; +import io.swagger.v3.oas.models.responses.ApiResponse; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.client.utils.URLEncodedUtils; +import org.apache.http.message.BasicNameValuePair; +import org.openapitools.codegen.CodegenModel; +import org.openapitools.codegen.CodegenParameter; +import org.openapitools.codegen.CodegenResponse; + +import java.io.IOException; +import java.nio.charset.Charset; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +@Slf4j +public class BoatStaticDocsGenerator extends org.openapitools.codegen.languages.StaticHtml2Generator { + + private static final ObjectMapper objectMapper = new ObjectMapper(); + private static final ObjectReader paramReader = BoatStaticDocsGenerator.objectMapper.readerFor(new TypeReference>() { + }); + protected Boolean generateAliasModel = true; + + public BoatStaticDocsGenerator() { + super(); + } + + @Override + public void preprocessOpenAPI(OpenAPI openAPI) { + super.preprocessOpenAPI(openAPI); + + // Add responses to additional properties + if (openAPI.getComponents().getResponses() != null) { + additionalProperties.put("responses", openAPI.getComponents().getResponses().entrySet().stream() + .map(this::mapCodegenResponse) + .collect(Collectors.toList())); + } + + // Add parameters to additonal properties + if (openAPI.getComponents().getParameters() != null) { + Set imports = new HashSet<>(); + additionalProperties.put("parameters", openAPI.getComponents().getParameters().entrySet().stream() + .map(nameParameter -> mapComponentParameter(imports, nameParameter)) + .collect(Collectors.toList())); + } + + // Add requests to addtional properties + if (openAPI.getComponents().getRequestBodies() != null) { + Set imports = new HashSet<>(); + additionalProperties.put("requestBodies", openAPI.getComponents().getRequestBodies().entrySet().stream() + .map(namedRequestBody -> mapComponentRequestBody(imports, namedRequestBody)) + .collect(Collectors.toList())); + } + + if (openAPI.getPaths() != null) + // Ensure single tags for operations + openAPI.getPaths().forEach((path, pathItem) -> + pathItem.readOperations().forEach(operation -> { + if (operation.getTags() != null && operation.getTags().size() > 1) { + String tag = operation.getTags().get(operation.getTags().size() - 1); + log.warn("Operation: {} contains multiple tags {} which hinders rendering documentation. Rep" + + "lacing it with a single tag: {}", operation.getOperationId(), operation.getTags(), tag); + operation.tags(Collections.singletonList(tag)); + } + })); + } + + private CodegenParameter mapComponentRequestBody(Set imports, java.util.Map.Entry namedRequestBody) { + String name = namedRequestBody.getKey(); + RequestBody requestBody = namedRequestBody.getValue(); + return fromRequestBody(requestBody, imports, name); + } + + private CodegenParameter mapComponentParameter(Set imports, java.util.Map.Entry nameParameter) { + Parameter parameter = nameParameter.getValue(); + return fromParameter(parameter, imports); + } + + private CodegenResponse mapCodegenResponse(java.util.Map.Entry codeResponse) { + String responseCode = codeResponse.getKey(); + // try to resolve response code from key. otherwise use default + responseCode = responseCode.replaceAll("\\D+", ""); + if (responseCode.length() != 3) { + responseCode = "default"; + } + ApiResponse response = codeResponse.getValue(); + return fromResponse(responseCode, response); + } + + @Override + public String toModelName(String name) { + String modelName = super.toModelName(name); + if (!name.equals(modelName)) { + log.debug("NOT converting toModelName: {} to: {}", name, modelName); + } + return name; + } + + @Override + public String toVarName(String name) { + String varName = super.toVarName(name); + if (!name.equals(varName)) { + log.debug("NOT converting varName: {} to: {}", name, varName); + } + return name; + } + + @Override + public String toApiVarName(String name) { + String apiVarName = super.toApiVarName(name); + if (!name.equals(apiVarName)) { + log.debug("NOT converting apiVarName: {} to: {}", name, apiVarName); + } + return name; + } + + @Override + public String toParamName(String name) { + String paramName = super.toParamName(name); + if (!name.equals(paramName)) { + log.debug("NOT converting apiVarName: {} to: {}", name, paramName); + } + return name; + } + + @Override + public CodegenParameter fromParameter(Parameter parameter, Set imports) { + CodegenParameter codegenParameter = super.fromParameter(parameter, imports); + log.debug("Created CodegenParameter model for parameter: {}", parameter.getName()); + return BoatCodegenParameter.fromCodegenParameter(parameter, codegenParameter, openAPI); + } + + @Override + public CodegenParameter fromRequestBody(RequestBody body, Set imports, String bodyParameterName) { + CodegenParameter codegenParameter = super.fromRequestBody(body, imports, bodyParameterName); + log.debug("Created CodegenParameter model for request body: {} with bodyParameterName: {}", codegenParameter.baseName, bodyParameterName); + return BoatCodegenParameter.fromCodegenParameter(codegenParameter, body, openAPI); + } + + @Override + public CodegenResponse fromResponse(String responseCode, ApiResponse response) { + CodegenResponse r = super.fromResponse(responseCode, response); + r.message = StringUtils.replace(r.message, "`", "\\`"); + + return new BoatCodegenResponse(r, responseCode, response, openAPI); + } + + @Override + public CodegenModel fromModel(String name, Schema schema) { + CodegenModel codegenModel = super.fromModel(name, schema); + log.debug("Created CodegenModel for name: {}, schema: {} resulting in: {}", name, schema.getName(), codegenModel.getName()); + codegenModel.isAlias = false; + return codegenModel; + } + + @Override + public void setParameterExampleValue(CodegenParameter codegenParameter, Parameter parameter) { + super.setParameterExampleValue(codegenParameter, parameter); + + Object example = parameter.getExample(); + + if (parameter.getStyle() != null + && parameter.getStyle() == Parameter.StyleEnum.FORM + && example instanceof ArrayNode && codegenParameter.isQueryParam) { + try { + List values = BoatStaticDocsGenerator.paramReader.readValue((ArrayNode) example); + List params = values.stream() + .map(value -> new BasicNameValuePair(codegenParameter.paramName, value)) + .collect(Collectors.toList()); + codegenParameter.example = URLEncodedUtils.format(params, Charset.defaultCharset()); + } catch (IOException e) { + log.warn("Failed to format query string parameter: {}", codegenParameter.example); + } + } + } +} diff --git a/boat-scaffold/src/main/java/com/backbase/oss/codegen/doc/BoatDocsGenerator.java b/boat-scaffold/src/main/java/com/backbase/oss/codegen/doc/BoatDocsGenerator.java index 526c3fcc0..311dd6e96 100644 --- a/boat-scaffold/src/main/java/com/backbase/oss/codegen/doc/BoatDocsGenerator.java +++ b/boat-scaffold/src/main/java/com/backbase/oss/codegen/doc/BoatDocsGenerator.java @@ -28,15 +28,9 @@ import org.openapitools.codegen.CodegenResponse; @Slf4j -public class BoatDocsGenerator extends org.openapitools.codegen.languages.StaticHtml2Generator { +public class BoatDocsGenerator extends com.backbase.oss.codegen.BoatStaticDocsGenerator { public static final String NAME = "boat-docs"; - protected Boolean generateAliasModel = true; - - private static final ObjectMapper objectMapper = new ObjectMapper(); - private static final ObjectReader paramReader = objectMapper.readerFor(new TypeReference>() { - }); - public BoatDocsGenerator() { super(); @@ -53,156 +47,6 @@ public BoatDocsGenerator() { } - @Override - public void preprocessOpenAPI(OpenAPI openAPI) { - super.preprocessOpenAPI(openAPI); - - // Add responses to additional properties - if (openAPI.getComponents().getResponses() != null) { - additionalProperties.put("responses", openAPI.getComponents().getResponses().entrySet().stream() - .map(this::mapCodegenResponse) - .collect(Collectors.toList())); - } - - // Add parameters to additonal properties - if (openAPI.getComponents().getParameters() != null) { - Set imports = new HashSet<>(); - additionalProperties.put("parameters", openAPI.getComponents().getParameters().entrySet().stream() - .map(nameParameter -> mapComponentParameter(imports, nameParameter)) - .collect(Collectors.toList())); - } - - // Add requests to addtional properties - if (openAPI.getComponents().getRequestBodies() != null) { - Set imports = new HashSet<>(); - additionalProperties.put("requestBodies", openAPI.getComponents().getRequestBodies().entrySet().stream() - .map(namedRequestBody -> mapComponentRequestBody(imports, namedRequestBody)) - .collect(Collectors.toList())); - } - - if (openAPI.getPaths() != null) - // Ensure single tags for operations - openAPI.getPaths().forEach((path, pathItem) -> - pathItem.readOperations().forEach(operation -> { - if (operation.getTags() != null && operation.getTags().size() > 1) { - String tag = operation.getTags().get(operation.getTags().size() -1 ); - log.warn("Operation: {} contains multiple tags {} which hinders rendering documentation. Rep" + - "lacing it with a single tag: {}", operation.getOperationId(), operation.getTags(), tag); - operation.tags(Collections.singletonList(tag)); - } - })); - } - - private CodegenParameter mapComponentRequestBody(Set imports, java.util.Map.Entry namedRequestBody) { - String name = namedRequestBody.getKey(); - RequestBody requestBody = namedRequestBody.getValue(); - return fromRequestBody(requestBody, imports, name); - } - - private CodegenParameter mapComponentParameter(Set imports, java.util.Map.Entry nameParameter) { - Parameter parameter = nameParameter.getValue(); - return fromParameter(parameter, imports); - } - - private CodegenResponse mapCodegenResponse(java.util.Map.Entry codeResponse) { - String responseCode = codeResponse.getKey(); - // try to resolve response code from key. otherwise use default - responseCode = responseCode.replaceAll("\\D+", ""); - if (responseCode.length() != 3) { - responseCode = "default"; - } - ApiResponse response = codeResponse.getValue(); - return fromResponse(responseCode, response); - } - - - @Override - public String toModelName(String name) { - String modelName = super.toModelName(name); - if (!name.equals(modelName)) { - log.debug("NOT converting toModelName: {} to: {}", name, modelName); - } - return name; - } - - @Override - public String toVarName(String name) { - String varName = super.toVarName(name); - if (!name.equals(varName)) { - log.debug("NOT converting varName: {} to: {}", name, varName); - } - return name; - } - - @Override - public String toApiVarName(String name) { - String apiVarName = super.toApiVarName(name); - if (!name.equals(apiVarName)) { - log.debug("NOT converting apiVarName: {} to: {}", name, apiVarName); - } - return name; - } - - @Override - public String toParamName(String name) { - String paramName = super.toParamName(name); - if (!name.equals(paramName)) { - log.debug("NOT converting apiVarName: {} to: {}", name, paramName); - } - return name; - } - - @Override - public CodegenParameter fromParameter(Parameter parameter, Set imports) { - CodegenParameter codegenParameter = super.fromParameter(parameter, imports); - log.debug("Created CodegenParameter model for parameter: {}", parameter.getName()); - return BoatCodegenParameter.fromCodegenParameter(parameter, codegenParameter, openAPI); - } - - @Override - public CodegenParameter fromRequestBody(RequestBody body, Set imports, String bodyParameterName) { - CodegenParameter codegenParameter = super.fromRequestBody(body, imports, bodyParameterName); - log.debug("Created CodegenParameter model for request body: {} with bodyParameterName: {}", codegenParameter.baseName, bodyParameterName); - return BoatCodegenParameter.fromCodegenParameter(codegenParameter, body, openAPI); - } - - @Override - public CodegenResponse fromResponse(String responseCode, ApiResponse response) { - CodegenResponse r = super.fromResponse(responseCode, response); - r.message = StringUtils.replace(r.message, "`", "\\`"); - - return new BoatCodegenResponse(r, responseCode, response, openAPI); - } - - @Override - public CodegenModel fromModel(String name, Schema schema) { - CodegenModel codegenModel = super.fromModel(name, schema); - log.debug("Created CodegenModel for name: {}, schema: {} resulting in: {}", name, schema.getName(), codegenModel.getName()); - codegenModel.isAlias = false; - return codegenModel; - } - - @Override - public void setParameterExampleValue(CodegenParameter codegenParameter, Parameter parameter) { - super.setParameterExampleValue(codegenParameter, parameter); - - Object example = parameter.getExample(); - - if (parameter.getStyle() != null - && parameter.getStyle() == Parameter.StyleEnum.FORM - && example instanceof ArrayNode && codegenParameter.isQueryParam) { - try { - List values = paramReader.readValue((ArrayNode) example); - List params = values.stream() - .map(value -> new BasicNameValuePair(codegenParameter.paramName, value)) - .collect(Collectors.toList()); - codegenParameter.example = URLEncodedUtils.format(params, Charset.defaultCharset()); - } catch (IOException e) { - log.warn("Failed to format query string parameter: {}", codegenParameter.example); - } - } - } - @Override public String getName() { return NAME; diff --git a/boat-scaffold/src/main/java/com/backbase/oss/codegen/marina/BoatMarinaConfig.java b/boat-scaffold/src/main/java/com/backbase/oss/codegen/marina/BoatMarinaConfig.java new file mode 100644 index 000000000..70ebd9759 --- /dev/null +++ b/boat-scaffold/src/main/java/com/backbase/oss/codegen/marina/BoatMarinaConfig.java @@ -0,0 +1,4 @@ +package com.backbase.oss.codegen.marina; + +public class BoatMarinaConfig { +} diff --git a/boat-scaffold/src/main/java/com/backbase/oss/codegen/marina/BoatMarinaGenerator.java b/boat-scaffold/src/main/java/com/backbase/oss/codegen/marina/BoatMarinaGenerator.java new file mode 100644 index 000000000..a10ca8414 --- /dev/null +++ b/boat-scaffold/src/main/java/com/backbase/oss/codegen/marina/BoatMarinaGenerator.java @@ -0,0 +1,77 @@ +package com.backbase.oss.codegen.marina; + +import com.backbase.oss.codegen.BoatStaticDocsGenerator; +import com.backbase.oss.codegen.doc.BoatDocsGenerator; +import org.openapitools.codegen.CliOption; +import org.openapitools.codegen.CodegenConstants; +import org.openapitools.codegen.SupportingFile; +import org.openapitools.codegen.templating.HandlebarsEngineAdapter; + +import java.io.File; +import java.util.HashMap; + +public class BoatMarinaGenerator extends BoatStaticDocsGenerator { + + public static final String NAME = "boat-marina"; + + public BoatMarinaGenerator() { + super(); + embeddedTemplateDir = templateDir = NAME; + cliOptions.add(new CliOption(CodegenConstants.GENERATE_ALIAS_AS_MODEL, CodegenConstants.GENERATE_ALIAS_AS_MODEL)); + additionalProperties.put(CodegenConstants.GENERATE_ALIAS_AS_MODEL, generateAliasModel); + additionalProperties.put("appName", "BOAT Marina Documentation"); + additionalProperties.put("appDescription", "For a collection of doc(k)s"); + additionalProperties.put("infoUrl", "https://backbase.github.io/backbase-openapi-tools/"); + additionalProperties.put("infoEmail", "oss@backbase.com"); + additionalProperties.put("licenseInfo", "All rights reserved"); + additionalProperties.put("licenseUrl", "http://apache.org/licenses/LICENSE-2.0.html"); + typeAliases = new HashMap<>(); + + } + + + @Override + public void processOpts() { + super.processOpts(); + this.supportingFiles.add(new SupportingFile("index.mustache", "index.html")); + + + this.supportingFiles.add(new SupportingFile("css/jsontreeviewer.css", "css/jsontreeviewer.css")); + this.supportingFiles.add(new SupportingFile("css/jsonschemaview.css", "css/jsonschemaview.css")); + this.supportingFiles.add(new SupportingFile("css/prettify.css", "css/prettify.css")); + this.supportingFiles.add(new SupportingFile("css/response.css", "css/response.css")); + this.supportingFiles.add(new SupportingFile("css/styles.css", "css/styles.css")); + + this.supportingFiles.add(new SupportingFile("js/json_stringify_safe.js", "js/json_stringify_safe.js")); + this.supportingFiles.add(new SupportingFile("js/jsonformatter.js", "js/jsonformatter.js")); + this.supportingFiles.add(new SupportingFile("js/jsonschema-ref-parser.js", "js/jsonschema-ref-parser.js")); + this.supportingFiles.add(new SupportingFile("js/jsonschemaview.js", "js/jsonschemaview.js")); + this.supportingFiles.add(new SupportingFile("js/jsontreeviewer.js", "js/jsontreeviewer.js")); + this.supportingFiles.add(new SupportingFile("js/jsonschemamergeallof.js", "js/jsonschemamergeallof.js")); + this.supportingFiles.add(new SupportingFile("js/marked.js", "js/marked.js")); + this.supportingFiles.add(new SupportingFile("js/prettify.js", "js/prettify.js")); + this.supportingFiles.add(new SupportingFile("js/webfontloader.js", "js/webfontloader.js")); + + this.supportingFiles.add(new SupportingFile("backbase-logo.svg", "backbase-logo.svg")); + + this.supportingFiles.add(new SupportingFile("index.js.mustache", "spec/index.js")); + +// this.apiTemplateFiles.put("api.js.mustache", ".js"); +// this.modelTemplateFiles.put("model.js.mustache", ".js"); + } + + @Override + public String apiFileFolder() { + return outputFolder + File.separator + "spec" + File.separator + "api"; + } + + @Override + public String modelFileFolder() { + return outputFolder + File.separator + "spec" + File.separator + "model"; + } + + @Override + public String getName() { + return NAME; + } +} diff --git a/boat-scaffold/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig b/boat-scaffold/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig index 965d5d7db..d18e7e34e 100644 --- a/boat-scaffold/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig +++ b/boat-scaffold/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig @@ -2,3 +2,4 @@ com.backbase.oss.codegen.java.BoatSpringCodeGen com.backbase.oss.codegen.java.BoatJavaCodeGen com.backbase.oss.codegen.doc.BoatDocsGenerator com.backbase.oss.codegen.angular.BoatAngularGenerator +com.backbase.oss.codegen.marina.BoatMarinaGenerator \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-marina/api.js.mustache b/boat-scaffold/src/main/templates/boat-marina/api.js.mustache new file mode 100644 index 000000000..0eadfe6b7 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-marina/api.js.mustache @@ -0,0 +1,6 @@ +{{>licenseInfo}} + +{{{.}}} + + + diff --git a/boat-scaffold/src/main/templates/boat-marina/backbase-logo.svg b/boat-scaffold/src/main/templates/boat-marina/backbase-logo.svg new file mode 100644 index 000000000..9806aacc4 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-marina/backbase-logo.svg @@ -0,0 +1,33 @@ + + Backbase + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-marina/css/jsonschemaview.css b/boat-scaffold/src/main/templates/boat-marina/css/jsonschemaview.css new file mode 100644 index 000000000..9ae6e426f --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-marina/css/jsonschemaview.css @@ -0,0 +1,210 @@ +.json-schema-view * { + font-size: 14px; +} + +.json-schema-view, +json-schema-view { + display: flex !important; +} + +.json-schema-view { + display: flex; + flex-direction: column; + width: 100%; +} + +.property .json-schema-view { + padding-bottom: 16px; + border-bottom: 1px solid #e3e3e3; +} + +.json-schema-view .property > *, +json-schema-view .property > * { + flex: 2; +} + +.json-schema-view .name, +json-schema-view .name { + flex: 0 20%; + font-size: 14px !important; + font-weight: 400 !important; + line-height: 1.5em; + color: rgb(51, 51, 51) !important; + display: flex; + position: relative; + text-align: left; + -webkit-font-smoothing: antialiased; + text-size-adjust: 100%; + text-rendering: optimizespeed !important; + word-break: break-word; +} + +.json-schema-view .property, +json-schema-view .property { + display: flex !important; + margin-bottom: 16px; +} + +.brace { + display: none !important; +} + +.bracket { + margin-left: 8px; +} + +.json-schema-view .type, +json-schema-view .type { + display: inline-flex; + vertical-align: middle; + font-size: 13px; + line-height: 20px; + color: rgba(102, 102, 102, 0.9); +} + +.json-schema-view .default, +json-schema-view .default { + vertical-align: middle; + font-size: 13px; + line-height: 20px; + border-radius: 2px; + color: #6f6f6f !important; + background-color: #f7f7f9; + margin: 0px 5px; + padding: 0px 5px; + border: 1px solid #e1e1e8; + font-family: Courier, monospace; +} + +.json-schema-view .format, +json-schema-view .format { + display: inline-flex; + vertical-align: middle; + font-size: 13px; + line-height: 20px; + color: rgba(102, 102, 102, 0.9); +} + +.json-schema-view .pattern { + vertical-align: middle; + font-size: 13px; + line-height: 20px; + color: rgb(14, 124, 134); + white-space: pre-wrap; + word-break: break-word; +} + +.json-schema-view .range { + vertical-align: middle; + font-size: 13px; + line-height: 20px; + border-radius: 2px; + background-color: rgba(104, 104, 207, 0.05); + color: rgba(50, 50, 159, 0.9); + margin: 0px 5px; + padding: 0px 5px; + border: 1px solid rgba(50, 50, 159, 0.1); + font-family: Courier, monospace; +} + +.json-schema-view .inner, +json-schema-view .inner { + margin-bottom: 8px; +} + +.json-schema-view .description, +json-schema-view .description { + margin-bottom: 12px; + font-size: 14px; + white-space: pre-wrap; + word-break: break-word; +} + +.json-schema-view .toggle-handle, +json-schema-view .toggle-handle { + position: relative; + width: 4px; + height: 4px; + left: -8px; +} +.json-schema-view .toggle-handle:after, +json-schema-view .toggle-handle:after { + content: "" !important; + position: absolute; + left: 2px; + top: 0; + border-top: 2px solid #fff; + border-left: 2px solid transparent; + border-right: 2px solid transparent; +} + +.json-schema-view .toggle-handle:before, +json-schema-view .toggle-handle:before { + content: ""; + position: absolute; + top: 0; + left: 0; + border-top: 4px solid #333; + border-left: 4px solid transparent; + border-right: 4px solid transparent; +} + +a.title { + display: inline-flex; + justify-content: center; + align-items: center; +} + +.json-formatter-string { + padding: 2px 4px; + color: #6f6f6f !important; + white-space: nowrap; + background-color: #f7f7f9; + border: 1px solid #e1e1e8; + border-radius: 3px; + white-space: pre-wrap; + word-break: break-word; +} + +.json-formatter-toggler-link { + margin-bottom: 8px; + display: flex; +} + +.json-formatter-children { + display: flex; + flex-wrap: wrap; +} + +.json-formatter-key { + display: none; +} + +.json-formatter-row .json-formatter-row { + margin: 0 8px 0 0 !important; +} + +.json-formatter-row .json-formatter-children.json-formatter-empty { + display: none; +} + +.json-formatter-row .json-formatter-bracket, +.json-formatter-row .json-formatter-number { + color: rgba(102, 102, 102, 0.9) !important; +} + +.fake.property .json-schema-view { + display: flex; + flex-direction: row; +} +.fake.property .json-schema-view .primitive { + flex: 3; + padding-right: 16px; +} +.fake.property .examples { + flex: 1; +} +.fake.property .examples h3 { + margin-top: 0; + padding-top: 0; +} diff --git a/boat-scaffold/src/main/templates/boat-marina/css/jsontreeviewer.css b/boat-scaffold/src/main/templates/boat-marina/css/jsontreeviewer.css new file mode 100644 index 000000000..cfc88056e --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-marina/css/jsontreeviewer.css @@ -0,0 +1,165 @@ +/* +* JSON Tree Viewer +* http://github.com/summerstyle/jsonTreeViewer +* +* Copyright 2017 Vera Lobacheva (http://iamvera.com) +* Released under the MIT license (LICENSE.txt) +*/ + +/* Background for the tree. May use for element */ +.jsontree_bg { + background: rgb(38, 50, 56); +} + +/* Styles for the container of the tree (e.g. fonts, margins etc.) */ +.jsontree_tree { + font-family: monospace; + font-size: 13px; +} + +/* Styles for a list of child nodes */ +.jsontree_child-nodes { + display: none; + margin-left: 35px; + margin-bottom: 5px; + line-height: 2; +} +.jsontree_node_expanded + > .jsontree_value-wrapper + > .jsontree_value + > .jsontree_child-nodes { + display: block; +} + +/* Styles for labels */ +.jsontree_label-wrapper { + float: left; + margin-right: 8px; +} +.jsontree_label { + font-weight: normal; + vertical-align: top; + color: #fff; + position: relative; + padding: 1px; + border-radius: 4px; + cursor: default; +} +.jsontree_node_marked > .jsontree_label-wrapper > .jsontree_label { + background: #fff; +} + +/* Styles for values */ +.jsontree_value-wrapper { + display: block; + overflow: hidden; +} +.jsontree_node_complex > .jsontree_value-wrapper { + overflow: inherit; +} +.jsontree_value { + vertical-align: top; + display: inline; +} +.jsontree_value_null { + color: #777; + font-weight: bold; +} +.jsontree_value_string { + color: #84f59c; + font-weight: bold; +} +.jsontree_value_number { + color: #84acf5; + font-weight: bold; +} +.jsontree_value_boolean { + color: #f58484; + font-weight: bold; +} + +/* Styles for active elements */ +.jsontree_expand-button { + position: absolute; + top: 3px; + left: -15px; + display: block; + width: 11px; + height: 11px; + background-color: white; + -webkit-mask-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTEiIGhlaWdodD0iMjIiPjxkZWZzPjxsaW5lYXJHcmFkaWVudCBpZD0iYSI+PHN0b3Agb2Zmc2V0PSIwIi8+PHN0b3Agb2Zmc2V0PSIxIiBzdG9wLW9wYWNpdHk9IjAiLz48L2xpbmVhckdyYWRpZW50PjxyYWRpYWxHcmFkaWVudCB4bGluazpocmVmPSIjYSIgY3g9IjkuNzM5IiBjeT0iOS43MTYiIGZ4PSI5LjczOSIgZnk9IjkuNzE2IiByPSIzLjcwOSIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiLz48L2RlZnM+PGcgc3Ryb2tlPSIjMDAwIiBmaWxsPSJub25lIj48ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgtMTI5LjUgLTMzMy44NjIpIHRyYW5zbGF0ZSgwIC4xODgpIj48cmVjdCB0cmFuc2Zvcm09Im1hdHJpeCguOTYyIDAgMCAuOTcxIDQuOTQzIDExLjU0OCkiIHJ5PSIyIiByeD0iMiIgeT0iMzMyLjM2MiIgeD0iMTMwIiBoZWlnaHQ9IjEwLjMzNyIgd2lkdGg9IjEwLjQzMiIgb3BhY2l0eT0iLjUiLz48Zz48cGF0aCBkPSJNMTMyIDMzOS4xNzVoNiIgb3BhY2l0eT0iLjUiLz48cGF0aCBkPSJNMTM1IDMzNi4xNzV2NiIgb3BhY2l0eT0iLjUiLz48L2c+PC9nPjxnIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0xMjkuNSAtMzMzLjg2MikiPjxyZWN0IHdpZHRoPSIxMC40MzIiIGhlaWdodD0iMTAuMzM3IiB4PSIxMzAiIHk9IjMzMi4zNjIiIHJ4PSIyIiByeT0iMiIgdHJhbnNmb3JtPSJtYXRyaXgoLjk2MiAwIDAgLjk3MSA0Ljk0MyAyMi43MzYpIiBvcGFjaXR5PSIuNSIvPjxwYXRoIGQ9Ik0xMzIgMzUwLjM2Mmg2IiBvcGFjaXR5PSIuNSIvPjwvZz48L2c+PC9zdmc+); + mask-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTEiIGhlaWdodD0iMjIiPjxkZWZzPjxsaW5lYXJHcmFkaWVudCBpZD0iYSI+PHN0b3Agb2Zmc2V0PSIwIi8+PHN0b3Agb2Zmc2V0PSIxIiBzdG9wLW9wYWNpdHk9IjAiLz48L2xpbmVhckdyYWRpZW50PjxyYWRpYWxHcmFkaWVudCB4bGluazpocmVmPSIjYSIgY3g9IjkuNzM5IiBjeT0iOS43MTYiIGZ4PSI5LjczOSIgZnk9IjkuNzE2IiByPSIzLjcwOSIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiLz48L2RlZnM+PGcgc3Ryb2tlPSIjMDAwIiBmaWxsPSJub25lIj48ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgtMTI5LjUgLTMzMy44NjIpIHRyYW5zbGF0ZSgwIC4xODgpIj48cmVjdCB0cmFuc2Zvcm09Im1hdHJpeCguOTYyIDAgMCAuOTcxIDQuOTQzIDExLjU0OCkiIHJ5PSIyIiByeD0iMiIgeT0iMzMyLjM2MiIgeD0iMTMwIiBoZWlnaHQ9IjEwLjMzNyIgd2lkdGg9IjEwLjQzMiIgb3BhY2l0eT0iLjUiLz48Zz48cGF0aCBkPSJNMTMyIDMzOS4xNzVoNiIgb3BhY2l0eT0iLjUiLz48cGF0aCBkPSJNMTM1IDMzNi4xNzV2NiIgb3BhY2l0eT0iLjUiLz48L2c+PC9nPjxnIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0xMjkuNSAtMzMzLjg2MikiPjxyZWN0IHdpZHRoPSIxMC40MzIiIGhlaWdodD0iMTAuMzM3IiB4PSIxMzAiIHk9IjMzMi4zNjIiIHJ4PSIyIiByeT0iMiIgdHJhbnNmb3JtPSJtYXRyaXgoLjk2MiAwIDAgLjk3MSA0Ljk0MyAyMi43MzYpIiBvcGFjaXR5PSIuNSIvPjxwYXRoIGQ9Ik0xMzIgMzUwLjM2Mmg2IiBvcGFjaXR5PSIuNSIvPjwvZz48L2c+PC9zdmc+); +} +.jsontree_node_expanded + > .jsontree_label-wrapper + > .jsontree_label + > .jsontree_expand-button { + -webkit-mask-position: 0 -11px; + mask-position: 0 -11px; +} +.jsontree_show-more { + cursor: pointer; +} +.jsontree_node_expanded + > .jsontree_value-wrapper + > .jsontree_value + > .jsontree_show-more { + display: none; +} +.jsontree_node_empty + > .jsontree_label-wrapper + > .jsontree_label + > .jsontree_expand-button, +.jsontree_node_empty + > .jsontree_value-wrapper + > .jsontree_value + > .jsontree_show-more { + display: none !important; +} +.jsontree_node_complex > .jsontree_label-wrapper > .jsontree_label { + cursor: pointer; +} +.jsontree_node_empty > .jsontree_label-wrapper > .jsontree_label { + cursor: default !important; +} + +.json-viewer > ul { + margin-left: 0; +} +.json-viewer ul, +.json-viewer ul li { + list-style-type: none !important; +} + +.json-viewer * { + font-size: 13px; + font-weight: normal; + word-break: break-all; +} + +.json-viewer b { + opacity: 0.7; +} + +.example-dropdown-value .buttons-wrapper { + display: flex; + transition: opacity 0.3s ease 0s; + justify-content: flex-end; +} + +.example-dropdown-value .buttons-wrapper button { + opacity: 0.7; + background-color: transparent; + border: 0px; + color: inherit; + padding: 2px 10px; + font-family: Roboto, sans-serif; + font-size: 14px; + line-height: 1.5em; + cursor: pointer; + outline: 0px; +} + +.example-dropdown-value .buttons-wrapper button:hover { + opacity: 1; +} diff --git a/boat-scaffold/src/main/templates/boat-marina/css/prettify.css b/boat-scaffold/src/main/templates/boat-marina/css/prettify.css new file mode 100644 index 000000000..35687dd18 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-marina/css/prettify.css @@ -0,0 +1,101 @@ +/* Pretty printing styles. Used with prettify.js. */ +/* Vim sunburst theme by David Leibovic */ +pre .str { + color: #65B042; +} +/* string - green */ +pre .kwd { + color: #E28964; +} +/* keyword - dark pink */ +pre .com { + color: #AEAEAE; + font-style: italic; +} +/* comment - gray */ +pre .typ { + color: #89bdff; +} +/* type - light blue */ +pre .lit { + color: #3387CC; +} +/* literal - blue */ +pre .pun { + color: #fff; +} +/* punctuation - white */ +pre .pln { + color: #fff; +} +/* plaintext - white */ +pre .tag { + color: #89bdff; +} +/* html/xml tag - light blue */ +pre .atn { + color: #bdb76b; +} +/* html/xml attribute name - khaki */ +pre .atv { + color: #65B042; +} +/* html/xml attribute value - green */ +pre .dec { + color: #3387CC; +} +/* decimal - blue */ +/* Specify class=linenums on a pre to get line numbering */ +ol.linenums { + margin-top: 0; + margin-bottom: 0; + color: #AEAEAE; +} +/* IE indents via margin-left */ +li.L0, +li.L1, +li.L2, +li.L3, +li.L5, +li.L6, +li.L7, +li.L8 { + list-style-type: none; +} +/* Alternate shading for lines */ +@media print { + pre .str { + color: #060; + } + pre .kwd { + color: #006; + font-weight: bold; + } + pre .com { + color: #600; + font-style: italic; + } + pre .typ { + color: #404; + font-weight: bold; + } + pre .lit { + color: #044; + } + pre .pun { + color: #440; + } + pre .pln { + color: #000; + } + pre .tag { + color: #006; + font-weight: bold; + } + pre .atn { + color: #404; + } + pre .atv { + color: #060; + } +} \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-marina/css/response.css b/boat-scaffold/src/main/templates/boat-marina/css/response.css new file mode 100644 index 000000000..6e87d36ea --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-marina/css/response.css @@ -0,0 +1,89 @@ +.response-content-block { + display: block; + margin-top: -4px; + width: 100%!important; +} + +.response-content-block > p { +width: calc(60% - 32px) !important; +} + +.response-content-block.collapsed { +display: none; +} + + +.response-content-block .schema-block { +width: 100%; +flex: 1; +} + +.response-content-block .exampleStyle { +width: 100%; +display: flex; +} + + +.exampleStyle .left-side{ +width: calc((100% + 64px) * 0.6 - 32px) +} + +.response-header-tab { + display: block; + border: 0px; + width: 100%; + text-align: left; + padding: 10px; + border-radius: 2px; + margin-bottom: 4px; + line-height: 1.5em; + cursor: pointer; + color: rgb(29, 129, 39); + background-color: rgba(29, 129, 39, 0.07); +} + +.response-header-tab-handle { + cursor: pointer; + margin: auto 0.3em; + font-size: 10px; + display: inline-block; + transform-origin: 50% 20%; + transition: transform 150ms ease-in; + position: relative; + width: 8px; + height: 8px; +} + +.response-header-tab-handle:before { + content: ""; + position: absolute; + top: 0; + left: 0; + border-top: 4px solid rgb(29, 129, 39); + border-left: 4px solid transparent; + border-right: 4px solid transparent; +} + +.response-header-tab-handle:after { + content: "" !important; + position: absolute; + left: 2px; + top: 0; + border-top: 2px solid #fff; + border-left: 2px solid transparent; + border-right: 2px solid transparent; +} +.response-header-tab.collapsed .response-header-tab-handle { + transform: rotate(-90deg); +} + +.response-header-tab[data-code^="4"], +.response-header-tab[data-code^="5"] { + color: rgb(212, 31, 28); + background-color: rgba(212, 31, 28, 0.07); +} + +.response-header-tab[data-code^="4"] .response-header-tab-handle:before, +.response-header-tab[data-code^="5"] .response-header-tab-handle:before { + border-top: 4px solid rgb(212, 31, 28); +} diff --git a/boat-scaffold/src/main/templates/boat-marina/css/styles.css b/boat-scaffold/src/main/templates/boat-marina/css/styles.css new file mode 100644 index 000000000..a94537fad --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-marina/css/styles.css @@ -0,0 +1,874 @@ +/* ------------------------------------------------------------------------------------------ +* Content +* ------------------------------------------------------------------------------------------ */ + +body { + font-family: "Roboto", sans-serif; + min-width: 980px; + background-color: #fff; + color: #333; + display: grid; + grid-template-areas: "navbar content"; + grid-template-columns: 300px 1fr; +} + +#sidenav { + grid-area: navbar; +} + +#content { + grid-area: content; + display: grid; + grid-template-areas: + "project example-area" + "header example-area" + "main example-area"; + grid-template-columns: 60% 40%; +} + +#header { + grid-area: header; +} +#project { + grid-area: project; + padding-left: 32px; +} + +#sections { + grid-area: main; + grid-column-end: example-area; +} + +#example-area { + grid-area: example-area; + background-color: rgb(38, 50, 56); + height: 100%; + width: 100%; +} + +article { + display: grid; + padding: 16px 32px !important; +} + +article > * { + width: calc(60% - 32px) !important; + box-sizing: border-box; +} + +* { + box-sizing: border-box; +} + +#methodsubtable > tbody > tr > td:first-child { + font-family: "Courier", monospace; + font-size: 14px; + padding: 2px 4px; + white-space: nowrap; +} + +.app-desc { + color: #121212; +} + +body, +p, +a, +div, +th, +td, +li { + font-family: "Roboto", sans-serif; + font-weight: 400; + font-size: 16px; + text-shadow: none !important; +} + +td.code { + font-size: 14px; + font-family: "Courier", monospace; + font-style: normal; + font-weight: 400; +} + +h1 { + font-family: "Roboto Semibold", sans-serif; + font-weight: normal; + font-size: 32px; + line-height: 38px; + margin: 0 0 10px 0; + padding: 0; +} + +h2 { + font-family: "Roboto", sans-serif; + font-weight: normal; + font-size: 24px; + line-height: 40px; + margin: 0 0 20px 0; + padding: 0; +} + +#project { + margin-bottom: 16px; + margin-top: 16px; +} + +#header { + padding: 32px; + margin-bottom: 32px; +} + +div.secured-by { + margin-bottom: 16px; + display: flex; + flex-direction: column; +} + +div.secured-by > h2 { + border-left: 4px solid orange; + padding-top: 0; + padding-left: 16px; + margin-bottom: 8px; +} + +div.secured-by > h2:only-child { + display: none !important; +} + +div.secured-by > pre { + margin: 0; + border: none; + border-radius: 0; + padding-top: 0; + padding-bottom: 8; +} + +div.secured-by > pre:nth-child(2) { + border-top-left-radius: 6px; + border-top-right-radius: 6px; + padding-top: 8px; +} + +div.secured-by > pre:last-child { + border-bottom-left-radius: 6px; + border-bottom-right-radius: 6px; + padding-bottom: 8px; +} + +section { + padding: 16px 0 16px 0; + margin-bottom: 32px; +} +section > h1 { + margin-left: 32px !important; +} + +section h1 { + font-family: "Roboto", sans-serif; + font-weight: 700; + font-size: 32px; + line-height: 40px; + padding-bottom: 14px; + margin: 0 0 20px 0; + padding: 0; +} + +article { + padding: 0 0 15px 0; +} + +article h1 { + font-family: "Roboto Bold", sans-serif; + font-weight: 500; + font-size: 24px; + line-height: 26px; + padding-top: 20px; + margin-bottom: 10px; +} + +article h2 { + font-family: "Roboto", sans-serif; + font-weight: 500; + font-size: 18px; + line-height: 24px; + padding-top: 20px; + margin-bottom: 10px; +} + +article h3 { + font-family: "Roboto", sans-serif; + font-weight: 500; + font-size: 16px; + line-height: 18px; + padding-top: 20px; + margin-bottom: 10px; +} + +article h4 { + font-family: "Roboto", sans-serif; + font-weight: 500; + font-size: 14px; + line-height: 16px; + padding-top: 20px; + margin-bottom: 10px; +} + +article h1, +article h2, +article h3 { + padding-bottom: 8px; + margin-bottom: 16px; + display: flex; + font-weight: bold; +} + +article h1 span { + color: #909090; + margin-left: 24px; + font-size: 18px; + font-weight: lighter; +} + +table { + border-collapse: collapse; + width: 100%; + margin: 0 0 20px 0; +} + +th { + background-color: #f5f5f5; + text-align: left; + font-family: "Roboto", sans-serif; + font-weight: 700; + padding: 4px 8px; + border: #e0e0e0 1px solid; +} + +td { + vertical-align: top; + padding: 2px 8px; + border: #e0e0e0 1px solid; +} + +#generator .content { + color: #b0b0b0; + border-top: 1px solid #ebebeb; + padding: 10px 0; +} + +.label-optional { + float: right; +} + +.open-left { + right: 0; + left: auto; +} + +/* ------------------------------------------------------------------------------------------ +* apidoc - intro +* ------------------------------------------------------------------------------------------ */ + +#apidoc .apidoc { + border-top: 1px solid #ebebeb; + padding: 30px 0; +} + +#apidoc h1 { + font-family: "Roboto", sans-serif; + font-weight: 700; + font-size: 32px; + line-height: 40px; + padding-bottom: 14px; + margin: 0 0 20px 0; + padding: 0; +} + +#apidoc h2 { + font-family: "Roboto Bold", sans-serif; + font-weight: 600; + font-size: 22px; + line-height: 26px; + padding-top: 14px; +} + +/* ------------------------------------------------------------------------------------------ +* pre / code +* ------------------------------------------------------------------------------------------ */ +pre { + font-family: Monaco, Menlo, Consolas, "Courier New", monospace !important; + background-color: #292b36; + color: #ffffff; + padding: 10px; + border-radius: 6px; + position: relative; + margin: 10px 0 20px 0; +} + +.dropdown-examples pre { + background-color: rgb(17, 23, 26); +} + +span.language-html { + margin-right: 8px; + display: inline-flex; + width: 46px; + min-width: 46px; + height: 20px; + align-items: center; + justify-content: center; + font-family: "Roboto", sans-serif; + font-weight: 600; + font-size: 10px; + border-radius: 6px; + text-transform: uppercase; + color: #ffffff; +} + +code.language-text { + word-wrap: break-word; +} + +pre.language-json { + overflow: auto; +} + +pre.language-html { + margin: 48px 0 20px 0; +} + +pre.language-html .http-method { + content: attr(data-type); + margin-right: 8px; + font-family: "Roboto", sans-serif; + font-weight: 600; + font-size: 15px; + display: inline-block; + padding: 2px 5px; + border-radius: 6px; + text-transform: uppercase; + background-color: #3387cc; + color: #ffffff; +} + +pre.language-html .http-method[data-type="get"], +span.language-html[data-type="get"] { + background-color: green; +} + +pre.language-html .http-method[data-type="put"], +span.language-html[data-type="put"] { + background-color: #e5c500; +} + +pre.language-html .http-method[data-type="post"], +span.language-html[data-type="post"] { + background-color: #4070ec; +} + +pre.language-html .http-method[data-type="delete"], +span.language-html[data-type="delete"] { + background-color: #ed0039; +} + +pre.language-html .http-method[data-type="patch"], +span.language-html[data-type="patch"] { + background-color: #3387cc; +} + +pre.language-api .str { + color: #ffffff; +} + +pre.language-api .pln, +pre.language-api .pun { + color: #65b042; +} + +pre code { + display: block; + font-size: 13px; + font-family: monospace !important; + font-style: normal; + font-weight: 400; +} + +pre code.sample-request-response-json { + white-space: pre-wrap; + max-height: 500px; + overflow: auto; +} + +/* ------------------------------------------------------------------------------------------ +* Sidenav +* ------------------------------------------------------------------------------------------ */ +.sidenav { + width: 300px; + margin: 0; + padding: 20px; + position: fixed; + top: 0; + left: 0; + bottom: 0; + overflow-x: hidden; + overflow-y: auto; + background-color: #f5f5f5; + z-index: 10; + border-right: 1px solid #ddd; +} + +.sidenav > li { + line-height: 24px; +} + +.sidenav > li > a { + display: inline-flex !important; + margin: 0; + padding: 8px 8px; + font-family: "Roboto", sans-serif; + font-weight: 400; + font-size: 14px; + color: rgb(40, 45, 68); + text-decoration: none; + display: block; + height: 100%; + line-height: 26px; + vertical-align: middle; + align-items: center; + width: 100%; +} + +.sidenav > li > a .text { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + min-width: 0; +} + +.sidenav > li.nav-header > a { + font-family: "Roboto", sans-serif; + font-size: 14px; + color: rgb(133, 139, 165); + font-weight: 600; + text-transform: uppercase; +} + +.sidenav > li.nav-header { + margin-top: 16px; +} +.sidenav > li.nav-header:first-child { + margin-top: 0px; +} +.sidenav > li.nav-header.active > a { + color: #333; +} + +.sidenav > .active > a { + position: relative; + z-index: 2; +} + +.sidenav > li > a:hover { + background-color: #ffffff; +} + +.nav-list > .active > a, +.nav-list > .active > a:hover, +.nav-list > .active > a:focus { + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.2); + color: #121212; + background-color: rgba(38, 50, 56, 0.1); + border-radius: 6px; + font-weight: bold; +} + +.sidenav > li.has-modifications a { + border-right: #60d060 4px solid; +} + +.sidenav > li.is-new a { + border-left: #e5e5e5 4px solid; +} + +/* ------------------------------------------------------------------------------------------ +* Tabs +* ------------------------------------------------------------------------------------------ */ +ul.nav-tabs { + margin: 0; +} + +.nav-tabs > li > a { + color: #666; +} + +.nav-tabs > li > a:hover, +.nav-tabs > li > a.active { + color: #333 !important; +} + +/* ------------------------------------------------------------------------------------------ +* Print +* ------------------------------------------------------------------------------------------ */ + +@media print { + #sidenav, + #version, + #versions, + section .version, + section .versions { + display: none; + } + + #content { + margin-left: 0; + } + + a { + text-decoration: none; + color: inherit; + } + + a:after { + content: " [" attr(href) "] "; + } + + p { + color: #000000; + } + + pre { + background-color: #ffffff; + color: #000000; + padding: 10px; + border: #808080 1px solid; + border-radius: 6px; + position: relative; + margin: 10px 0 20px 0; + } +} /* /@media print */ + +.doc-chapter { + display: none; + background-color: #eee; + border-radius: 1px; + padding: 10px; + margin-bottom: 20px; +} + +/*! +* json-schema-view-js +* https://github.com/mohsen1/json-schema-view-js#readme +* Version: 0.4.1 - 2015-11-12T17:19:27.615Z +* License: MIT +*/ + +.json-schema-view .toggle-handle:after, +.json-schema-view.json-schema-view-dark .toggle-handle:after, +json-schema-view .toggle-handle:after, +json-schema-view[json-schema-view-dark] .toggle-handle:after { + content: "\25BC"; +} +.json-schema-view .title, +.json-schema-view.json-schema-view-dark .title, +json-schema-view .title, +json-schema-view[json-schema-view-dark] .title { + font-weight: 700; + cursor: pointer; +} +.json-schema-view, +json-schema-view { + font-family: "Courier", monospace; + font-size: 0; + display: table-cell; +} +.json-schema-view > *, +json-schema-view > * { + font-size: 14px; +} +.json-schema-view .toggle-handle, +json-schema-view .toggle-handle { + cursor: pointer; + margin: auto 0.3em; + font-size: 10px; + display: inline-block; + transform-origin: 50% 40%; + transition: transform 150ms ease-in; +} +.json-schema-view .toggle-handle, +.json-schema-view .toggle-handle:hover, +json-schema-view .toggle-handle, +json-schema-view .toggle-handle:hover { + text-decoration: none; + color: #333; +} +.json-schema-view .readOnly, +json-schema-view .readOnly { + color: gray; + font-style: italic; +} +.json-schema-view .nullable, +json-schema-view .nullable { + color: gray; + font-style: italic; +} +.default { + color: black; +} +.required { + color: black; +} +.json-schema-view .title, +.json-schema-view .title:hover, +json-schema-view .title, +json-schema-view .title:hover { + text-decoration: none; + color: #333; +} +.json-schema-view .brace, +.json-schema-view .bracket, +.json-schema-view .title, +json-schema-view .brace, +json-schema-view .bracket, +json-schema-view .title { + color: #333; +} +.json-schema-view .property, +json-schema-view .property { + font-size: 0; + display: table-row; +} +.json-schema-view .property > *, +json-schema-view .property > * { + font-size: 14px; + padding: 0.2em; +} +.json-schema-view .name, +json-schema-view .name { + color: #00f; + font-family: "Courier", monospace; + display: table-cell; + vertical-align: top; +} +.json-schema-view .type, +json-schema-view .type { + font-family: "Courier", monospace; +} +.json-schema-view .type-any, +json-schema-view .type-any { + color: #33f; +} +.json-schema-view .required, +json-schema-view .required { + color: #ed0039; +} +.json-schema-view.collapsed .description, +.json-schema-view.collapsed .property, +json-schema-view.collapsed .description, +json-schema-view.collapsed .property { + display: none; +} +.json-schema-view.collapsed .closeing.brace, +json-schema-view.collapsed .closeing.brace { + display: inline-block; +} +.json-schema-view.collapsed .toggle-handle, +json-schema-view.collapsed .toggle-handle { + transform: rotate(-90deg); +} +.json-schema-view.json-schema-view-dark, +json-schema-view[json-schema-view-dark] { + font-family: "Courier", monospace; + font-size: 0; + display: table-cell; +} +.json-schema-view.json-schema-view-dark > *, +json-schema-view[json-schema-view-dark] > * { + font-size: 14px; +} +.json-schema-view.json-schema-view-dark .toggle-handle, +json-schema-view[json-schema-view-dark] .toggle-handle { + cursor: pointer; + margin: auto 0.3em; + font-size: 10px; + display: inline-block; + transform-origin: 50% 40%; + transition: transform 150ms ease-in; +} +.json-schema-view.json-schema-view-dark .toggle-handle, +.json-schema-view.json-schema-view-dark .toggle-handle:hover, +json-schema-view[json-schema-view-dark] .toggle-handle, +json-schema-view[json-schema-view-dark] .toggle-handle:hover { + text-decoration: none; + color: #eee; +} +.json-schema-view.json-schema-view-dark .description, +json-schema-view[json-schema-view-dark] .description { + color: gray; + font-style: italic; +} +.json-schema-view.json-schema-view-dark .title, +.json-schema-view.json-schema-view-dark .title:hover, +json-schema-view[json-schema-view-dark] .title, +json-schema-view[json-schema-view-dark] .title:hover { + text-decoration: none; + color: #eee; +} +.json-schema-view.json-schema-view-dark .brace, +.json-schema-view.json-schema-view-dark .bracket, +.json-schema-view.json-schema-view-dark .title, +json-schema-view[json-schema-view-dark] .brace, +json-schema-view[json-schema-view-dark] .bracket, +json-schema-view[json-schema-view-dark] .title { + color: #eee; +} +.json-schema-view.json-schema-view-dark .property, +json-schema-view[json-schema-view-dark] .property { + font-size: 0; + display: table-row; +} +.json-schema-view.json-schema-view-dark .property > *, +json-schema-view[json-schema-view-dark] .property > * { + font-size: 14px; + padding: 0.2em; +} +.json-schema-view.json-schema-view-dark .name, +json-schema-view[json-schema-view-dark] .name { + color: #add8e6; + display: table-cell; + vertical-align: top; +} +.json-schema-view.json-schema-view-dark .type, +json-schema-view[json-schema-view-dark] .type { + color: #90ee90; +} +.json-schema-view.json-schema-view-dark .type-any, +json-schema-view[json-schema-view-dark] .type-any { + color: #d4ebf2; +} +.json-schema-view.json-schema-view-dark .required, +json-schema-view[json-schema-view-dark] .required { + color: #fe0000; +} +.json-schema-view.json-schema-view-dark .inner, +json-schema-view[json-schema-view-dark] .inner { + padding-left: 18px; +} +.json-schema-view.json-schema-view-dark.collapsed .description, +.json-schema-view.json-schema-view-dark.collapsed .property, +json-schema-view[json-schema-view-dark].collapsed .description, +json-schema-view[json-schema-view-dark].collapsed .property { + display: none; +} +.json-schema-view.json-schema-view-dark.collapsed .closeing.brace, +json-schema-view[json-schema-view-dark].collapsed .closeing.brace { + display: inline-block; +} +.json-schema-view.json-schema-view-dark.collapsed .toggle-handle, +json-schema-view[json-schema-view-dark].collapsed .toggle-handle { + transform: rotate(-90deg); +} + +.requests-wrapper .responses-wrapper { + display: flex; +} + +.requests-wrapper .tab-content, +.responses-wrapper .tab-content { + display: flex; +} +.examples-tab-wrapper { + flex: 1; +} + +.exampleStyle { + flex: 1; + display: flex; + min-height: 20px; +} + +.exampleStyle > .json-schema-view > .object > .title { + margin-bottom: 16px; +} +.exampleStyle .placeholder { + display: flex; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; +} +.examples-wrapper { + display: flex; +} + +.request-body, +.response-body { + width: 100% !important; +} + +.tab-content { + overflow: initial; +} + +.dropdown-examples { + width: calc((100% + 64px) * 0.4 - 64px); + z-index: 2; + color: rgb(255, 255, 255); + padding: 0px 40px; + background: rgb(17, 23, 26); + margin-top: -55px; + margin-left: 32px; + border-radius: 6px; + height: min-content; +} + +.dropdown-examples label { + position: relative; +} + +.dropdown-examples label span { + font-size: 12px; + font-weight: 100; +} +.dropdown-examples .example-dropdown-select { + padding: 8px; + display: flex; + height: auto; + margin-bottom: 16px; + margin-right: 0; + width: 100%; + padding: 0.9em; + background-color: rgba(38, 50, 56, 0.4); + margin: 0px 0px 10px; + display: block; + font-size: 0.929em; + line-height: 1.5em; + color: #fff; + box-sizing: border-box; + -webkit-tap-highlight-color: rgba(255, 255, 255, 0); + border: none; +} + +.dropdown-examples .example-dropdown-value { + display: none; +} + +[data-deprecated="true"] .text { + text-decoration: line-through; +} + +.deprecated { + display: inline-flex; + padding: 2px 8px; + margin: 0px; + background-color: rgb(255, 165, 0); + color: rgb(255, 255, 255); + vertical-align: middle; + line-height: 1.6; + border-radius: 4px; + font-weight: 600; + font-size: 12px; + align-items: center; + justify-content: center; + margin-left: 16px; +} diff --git a/boat-scaffold/src/main/templates/boat-marina/header.mustache b/boat-scaffold/src/main/templates/boat-marina/header.mustache new file mode 100644 index 000000000..59dbd9349 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-marina/header.mustache @@ -0,0 +1,10 @@ +
+ {{baseName}} +
+
+ {{datatype}} + {{dataFormat}} +
{{description}}
+
+
+
diff --git a/boat-scaffold/src/main/templates/boat-marina/index.js.mustache b/boat-scaffold/src/main/templates/boat-marina/index.js.mustache new file mode 100644 index 000000000..45c8f4eb0 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-marina/index.js.mustache @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + +{{=< >=}} +<#models> + <#model> + import("'); + + +<={{ }}=> diff --git a/boat-scaffold/src/main/templates/boat-marina/index.mustache b/boat-scaffold/src/main/templates/boat-marina/index.mustache new file mode 100644 index 000000000..eaf708deb --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-marina/index.mustache @@ -0,0 +1,413 @@ + + + + + {{{appName}}} + + + + + + + + + + + + + + + + + + + {{>sidenav}} +
+
+

{{{appName}}}

+ {{#version}} +
Version: {{{version}}}
+ {{/version}} +
+ +
+ {{#apiInfo}} + {{#apis}} + {{#operations}} +
+

{{baseName}}

+ {{#operation}} +
+
+

{{#summary}}{{.}}{{/summary}}{{^summary}}{{nickname}}{{/summary}}{{#isDeprecated}}Deprecated {{/isDeprecated}}

+ {{#description}}

{{description}}

{{/description}} +

{{notes}}

+
+ {{#vendorExtensions}} +
+

Secured by Backbase Access Control

+ {{#x-BbAccessControl-resource}}
Resource: {{.}}
{{/x-BbAccessControl-resource}} + {{#x-BbAccessControl-function}}
Function: {{.}}
{{/x-BbAccessControl-function}} + {{#x-BbAccessControl-privilege}}
Privilege: {{.}}
{{/x-BbAccessControl-privilege}} +
+ {{/vendorExtensions}} +
{{httpMethod}}{{path}}
+ + {{#hasAuthMethods}} +

Scopes

+ + {{#authMethods}}{{#scopes}} + + + + + {{/scopes}}{{/authMethods}} +
{{scope}}{{description}}
+ {{/hasAuthMethods}} + + {{#hasPathParams}} +

Path parameters

+
+ {{#pathParams}} + {{>param}} + {{/pathParams}} +
+ {{/hasPathParams}} + + {{#hasHeaderParams}} +

Header parameters

+
+ {{#headerParams}} + {{>param}} + {{/headerParams}} +
+ {{/hasHeaderParams}} + + {{#hasFormParams}} +

Form parameters

+
+ {{#formParams}} + {{>param}} + {{/formParams}} +
+ {{/hasFormParams}} + + {{#hasQueryParams}} +

Query parameters

+
+ {{#queryParams}} + {{>param}} + {{/queryParams}} +
+ {{/hasQueryParams}} + + {{#hasBodyParam}} +

Request Body Schema

+ {{#bodyParams}} + {{>paramB}} + {{/bodyParams}} + + {{/hasBodyParam}} + +

Responses

+ {{#responses}} + {{>response}} + {{/responses}} +
+
+ {{/operation}} +
+ {{/operations}} + {{/apis}} + {{/apiInfo}} +
+
+ +{{^hideGenerationTimestamp}} +
+
+ Generated {{generatedDate}} +
+
+{{/hideGenerationTimestamp}} + +
+ + + + + + + + + + + + + + + + + + diff --git a/boat-scaffold/src/main/templates/boat-marina/js/json_stringify_safe.js b/boat-scaffold/src/main/templates/boat-marina/js/json_stringify_safe.js new file mode 100644 index 000000000..cd16b3d01 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-marina/js/json_stringify_safe.js @@ -0,0 +1,25 @@ +// https://github.com/isaacs/json-stringify-safe v5.0.1 +function stringify(obj, replacer, spaces, cycleReplacer) { + return JSON.stringify(obj, serializer(replacer, cycleReplacer), spaces) +} + +function serializer(replacer, cycleReplacer) { + var stack = [], keys = [] + + if (cycleReplacer == null) cycleReplacer = function(key, value) { + if (stack[0] === value) return "[Circular ~]" + return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]" + } + + return function(key, value) { + if (stack.length > 0) { + var thisPos = stack.indexOf(this) + ~thisPos ? stack.splice(thisPos + 1) : stack.push(this) + ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key) + if (~stack.indexOf(value)) value = cycleReplacer.call(this, key, value) + } + else stack.push(value) + + return replacer == null ? value : replacer.call(this, key, value) + } +} diff --git a/boat-scaffold/src/main/templates/boat-marina/js/jsonformatter.js b/boat-scaffold/src/main/templates/boat-marina/js/jsonformatter.js new file mode 100644 index 000000000..4c8695874 --- /dev/null +++ b/boat-scaffold/src/main/templates/boat-marina/js/jsonformatter.js @@ -0,0 +1,961 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define("JSONFormatter", [], factory); + else if(typeof exports === 'object') + exports["JSONFormatter"] = factory(); + else + root["JSONFormatter"] = factory(); +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; +/******/ +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.loaded = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = "dist"; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = __webpack_require__(1); + + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + __webpack_require__(2); + var helpers_ts_1 = __webpack_require__(6); + var DATE_STRING_REGEX = /(^\d{1,4}[\.|\\/|-]\d{1,2}[\.|\\/|-]\d{1,4})(\s*(?:0?[1-9]:[0-5]|1(?=[012])\d:[0-5])\d\s*[ap]m)?$/; + var PARTIAL_DATE_REGEX = /\d{2}:\d{2}:\d{2} GMT-\d{4}/; + var JSON_DATE_REGEX = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/; + // When toggleing, don't animated removal or addition of more than a few items + var MAX_ANIMATED_TOGGLE_ITEMS = 10; + var requestAnimationFrame = window.requestAnimationFrame || function (cb) { cb(); return 0; }; + ; + var _defaultConfig = { + hoverPreviewEnabled: false, + hoverPreviewArrayCount: 100, + hoverPreviewFieldCount: 5, + animateOpen: true, + animateClose: true, + theme: null + }; + module.exports = (function () { + /** + * @param {object} json The JSON object you want to render. It has to be an + * object or array. Do NOT pass raw JSON string. + * + * @param {number} [open=1] his number indicates up to how many levels the + * rendered tree should expand. Set it to `0` to make the whole tree collapsed + * or set it to `Infinity` to expand the tree deeply + * + * @param {object} [config=defaultConfig] - + * defaultConfig = { + * hoverPreviewEnabled: false, + * hoverPreviewArrayCount: 100, + * hoverPreviewFieldCount: 5 + * } + * + * Available configurations: + * #####Hover Preview + * * `hoverPreviewEnabled`: enable preview on hover + * * `hoverPreviewArrayCount`: number of array items to show in preview Any + * array larger than this number will be shown as `Array[XXX]` where `XXX` + * is length of the array. + * * `hoverPreviewFieldCount`: number of object properties to show for object + * preview. Any object with more properties that thin number will be + * truncated. + * + * @param {string} [key=undefined] The key that this object in it's parent + * context + */ + function JSONFormatter(json, open, config, key) { + if (open === void 0) { open = 1; } + if (config === void 0) { config = _defaultConfig; } + this.json = json; + this.open = open; + this.config = config; + this.key = key; + // Hold the open state after the toggler is used + this._isOpen = null; + // Setting default values for config object + if (this.config.hoverPreviewEnabled === undefined) { + this.config.hoverPreviewEnabled = _defaultConfig.hoverPreviewEnabled; + } + if (this.config.hoverPreviewArrayCount === undefined) { + this.config.hoverPreviewArrayCount = _defaultConfig.hoverPreviewArrayCount; + } + if (this.config.hoverPreviewFieldCount === undefined) { + this.config.hoverPreviewFieldCount = _defaultConfig.hoverPreviewFieldCount; + } + } + Object.defineProperty(JSONFormatter.prototype, "isOpen", { + /* + * is formatter open? + */ + get: function () { + if (this._isOpen !== null) { + return this._isOpen; + } + else { + return this.open > 0; + } + }, + /* + * set open state (from toggler) + */ + set: function (value) { + this._isOpen = value; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(JSONFormatter.prototype, "isDate", { + /* + * is this a date string? + */ + get: function () { + return (this.type === 'string') && + (DATE_STRING_REGEX.test(this.json) || + JSON_DATE_REGEX.test(this.json) || + PARTIAL_DATE_REGEX.test(this.json)); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(JSONFormatter.prototype, "isUrl", { + /* + * is this a URL string? + */ + get: function () { + return this.type === 'string' && (this.json.indexOf('http') === 0); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(JSONFormatter.prototype, "isArray", { + /* + * is this an array? + */ + get: function () { + return Array.isArray(this.json); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(JSONFormatter.prototype, "isObject", { + /* + * is this an object? + * Note: In this context arrays are object as well + */ + get: function () { + return helpers_ts_1.isObject(this.json); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(JSONFormatter.prototype, "isEmptyObject", { + /* + * is this an empty object with no properties? + */ + get: function () { + return !this.keys.length && !this.isArray; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(JSONFormatter.prototype, "isEmpty", { + /* + * is this an empty object or array? + */ + get: function () { + return this.isEmptyObject || (this.keys && !this.keys.length && this.isArray); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(JSONFormatter.prototype, "hasKey", { + /* + * did we receive a key argument? + * This means that the formatter was called as a sub formatter of a parent formatter + */ + get: function () { + return typeof this.key !== 'undefined'; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(JSONFormatter.prototype, "constructorName", { + /* + * if this is an object, get constructor function name + */ + get: function () { + return helpers_ts_1.getObjectName(this.json); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(JSONFormatter.prototype, "type", { + /* + * get type of this value + * Possible values: all JavaScript primitive types plus "array" and "null" + */ + get: function () { + return helpers_ts_1.getType(this.json); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(JSONFormatter.prototype, "keys", { + /* + * get object keys + * If there is an empty key we pad it wit quotes to make it visible + */ + get: function () { + if (this.isObject) { + return Object.keys(this.json).map(function (key) { return key ? key : '""'; }); + } + else { + return []; + } + }, + enumerable: true, + configurable: true + }); + /** + * Toggles `isOpen` state + * + */ + JSONFormatter.prototype.toggleOpen = function () { + this.isOpen = !this.isOpen; + if (this.element) { + if (this.isOpen) { + this.appendChildren(this.config.animateOpen); + } + else { + this.removeChildren(this.config.animateClose); + } + this.element.classList.toggle(helpers_ts_1.cssClass('open')); + } + }; + /** + * Open all children up to a certain depth. + * Allows actions such as expand all/collapse all + * + */ + JSONFormatter.prototype.openAtDepth = function (depth) { + if (depth === void 0) { depth = 1; } + if (depth < 0) { + return; + } + this.open = depth; + this.isOpen = (depth !== 0); + if (this.element) { + this.removeChildren(false); + if (depth === 0) { + this.element.classList.remove(helpers_ts_1.cssClass('open')); + } + else { + this.appendChildren(this.config.animateOpen); + this.element.classList.add(helpers_ts_1.cssClass('open')); + } + } + }; + /** + * Generates inline preview + * + * @returns {string} + */ + JSONFormatter.prototype.getInlinepreview = function () { + var _this = this; + if (this.isArray) { + // if array length is greater then 100 it shows "Array[101]" + if (this.json.length > this.config.hoverPreviewArrayCount) { + return "Array[" + this.json.length + "]"; + } + else { + return "[" + this.json.map(helpers_ts_1.getPreview).join(', ') + "]"; + } + } + else { + var keys = this.keys; + // the first five keys (like Chrome Developer Tool) + var narrowKeys = keys.slice(0, this.config.hoverPreviewFieldCount); + // json value schematic information + var kvs = narrowKeys.map(function (key) { return (key + ":" + helpers_ts_1.getPreview(_this.json[key])); }); + // if keys count greater then 5 then show ellipsis + var ellipsis = keys.length >= this.config.hoverPreviewFieldCount ? '…' : ''; + return "{" + kvs.join(', ') + ellipsis + "}"; + } + }; + /** + * Renders an HTML element and installs event listeners + * + * @returns {HTMLDivElement} + */ + JSONFormatter.prototype.render = function () { + // construct the root element and assign it to this.element + this.element = helpers_ts_1.createElement('div', 'row'); + // construct the toggler link + var togglerLink = helpers_ts_1.createElement('a', 'toggler-link'); + // if this is an object we need a wrapper span (toggler) + if (this.isObject) { + togglerLink.appendChild(helpers_ts_1.createElement('span', 'toggler')); + } + // if this is child of a parent formatter we need to append the key + if (this.hasKey) { + togglerLink.appendChild(helpers_ts_1.createElement('span', 'key', this.key + ":")); + } + // Value for objects and arrays + if (this.isObject) { + // construct the value holder element + var value = helpers_ts_1.createElement('span', 'value'); + // we need a wrapper span for objects + var objectWrapperSpan = helpers_ts_1.createElement('span'); + // get constructor name and append it to wrapper span + var constructorName = helpers_ts_1.createElement('span', 'constructor-name', this.constructorName); + objectWrapperSpan.appendChild(constructorName); + // if it's an array append the array specific elements like brackets and length + if (this.isArray) { + var arrayWrapperSpan = helpers_ts_1.createElement('span'); + arrayWrapperSpan.appendChild(helpers_ts_1.createElement('span', 'bracket', '[')); + arrayWrapperSpan.appendChild(helpers_ts_1.createElement('span', 'number', (this.json.length))); + arrayWrapperSpan.appendChild(helpers_ts_1.createElement('span', 'bracket', ']')); + objectWrapperSpan.appendChild(arrayWrapperSpan); + } + // append object wrapper span to toggler link + value.appendChild(objectWrapperSpan); + togglerLink.appendChild(value); + } + else { + // make a value holder element + var value = this.isUrl ? helpers_ts_1.createElement('a') : helpers_ts_1.createElement('span'); + // add type and other type related CSS classes + value.classList.add(helpers_ts_1.cssClass(this.type)); + if (this.isDate) { + value.classList.add(helpers_ts_1.cssClass('date')); + } + if (this.isUrl) { + value.classList.add(helpers_ts_1.cssClass('url')); + value.setAttribute('href', this.json); + } + // Append value content to value element + var valuePreview = helpers_ts_1.getValuePreview(this.json, this.json); + value.appendChild(document.createTextNode(valuePreview)); + // append the value element to toggler link + togglerLink.appendChild(value); + } + // if hover preview is enabled, append the inline preview element + if (this.isObject && this.config.hoverPreviewEnabled) { + var preview = helpers_ts_1.createElement('span', 'preview-text'); + preview.appendChild(document.createTextNode(this.getInlinepreview())); + togglerLink.appendChild(preview); + } + // construct a children element + var children = helpers_ts_1.createElement('div', 'children'); + // set CSS classes for children + if (this.isObject) { + children.classList.add(helpers_ts_1.cssClass('object')); + } + if (this.isArray) { + children.classList.add(helpers_ts_1.cssClass('array')); + } + if (this.isEmpty) { + children.classList.add(helpers_ts_1.cssClass('empty')); + } + // set CSS classes for root element + if (this.config && this.config.theme) { + this.element.classList.add(helpers_ts_1.cssClass(this.config.theme)); + } + if (this.isOpen) { + this.element.classList.add(helpers_ts_1.cssClass('open')); + } + // append toggler and children elements to root element + this.element.appendChild(togglerLink); + this.element.appendChild(children); + // if formatter is set to be open call appendChildren + if (this.isObject && this.isOpen) { + this.appendChildren(); + } + // add event listener for toggling + if (this.isObject) { + togglerLink.addEventListener('click', this.toggleOpen.bind(this)); + } + return this.element; + }; + /** + * Appends all the children to children element + * Animated option is used when user triggers this via a click + */ + JSONFormatter.prototype.appendChildren = function (animated) { + var _this = this; + if (animated === void 0) { animated = false; } + var children = this.element.querySelector("div." + helpers_ts_1.cssClass('children')); + if (!children || this.isEmpty) { + return; + } + if (animated) { + var index_1 = 0; + var addAChild_1 = function () { + var key = _this.keys[index_1]; + var formatter = new JSONFormatter(_this.json[key], _this.open - 1, _this.config, key); + children.appendChild(formatter.render()); + index_1 += 1; + if (index_1 < _this.keys.length) { + if (index_1 > MAX_ANIMATED_TOGGLE_ITEMS) { + addAChild_1(); + } + else { + requestAnimationFrame(addAChild_1); + } + } + }; + requestAnimationFrame(addAChild_1); + } + else { + this.keys.forEach(function (key) { + var formatter = new JSONFormatter(_this.json[key], _this.open - 1, _this.config, key); + children.appendChild(formatter.render()); + }); + } + }; + /** + * Removes all the children from children element + * Animated option is used when user triggers this via a click + */ + JSONFormatter.prototype.removeChildren = function (animated) { + if (animated === void 0) { animated = false; } + var childrenElement = this.element.querySelector("div." + helpers_ts_1.cssClass('children')); + if (animated) { + var childrenRemoved_1 = 0; + var removeAChild_1 = function () { + if (childrenElement && childrenElement.children.length) { + childrenElement.removeChild(childrenElement.children[0]); + childrenRemoved_1 += 1; + if (childrenRemoved_1 > MAX_ANIMATED_TOGGLE_ITEMS) { + removeAChild_1(); + } + else { + requestAnimationFrame(removeAChild_1); + } + } + }; + requestAnimationFrame(removeAChild_1); + } + else { + if (childrenElement) { + childrenElement.innerHTML = ''; + } + } + }; + return JSONFormatter; + }()); + + +/***/ }, +/* 2 */ +/***/ function(module, exports, __webpack_require__) { + + // style-loader: Adds some css to the DOM by adding a - - - - - - - - - {{>sidenav}} -
-
-

{{{appName}}}

- {{#version}} -
Version: {{{version}}}
- {{/version}} -
- -
- {{#apiInfo}} - {{#apis}} - {{#operations}} -
-

{{baseName}}

- {{#operation}} -
-
-

{{#summary}}{{.}}{{/summary}}{{^summary}}{{nickname}}{{/summary}}{{#isDeprecated}}Deprecated {{/isDeprecated}}

- {{#description}}

{{description}}

{{/description}} -

{{notes}}

-
- {{#vendorExtensions}} -
-

Secured by Backbase Access Control

- {{#x-BbAccessControl-resource}}
Resource: {{.}}
{{/x-BbAccessControl-resource}} - {{#x-BbAccessControl-function}}
Function: {{.}}
{{/x-BbAccessControl-function}} - {{#x-BbAccessControl-privilege}}
Privilege: {{.}}
{{/x-BbAccessControl-privilege}} -
- {{/vendorExtensions}} -
{{httpMethod}}{{path}}
- - {{#hasAuthMethods}} -

Scopes

- - {{#authMethods}}{{#scopes}} - - - - - {{/scopes}}{{/authMethods}} -
{{scope}}{{description}}
- {{/hasAuthMethods}} - - {{#hasPathParams}} -

Path parameters

-
- {{#pathParams}} - {{>param}} - {{/pathParams}} -
- {{/hasPathParams}} - - {{#hasHeaderParams}} -

Header parameters

-
- {{#headerParams}} - {{>param}} - {{/headerParams}} -
- {{/hasHeaderParams}} - - {{#hasFormParams}} -

Form parameters

-
- {{#formParams}} - {{>param}} - {{/formParams}} -
- {{/hasFormParams}} - - {{#hasQueryParams}} -

Query parameters

-
- {{#queryParams}} - {{>param}} - {{/queryParams}} -
- {{/hasQueryParams}} - - {{#hasBodyParam}} -

Request Body Schema

- {{#bodyParams}} - {{>paramB}} - {{/bodyParams}} - - {{/hasBodyParam}} - -

Responses

- {{#responses}} - {{>response}} - {{/responses}} -
-
- {{/operation}} -
- {{/operations}} - {{/apis}} - {{/apiInfo}} -
-
- -{{^hideGenerationTimestamp}} -
-
- Generated {{generatedDate}} -
-
-{{/hideGenerationTimestamp}} - -
- - - - - - - - - - - - - - - - - - diff --git a/boat-scaffold/src/main/templates/boat-marina/index.js.handlebars b/boat-scaffold/src/main/templates/boat-marina/index.js.handlebars deleted file mode 100644 index b82b8d6bb..000000000 --- a/boat-scaffold/src/main/templates/boat-marina/index.js.handlebars +++ /dev/null @@ -1 +0,0 @@ -{{. json}} \ No newline at end of file diff --git a/boat-scaffold/src/main/templates/boat-marina/js/json_stringify_safe.js b/boat-scaffold/src/main/templates/boat-marina/js/json_stringify_safe.js deleted file mode 100644 index cd16b3d01..000000000 --- a/boat-scaffold/src/main/templates/boat-marina/js/json_stringify_safe.js +++ /dev/null @@ -1,25 +0,0 @@ -// https://github.com/isaacs/json-stringify-safe v5.0.1 -function stringify(obj, replacer, spaces, cycleReplacer) { - return JSON.stringify(obj, serializer(replacer, cycleReplacer), spaces) -} - -function serializer(replacer, cycleReplacer) { - var stack = [], keys = [] - - if (cycleReplacer == null) cycleReplacer = function(key, value) { - if (stack[0] === value) return "[Circular ~]" - return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]" - } - - return function(key, value) { - if (stack.length > 0) { - var thisPos = stack.indexOf(this) - ~thisPos ? stack.splice(thisPos + 1) : stack.push(this) - ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key) - if (~stack.indexOf(value)) value = cycleReplacer.call(this, key, value) - } - else stack.push(value) - - return replacer == null ? value : replacer.call(this, key, value) - } -} diff --git a/boat-scaffold/src/main/templates/boat-marina/js/jsonformatter.js b/boat-scaffold/src/main/templates/boat-marina/js/jsonformatter.js deleted file mode 100644 index 4c8695874..000000000 --- a/boat-scaffold/src/main/templates/boat-marina/js/jsonformatter.js +++ /dev/null @@ -1,961 +0,0 @@ -(function webpackUniversalModuleDefinition(root, factory) { - if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(); - else if(typeof define === 'function' && define.amd) - define("JSONFormatter", [], factory); - else if(typeof exports === 'object') - exports["JSONFormatter"] = factory(); - else - root["JSONFormatter"] = factory(); -})(this, function() { -return /******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) -/******/ return installedModules[moduleId].exports; -/******/ -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ exports: {}, -/******/ id: moduleId, -/******/ loaded: false -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.loaded = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = "dist"; -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(0); -/******/ }) -/************************************************************************/ -/******/ ([ -/* 0 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = __webpack_require__(1); - - -/***/ }, -/* 1 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - __webpack_require__(2); - var helpers_ts_1 = __webpack_require__(6); - var DATE_STRING_REGEX = /(^\d{1,4}[\.|\\/|-]\d{1,2}[\.|\\/|-]\d{1,4})(\s*(?:0?[1-9]:[0-5]|1(?=[012])\d:[0-5])\d\s*[ap]m)?$/; - var PARTIAL_DATE_REGEX = /\d{2}:\d{2}:\d{2} GMT-\d{4}/; - var JSON_DATE_REGEX = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/; - // When toggleing, don't animated removal or addition of more than a few items - var MAX_ANIMATED_TOGGLE_ITEMS = 10; - var requestAnimationFrame = window.requestAnimationFrame || function (cb) { cb(); return 0; }; - ; - var _defaultConfig = { - hoverPreviewEnabled: false, - hoverPreviewArrayCount: 100, - hoverPreviewFieldCount: 5, - animateOpen: true, - animateClose: true, - theme: null - }; - module.exports = (function () { - /** - * @param {object} json The JSON object you want to render. It has to be an - * object or array. Do NOT pass raw JSON string. - * - * @param {number} [open=1] his number indicates up to how many levels the - * rendered tree should expand. Set it to `0` to make the whole tree collapsed - * or set it to `Infinity` to expand the tree deeply - * - * @param {object} [config=defaultConfig] - - * defaultConfig = { - * hoverPreviewEnabled: false, - * hoverPreviewArrayCount: 100, - * hoverPreviewFieldCount: 5 - * } - * - * Available configurations: - * #####Hover Preview - * * `hoverPreviewEnabled`: enable preview on hover - * * `hoverPreviewArrayCount`: number of array items to show in preview Any - * array larger than this number will be shown as `Array[XXX]` where `XXX` - * is length of the array. - * * `hoverPreviewFieldCount`: number of object properties to show for object - * preview. Any object with more properties that thin number will be - * truncated. - * - * @param {string} [key=undefined] The key that this object in it's parent - * context - */ - function JSONFormatter(json, open, config, key) { - if (open === void 0) { open = 1; } - if (config === void 0) { config = _defaultConfig; } - this.json = json; - this.open = open; - this.config = config; - this.key = key; - // Hold the open state after the toggler is used - this._isOpen = null; - // Setting default values for config object - if (this.config.hoverPreviewEnabled === undefined) { - this.config.hoverPreviewEnabled = _defaultConfig.hoverPreviewEnabled; - } - if (this.config.hoverPreviewArrayCount === undefined) { - this.config.hoverPreviewArrayCount = _defaultConfig.hoverPreviewArrayCount; - } - if (this.config.hoverPreviewFieldCount === undefined) { - this.config.hoverPreviewFieldCount = _defaultConfig.hoverPreviewFieldCount; - } - } - Object.defineProperty(JSONFormatter.prototype, "isOpen", { - /* - * is formatter open? - */ - get: function () { - if (this._isOpen !== null) { - return this._isOpen; - } - else { - return this.open > 0; - } - }, - /* - * set open state (from toggler) - */ - set: function (value) { - this._isOpen = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(JSONFormatter.prototype, "isDate", { - /* - * is this a date string? - */ - get: function () { - return (this.type === 'string') && - (DATE_STRING_REGEX.test(this.json) || - JSON_DATE_REGEX.test(this.json) || - PARTIAL_DATE_REGEX.test(this.json)); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(JSONFormatter.prototype, "isUrl", { - /* - * is this a URL string? - */ - get: function () { - return this.type === 'string' && (this.json.indexOf('http') === 0); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(JSONFormatter.prototype, "isArray", { - /* - * is this an array? - */ - get: function () { - return Array.isArray(this.json); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(JSONFormatter.prototype, "isObject", { - /* - * is this an object? - * Note: In this context arrays are object as well - */ - get: function () { - return helpers_ts_1.isObject(this.json); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(JSONFormatter.prototype, "isEmptyObject", { - /* - * is this an empty object with no properties? - */ - get: function () { - return !this.keys.length && !this.isArray; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(JSONFormatter.prototype, "isEmpty", { - /* - * is this an empty object or array? - */ - get: function () { - return this.isEmptyObject || (this.keys && !this.keys.length && this.isArray); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(JSONFormatter.prototype, "hasKey", { - /* - * did we receive a key argument? - * This means that the formatter was called as a sub formatter of a parent formatter - */ - get: function () { - return typeof this.key !== 'undefined'; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(JSONFormatter.prototype, "constructorName", { - /* - * if this is an object, get constructor function name - */ - get: function () { - return helpers_ts_1.getObjectName(this.json); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(JSONFormatter.prototype, "type", { - /* - * get type of this value - * Possible values: all JavaScript primitive types plus "array" and "null" - */ - get: function () { - return helpers_ts_1.getType(this.json); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(JSONFormatter.prototype, "keys", { - /* - * get object keys - * If there is an empty key we pad it wit quotes to make it visible - */ - get: function () { - if (this.isObject) { - return Object.keys(this.json).map(function (key) { return key ? key : '""'; }); - } - else { - return []; - } - }, - enumerable: true, - configurable: true - }); - /** - * Toggles `isOpen` state - * - */ - JSONFormatter.prototype.toggleOpen = function () { - this.isOpen = !this.isOpen; - if (this.element) { - if (this.isOpen) { - this.appendChildren(this.config.animateOpen); - } - else { - this.removeChildren(this.config.animateClose); - } - this.element.classList.toggle(helpers_ts_1.cssClass('open')); - } - }; - /** - * Open all children up to a certain depth. - * Allows actions such as expand all/collapse all - * - */ - JSONFormatter.prototype.openAtDepth = function (depth) { - if (depth === void 0) { depth = 1; } - if (depth < 0) { - return; - } - this.open = depth; - this.isOpen = (depth !== 0); - if (this.element) { - this.removeChildren(false); - if (depth === 0) { - this.element.classList.remove(helpers_ts_1.cssClass('open')); - } - else { - this.appendChildren(this.config.animateOpen); - this.element.classList.add(helpers_ts_1.cssClass('open')); - } - } - }; - /** - * Generates inline preview - * - * @returns {string} - */ - JSONFormatter.prototype.getInlinepreview = function () { - var _this = this; - if (this.isArray) { - // if array length is greater then 100 it shows "Array[101]" - if (this.json.length > this.config.hoverPreviewArrayCount) { - return "Array[" + this.json.length + "]"; - } - else { - return "[" + this.json.map(helpers_ts_1.getPreview).join(', ') + "]"; - } - } - else { - var keys = this.keys; - // the first five keys (like Chrome Developer Tool) - var narrowKeys = keys.slice(0, this.config.hoverPreviewFieldCount); - // json value schematic information - var kvs = narrowKeys.map(function (key) { return (key + ":" + helpers_ts_1.getPreview(_this.json[key])); }); - // if keys count greater then 5 then show ellipsis - var ellipsis = keys.length >= this.config.hoverPreviewFieldCount ? '…' : ''; - return "{" + kvs.join(', ') + ellipsis + "}"; - } - }; - /** - * Renders an HTML element and installs event listeners - * - * @returns {HTMLDivElement} - */ - JSONFormatter.prototype.render = function () { - // construct the root element and assign it to this.element - this.element = helpers_ts_1.createElement('div', 'row'); - // construct the toggler link - var togglerLink = helpers_ts_1.createElement('a', 'toggler-link'); - // if this is an object we need a wrapper span (toggler) - if (this.isObject) { - togglerLink.appendChild(helpers_ts_1.createElement('span', 'toggler')); - } - // if this is child of a parent formatter we need to append the key - if (this.hasKey) { - togglerLink.appendChild(helpers_ts_1.createElement('span', 'key', this.key + ":")); - } - // Value for objects and arrays - if (this.isObject) { - // construct the value holder element - var value = helpers_ts_1.createElement('span', 'value'); - // we need a wrapper span for objects - var objectWrapperSpan = helpers_ts_1.createElement('span'); - // get constructor name and append it to wrapper span - var constructorName = helpers_ts_1.createElement('span', 'constructor-name', this.constructorName); - objectWrapperSpan.appendChild(constructorName); - // if it's an array append the array specific elements like brackets and length - if (this.isArray) { - var arrayWrapperSpan = helpers_ts_1.createElement('span'); - arrayWrapperSpan.appendChild(helpers_ts_1.createElement('span', 'bracket', '[')); - arrayWrapperSpan.appendChild(helpers_ts_1.createElement('span', 'number', (this.json.length))); - arrayWrapperSpan.appendChild(helpers_ts_1.createElement('span', 'bracket', ']')); - objectWrapperSpan.appendChild(arrayWrapperSpan); - } - // append object wrapper span to toggler link - value.appendChild(objectWrapperSpan); - togglerLink.appendChild(value); - } - else { - // make a value holder element - var value = this.isUrl ? helpers_ts_1.createElement('a') : helpers_ts_1.createElement('span'); - // add type and other type related CSS classes - value.classList.add(helpers_ts_1.cssClass(this.type)); - if (this.isDate) { - value.classList.add(helpers_ts_1.cssClass('date')); - } - if (this.isUrl) { - value.classList.add(helpers_ts_1.cssClass('url')); - value.setAttribute('href', this.json); - } - // Append value content to value element - var valuePreview = helpers_ts_1.getValuePreview(this.json, this.json); - value.appendChild(document.createTextNode(valuePreview)); - // append the value element to toggler link - togglerLink.appendChild(value); - } - // if hover preview is enabled, append the inline preview element - if (this.isObject && this.config.hoverPreviewEnabled) { - var preview = helpers_ts_1.createElement('span', 'preview-text'); - preview.appendChild(document.createTextNode(this.getInlinepreview())); - togglerLink.appendChild(preview); - } - // construct a children element - var children = helpers_ts_1.createElement('div', 'children'); - // set CSS classes for children - if (this.isObject) { - children.classList.add(helpers_ts_1.cssClass('object')); - } - if (this.isArray) { - children.classList.add(helpers_ts_1.cssClass('array')); - } - if (this.isEmpty) { - children.classList.add(helpers_ts_1.cssClass('empty')); - } - // set CSS classes for root element - if (this.config && this.config.theme) { - this.element.classList.add(helpers_ts_1.cssClass(this.config.theme)); - } - if (this.isOpen) { - this.element.classList.add(helpers_ts_1.cssClass('open')); - } - // append toggler and children elements to root element - this.element.appendChild(togglerLink); - this.element.appendChild(children); - // if formatter is set to be open call appendChildren - if (this.isObject && this.isOpen) { - this.appendChildren(); - } - // add event listener for toggling - if (this.isObject) { - togglerLink.addEventListener('click', this.toggleOpen.bind(this)); - } - return this.element; - }; - /** - * Appends all the children to children element - * Animated option is used when user triggers this via a click - */ - JSONFormatter.prototype.appendChildren = function (animated) { - var _this = this; - if (animated === void 0) { animated = false; } - var children = this.element.querySelector("div." + helpers_ts_1.cssClass('children')); - if (!children || this.isEmpty) { - return; - } - if (animated) { - var index_1 = 0; - var addAChild_1 = function () { - var key = _this.keys[index_1]; - var formatter = new JSONFormatter(_this.json[key], _this.open - 1, _this.config, key); - children.appendChild(formatter.render()); - index_1 += 1; - if (index_1 < _this.keys.length) { - if (index_1 > MAX_ANIMATED_TOGGLE_ITEMS) { - addAChild_1(); - } - else { - requestAnimationFrame(addAChild_1); - } - } - }; - requestAnimationFrame(addAChild_1); - } - else { - this.keys.forEach(function (key) { - var formatter = new JSONFormatter(_this.json[key], _this.open - 1, _this.config, key); - children.appendChild(formatter.render()); - }); - } - }; - /** - * Removes all the children from children element - * Animated option is used when user triggers this via a click - */ - JSONFormatter.prototype.removeChildren = function (animated) { - if (animated === void 0) { animated = false; } - var childrenElement = this.element.querySelector("div." + helpers_ts_1.cssClass('children')); - if (animated) { - var childrenRemoved_1 = 0; - var removeAChild_1 = function () { - if (childrenElement && childrenElement.children.length) { - childrenElement.removeChild(childrenElement.children[0]); - childrenRemoved_1 += 1; - if (childrenRemoved_1 > MAX_ANIMATED_TOGGLE_ITEMS) { - removeAChild_1(); - } - else { - requestAnimationFrame(removeAChild_1); - } - } - }; - requestAnimationFrame(removeAChild_1); - } - else { - if (childrenElement) { - childrenElement.innerHTML = ''; - } - } - }; - return JSONFormatter; - }()); - - -/***/ }, -/* 2 */ -/***/ function(module, exports, __webpack_require__) { - - // style-loader: Adds some css to the DOM by adding a