Update Dart petstore with OAS3, fix mustache format (#227)

* update dart petstore with oas3, fix mustache format

* update default value to null
This commit is contained in:
William Cheng 2018-05-05 21:02:18 +08:00 committed by GitHub
parent 252a1c2599
commit c791146b62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 214 additions and 221 deletions

51
bin/openapi3/dart-petstore.sh Executable file
View File

@ -0,0 +1,51 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
# Generate non-browserClient
ags="$@ generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l dart -o samples/client/petstore/dart/swagger -DhideGenerationTimestamp=true -DbrowserClient=false"
# then options to generate the library for vm would be:
#ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l dart -o samples/client/petstore/dart/swagger_vm -DbrowserClient=false -DpubName=swagger_vm"
#java $JAVA_OPTS -jar $executable $ags
# Generate browserClient
ags="$@ generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l dart -o samples/client/petstore/dart/swagger-browser-client -DhideGenerationTimestamp=true -DbrowserClient=true"
#java $JAVA_OPTS -jar $executable $ags
# Generate non-browserClient and put it to the flutter sample app
ags="$@ generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -l dart -o samples/client/petstore/dart/flutter_petstore/swagger -DhideGenerationTimestamp=true -DbrowserClient=false"
java $JAVA_OPTS -jar $executable $ags
# There is a proposal to allow importing different libraries depending on the environment:
# https://github.com/munificent/dep-interface-libraries
# When this is implemented there will only be one library.
# The current petstore test will then work for both: the browser library and the vm library.

View File

@ -283,13 +283,18 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
} }
@Override @Override
public String toDefaultValue(Schema p) { public String toDefaultValue(Schema schema) {
if (ModelUtils.isMapSchema(p)) { if (ModelUtils.isMapSchema(schema)) {
return "{}"; return "{}";
} else if (ModelUtils.isArraySchema(p)) { } else if (ModelUtils.isArraySchema(schema)) {
return "[]"; return "[]";
} }
return super.toDefaultValue(p);
if (schema.getDefault() != null) {
return schema.getDefault().toString();
} else {
return "null";
}
} }
@Override @Override

View File

@ -40,7 +40,8 @@ class {{classname}} {
} }
{{/required}} {{/required}}
{{/queryParams}} {{/queryParams}}
{{#headerParams}}headerParams["{{baseName}}"] = {{paramName}}; {{#headerParams}}
headerParams["{{baseName}}"] = {{paramName}};
{{/headerParams}} {{/headerParams}}
List<String> contentTypes = [{{#consumes}}"{{{mediaType}}}"{{#hasMore}},{{/hasMore}}{{/consumes}}]; List<String> contentTypes = [{{#consumes}}"{{{mediaType}}}"{{#hasMore}},{{/hasMore}}{{/consumes}}];
@ -90,16 +91,21 @@ class {{classname}} {
if(response.statusCode >= 400) { if(response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if(response.body != null) { } else if(response.body != null) {
return
{{#isListContainer}} {{#isListContainer}}
{{#returnType}}(apiClient.deserialize(response.body, '{{{returnType}}}') as List).map((item) => item as {{returnBaseType}}).toList();{{/returnType}} {{#returnType}}
return (apiClient.deserialize(response.body, '{{{returnType}}}') as List).map((item) => item as {{returnBaseType}}).toList();
{{/returnType}}
{{/isListContainer}} {{/isListContainer}}
{{^isListContainer}} {{^isListContainer}}
{{#isMapContainer}} {{#isMapContainer}}
{{#returnType}}new {{{returnType}}}.from(apiClient.deserialize(response.body, '{{{returnType}}}')) {{/returnType}}; {{#returnType}}
return new {{{returnType}}}.from(apiClient.deserialize(response.body, '{{{returnType}}}'));
{{/returnType}};
{{/isMapContainer}} {{/isMapContainer}}
{{^isMapContainer}} {{^isMapContainer}}
{{#returnType}}apiClient.deserialize(response.body, '{{{returnType}}}') as {{{returnType}}} {{/returnType}}; {{#returnType}}
return apiClient.deserialize(response.body, '{{{returnType}}}') as {{{returnType}}};
{{/returnType}}
{{/isMapContainer}} {{/isMapContainer}}
{{/isListContainer}} {{/isListContainer}}
} else { } else {

View File

@ -1,7 +1,10 @@
class {{classname}} { class {{classname}} {
{{#vars}}{{#description}}/* {{{description}}} */{{/description}} {{#vars}}
{{#description}}/* {{{description}}} */{{/description}}
{{{datatype}}} {{name}} = {{{defaultValue}}}; {{{datatype}}} {{name}} = {{{defaultValue}}};
{{#allowableValues}}{{#min}} // range from {{min}} to {{max}}{{/min}}//{{^min}}enum {{name}}Enum { {{#values}} {{.}}, {{/values}} };{{/min}}{{/allowableValues}} {{#allowableValues}}
{{#min}} // range from {{min}} to {{max}}{{/min}}//{{^min}}enum {{name}}Enum { {{#values}} {{.}}, {{/values}} };{{/min}}{
{{/allowableValues}}
{{/vars}} {{/vars}}
{{classname}}(); {{classname}}();
@ -17,20 +20,27 @@ class {{classname}} {
{{name}} = json['{{name}}'] == null ? null : DateTime.parse(json['{{name}}']); {{name}} = json['{{name}}'] == null ? null : DateTime.parse(json['{{name}}']);
{{/isDateTime}} {{/isDateTime}}
{{^isDateTime}} {{^isDateTime}}
{{name}} =
{{#complexType}} {{#complexType}}
{{#isListContainer}}{{complexType}}.listFromJson(json['{{name}}']){{/isListContainer}}{{^isListContainer}} {{#isListContainer}}
{{#isMapContainer}}{{complexType}}.mapFromJson(json['{{name}}']){{/isMapContainer}} {{name}} = {{complexType}}.listFromJson(json['{{name}}']);
{{^isMapContainer}}new {{complexType}}.fromJson(json['{{name}}']){{/isMapContainer}}{{/isListContainer}} {{/isListContainer}}
{{^isListContainer}}
{{#isMapContainer}}
{{name}} = {{complexType}}.mapFromJson(json['{{name}}']);
{{/isMapContainer}}
{{^isMapContainer}}
{{name}} = new {{complexType}}.fromJson(json['{{name}}']);
{{/isMapContainer}}
{{/isListContainer}}
{{/complexType}} {{/complexType}}
{{^complexType}} {{^complexType}}
{{#isListContainer}} {{#isListContainer}}
(json['{{name}}'] as List).map((item) => item as {{items.datatype}}).toList() {{name}} = (json['{{name}}'] as List).map((item) => item as {{items.datatype}}).toList();
{{/isListContainer}} {{/isListContainer}}
{{^isListContainer}} {{^isListContainer}}
json['{{name}}'] {{name}} = json['{{name}}'];
{{/isListContainer}} {{/isListContainer}}
{{/complexType}}; {{/complexType}}
{{/isDateTime}} {{/isDateTime}}
{{/vars}} {{/vars}}
} }
@ -38,7 +48,12 @@ class {{classname}} {
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return { return {
{{#vars}} {{#vars}}
{{#isDateTime}}'{{name}}': {{name}} == null ? '' : {{name}}.toUtc().toIso8601String(){{^-last}},{{/-last}}{{/isDateTime}}{{^isDateTime}}'{{name}}': {{name}}{{^-last}},{{/-last}}{{/isDateTime}} {{#isDateTime}}
'{{name}}': {{name}} == null ? '' : {{name}}.toUtc().toIso8601String(){{^-last}},{{/-last}}
{{/isDateTime}}
{{^isDateTime}}
'{{name}}': {{name}}{{^-last}},{{/-last}}
{{/isDateTime}}
{{/vars}} {{/vars}}
}; };
} }

View File

@ -2,6 +2,11 @@ part of {{pubName}}.api;
{{#models}} {{#models}}
{{#model}} {{#model}}
{{#isEnum}}{{>enum}}{{/isEnum}}{{^isEnum}}{{>class}}{{/isEnum}} {{#isEnum}}
{{>enum}}
{{/isEnum}}
{{^isEnum}}
{{>class}}
{{/isEnum}}
{{/model}} {{/model}}
{{/models}} {{/models}}

View File

@ -1 +1 @@
2.4.0-SNAPSHOT 3.0.0-SNAPSHOT

View File

@ -1,7 +1,7 @@
# swagger # swagger
This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
This Dart package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: This Dart package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
- API version: 1.0.0 - API version: 1.0.0
- Build package: org.openapitools.codegen.languages.DartClientCodegen - Build package: org.openapitools.codegen.languages.DartClientCodegen

View File

@ -13,7 +13,7 @@ Name | Type | Description | Notes
**quantity** | **int** | | [optional] [default to null] **quantity** | **int** | | [optional] [default to null]
**shipDate** | [**DateTime**](DateTime.md) | | [optional] [default to null] **shipDate** | [**DateTime**](DateTime.md) | | [optional] [default to null]
**status** | **String** | Order Status | [optional] [default to null] **status** | **String** | Order Status | [optional] [default to null]
**complete** | **bool** | | [optional] [default to null] **complete** | **bool** | | [optional] [default to false]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -312,8 +312,8 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet that needs to be updated | **petId** | **int**| ID of pet that needs to be updated |
**name** | **String**| Updated name of the pet | [optional] **name** | **String**| Updated name of the pet | [optional] [default to null]
**status** | **String**| Updated status of the pet | [optional] **status** | **String**| Updated status of the pet | [optional] [default to null]
### Return type ### Return type
@ -359,8 +359,8 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**petId** | **int**| ID of pet to update | **petId** | **int**| ID of pet to update |
**additionalMetadata** | **String**| Additional data to pass to server | [optional] **additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null]
**file** | **MultipartFile**| file to upload | [optional] **file** | **MultipartFile**| file to upload | [optional] [default to null]
### Return type ### Return type

View File

@ -179,7 +179,7 @@ No authorization required
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: application/json
- **Accept**: application/xml, application/json - **Accept**: application/xml, application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

View File

@ -56,7 +56,7 @@ No authorization required
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: application/json
- **Accept**: Not defined - **Accept**: Not defined
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
@ -96,7 +96,7 @@ No authorization required
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: application/json
- **Accept**: Not defined - **Accept**: Not defined
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
@ -136,7 +136,7 @@ No authorization required
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: application/json
- **Accept**: Not defined - **Accept**: Not defined
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
@ -342,7 +342,7 @@ No authorization required
### HTTP request headers ### HTTP request headers
- **Content-Type**: Not defined - **Content-Type**: application/json
- **Accept**: Not defined - **Accept**: Not defined
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
# #
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" # Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
git_user_id=$1 git_user_id=$1
git_repo_id=$2 git_repo_id=$2

View File

@ -52,7 +52,6 @@ class PetApi {
if(response.statusCode >= 400) { if(response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if(response.body != null) { } else if(response.body != null) {
return ;
} else { } else {
return; return;
} }
@ -103,7 +102,6 @@ class PetApi {
if(response.statusCode >= 400) { if(response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if(response.body != null) { } else if(response.body != null) {
return ;
} else { } else {
return; return;
} }
@ -126,7 +124,7 @@ class PetApi {
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
queryParams.addAll(_convertParametersForCollectionFormat("", "status", status)); queryParams.addAll(_convertParametersForCollectionFormat("csv", "status", status));
List<String> contentTypes = []; List<String> contentTypes = [];
@ -154,7 +152,7 @@ class PetApi {
if(response.statusCode >= 400) { if(response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if(response.body != null) { } else if(response.body != null) {
return apiClient.deserialize(response.body, 'List<Pet>') as List<Pet> ; return (apiClient.deserialize(response.body, 'List<Pet>') as List).map((item) => item as Pet).toList();
} else { } else {
return null; return null;
} }
@ -177,7 +175,7 @@ class PetApi {
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
queryParams.addAll(_convertParametersForCollectionFormat("", "tags", tags)); queryParams.addAll(_convertParametersForCollectionFormat("csv", "tags", tags));
List<String> contentTypes = []; List<String> contentTypes = [];
@ -205,7 +203,7 @@ class PetApi {
if(response.statusCode >= 400) { if(response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if(response.body != null) { } else if(response.body != null) {
return apiClient.deserialize(response.body, 'List<Pet>') as List<Pet> ; return (apiClient.deserialize(response.body, 'List<Pet>') as List).map((item) => item as Pet).toList();
} else { } else {
return null; return null;
} }
@ -305,7 +303,6 @@ class PetApi {
if(response.statusCode >= 400) { if(response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if(response.body != null) { } else if(response.body != null) {
return ;
} else { } else {
return; return;
} }
@ -367,7 +364,6 @@ class PetApi {
if(response.statusCode >= 400) { if(response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if(response.body != null) { } else if(response.body != null) {
return ;
} else { } else {
return; return;
} }

View File

@ -52,7 +52,6 @@ class StoreApi {
if(response.statusCode >= 400) { if(response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if(response.body != null) { } else if(response.body != null) {
return ;
} else { } else {
return; return;
} }
@ -99,7 +98,8 @@ class StoreApi {
if(response.statusCode >= 400) { if(response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if(response.body != null) { } else if(response.body != null) {
return apiClient.deserialize(response.body, 'Map<String, int>') as Map<String, int> ; return new Map<String, int>.from(apiClient.deserialize(response.body, 'Map<String, int>'));
;
} else { } else {
return null; return null;
} }
@ -173,7 +173,7 @@ class StoreApi {
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
List<String> contentTypes = []; List<String> contentTypes = ["application/json"];
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];

View File

@ -26,7 +26,7 @@ class UserApi {
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
List<String> contentTypes = []; List<String> contentTypes = ["application/json"];
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
@ -52,7 +52,6 @@ class UserApi {
if(response.statusCode >= 400) { if(response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if(response.body != null) { } else if(response.body != null) {
return ;
} else { } else {
return; return;
} }
@ -76,7 +75,7 @@ class UserApi {
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
List<String> contentTypes = []; List<String> contentTypes = ["application/json"];
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
@ -102,7 +101,6 @@ class UserApi {
if(response.statusCode >= 400) { if(response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if(response.body != null) { } else if(response.body != null) {
return ;
} else { } else {
return; return;
} }
@ -126,7 +124,7 @@ class UserApi {
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
List<String> contentTypes = []; List<String> contentTypes = ["application/json"];
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
@ -152,7 +150,6 @@ class UserApi {
if(response.statusCode >= 400) { if(response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if(response.body != null) { } else if(response.body != null) {
return ;
} else { } else {
return; return;
} }
@ -202,7 +199,6 @@ class UserApi {
if(response.statusCode >= 400) { if(response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if(response.body != null) { } else if(response.body != null) {
return ;
} else { } else {
return; return;
} }
@ -354,7 +350,6 @@ class UserApi {
if(response.statusCode >= 400) { if(response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if(response.body != null) { } else if(response.body != null) {
return ;
} else { } else {
return; return;
} }
@ -381,7 +376,7 @@ class UserApi {
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
List<String> contentTypes = []; List<String> contentTypes = ["application/json"];
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
@ -407,7 +402,6 @@ class UserApi {
if(response.statusCode >= 400) { if(response.statusCode >= 400) {
throw new ApiException(response.statusCode, response.body); throw new ApiException(response.statusCode, response.body);
} else if(response.body != null) { } else if(response.body != null) {
return ;
} else { } else {
return; return;
} }

View File

@ -4,12 +4,9 @@ class ApiResponse {
int code = null; int code = null;
String type = null; String type = null;
String message = null; String message = null;
ApiResponse(); ApiResponse();
@override @override
@ -19,12 +16,9 @@ class ApiResponse {
ApiResponse.fromJson(Map<String, dynamic> json) { ApiResponse.fromJson(Map<String, dynamic> json) {
if (json == null) return; if (json == null) return;
code = code = json['code'];
json['code']; type = json['type'];
type = message = json['message'];
json['type'];
message =
json['message'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@ -35,12 +29,8 @@ class ApiResponse {
}; };
} }
static List<ApiResponse> listFromJson(List<Map<String, dynamic>> json) { static List<ApiResponse> listFromJson(List<dynamic> json) {
var list = new List<ApiResponse>(); return json == null ? new List<ApiResponse>() : json.map((value) => new ApiResponse.fromJson(value)).toList();
if (json != null && json.length > 0) {
json.forEach((Map<String, dynamic> value) => list.add(new ApiResponse.fromJson(value)));
}
return list;
} }
static Map<String, ApiResponse> mapFromJson(Map<String, Map<String, dynamic>> json) { static Map<String, ApiResponse> mapFromJson(Map<String, Map<String, dynamic>> json) {

View File

@ -4,9 +4,7 @@ class Category {
int id = null; int id = null;
String name = null; String name = null;
Category(); Category();
@override @override
@ -16,10 +14,8 @@ class Category {
Category.fromJson(Map<String, dynamic> json) { Category.fromJson(Map<String, dynamic> json) {
if (json == null) return; if (json == null) return;
id = id = json['id'];
json['id']; name = json['name'];
name =
json['name'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@ -29,12 +25,8 @@ class Category {
}; };
} }
static List<Category> listFromJson(List<Map<String, dynamic>> json) { static List<Category> listFromJson(List<dynamic> json) {
var list = new List<Category>(); return json == null ? new List<Category>() : json.map((value) => new Category.fromJson(value)).toList();
if (json != null && json.length > 0) {
json.forEach((Map<String, dynamic> value) => list.add(new Category.fromJson(value)));
}
return list;
} }
static Map<String, Category> mapFromJson(Map<String, Map<String, dynamic>> json) { static Map<String, Category> mapFromJson(Map<String, Map<String, dynamic>> json) {

View File

@ -4,21 +4,16 @@ 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 */ /* Order Status */
String status = null; String status = null;
//enum statusEnum { placed, approved, delivered, }; //enum statusEnum { placed, approved, delivered, };{
bool complete = null;
bool complete = false;
Order(); Order();
@override @override
@ -28,17 +23,12 @@ class Order {
Order.fromJson(Map<String, dynamic> json) { Order.fromJson(Map<String, dynamic> json) {
if (json == null) return; if (json == null) return;
id = id = json['id'];
json['id']; petId = json['petId'];
petId = quantity = json['quantity'];
json['petId'];
quantity =
json['quantity'];
shipDate = json['shipDate'] == null ? null : DateTime.parse(json['shipDate']); shipDate = json['shipDate'] == null ? null : DateTime.parse(json['shipDate']);
status = status = json['status'];
json['status']; complete = json['complete'];
complete =
json['complete'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@ -52,12 +42,8 @@ class Order {
}; };
} }
static List<Order> listFromJson(List<Map<String, dynamic>> json) { static List<Order> listFromJson(List<dynamic> json) {
var list = new List<Order>(); return json == null ? new List<Order>() : json.map((value) => new Order.fromJson(value)).toList();
if (json != null && json.length > 0) {
json.forEach((Map<String, dynamic> value) => list.add(new Order.fromJson(value)));
}
return list;
} }
static Map<String, Order> mapFromJson(Map<String, Map<String, dynamic>> json) { static Map<String, Order> mapFromJson(Map<String, Map<String, dynamic>> json) {

View File

@ -4,21 +4,16 @@ 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 */ /* pet status in the store */
String status = null; String status = null;
//enum statusEnum { available, pending, sold, }; //enum statusEnum { available, pending, sold, };{
Pet(); Pet();
@override @override
@ -28,22 +23,12 @@ class Pet {
Pet.fromJson(Map<String, dynamic> json) { Pet.fromJson(Map<String, dynamic> json) {
if (json == null) return; if (json == null) return;
id = id = json['id'];
json['id']; category = new Category.fromJson(json['category']);
category = name = json['name'];
photoUrls = (json['photoUrls'] as List).map((item) => item as String).toList();
tags = Tag.listFromJson(json['tags']);
new Category.fromJson(json['category']) status = json['status'];
;
name =
json['name'];
photoUrls =
json['photoUrls'];
tags =
Tag.listFromJson(json['tags'])
;
status =
json['status'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@ -57,12 +42,8 @@ class Pet {
}; };
} }
static List<Pet> listFromJson(List<Map<String, dynamic>> json) { static List<Pet> listFromJson(List<dynamic> json) {
var list = new List<Pet>(); return json == null ? new List<Pet>() : json.map((value) => new Pet.fromJson(value)).toList();
if (json != null && json.length > 0) {
json.forEach((Map<String, dynamic> value) => list.add(new Pet.fromJson(value)));
}
return list;
} }
static Map<String, Pet> mapFromJson(Map<String, Map<String, dynamic>> json) { static Map<String, Pet> mapFromJson(Map<String, Map<String, dynamic>> json) {

View File

@ -4,9 +4,7 @@ class Tag {
int id = null; int id = null;
String name = null; String name = null;
Tag(); Tag();
@override @override
@ -16,10 +14,8 @@ class Tag {
Tag.fromJson(Map<String, dynamic> json) { Tag.fromJson(Map<String, dynamic> json) {
if (json == null) return; if (json == null) return;
id = id = json['id'];
json['id']; name = json['name'];
name =
json['name'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@ -29,12 +25,8 @@ class Tag {
}; };
} }
static List<Tag> listFromJson(List<Map<String, dynamic>> json) { static List<Tag> listFromJson(List<dynamic> json) {
var list = new List<Tag>(); return json == null ? new List<Tag>() : json.map((value) => new Tag.fromJson(value)).toList();
if (json != null && json.length > 0) {
json.forEach((Map<String, dynamic> value) => list.add(new Tag.fromJson(value)));
}
return list;
} }
static Map<String, Tag> mapFromJson(Map<String, Map<String, dynamic>> json) { static Map<String, Tag> mapFromJson(Map<String, Map<String, dynamic>> json) {

View File

@ -4,27 +4,19 @@ 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 */ /* User Status */
int userStatus = null; int userStatus = null;
User(); User();
@override @override
@ -34,22 +26,14 @@ class User {
User.fromJson(Map<String, dynamic> json) { User.fromJson(Map<String, dynamic> json) {
if (json == null) return; if (json == null) return;
id = id = json['id'];
json['id']; username = json['username'];
username = firstName = json['firstName'];
json['username']; lastName = json['lastName'];
firstName = email = json['email'];
json['firstName']; password = json['password'];
lastName = phone = json['phone'];
json['lastName']; userStatus = json['userStatus'];
email =
json['email'];
password =
json['password'];
phone =
json['phone'];
userStatus =
json['userStatus'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@ -65,12 +49,8 @@ class User {
}; };
} }
static List<User> listFromJson(List<Map<String, dynamic>> json) { static List<User> listFromJson(List<dynamic> json) {
var list = new List<User>(); return json == null ? new List<User>() : json.map((value) => new User.fromJson(value)).toList();
if (json != null && json.length > 0) {
json.forEach((Map<String, dynamic> value) => list.add(new User.fromJson(value)));
}
return list;
} }
static Map<String, User> mapFromJson(Map<String, Map<String, dynamic>> json) { static Map<String, User> mapFromJson(Map<String, Map<String, dynamic>> json) {