Skip to content

Commit c2c43bb

Browse files
committed
make datetime nullable
1 parent 92dd5ca commit c2c43bb

File tree

2 files changed

+7
-5
lines changed
  • modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages
  • samples/client/petstore/csharp/src/main/csharp/io/swagger/Model

2 files changed

+7
-5
lines changed

modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/CSharpClientCodegen.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public CSharpClientCodegen() {
6060
"byte[]",
6161
"List",
6262
"Dictionary",
63-
"DateTime",
63+
"DateTime?",
6464
"String",
6565
"Boolean",
6666
"Double",
@@ -80,9 +80,11 @@ public CSharpClientCodegen() {
8080
typeMapping.put("long", "long?");
8181
typeMapping.put("double", "double?");
8282
typeMapping.put("number", "double?");
83-
typeMapping.put("Date", "DateTime");
83+
typeMapping.put("datetime", "DateTime?");
84+
typeMapping.put("date", "DateTime?");
8485
typeMapping.put("file", "string"); // path to file
8586
typeMapping.put("array", "List");
87+
typeMapping.put("list", "List");
8688
typeMapping.put("map", "Dictionary");
8789
typeMapping.put("object", "Object");
8890

@@ -166,8 +168,8 @@ else if (p instanceof MapProperty) {
166168
public String getSwaggerType(Property p) {
167169
String swaggerType = super.getSwaggerType(p);
168170
String type = null;
169-
if(typeMapping.containsKey(swaggerType)) {
170-
type = typeMapping.get(swaggerType);
171+
if(typeMapping.containsKey(swaggerType.toLowerCase())) {
172+
type = typeMapping.get(swaggerType.toLowerCase());
171173
if(languageSpecificPrimitives.contains(type))
172174
return type;
173175
}

samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Order.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class Order {
2525

2626

2727
[DataMember(Name="shipDate", EmitDefaultValue=false)]
28-
public DateTime ShipDate { get; set; }
28+
public DateTime? ShipDate { get; set; }
2929

3030

3131
/* Order Status */

0 commit comments

Comments
 (0)