forked from loafle/openapi-generator-original
[cpp-restsdk] Support multi-line descriptions (#753)
* Update IndentedLambda to take optional prefix * Add `multiline_comment_4` to CppRestSdkClient * Update cpp-restsdk example
This commit is contained in:
parent
a0984a9be8
commit
987fd77042
@ -19,13 +19,17 @@ package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenProperty;
|
||||
import org.openapitools.codegen.DefaultCodegen;
|
||||
import org.openapitools.codegen.mustache.IndentedLambda;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
abstract public class AbstractCppCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractCppCodegen.class);
|
||||
@ -242,4 +246,23 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg
|
||||
public String getTypeDeclaration(String str) {
|
||||
return "std::shared_ptr<" + toModelName(str) + ">";
|
||||
}
|
||||
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
addMustacheLambdas(additionalProperties);
|
||||
}
|
||||
|
||||
private void addMustacheLambdas(Map<String, Object> objs) {
|
||||
|
||||
Map<String, Mustache.Lambda> lambdas = new ImmutableMap.Builder<String, Mustache.Lambda>()
|
||||
.put("multiline_comment_4", new IndentedLambda(4, " ", "///"))
|
||||
.build();
|
||||
|
||||
if (objs.containsKey("lambda")) {
|
||||
LOGGER.warn("A property named 'lambda' already exists. Mustache lambdas renamed from 'lambda' to '_lambda'.");
|
||||
objs.put("_lambda", lambdas);
|
||||
} else {
|
||||
objs.put("lambda", lambdas);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,13 +43,14 @@ import java.io.Writer;
|
||||
*/
|
||||
public class IndentedLambda implements Mustache.Lambda {
|
||||
private final int prefixSpaceCount;
|
||||
private final String prefix;
|
||||
private int spaceCode;
|
||||
|
||||
/**
|
||||
* Constructs a new instance of {@link IndentedLambda}, with an indent count of 4 spaces
|
||||
*/
|
||||
public IndentedLambda() {
|
||||
this(4, " ");
|
||||
this(4, " ", null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -59,15 +60,38 @@ public class IndentedLambda implements Mustache.Lambda {
|
||||
* @param indentionCharacter String representation of the character used in the indent (e.g. " ", "\t", ".").
|
||||
*/
|
||||
public IndentedLambda(int prefixSpaceCount, String indentionCharacter) {
|
||||
this(prefixSpaceCount, Character.codePointAt(indentionCharacter, 0));
|
||||
this(prefixSpaceCount, Character.codePointAt(indentionCharacter, 0), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new instance of {@link IndentedLambda}, with customized indent count and intention character
|
||||
*
|
||||
* @param prefixSpaceCount The number of indented characters to apply as a prefix to a fragment.
|
||||
* @param indentionCharacter String representation of the character used in the indent (e.g. " ", "\t", ".").
|
||||
* @param prefix An optional prefix to prepend before the line (useful for multi-line comments).
|
||||
*/
|
||||
public IndentedLambda(int prefixSpaceCount, String indentionCharacter, String prefix) {
|
||||
this(prefixSpaceCount, Character.codePointAt(indentionCharacter, 0), prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new instance of {@link IndentedLambda}
|
||||
*
|
||||
* @param prefixSpaceCount The number of indented characters to apply as a prefix to a fragment.
|
||||
* @param indentionCodePoint Code point of the single character used for indentation.
|
||||
*/
|
||||
private IndentedLambda(int prefixSpaceCount, int indentionCodePoint) {
|
||||
this(prefixSpaceCount, indentionCodePoint, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new instance of {@link IndentedLambda}
|
||||
*
|
||||
* @param prefixSpaceCount The number of indented characters to apply as a prefix to a fragment.
|
||||
* @param indentionCodePoint Code point of the single character used for indentation.
|
||||
* @param prefix An optional prefix to prepend before the line (useful for multi-line comments).
|
||||
*/
|
||||
private IndentedLambda(int prefixSpaceCount, int indentionCodePoint, String prefix) {
|
||||
if (prefixSpaceCount <= 0) {
|
||||
throw new IllegalArgumentException("prefixSpaceCount must be greater than 0");
|
||||
}
|
||||
@ -78,6 +102,7 @@ public class IndentedLambda implements Mustache.Lambda {
|
||||
|
||||
this.prefixSpaceCount = prefixSpaceCount;
|
||||
this.spaceCode = indentionCodePoint;
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -96,6 +121,7 @@ public class IndentedLambda implements Mustache.Lambda {
|
||||
// So, we want to skip the first line.
|
||||
if (i > 0) {
|
||||
sb.append(prefixedIndention);
|
||||
if (prefix != null) sb.append(prefix);
|
||||
}
|
||||
|
||||
sb.append(line);
|
||||
|
@ -62,7 +62,7 @@ public:
|
||||
/// {{notes}}
|
||||
/// </remarks>
|
||||
{{#allParams}}
|
||||
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
|
||||
/// <param name="{{paramName}}">{{#lambda.multiline_comment_4}}{{description}}{{/lambda.multiline_comment_4}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
|
||||
{{/allParams}}
|
||||
pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> {{operationId}}(
|
||||
{{#allParams}}
|
||||
|
@ -1 +1 @@
|
||||
3.1.2-SNAPSHOT
|
||||
3.2.1-SNAPSHOT
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.1.2-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user