Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor improvements to plantuml doc generator #6298

Merged
merged 3 commits into from
May 15, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,7 @@ Here is a list of template creators:
* AsciiDoc: @man-at-home
* HTML Doc 2: @jhitchcock
* Confluence Wiki: @jhitchcock
* PlantUML: @pburls
* Configuration
* Apache2: @stkrwork
* k6: @mostafa
Expand Down
2 changes: 1 addition & 1 deletion bin/plantuml-documentation-petstore.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ fi

# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g plantuml -o samples/documentation/petstore/plantuml"
ags="$@ generate -t modules/openapi-generator/src/main/resources/plantuml -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g plantuml -o samples/documentation/petstore/plantuml"

java ${JAVA_OPTS} -jar ${executable} ${ags}
2 changes: 1 addition & 1 deletion bin/windows/plantuml-documentation-petstore.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ If Not Exist %executable% (
)

REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
set ags=generate --artifact-id "plantuml-petstore-documentation" -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g plantuml -o samples\documentation\petstore\plantuml
set ags=generate -t modules\openapi-generator\src\main\resources\plantuml-documentation -i modules\openapi-generator\src\test\resources\3_0\petstore.yaml -g plantuml -o samples\documentation\petstore\plantuml
wing328 marked this conversation as resolved.
Show resolved Hide resolved

java %JAVA_OPTS% -jar %executable% %ags%
2 changes: 1 addition & 1 deletion docs/generators.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ The following generators are available:
* [markdown (beta)](generators/markdown.md)
* [openapi](generators/openapi.md)
* [openapi-yaml](generators/openapi-yaml.md)
* [plantuml](generators/plantuml.md)
* [plantuml (beta)](generators/plantuml.md)


## SCHEMA generators
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
/*
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.openapitools.codegen.languages;

import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.GeneratorMetadata;
import org.openapitools.codegen.meta.Stability;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class PlantumlDocumentationCodegen extends DefaultCodegen implements CodegenConfig {
public static final String ALL_OF_SUFFIX = "AllOf";

Expand All @@ -29,8 +46,12 @@ public String getHelp() {
public PlantumlDocumentationCodegen() {
super();

generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
.stability(Stability.BETA)
.build();

outputFolder = "generated-code" + File.separator + "plantuml";
embeddedTemplateDir = templateDir = "plantuml-documentation";
embeddedTemplateDir = templateDir = "plantuml";
supportingFiles.add(new SupportingFile("schemas.mustache", "", "schemas.plantuml"));
}

Expand All @@ -41,7 +62,7 @@ public Map<String, Object> postProcessSupportingFileData(Map<String, Object> obj
List<Object> modelsList = (List<Object>) models;
List<CodegenModel> codegenModelList = modelsList.stream()
.filter(listItem -> listItem instanceof HashMap<?, ?>)
.map(listItem -> (CodegenModel)((HashMap<?, ?>)listItem).get("model"))
.map(listItem -> (CodegenModel) ((HashMap<?, ?>) listItem).get("model"))
.collect(Collectors.toList());

List<CodegenModel> inlineAllOfCodegenModelList = codegenModelList.stream()
Expand Down Expand Up @@ -118,8 +139,8 @@ private Object createFieldFor(CodegenProperty codegenProperty) {

@SuppressWarnings("unchecked")
private List<Map<String, Object>> calculateCompositionRelationshipsFrom(List<Map<String, Object>> entities) {
Map<String, List<Map<String, Object>>> entityFieldsMap = entities.stream()
.collect(Collectors.toMap(entity -> (String)entity.get("name"), entity -> (List<Map<String, Object>>)entity.get("fields")));
Map<String, List<Map<String, Object>>> entityFieldsMap = entities.stream()
.collect(Collectors.toMap(entity -> (String) entity.get("name"), entity -> (List<Map<String, Object>>) entity.get("fields")));

return entityFieldsMap.entrySet().stream()
.map(entry -> createRelationshipsFor(entry.getKey(), entry.getValue()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ org.openapitools.codegen.languages.AdaServerCodegen
org.openapitools.codegen.languages.AndroidClientCodegen
org.openapitools.codegen.languages.Apache2ConfigCodegen
org.openapitools.codegen.languages.ApexClientCodegen
org.openapitools.codegen.languages.AsciidocDocumentationCodegen
org.openapitools.codegen.languages.AspNetCoreServerCodegen
org.openapitools.codegen.languages.AvroSchemaCodegen
org.openapitools.codegen.languages.BashClientCodegen
Expand All @@ -29,6 +30,7 @@ org.openapitools.codegen.languages.ErlangClientCodegen
org.openapitools.codegen.languages.ErlangProperCodegen
org.openapitools.codegen.languages.ErlangServerCodegen
org.openapitools.codegen.languages.FlashClientCodegen
org.openapitools.codegen.languages.FsharpFunctionsServerCodegen
org.openapitools.codegen.languages.FsharpGiraffeServerCodegen
org.openapitools.codegen.languages.GoClientCodegen
org.openapitools.codegen.languages.GoClientExperimentalCodegen
Expand Down Expand Up @@ -66,6 +68,7 @@ org.openapitools.codegen.languages.JavascriptClosureAngularClientCodegen
org.openapitools.codegen.languages.JMeterClientCodegen
org.openapitools.codegen.languages.K6ClientCodegen
org.openapitools.codegen.languages.LuaClientCodegen
org.openapitools.codegen.languages.MarkdownDocumentationCodegen
org.openapitools.codegen.languages.MysqlSchemaCodegen
org.openapitools.codegen.languages.NimClientCodegen
org.openapitools.codegen.languages.NodeJSServerCodegen
Expand All @@ -74,6 +77,7 @@ org.openapitools.codegen.languages.ObjcClientCodegen
org.openapitools.codegen.languages.OCamlClientCodegen
org.openapitools.codegen.languages.OpenAPIGenerator
org.openapitools.codegen.languages.OpenAPIYamlGenerator
org.openapitools.codegen.languages.PlantumlDocumentationCodegen
org.openapitools.codegen.languages.PerlClientCodegen
org.openapitools.codegen.languages.PhpClientCodegen
org.openapitools.codegen.languages.PhpLaravelServerCodegen
Expand All @@ -98,11 +102,13 @@ org.openapitools.codegen.languages.RustClientCodegen
org.openapitools.codegen.languages.RustServerCodegen
org.openapitools.codegen.languages.ScalatraServerCodegen
org.openapitools.codegen.languages.ScalaAkkaClientCodegen
org.openapitools.codegen.languages.ScalaAkkaHttpServerCodegen
org.openapitools.codegen.languages.ScalaFinchServerCodegen
org.openapitools.codegen.languages.ScalaHttpClientCodegen
org.openapitools.codegen.languages.ScalaGatlingCodegen
org.openapitools.codegen.languages.ScalaLagomServerCodegen
org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen
org.openapitools.codegen.languages.ScalaSttpClientCodegen
org.openapitools.codegen.languages.ScalazClientCodegen
org.openapitools.codegen.languages.SpringCodegen
org.openapitools.codegen.languages.StaticDocCodegen
Expand All @@ -121,14 +127,4 @@ org.openapitools.codegen.languages.TypeScriptInversifyClientCodegen
org.openapitools.codegen.languages.TypeScriptJqueryClientCodegen
org.openapitools.codegen.languages.TypeScriptNodeClientCodegen
org.openapitools.codegen.languages.TypeScriptReduxQueryClientCodegen
org.openapitools.codegen.languages.TypeScriptRxjsClientCodegen
org.openapitools.codegen.languages.FsharpGiraffeServerCodegen
org.openapitools.codegen.languages.AsciidocDocumentationCodegen
org.openapitools.codegen.languages.FsharpFunctionsServerCodegen

org.openapitools.codegen.languages.MarkdownDocumentationCodegen
org.openapitools.codegen.languages.ScalaSttpClientCodegen

org.openapitools.codegen.languages.ScalaAkkaHttpServerCodegen

org.openapitools.codegen.languages.PlantumlDocumentationCodegen
org.openapitools.codegen.languages.TypeScriptRxjsClientCodegen
10 changes: 10 additions & 0 deletions samples/documentation/petstore/plantuml/schemas.plantuml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ entity Category {
name: String
}

entity InlineObject {
name: String
status: String
}

entity InlineObject1 {
additionalMetadata: String
file: File
}

entity Order {
id: Long
petId: Long
Expand Down