mirror of
				https://github.com/OpenAPITools/openapi-generator.git
				synced 2025-10-31 00:33:49 +00:00 
			
		
		
		
	Fix boolean option in asciidoc generator (#4856)
* fix boolean option in asciidoc generator * minor code format chagne
This commit is contained in:
		
							parent
							
								
									e90fa5c4df
								
							
						
					
					
						commit
						a95e3e3684
					
				| @ -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} | ||||
|  | ||||
| @ -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; | ||||
| @ -160,7 +161,7 @@ public class AsciidocDocumentationCodegen extends DefaultCodegen implements Code | ||||
|     static String sanitize(final String name) { | ||||
|         String sanitized = name == null ? "" : name.trim(); | ||||
|         sanitized = sanitized.replace("//", "/"); // rest paths may or may not end with slashes, leading to redundant | ||||
|                                                   // path separators. | ||||
|         // path separators. | ||||
|         return sanitized.startsWith(File.separator) || sanitized.startsWith("/") ? sanitized.substring(1) : sanitized; | ||||
|     } | ||||
| 
 | ||||
| @ -203,13 +204,13 @@ public class AsciidocDocumentationCodegen extends DefaultCodegen implements Code | ||||
| 
 | ||||
|         cliOptions.add(new CliOption(SNIPPET_DIR, | ||||
|                 "path with includable markup snippets (e.g. test output generated by restdoc, default: .)") | ||||
|                         .defaultValue(".")); | ||||
|                 .defaultValue(".")); | ||||
|         cliOptions.add(new CliOption(SPEC_DIR, | ||||
|                 "path with includable markup spec files (e.g. handwritten additional docs, default: ..)") | ||||
|                         .defaultValue(".."));        | ||||
|                 .defaultValue("..")); | ||||
|         cliOptions.add(CliOption.newBoolean(HEADER_ATTRIBUTES_FLAG, | ||||
|                 "generation of asciidoc header meta data attributes (set to false to suppress, default: true)", | ||||
|                 true));         | ||||
|                 true)); | ||||
| 
 | ||||
|         additionalProperties.put("appName", "OpenAPI Sample description"); | ||||
|         additionalProperties.put("appDescription", "A sample OpenAPI documentation"); | ||||
| @ -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(); | ||||
| @ -264,16 +273,12 @@ 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); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user