Fix boolean option in asciidoc generator (#4856)

* fix boolean option in asciidoc generator

* minor code format chagne
This commit is contained in:
William Cheng 2019-12-22 18:18:16 +08:00 committed by GitHub
parent e90fa5c4df
commit a95e3e3684
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 15 deletions

View File

@ -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 -t modules/openapi-generator/src/main/resources/asciidoc-documentation --additional-properties=specDir=modules/openapi-generator/src/main/resources/asciidoc-documentation,snippetDir=. -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g asciidoc -o samples/documentation/asciidoc"
ags="generate -t modules/openapi-generator/src/main/resources/asciidoc-documentation --additional-properties=specDir=modules/openapi-generator/src/main/resources/asciidoc-documentation,snippetDir=. -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g asciidoc -o samples/documentation/asciidoc $@"
java ${JAVA_OPTS} -jar ${executable} ${ags}

View File

@ -141,6 +141,7 @@ public class AsciidocDocumentationCodegen extends DefaultCodegen implements Code
protected String groupId = "org.openapitools";
protected String artifactId = "openapi-client";
protected String artifactVersion = "1.0.0";
protected boolean headerAttributes = true;
private IncludeMarkupLambda includeSpecMarkupLambda;
private IncludeMarkupLambda includeSnippetMarkupLambda;
@ -240,6 +241,14 @@ public class AsciidocDocumentationCodegen extends DefaultCodegen implements Code
return input; // just return the original string
}
public boolean isHeaderAttributes() {
return headerAttributes;
}
public void setHeaderAttributes(boolean headerAttributes) {
this.headerAttributes = headerAttributes;
}
@Override
public void processOpts() {
super.processOpts();
@ -265,15 +274,11 @@ public class AsciidocDocumentationCodegen extends DefaultCodegen implements Code
this.linkSnippetMarkupLambda = new LinkMarkupLambda(snippetDir);
additionalProperties.put("snippetlink", this.linkSnippetMarkupLambda);
if(this.additionalProperties.get(HEADER_ATTRIBUTES_FLAG) == null ||
! (this.additionalProperties.get(HEADER_ATTRIBUTES_FLAG) instanceof String) ) {
{
this.additionalProperties.put(HEADER_ATTRIBUTES_FLAG, true);
}
if (additionalProperties.containsKey(HEADER_ATTRIBUTES_FLAG)) {
this.setHeaderAttributes(convertPropertyToBooleanAndWriteBack(HEADER_ATTRIBUTES_FLAG));
} else {
String headerAttributesFlagValue = (String) this.additionalProperties.get(HEADER_ATTRIBUTES_FLAG);
LOGGER.debug("asciidoc: header attributes flag..: " + headerAttributesFlagValue);
this.additionalProperties.put(HEADER_ATTRIBUTES_FLAG, "TRUE".equalsIgnoreCase(headerAttributesFlagValue)); // change attribute in map to type boolean.
additionalProperties.put(HEADER_ATTRIBUTES_FLAG, headerAttributes);
}
}

View File

@ -6,7 +6,7 @@ team@openapitools.org
:toclevels: 3
:source-highlighter: highlightjs
:keywords: openapi, rest, OpenAPI Petstore
:specDir: modules\openapi-generator\src\main\resources\asciidoc-documentation
:specDir: modules/openapi-generator/src/main/resources/asciidoc-documentation
:snippetDir: .
:generator-template: v1 2019-12-20
:info-url: https://openapi-generator.tech