diff --git a/modules/openapi-generator/src/main/resources/dart2/class.mustache b/modules/openapi-generator/src/main/resources/dart2/class.mustache index 9f9af4e51a786202108ec142617bdff93f2b4649..a2275ec87926313068fc3dbb475c7605cf795ee8 100644 --- a/modules/openapi-generator/src/main/resources/dart2/class.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/class.mustache @@ -16,51 +16,63 @@ class {{classname}} { {{classname}}.fromJson(Map<String, dynamic> json) { if (json == null) return; {{#vars}} - if (json['{{baseName}}'] == null) { - {{name}} = null; - } else { {{#isDateTime}} - {{name}} = DateTime.parse(json['{{baseName}}']); + {{name}} = (json['{{baseName}}'] == null) ? + null : + DateTime.parse(json['{{baseName}}']); {{/isDateTime}} {{#isDate}} - {{name}} = DateTime.parse(json['{{baseName}}']); + {{name}} = (json['{{baseName}}'] == null) ? + null : + DateTime.parse(json['{{baseName}}']); {{/isDate}} {{^isDateTime}} {{^isDate}} {{#complexType}} {{#isListContainer}} - {{name}} = {{complexType}}.listFromJson(json['{{baseName}}']); + {{name}} = (json['{{baseName}}'] == null) ? + null : + {{complexType}}.listFromJson(json['{{baseName}}']); {{/isListContainer}} {{^isListContainer}} {{#isMapContainer}} - {{name}} = {{complexType}}.mapFromJson(json['{{baseName}}']); + {{name}} = (json['{{baseName}}'] == null) ? + null : + {{complexType}}.mapFromJson(json['{{baseName}}']); {{/isMapContainer}} {{^isMapContainer}} - {{name}} = {{complexType}}.fromJson(json['{{baseName}}']); + {{name}} = (json['{{baseName}}'] == null) ? + null : + {{complexType}}.fromJson(json['{{baseName}}']); {{/isMapContainer}} {{/isListContainer}} {{/complexType}} {{^complexType}} {{#isListContainer}} - {{name}} = (json['{{baseName}}'] as List).cast<{{items.datatype}}>(); + {{name}} = (json['{{baseName}}'] == null) ? + null : + (json['{{baseName}}'] as List).cast<{{items.datatype}}>(); {{/isListContainer}} {{^isListContainer}} {{#isMapContainer}} - {{name}} = (json['{{baseName}}'] as Map).cast<String, {{items.datatype}}>(); + {{name}} = (json['{{baseName}}'] == null) ? + null : + (json['{{baseName}}'] as Map).cast<String, {{items.datatype}}>(); {{/isMapContainer}} {{^isMapContainer}} - {{#isDouble}} - {{name}} = json['{{baseName}}'].toDouble(); - {{/isDouble}} - {{^isDouble}} - {{name}} = json['{{baseName}}']; - {{/isDouble}} + {{#isDouble}} + {{name}} = (json['{{baseName}}'] == null) ? + null : + json['{{baseName}}'].toDouble(); + {{/isDouble}} + {{^isDouble}} + {{name}} = json['{{baseName}}']; + {{/isDouble}} {{/isMapContainer}} {{/isListContainer}} {{/complexType}} {{/isDate}} {{/isDateTime}} - } {{/vars}} } diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/api_response.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/api_response.dart index f2fddde347aedf00211cb2e18970c9920fc7bcb8..cedd5b7511ae252204cc43894ffbbdf60840a138 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/api_response.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/api_response.dart @@ -2,11 +2,11 @@ part of openapi.api; class ApiResponse { - int code = null; + int code = null; - String type = null; + String type = null; - String message = null; + String message = null; ApiResponse(); @override @@ -16,21 +16,9 @@ class ApiResponse { ApiResponse.fromJson(Map<String, dynamic> json) { if (json == null) return; - if (json['code'] == null) { - code = null; - } else { - code = json['code']; - } - if (json['type'] == null) { - type = null; - } else { - type = json['type']; - } - if (json['message'] == null) { - message = null; - } else { - message = json['message']; - } + code = json['code']; + type = json['type']; + message = json['message']; } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/category.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/category.dart index 1750c6a0acb10673a5afdf509b5f33b2e9e8341d..81453b69cab0894fff38e60e9f13c6d1fce12dad 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/category.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/category.dart @@ -2,9 +2,9 @@ part of openapi.api; class Category { - int id = null; + int id = null; - String name = null; + String name = null; Category(); @override @@ -14,16 +14,8 @@ class Category { Category.fromJson(Map<String, dynamic> json) { if (json == null) return; - if (json['id'] == null) { - id = null; - } else { - id = json['id']; - } - if (json['name'] == null) { - name = null; - } else { - name = json['name']; - } + id = json['id']; + name = json['name']; } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/inline_object.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/inline_object.dart index e2a59c2ca40f3903dc3809aca61731b6990f1bb3..91e9c7d11756d38cf21e820d8e4fbe0c45a6d13a 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/inline_object.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/inline_object.dart @@ -2,9 +2,9 @@ part of openapi.api; class InlineObject { /* Updated name of the pet */ - String name = null; + String name = null; /* Updated status of the pet */ - String status = null; + String status = null; InlineObject(); @override @@ -14,16 +14,8 @@ class InlineObject { InlineObject.fromJson(Map<String, dynamic> json) { if (json == null) return; - if (json['name'] == null) { - name = null; - } else { - name = json['name']; - } - if (json['status'] == null) { - status = null; - } else { - status = json['status']; - } + name = json['name']; + status = json['status']; } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/inline_object1.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/inline_object1.dart index eba9610c5567b467746811ef8aa24ddd761f9d3d..6f5f3a426c31e5a50ef0235c125385b0d714585b 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/inline_object1.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/inline_object1.dart @@ -2,9 +2,9 @@ part of openapi.api; class InlineObject1 { /* Additional data to pass to server */ - String additionalMetadata = null; + String additionalMetadata = null; /* file to upload */ - MultipartFile file = null; + MultipartFile file = null; InlineObject1(); @override @@ -14,16 +14,10 @@ class InlineObject1 { InlineObject1.fromJson(Map<String, dynamic> json) { if (json == null) return; - if (json['additionalMetadata'] == null) { - additionalMetadata = null; - } else { - additionalMetadata = json['additionalMetadata']; - } - if (json['file'] == null) { - file = null; - } else { - file = File.fromJson(json['file']); - } + additionalMetadata = json['additionalMetadata']; + file = (json['file'] == null) ? + null : + File.fromJson(json['file']); } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/order.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/order.dart index 51d15f7304154d54dc94594efe4fd14496056ed4..6258047f463969e4cd29b2eadd167be93f0bfad3 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/order.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/order.dart @@ -2,18 +2,18 @@ part of openapi.api; class Order { - int id = null; + int id = null; - int petId = null; + int petId = null; - int quantity = null; + int quantity = null; - DateTime shipDate = null; + DateTime shipDate = null; /* Order Status */ - String status = null; + String status = null; //enum statusEnum { placed, approved, delivered, };{ - bool complete = false; + bool complete = false; Order(); @override @@ -23,36 +23,14 @@ class Order { Order.fromJson(Map<String, dynamic> json) { if (json == null) return; - if (json['id'] == null) { - id = null; - } else { - id = json['id']; - } - if (json['petId'] == null) { - petId = null; - } else { - petId = json['petId']; - } - if (json['quantity'] == null) { - quantity = null; - } else { - quantity = json['quantity']; - } - if (json['shipDate'] == null) { - shipDate = null; - } else { - shipDate = DateTime.parse(json['shipDate']); - } - if (json['status'] == null) { - status = null; - } else { - status = json['status']; - } - if (json['complete'] == null) { - complete = null; - } else { - complete = json['complete']; - } + id = json['id']; + petId = json['petId']; + quantity = json['quantity']; + shipDate = (json['shipDate'] == null) ? + null : + DateTime.parse(json['shipDate']); + status = json['status']; + complete = json['complete']; } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/pet.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/pet.dart index c64406368d87beb1de477c323870a66f5f5b71f1..7c04ed8b501e7202a319804e56b57dc7b8e6e92d 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/pet.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/pet.dart @@ -2,17 +2,17 @@ part of openapi.api; class Pet { - int id = null; + int id = null; - Category category = null; + Category category = null; - String name = null; + String name = null; - List<String> photoUrls = []; + List<String> photoUrls = []; - List<Tag> tags = []; + List<Tag> tags = []; /* pet status in the store */ - String status = null; + String status = null; //enum statusEnum { available, pending, sold, };{ Pet(); @@ -23,36 +23,18 @@ class Pet { Pet.fromJson(Map<String, dynamic> json) { if (json == null) return; - if (json['id'] == null) { - id = null; - } else { - id = json['id']; - } - if (json['category'] == null) { - category = null; - } else { - category = new Category.fromJson(json['category']); - } - if (json['name'] == null) { - name = null; - } else { - name = json['name']; - } - if (json['photoUrls'] == null) { - photoUrls = null; - } else { - photoUrls = (json['photoUrls'] as List).map((item) => item as String).toList(); - } - if (json['tags'] == null) { - tags = null; - } else { - tags = Tag.listFromJson(json['tags']); - } - if (json['status'] == null) { - status = null; - } else { - status = json['status']; - } + id = json['id']; + category = (json['category'] == null) ? + null : + Category.fromJson(json['category']); + name = json['name']; + photoUrls = (json['photoUrls'] == null) ? + null : + (json['photoUrls'] as List).cast<String>(); + tags = (json['tags'] == null) ? + null : + Tag.listFromJson(json['tags']); + status = json['status']; } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/tag.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/tag.dart index 980c6e01630200ee32e28ed1bcf746f4da16ee50..d2bb6b62600bd366ff2dbac082e730646995691c 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/tag.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/tag.dart @@ -2,9 +2,9 @@ part of openapi.api; class Tag { - int id = null; + int id = null; - String name = null; + String name = null; Tag(); @override @@ -14,16 +14,8 @@ class Tag { Tag.fromJson(Map<String, dynamic> json) { if (json == null) return; - if (json['id'] == null) { - id = null; - } else { - id = json['id']; - } - if (json['name'] == null) { - name = null; - } else { - name = json['name']; - } + id = json['id']; + name = json['name']; } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/user.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/user.dart index 1555eb0a3ef57c55e733e6c3024a8ebe0da512e2..1241e0d3b4c05cb574af0389542e790cb0ab0a60 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/user.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/user.dart @@ -2,21 +2,21 @@ part of openapi.api; class User { - int id = null; + int id = null; - String username = null; + String username = null; - String firstName = null; + String firstName = null; - String lastName = null; + String lastName = null; - String email = null; + String email = null; - String password = null; + String password = null; - String phone = null; + String phone = null; /* User Status */ - int userStatus = null; + int userStatus = null; User(); @override @@ -26,46 +26,14 @@ class User { User.fromJson(Map<String, dynamic> json) { if (json == null) return; - if (json['id'] == null) { - id = null; - } else { - id = json['id']; - } - if (json['username'] == null) { - username = null; - } else { - username = json['username']; - } - if (json['firstName'] == null) { - firstName = null; - } else { - firstName = json['firstName']; - } - if (json['lastName'] == null) { - lastName = null; - } else { - lastName = json['lastName']; - } - if (json['email'] == null) { - email = null; - } else { - email = json['email']; - } - if (json['password'] == null) { - password = null; - } else { - password = json['password']; - } - if (json['phone'] == null) { - phone = null; - } else { - phone = json['phone']; - } - if (json['userStatus'] == null) { - userStatus = null; - } else { - userStatus = json['userStatus']; - } + id = json['id']; + username = json['username']; + firstName = json['firstName']; + lastName = json['lastName']; + email = json['email']; + password = json['password']; + phone = json['phone']; + userStatus = json['userStatus']; } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/api_response.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/api_response.dart index be01c2de8195b21fd70f51565a0226ad6ba8fcf7..b7f98cffb43b73f4b6fb2424e7e0d0d689c37dab 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/api_response.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/api_response.dart @@ -2,11 +2,11 @@ part of openapi.api; class ApiResponse { - int code = null; + int code = null; - String type = null; + String type = null; - String message = null; + String message = null; ApiResponse(); @override @@ -16,21 +16,9 @@ class ApiResponse { ApiResponse.fromJson(Map<String, dynamic> json) { if (json == null) return; - if (json['code'] == null) { - code = null; - } else { - code = json['code']; - } - if (json['type'] == null) { - type = null; - } else { - type = json['type']; - } - if (json['message'] == null) { - message = null; - } else { - message = json['message']; - } + code = json['code']; + type = json['type']; + message = json['message']; } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/category.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/category.dart index 696468a1619115f34115266c9779f7f46d47f3ae..c14bf1b1fea5ff23b3520d6a3c8e3e64a490820c 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/category.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/category.dart @@ -2,9 +2,9 @@ part of openapi.api; class Category { - int id = null; + int id = null; - String name = null; + String name = null; Category(); @override @@ -14,16 +14,8 @@ class Category { Category.fromJson(Map<String, dynamic> json) { if (json == null) return; - if (json['id'] == null) { - id = null; - } else { - id = json['id']; - } - if (json['name'] == null) { - name = null; - } else { - name = json['name']; - } + id = json['id']; + name = json['name']; } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/order.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/order.dart index be5a12e1ed19f734c5ffb2bfd15699a111cd25a7..53796606a4a53ac2111cc0d8f8d612cb50f0f86a 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/order.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/order.dart @@ -2,18 +2,18 @@ part of openapi.api; class Order { - int id = null; + int id = null; - int petId = null; + int petId = null; - int quantity = null; + int quantity = null; - DateTime shipDate = null; + DateTime shipDate = null; /* Order Status */ - String status = null; + String status = null; //enum statusEnum { placed, approved, delivered, };{ - bool complete = false; + bool complete = false; Order(); @override @@ -23,36 +23,14 @@ class Order { Order.fromJson(Map<String, dynamic> json) { if (json == null) return; - if (json['id'] == null) { - id = null; - } else { - id = json['id']; - } - if (json['petId'] == null) { - petId = null; - } else { - petId = json['petId']; - } - if (json['quantity'] == null) { - quantity = null; - } else { - quantity = json['quantity']; - } - if (json['shipDate'] == null) { - shipDate = null; - } else { - shipDate = DateTime.parse(json['shipDate']); - } - if (json['status'] == null) { - status = null; - } else { - status = json['status']; - } - if (json['complete'] == null) { - complete = null; - } else { - complete = json['complete']; - } + id = json['id']; + petId = json['petId']; + quantity = json['quantity']; + shipDate = (json['shipDate'] == null) ? + null : + DateTime.parse(json['shipDate']); + status = json['status']; + complete = json['complete']; } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/pet.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/pet.dart index 4f19829878aa4c57449a3bb622f37bc345934f8d..065ffa76f675a322138cc154bff27ea355804dd9 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/pet.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/pet.dart @@ -2,17 +2,17 @@ part of openapi.api; class Pet { - int id = null; + int id = null; - Category category = null; + Category category = null; - String name = null; + String name = null; - List<String> photoUrls = []; + List<String> photoUrls = []; - List<Tag> tags = []; + List<Tag> tags = []; /* pet status in the store */ - String status = null; + String status = null; //enum statusEnum { available, pending, sold, };{ Pet(); @@ -23,36 +23,18 @@ class Pet { Pet.fromJson(Map<String, dynamic> json) { if (json == null) return; - if (json['id'] == null) { - id = null; - } else { - id = json['id']; - } - if (json['category'] == null) { - category = null; - } else { - category = Category.fromJson(json['category']); - } - if (json['name'] == null) { - name = null; - } else { - name = json['name']; - } - if (json['photoUrls'] == null) { - photoUrls = null; - } else { - photoUrls = (json['photoUrls'] as List).cast<String>(); - } - if (json['tags'] == null) { - tags = null; - } else { - tags = Tag.listFromJson(json['tags']); - } - if (json['status'] == null) { - status = null; - } else { - status = json['status']; - } + id = json['id']; + category = (json['category'] == null) ? + null : + Category.fromJson(json['category']); + name = json['name']; + photoUrls = (json['photoUrls'] == null) ? + null : + (json['photoUrls'] as List).cast<String>(); + tags = (json['tags'] == null) ? + null : + Tag.listFromJson(json['tags']); + status = json['status']; } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/tag.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/tag.dart index a3485e5d3c6398d50b18a2bbeb3ef4a498cdbc14..0e77376a49af54c53684aba07f3f121ad5f9c37b 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/tag.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/tag.dart @@ -2,9 +2,9 @@ part of openapi.api; class Tag { - int id = null; + int id = null; - String name = null; + String name = null; Tag(); @override @@ -14,16 +14,8 @@ class Tag { Tag.fromJson(Map<String, dynamic> json) { if (json == null) return; - if (json['id'] == null) { - id = null; - } else { - id = json['id']; - } - if (json['name'] == null) { - name = null; - } else { - name = json['name']; - } + id = json['id']; + name = json['name']; } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/user.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/user.dart index 48f061d969b1d6ac1a9066bb6d0f3be918ce32a0..8b6812dcd2db97a94c75c3bbc5ea65147ef0d8e9 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/user.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/user.dart @@ -2,21 +2,21 @@ part of openapi.api; class User { - int id = null; + int id = null; - String username = null; + String username = null; - String firstName = null; + String firstName = null; - String lastName = null; + String lastName = null; - String email = null; + String email = null; - String password = null; + String password = null; - String phone = null; + String phone = null; /* User Status */ - int userStatus = null; + int userStatus = null; User(); @override @@ -26,46 +26,14 @@ class User { User.fromJson(Map<String, dynamic> json) { if (json == null) return; - if (json['id'] == null) { - id = null; - } else { - id = json['id']; - } - if (json['username'] == null) { - username = null; - } else { - username = json['username']; - } - if (json['firstName'] == null) { - firstName = null; - } else { - firstName = json['firstName']; - } - if (json['lastName'] == null) { - lastName = null; - } else { - lastName = json['lastName']; - } - if (json['email'] == null) { - email = null; - } else { - email = json['email']; - } - if (json['password'] == null) { - password = null; - } else { - password = json['password']; - } - if (json['phone'] == null) { - phone = null; - } else { - phone = json['phone']; - } - if (json['userStatus'] == null) { - userStatus = null; - } else { - userStatus = json['userStatus']; - } + id = json['id']; + username = json['username']; + firstName = json['firstName']; + lastName = json['lastName']; + email = json['email']; + password = json['password']; + phone = json['phone']; + userStatus = json['userStatus']; } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/model/api_response.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/model/api_response.dart index be01c2de8195b21fd70f51565a0226ad6ba8fcf7..b7f98cffb43b73f4b6fb2424e7e0d0d689c37dab 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/model/api_response.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/model/api_response.dart @@ -2,11 +2,11 @@ part of openapi.api; class ApiResponse { - int code = null; + int code = null; - String type = null; + String type = null; - String message = null; + String message = null; ApiResponse(); @override @@ -16,21 +16,9 @@ class ApiResponse { ApiResponse.fromJson(Map<String, dynamic> json) { if (json == null) return; - if (json['code'] == null) { - code = null; - } else { - code = json['code']; - } - if (json['type'] == null) { - type = null; - } else { - type = json['type']; - } - if (json['message'] == null) { - message = null; - } else { - message = json['message']; - } + code = json['code']; + type = json['type']; + message = json['message']; } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/model/category.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/model/category.dart index 696468a1619115f34115266c9779f7f46d47f3ae..c14bf1b1fea5ff23b3520d6a3c8e3e64a490820c 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/model/category.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/model/category.dart @@ -2,9 +2,9 @@ part of openapi.api; class Category { - int id = null; + int id = null; - String name = null; + String name = null; Category(); @override @@ -14,16 +14,8 @@ class Category { Category.fromJson(Map<String, dynamic> json) { if (json == null) return; - if (json['id'] == null) { - id = null; - } else { - id = json['id']; - } - if (json['name'] == null) { - name = null; - } else { - name = json['name']; - } + id = json['id']; + name = json['name']; } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/model/order.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/model/order.dart index be5a12e1ed19f734c5ffb2bfd15699a111cd25a7..53796606a4a53ac2111cc0d8f8d612cb50f0f86a 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/model/order.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/model/order.dart @@ -2,18 +2,18 @@ part of openapi.api; class Order { - int id = null; + int id = null; - int petId = null; + int petId = null; - int quantity = null; + int quantity = null; - DateTime shipDate = null; + DateTime shipDate = null; /* Order Status */ - String status = null; + String status = null; //enum statusEnum { placed, approved, delivered, };{ - bool complete = false; + bool complete = false; Order(); @override @@ -23,36 +23,14 @@ class Order { Order.fromJson(Map<String, dynamic> json) { if (json == null) return; - if (json['id'] == null) { - id = null; - } else { - id = json['id']; - } - if (json['petId'] == null) { - petId = null; - } else { - petId = json['petId']; - } - if (json['quantity'] == null) { - quantity = null; - } else { - quantity = json['quantity']; - } - if (json['shipDate'] == null) { - shipDate = null; - } else { - shipDate = DateTime.parse(json['shipDate']); - } - if (json['status'] == null) { - status = null; - } else { - status = json['status']; - } - if (json['complete'] == null) { - complete = null; - } else { - complete = json['complete']; - } + id = json['id']; + petId = json['petId']; + quantity = json['quantity']; + shipDate = (json['shipDate'] == null) ? + null : + DateTime.parse(json['shipDate']); + status = json['status']; + complete = json['complete']; } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/model/pet.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/model/pet.dart index 4f19829878aa4c57449a3bb622f37bc345934f8d..065ffa76f675a322138cc154bff27ea355804dd9 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/model/pet.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/model/pet.dart @@ -2,17 +2,17 @@ part of openapi.api; class Pet { - int id = null; + int id = null; - Category category = null; + Category category = null; - String name = null; + String name = null; - List<String> photoUrls = []; + List<String> photoUrls = []; - List<Tag> tags = []; + List<Tag> tags = []; /* pet status in the store */ - String status = null; + String status = null; //enum statusEnum { available, pending, sold, };{ Pet(); @@ -23,36 +23,18 @@ class Pet { Pet.fromJson(Map<String, dynamic> json) { if (json == null) return; - if (json['id'] == null) { - id = null; - } else { - id = json['id']; - } - if (json['category'] == null) { - category = null; - } else { - category = Category.fromJson(json['category']); - } - if (json['name'] == null) { - name = null; - } else { - name = json['name']; - } - if (json['photoUrls'] == null) { - photoUrls = null; - } else { - photoUrls = (json['photoUrls'] as List).cast<String>(); - } - if (json['tags'] == null) { - tags = null; - } else { - tags = Tag.listFromJson(json['tags']); - } - if (json['status'] == null) { - status = null; - } else { - status = json['status']; - } + id = json['id']; + category = (json['category'] == null) ? + null : + Category.fromJson(json['category']); + name = json['name']; + photoUrls = (json['photoUrls'] == null) ? + null : + (json['photoUrls'] as List).cast<String>(); + tags = (json['tags'] == null) ? + null : + Tag.listFromJson(json['tags']); + status = json['status']; } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/model/tag.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/model/tag.dart index a3485e5d3c6398d50b18a2bbeb3ef4a498cdbc14..0e77376a49af54c53684aba07f3f121ad5f9c37b 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/model/tag.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/model/tag.dart @@ -2,9 +2,9 @@ part of openapi.api; class Tag { - int id = null; + int id = null; - String name = null; + String name = null; Tag(); @override @@ -14,16 +14,8 @@ class Tag { Tag.fromJson(Map<String, dynamic> json) { if (json == null) return; - if (json['id'] == null) { - id = null; - } else { - id = json['id']; - } - if (json['name'] == null) { - name = null; - } else { - name = json['name']; - } + id = json['id']; + name = json['name']; } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/model/user.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/model/user.dart index 48f061d969b1d6ac1a9066bb6d0f3be918ce32a0..8b6812dcd2db97a94c75c3bbc5ea65147ef0d8e9 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/model/user.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/model/user.dart @@ -2,21 +2,21 @@ part of openapi.api; class User { - int id = null; + int id = null; - String username = null; + String username = null; - String firstName = null; + String firstName = null; - String lastName = null; + String lastName = null; - String email = null; + String email = null; - String password = null; + String password = null; - String phone = null; + String phone = null; /* User Status */ - int userStatus = null; + int userStatus = null; User(); @override @@ -26,46 +26,14 @@ class User { User.fromJson(Map<String, dynamic> json) { if (json == null) return; - if (json['id'] == null) { - id = null; - } else { - id = json['id']; - } - if (json['username'] == null) { - username = null; - } else { - username = json['username']; - } - if (json['firstName'] == null) { - firstName = null; - } else { - firstName = json['firstName']; - } - if (json['lastName'] == null) { - lastName = null; - } else { - lastName = json['lastName']; - } - if (json['email'] == null) { - email = null; - } else { - email = json['email']; - } - if (json['password'] == null) { - password = null; - } else { - password = json['password']; - } - if (json['phone'] == null) { - phone = null; - } else { - phone = json['phone']; - } - if (json['userStatus'] == null) { - userStatus = null; - } else { - userStatus = json['userStatus']; - } + id = json['id']; + username = json['username']; + firstName = json['firstName']; + lastName = json['lastName']; + email = json['email']; + password = json['password']; + phone = json['phone']; + userStatus = json['userStatus']; } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart2/openapi/lib/model/api_response.dart b/samples/client/petstore/dart2/openapi/lib/model/api_response.dart index be01c2de8195b21fd70f51565a0226ad6ba8fcf7..b7f98cffb43b73f4b6fb2424e7e0d0d689c37dab 100644 --- a/samples/client/petstore/dart2/openapi/lib/model/api_response.dart +++ b/samples/client/petstore/dart2/openapi/lib/model/api_response.dart @@ -2,11 +2,11 @@ part of openapi.api; class ApiResponse { - int code = null; + int code = null; - String type = null; + String type = null; - String message = null; + String message = null; ApiResponse(); @override @@ -16,21 +16,9 @@ class ApiResponse { ApiResponse.fromJson(Map<String, dynamic> json) { if (json == null) return; - if (json['code'] == null) { - code = null; - } else { - code = json['code']; - } - if (json['type'] == null) { - type = null; - } else { - type = json['type']; - } - if (json['message'] == null) { - message = null; - } else { - message = json['message']; - } + code = json['code']; + type = json['type']; + message = json['message']; } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart2/openapi/lib/model/category.dart b/samples/client/petstore/dart2/openapi/lib/model/category.dart index 696468a1619115f34115266c9779f7f46d47f3ae..c14bf1b1fea5ff23b3520d6a3c8e3e64a490820c 100644 --- a/samples/client/petstore/dart2/openapi/lib/model/category.dart +++ b/samples/client/petstore/dart2/openapi/lib/model/category.dart @@ -2,9 +2,9 @@ part of openapi.api; class Category { - int id = null; + int id = null; - String name = null; + String name = null; Category(); @override @@ -14,16 +14,8 @@ class Category { Category.fromJson(Map<String, dynamic> json) { if (json == null) return; - if (json['id'] == null) { - id = null; - } else { - id = json['id']; - } - if (json['name'] == null) { - name = null; - } else { - name = json['name']; - } + id = json['id']; + name = json['name']; } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart2/openapi/lib/model/order.dart b/samples/client/petstore/dart2/openapi/lib/model/order.dart index be5a12e1ed19f734c5ffb2bfd15699a111cd25a7..53796606a4a53ac2111cc0d8f8d612cb50f0f86a 100644 --- a/samples/client/petstore/dart2/openapi/lib/model/order.dart +++ b/samples/client/petstore/dart2/openapi/lib/model/order.dart @@ -2,18 +2,18 @@ part of openapi.api; class Order { - int id = null; + int id = null; - int petId = null; + int petId = null; - int quantity = null; + int quantity = null; - DateTime shipDate = null; + DateTime shipDate = null; /* Order Status */ - String status = null; + String status = null; //enum statusEnum { placed, approved, delivered, };{ - bool complete = false; + bool complete = false; Order(); @override @@ -23,36 +23,14 @@ class Order { Order.fromJson(Map<String, dynamic> json) { if (json == null) return; - if (json['id'] == null) { - id = null; - } else { - id = json['id']; - } - if (json['petId'] == null) { - petId = null; - } else { - petId = json['petId']; - } - if (json['quantity'] == null) { - quantity = null; - } else { - quantity = json['quantity']; - } - if (json['shipDate'] == null) { - shipDate = null; - } else { - shipDate = DateTime.parse(json['shipDate']); - } - if (json['status'] == null) { - status = null; - } else { - status = json['status']; - } - if (json['complete'] == null) { - complete = null; - } else { - complete = json['complete']; - } + id = json['id']; + petId = json['petId']; + quantity = json['quantity']; + shipDate = (json['shipDate'] == null) ? + null : + DateTime.parse(json['shipDate']); + status = json['status']; + complete = json['complete']; } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart2/openapi/lib/model/pet.dart b/samples/client/petstore/dart2/openapi/lib/model/pet.dart index 4f19829878aa4c57449a3bb622f37bc345934f8d..065ffa76f675a322138cc154bff27ea355804dd9 100644 --- a/samples/client/petstore/dart2/openapi/lib/model/pet.dart +++ b/samples/client/petstore/dart2/openapi/lib/model/pet.dart @@ -2,17 +2,17 @@ part of openapi.api; class Pet { - int id = null; + int id = null; - Category category = null; + Category category = null; - String name = null; + String name = null; - List<String> photoUrls = []; + List<String> photoUrls = []; - List<Tag> tags = []; + List<Tag> tags = []; /* pet status in the store */ - String status = null; + String status = null; //enum statusEnum { available, pending, sold, };{ Pet(); @@ -23,36 +23,18 @@ class Pet { Pet.fromJson(Map<String, dynamic> json) { if (json == null) return; - if (json['id'] == null) { - id = null; - } else { - id = json['id']; - } - if (json['category'] == null) { - category = null; - } else { - category = Category.fromJson(json['category']); - } - if (json['name'] == null) { - name = null; - } else { - name = json['name']; - } - if (json['photoUrls'] == null) { - photoUrls = null; - } else { - photoUrls = (json['photoUrls'] as List).cast<String>(); - } - if (json['tags'] == null) { - tags = null; - } else { - tags = Tag.listFromJson(json['tags']); - } - if (json['status'] == null) { - status = null; - } else { - status = json['status']; - } + id = json['id']; + category = (json['category'] == null) ? + null : + Category.fromJson(json['category']); + name = json['name']; + photoUrls = (json['photoUrls'] == null) ? + null : + (json['photoUrls'] as List).cast<String>(); + tags = (json['tags'] == null) ? + null : + Tag.listFromJson(json['tags']); + status = json['status']; } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart2/openapi/lib/model/tag.dart b/samples/client/petstore/dart2/openapi/lib/model/tag.dart index a3485e5d3c6398d50b18a2bbeb3ef4a498cdbc14..0e77376a49af54c53684aba07f3f121ad5f9c37b 100644 --- a/samples/client/petstore/dart2/openapi/lib/model/tag.dart +++ b/samples/client/petstore/dart2/openapi/lib/model/tag.dart @@ -2,9 +2,9 @@ part of openapi.api; class Tag { - int id = null; + int id = null; - String name = null; + String name = null; Tag(); @override @@ -14,16 +14,8 @@ class Tag { Tag.fromJson(Map<String, dynamic> json) { if (json == null) return; - if (json['id'] == null) { - id = null; - } else { - id = json['id']; - } - if (json['name'] == null) { - name = null; - } else { - name = json['name']; - } + id = json['id']; + name = json['name']; } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart2/openapi/lib/model/user.dart b/samples/client/petstore/dart2/openapi/lib/model/user.dart index 48f061d969b1d6ac1a9066bb6d0f3be918ce32a0..8b6812dcd2db97a94c75c3bbc5ea65147ef0d8e9 100644 --- a/samples/client/petstore/dart2/openapi/lib/model/user.dart +++ b/samples/client/petstore/dart2/openapi/lib/model/user.dart @@ -2,21 +2,21 @@ part of openapi.api; class User { - int id = null; + int id = null; - String username = null; + String username = null; - String firstName = null; + String firstName = null; - String lastName = null; + String lastName = null; - String email = null; + String email = null; - String password = null; + String password = null; - String phone = null; + String phone = null; /* User Status */ - int userStatus = null; + int userStatus = null; User(); @override @@ -26,46 +26,14 @@ class User { User.fromJson(Map<String, dynamic> json) { if (json == null) return; - if (json['id'] == null) { - id = null; - } else { - id = json['id']; - } - if (json['username'] == null) { - username = null; - } else { - username = json['username']; - } - if (json['firstName'] == null) { - firstName = null; - } else { - firstName = json['firstName']; - } - if (json['lastName'] == null) { - lastName = null; - } else { - lastName = json['lastName']; - } - if (json['email'] == null) { - email = null; - } else { - email = json['email']; - } - if (json['password'] == null) { - password = null; - } else { - password = json['password']; - } - if (json['phone'] == null) { - phone = null; - } else { - phone = json['phone']; - } - if (json['userStatus'] == null) { - userStatus = null; - } else { - userStatus = json['userStatus']; - } + id = json['id']; + username = json['username']; + firstName = json['firstName']; + lastName = json['lastName']; + email = json['email']; + password = json['password']; + phone = json['phone']; + userStatus = json['userStatus']; } Map<String, dynamic> toJson() {