[Dart 2] Add support for Dart 2 (#754)

* Add an option for Dart2

* add dart2 samples, update travis

* fix dart installation

* Upper constraints on the SDK version

* Update dependencies

* supportDart2 option can now be passed through --additional-properties

* Update petstore tests

* Update dart2-petstore.sh

* Running tests on Dart VM

* Fixed JSON deserialization bugs

* Fixed missing initialization of postBody

* Run bin/dart2-petstore.sh to regenerate libraries

* Update pom.xml

* Added SDK version constraints in pubspec.mustache

* Run bin/dart2-petstore.sh to regenerate libraries

* move dart2 test to the end
This commit is contained in:
Yimin Lin
2018-09-01 01:49:18 +08:00
committed by William Cheng
parent 31149a5a69
commit d327c5be46
131 changed files with 10604 additions and 2 deletions

View File

@@ -0,0 +1,44 @@
part of openapi.api;
class ApiResponse {
int code = null;
String type = null;
String message = null;
ApiResponse();
@override
String toString() {
return 'ApiResponse[code=$code, type=$type, message=$message, ]';
}
ApiResponse.fromJson(Map<String, dynamic> json) {
if (json == null) return;
code = json['code'];
type = json['type'];
message = json['message'];
}
Map<String, dynamic> toJson() {
return {
'code': code,
'type': type,
'message': message
};
}
static List<ApiResponse> listFromJson(List<dynamic> json) {
return json == null ? new List<ApiResponse>() : json.map((value) => new ApiResponse.fromJson(value)).toList();
}
static Map<String, ApiResponse> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, ApiResponse>();
if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => map[key] = new ApiResponse.fromJson(value));
}
return map;
}
}

View File

@@ -0,0 +1,40 @@
part of openapi.api;
class Category {
int id = null;
String name = null;
Category();
@override
String toString() {
return 'Category[id=$id, name=$name, ]';
}
Category.fromJson(Map<String, dynamic> json) {
if (json == null) return;
id = json['id'];
name = json['name'];
}
Map<String, dynamic> toJson() {
return {
'id': id,
'name': name
};
}
static List<Category> listFromJson(List<dynamic> json) {
return json == null ? new List<Category>() : json.map((value) => new Category.fromJson(value)).toList();
}
static Map<String, Category> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, Category>();
if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => map[key] = new Category.fromJson(value));
}
return map;
}
}

View File

@@ -0,0 +1,57 @@
part of openapi.api;
class Order {
int id = null;
int petId = null;
int quantity = null;
DateTime shipDate = null;
/* Order Status */
String status = null;
//enum statusEnum { placed, approved, delivered, };{
bool complete = false;
Order();
@override
String toString() {
return 'Order[id=$id, petId=$petId, quantity=$quantity, shipDate=$shipDate, status=$status, complete=$complete, ]';
}
Order.fromJson(Map<String, dynamic> json) {
if (json == null) return;
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() {
return {
'id': id,
'petId': petId,
'quantity': quantity,
'shipDate': shipDate == null ? '' : shipDate.toUtc().toIso8601String(),
'status': status,
'complete': complete
};
}
static List<Order> listFromJson(List<dynamic> json) {
return json == null ? new List<Order>() : json.map((value) => new Order.fromJson(value)).toList();
}
static Map<String, Order> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, Order>();
if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => map[key] = new Order.fromJson(value));
}
return map;
}
}

View File

@@ -0,0 +1,57 @@
part of openapi.api;
class Pet {
int id = null;
Category category = null;
String name = null;
List<String> photoUrls = [];
List<Tag> tags = [];
/* pet status in the store */
String status = null;
//enum statusEnum { available, pending, sold, };{
Pet();
@override
String toString() {
return 'Pet[id=$id, category=$category, name=$name, photoUrls=$photoUrls, tags=$tags, status=$status, ]';
}
Pet.fromJson(Map<String, dynamic> json) {
if (json == null) return;
id = json['id'];
category = new Category.fromJson(json['category']);
name = json['name'];
photoUrls = ((json['photoUrls'] ?? []) as List).map((item) => item as String).toList();
tags = Tag.listFromJson(json['tags']);
status = json['status'];
}
Map<String, dynamic> toJson() {
return {
'id': id,
'category': category,
'name': name,
'photoUrls': photoUrls,
'tags': tags,
'status': status
};
}
static List<Pet> listFromJson(List<dynamic> json) {
return json == null ? new List<Pet>() : json.map((value) => new Pet.fromJson(value)).toList();
}
static Map<String, Pet> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, Pet>();
if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => map[key] = new Pet.fromJson(value));
}
return map;
}
}

View File

@@ -0,0 +1,40 @@
part of openapi.api;
class Tag {
int id = null;
String name = null;
Tag();
@override
String toString() {
return 'Tag[id=$id, name=$name, ]';
}
Tag.fromJson(Map<String, dynamic> json) {
if (json == null) return;
id = json['id'];
name = json['name'];
}
Map<String, dynamic> toJson() {
return {
'id': id,
'name': name
};
}
static List<Tag> listFromJson(List<dynamic> json) {
return json == null ? new List<Tag>() : json.map((value) => new Tag.fromJson(value)).toList();
}
static Map<String, Tag> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, Tag>();
if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => map[key] = new Tag.fromJson(value));
}
return map;
}
}

View File

@@ -0,0 +1,64 @@
part of openapi.api;
class User {
int id = null;
String username = null;
String firstName = null;
String lastName = null;
String email = null;
String password = null;
String phone = null;
/* User Status */
int userStatus = null;
User();
@override
String toString() {
return 'User[id=$id, username=$username, firstName=$firstName, lastName=$lastName, email=$email, password=$password, phone=$phone, userStatus=$userStatus, ]';
}
User.fromJson(Map<String, dynamic> json) {
if (json == null) return;
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() {
return {
'id': id,
'username': username,
'firstName': firstName,
'lastName': lastName,
'email': email,
'password': password,
'phone': phone,
'userStatus': userStatus
};
}
static List<User> listFromJson(List<dynamic> json) {
return json == null ? new List<User>() : json.map((value) => new User.fromJson(value)).toList();
}
static Map<String, User> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, User>();
if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => map[key] = new User.fromJson(value));
}
return map;
}
}