Updated as requested to use isMapModel

This commit is contained in:
etherealjoy 2018-06-24 09:21:47 +02:00
parent dd4b1aff2e
commit f45ec312ee
3 changed files with 3 additions and 4 deletions

View File

@ -58,7 +58,7 @@ public class CodegenModel {
public Set<String> allMandatory;
public Set<String> imports = new TreeSet<String>();
public boolean hasVars, emptyVars, hasMoreModels, hasEnums, isEnum, hasRequired, hasOptional, isArrayModel, hasChildren, isCollectionModel;
public boolean hasVars, emptyVars, hasMoreModels, hasEnums, isEnum, hasRequired, hasOptional, isArrayModel, hasChildren, isMapModel;
public boolean hasOnlyReadOnly = true; // true if all properties are read-only
public ExternalDocumentation externalDocumentation;

View File

@ -1412,7 +1412,6 @@ public class DefaultCodegen implements CodegenConfig {
if (ModelUtils.isArraySchema(schema)) {
m.isArrayModel = true;
m.isCollectionModel = true;
m.arrayModelType = fromProperty(name, schema).complexType;
addParentContainer(m, name, schema);
} else if (schema instanceof ComposedSchema) {
@ -1522,7 +1521,7 @@ public class DefaultCodegen implements CodegenConfig {
}
if (ModelUtils.isMapSchema(schema)) {
addAdditionPropertiesToCodeGenModel(m, schema);
m.isCollectionModel = true;
m.isMapModel = true;
}
addVars(m, schema.getProperties(), schema.getRequired());
}

View File

@ -56,7 +56,7 @@ namespace {{packageName}}.Models
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public {{#parent}}{{^isCollectionModel}}new {{/isCollectionModel}}{{/parent}}string ToJson()
public {{#parent}}{{^isMapModel}}{{^isArrayModel}}new {{/isArrayModel}}{{/isMapModel}}{{/parent}}string ToJson()
{
return JsonConvert.SerializeObject(this, Formatting.Indented);
}