forked from loafle/openapi-generator-original
[Kotlin][client] Add nullable query parameter support (#4197)
* add nullable query parameter support * remove redundant bracket
This commit is contained in:
parent
5d7bb17cc6
commit
9fe2f4d3ef
@ -1893,7 +1893,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(composed.getRequired() != null) {
|
if (composed.getRequired() != null) {
|
||||||
required.addAll(composed.getRequired());
|
required.addAll(composed.getRequired());
|
||||||
}
|
}
|
||||||
addVars(m, unaliasPropertySchema(properties), required, unaliasPropertySchema(allProperties), allRequired);
|
addVars(m, unaliasPropertySchema(properties), required, unaliasPropertySchema(allProperties), allRequired);
|
||||||
@ -2002,7 +2002,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
addProperties(properties, required, component);
|
addProperties(properties, required, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(schema.getRequired() != null) {
|
if (schema.getRequired() != null) {
|
||||||
required.addAll(schema.getRequired());
|
required.addAll(schema.getRequired());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2508,15 +2508,15 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
/**
|
/**
|
||||||
* Set op's returnBaseType, returnType, examples etc.
|
* Set op's returnBaseType, returnType, examples etc.
|
||||||
*
|
*
|
||||||
* @param operation endpoint Operation
|
* @param operation endpoint Operation
|
||||||
* @param schemas a map of the schemas in the openapi spec
|
* @param schemas a map of the schemas in the openapi spec
|
||||||
* @param op endpoint CodegenOperation
|
* @param op endpoint CodegenOperation
|
||||||
* @param methodResponse the default ApiResponse for the endpoint
|
* @param methodResponse the default ApiResponse for the endpoint
|
||||||
*/
|
*/
|
||||||
protected void handleMethodResponse(Operation operation,
|
protected void handleMethodResponse(Operation operation,
|
||||||
Map<String, Schema> schemas,
|
Map<String, Schema> schemas,
|
||||||
CodegenOperation op,
|
CodegenOperation op,
|
||||||
ApiResponse methodResponse) {
|
ApiResponse methodResponse) {
|
||||||
Schema responseSchema = ModelUtils.unaliasSchema(this.openAPI, ModelUtils.getSchemaFromResponse(methodResponse));
|
Schema responseSchema = ModelUtils.unaliasSchema(this.openAPI, ModelUtils.getSchemaFromResponse(methodResponse));
|
||||||
|
|
||||||
if (responseSchema != null) {
|
if (responseSchema != null) {
|
||||||
@ -4101,7 +4101,7 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
*
|
*
|
||||||
* @param name string to be sanitize
|
* @param name string to be sanitize
|
||||||
* @param removeCharRegEx a regex containing all char that will be removed
|
* @param removeCharRegEx a regex containing all char that will be removed
|
||||||
* @param exceptionList a list of matches which should not be sanitized (i.e expections)
|
* @param exceptionList a list of matches which should not be sanitized (i.e expections)
|
||||||
* @return sanitized string
|
* @return sanitized string
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("static-method")
|
@SuppressWarnings("static-method")
|
||||||
@ -4529,8 +4529,8 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
for (String consume : consumesInfo) {
|
for (String consume : consumesInfo) {
|
||||||
if (consume != null &&
|
if (consume != null &&
|
||||||
(consume.toLowerCase(Locale.ROOT).startsWith("application/x-www-form-urlencoded") ||
|
(consume.toLowerCase(Locale.ROOT).startsWith("application/x-www-form-urlencoded") ||
|
||||||
consume.toLowerCase(Locale.ROOT).startsWith("multipart"))) {
|
consume.toLowerCase(Locale.ROOT).startsWith("multipart"))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5022,7 +5022,6 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
codegenParameter.pattern = codegenProperty.pattern;
|
codegenParameter.pattern = codegenProperty.pattern;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (codegenProperty.complexType != null) {
|
if (codegenProperty.complexType != null) {
|
||||||
imports.add(codegenProperty.complexType);
|
imports.add(codegenProperty.complexType);
|
||||||
}
|
}
|
||||||
|
@ -33,9 +33,21 @@ import {{packageName}}.infrastructure.toMultiValue
|
|||||||
{{/hasQueryParams}}{{#hasQueryParams}}mutableMapOf<kotlin.String, List<kotlin.String>>()
|
{{/hasQueryParams}}{{#hasQueryParams}}mutableMapOf<kotlin.String, List<kotlin.String>>()
|
||||||
.apply {
|
.apply {
|
||||||
{{#queryParams}}
|
{{#queryParams}}
|
||||||
{{^required}}if ({{paramName}} != null) {
|
{{^required}}
|
||||||
|
if ({{paramName}} != null) {
|
||||||
put("{{paramName}}", {{#isContainer}}toMultiValue({{paramName}}.toList(), "{{collectionFormat}}"){{/isContainer}}{{^isContainer}}listOf({{paramName}}.toString()){{/isContainer}})
|
put("{{paramName}}", {{#isContainer}}toMultiValue({{paramName}}.toList(), "{{collectionFormat}}"){{/isContainer}}{{^isContainer}}listOf({{paramName}}.toString()){{/isContainer}})
|
||||||
}{{/required}}{{#required}}put("{{paramName}}", {{#isContainer}}toMultiValue({{paramName}}.toList(), "{{collectionFormat}}"){{/isContainer}}{{^isContainer}}listOf({{paramName}}.toString()){{/isContainer}}){{/required}}
|
}
|
||||||
|
{{/required}}
|
||||||
|
{{#required}}
|
||||||
|
{{#isNullable}}
|
||||||
|
if ({{paramName}} != null) {
|
||||||
|
put("{{paramName}}", {{#isContainer}}toMultiValue({{paramName}}.toList(), "{{collectionFormat}}"){{/isContainer}}{{^isContainer}}listOf({{paramName}}.toString()){{/isContainer}})
|
||||||
|
}
|
||||||
|
{{/isNullable}}
|
||||||
|
{{^isNullable}}
|
||||||
|
put("{{paramName}}", {{#isContainer}}toMultiValue({{paramName}}.toList(), "{{collectionFormat}}"){{/isContainer}}{{^isContainer}}listOf({{paramName}}.toString()){{/isContainer}})
|
||||||
|
{{/isNullable}}
|
||||||
|
{{/required}}
|
||||||
{{/queryParams}}
|
{{/queryParams}}
|
||||||
}
|
}
|
||||||
{{/hasQueryParams}}
|
{{/hasQueryParams}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user