mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2026-03-17 15:19:09 +00:00
Adds spec additionalProperties + nullable examples (#2405)
* Adds v2 spec additionalproperties examples, adds v3 spec nulllable model example, updates samples * Remaining samples updates * Adds csharp generator update to handle models with multilevel parent types, which works for the AdditionalPropertiesObject model, samples updated
This commit is contained in:
committed by
William Cheng
parent
c10463600a
commit
b67318ef21
@@ -19,6 +19,7 @@ package org.openapitools.codegen.languages;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
@@ -837,4 +838,28 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
// To avoid unexpected behaviors when options are passed programmatically such as { "supportsAsync": "" }
|
||||
return super.processCompiler(compiler).emptyStringIsFalse(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the instantiation type of the property, especially for map and array
|
||||
*
|
||||
* @param schema property schema
|
||||
* @return string presentation of the instantiation type of the property
|
||||
*/
|
||||
@Override
|
||||
public String toInstantiationType(Schema schema) {
|
||||
if (ModelUtils.isMapSchema(schema)) {
|
||||
Schema additionalProperties = ModelUtils.getAdditionalProperties(schema);
|
||||
String inner = getSchemaType(additionalProperties);
|
||||
if (ModelUtils.isMapSchema(additionalProperties)) {
|
||||
inner = toInstantiationType(additionalProperties);
|
||||
}
|
||||
return instantiationTypes.get("map") + "<String, " + inner + ">";
|
||||
} else if (ModelUtils.isArraySchema(schema)) {
|
||||
ArraySchema arraySchema = (ArraySchema) schema;
|
||||
String inner = getSchemaType(arraySchema.getItems());
|
||||
return instantiationTypes.get("array") + "<" + inner + ">";
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user