forked from loafle/openapi-generator-original
fix csharp extra comma in constructor
This commit is contained in:
@@ -32,6 +32,7 @@ public class CodegenProperty {
|
||||
public Boolean exclusiveMinimum;
|
||||
public Boolean exclusiveMaximum;
|
||||
public Boolean hasMore, required, secondaryParam;
|
||||
public Boolean hasMoreNonReadOnly; // for model constructor, true if next properyt is not readonly
|
||||
public Boolean isPrimitiveType, isContainer, isNotContainer;
|
||||
public Boolean isString, isInteger, isLong, isFloat, isDouble, isByteArray, isBinary, isBoolean, isDate, isDateTime;
|
||||
public Boolean isListContainer, isMapContainer;
|
||||
@@ -63,6 +64,7 @@ public class CodegenProperty {
|
||||
result = prime * result + ((exclusiveMinimum == null) ? 0 : exclusiveMinimum.hashCode());
|
||||
result = prime * result + ((getter == null) ? 0 : getter.hashCode());
|
||||
result = prime * result + ((hasMore == null) ? 0 : hasMore.hashCode());
|
||||
result = prime * result + ((hasMoreNonReadOnly == null) ? 0 : hasMoreNonReadOnly.hashCode());
|
||||
result = prime * result + ((isContainer == null) ? 0 : isContainer.hashCode());
|
||||
result = prime * result + (isEnum ? 1231 : 1237);
|
||||
result = prime * result + ((isNotContainer == null) ? 0 : isNotContainer.hashCode());
|
||||
|
||||
@@ -2220,9 +2220,13 @@ public class DefaultCodegen {
|
||||
}
|
||||
|
||||
private void addVars(CodegenModel m, List<CodegenProperty> vars, Map<String, Property> properties, Set<String> mandatory) {
|
||||
final int totalCount = properties.size();
|
||||
int count = 0;
|
||||
for (Map.Entry<String, Property> entry : properties.entrySet()) {
|
||||
List<Map.Entry<String, Property>> propertyList = new ArrayList<Map.Entry<String, Property>>(properties.entrySet());
|
||||
final int totalCount = propertyList.size();
|
||||
//for (Iterator<Map.Entry<String, Property>> it = properties.entrySet().iterator(); it.hasNext(); ) {
|
||||
//for (Map.Entry<String, Property> entry : properties.entrySet()) {
|
||||
for (int i = 0; i < totalCount; i++) {
|
||||
Map.Entry<String, Property> entry = propertyList.get(i);
|
||||
|
||||
final String key = entry.getKey();
|
||||
final Property prop = entry.getValue();
|
||||
|
||||
@@ -2236,13 +2240,22 @@ public class DefaultCodegen {
|
||||
// m.hasEnums to be set incorrectly if allProperties has enumerations but properties does not.
|
||||
m.hasEnums = true;
|
||||
}
|
||||
count++;
|
||||
if (count != totalCount) {
|
||||
|
||||
if (i+1 != totalCount) {
|
||||
cp.hasMore = true;
|
||||
// check the next entry
|
||||
//Map.Entry<String, Property> nextEntry = propertyList.get(i+1);
|
||||
//final Property nextProp = propertyList.get(i+1).getValue();
|
||||
if (!Boolean.TRUE.equals(propertyList.get(i+1).getValue().getReadOnly())) {
|
||||
cp.hasMoreNonReadOnly = true;
|
||||
LOGGER.info("set hasMoreNonReadONly to true");
|
||||
}
|
||||
}
|
||||
|
||||
if (cp.isContainer != null) {
|
||||
addImport(m, typeMapping.get("array"));
|
||||
}
|
||||
|
||||
addImport(m, cp.baseType);
|
||||
addImport(m, cp.complexType);
|
||||
vars.add(cp);
|
||||
|
||||
@@ -101,6 +101,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
typeMapping = new HashMap<String, String>();
|
||||
typeMapping.put("string", "string");
|
||||
typeMapping.put("binary", "byte[]");
|
||||
typeMapping.put("bytearray", "byte[]");
|
||||
typeMapping.put("boolean", "bool?");
|
||||
typeMapping.put("integer", "int?");
|
||||
typeMapping.put("float", "float?");
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace {{packageName}}.Model
|
||||
/// </summary>
|
||||
{{#vars}}{{^isReadOnly}} /// <param name="{{name}}">{{#description}}{{description}}{{/description}}{{^description}}{{name}}{{/description}}{{#required}} (required){{/required}}{{#defaultValue}} (default to {{defaultValue}}){{/defaultValue}}.</param>
|
||||
{{/isReadOnly}}{{/vars}}
|
||||
public {{classname}}({{#vars}}{{^isReadOnly}}{{{datatypeWithEnum}}} {{name}} = null{{#hasMore}}, {{/hasMore}}{{/isReadOnly}}{{/vars}})
|
||||
public {{classname}}({{#vars}}{{^isReadOnly}}{{{datatypeWithEnum}}} {{name}} = null{{#hasMoreNonReadOnly}}, {{/hasMoreNonReadOnly}}{{/isReadOnly}}{{/vars}})
|
||||
{
|
||||
{{#vars}}{{^isReadOnly}}{{#required}}// to ensure "{{name}}" is required (not null)
|
||||
if ({{name}} == null)
|
||||
|
||||
@@ -1314,12 +1314,16 @@
|
||||
},
|
||||
"Name": {
|
||||
"description": "Model for testing model name same as property name",
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"snake_case": {
|
||||
"readOnly": true,
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace IO.Swagger.Model
|
||||
/// <param name="Date">Date.</param>
|
||||
/// <param name="DateTime">DateTime.</param>
|
||||
|
||||
public FormatTest(int? Integer = null, int? Int32 = null, long? Int64 = null, double? Number = null, float? _Float = null, double? _Double = null, string _String = null, ByteArray _Byte = null, byte[] Binary = null, DateTime? Date = null, string DateTime = null)
|
||||
public FormatTest(int? Integer = null, int? Int32 = null, long? Int64 = null, double? Number = null, float? _Float = null, double? _Double = null, string _String = null, byte[] _Byte = null, byte[] Binary = null, DateTime? Date = null, string DateTime = null)
|
||||
{
|
||||
// to ensure "Number" is required (not null)
|
||||
if (Number == null)
|
||||
@@ -105,7 +105,7 @@ namespace IO.Swagger.Model
|
||||
/// Gets or Sets _Byte
|
||||
/// </summary>
|
||||
[DataMember(Name="byte", EmitDefaultValue=false)]
|
||||
public ByteArray _Byte { get; set; }
|
||||
public byte[] _Byte { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Binary
|
||||
|
||||
@@ -22,13 +22,19 @@ namespace IO.Swagger.Model
|
||||
/// Initializes a new instance of the <see cref="Name" /> class.
|
||||
/// Initializes a new instance of the <see cref="Name" />class.
|
||||
/// </summary>
|
||||
/// <param name="_Name">_Name.</param>
|
||||
/// <param name="SnakeCase">SnakeCase.</param>
|
||||
/// <param name="_Name">_Name (required).</param>
|
||||
|
||||
public Name(int? _Name = null, int? SnakeCase = null)
|
||||
public Name(int? _Name = null)
|
||||
{
|
||||
this._Name = _Name;
|
||||
this.SnakeCase = SnakeCase;
|
||||
// to ensure "_Name" is required (not null)
|
||||
if (_Name == null)
|
||||
{
|
||||
throw new InvalidDataException("_Name is a required property for Name and cannot be null");
|
||||
}
|
||||
else
|
||||
{
|
||||
this._Name = _Name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,7 +49,7 @@ namespace IO.Swagger.Model
|
||||
/// Gets or Sets SnakeCase
|
||||
/// </summary>
|
||||
[DataMember(Name="snake_case", EmitDefaultValue=false)]
|
||||
public int? SnakeCase { get; set; }
|
||||
public int? SnakeCase { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the string presentation of the object
|
||||
|
||||
Reference in New Issue
Block a user