forked from loafle/openapi-generator-original
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:
parent
252a1c2599
commit
c791146b62
51
bin/openapi3/dart-petstore.sh
Executable file
51
bin/openapi3/dart-petstore.sh
Executable 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.
|
||||
|
@ -283,13 +283,18 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toDefaultValue(Schema p) {
|
||||
if (ModelUtils.isMapSchema(p)) {
|
||||
public String toDefaultValue(Schema schema) {
|
||||
if (ModelUtils.isMapSchema(schema)) {
|
||||
return "{}";
|
||||
} else if (ModelUtils.isArraySchema(p)) {
|
||||
} else if (ModelUtils.isArraySchema(schema)) {
|
||||
return "[]";
|
||||
}
|
||||
return super.toDefaultValue(p);
|
||||
|
||||
if (schema.getDefault() != null) {
|
||||
return schema.getDefault().toString();
|
||||
} else {
|
||||
return "null";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,7 +40,8 @@ class {{classname}} {
|
||||
}
|
||||
{{/required}}
|
||||
{{/queryParams}}
|
||||
{{#headerParams}}headerParams["{{baseName}}"] = {{paramName}};
|
||||
{{#headerParams}}
|
||||
headerParams["{{baseName}}"] = {{paramName}};
|
||||
{{/headerParams}}
|
||||
|
||||
List<String> contentTypes = [{{#consumes}}"{{{mediaType}}}"{{#hasMore}},{{/hasMore}}{{/consumes}}];
|
||||
@ -90,16 +91,21 @@ class {{classname}} {
|
||||
if(response.statusCode >= 400) {
|
||||
throw new ApiException(response.statusCode, response.body);
|
||||
} else if(response.body != null) {
|
||||
return
|
||||
{{#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}}
|
||||
{{#isMapContainer}}
|
||||
{{#returnType}}new {{{returnType}}}.from(apiClient.deserialize(response.body, '{{{returnType}}}')) {{/returnType}};
|
||||
{{#returnType}}
|
||||
return new {{{returnType}}}.from(apiClient.deserialize(response.body, '{{{returnType}}}'));
|
||||
{{/returnType}};
|
||||
{{/isMapContainer}}
|
||||
{{^isMapContainer}}
|
||||
{{#returnType}}apiClient.deserialize(response.body, '{{{returnType}}}') as {{{returnType}}} {{/returnType}};
|
||||
{{#returnType}}
|
||||
return apiClient.deserialize(response.body, '{{{returnType}}}') as {{{returnType}}};
|
||||
{{/returnType}}
|
||||
{{/isMapContainer}}
|
||||
{{/isListContainer}}
|
||||
} else {
|
||||
|
@ -1,7 +1,10 @@
|
||||
class {{classname}} {
|
||||
{{#vars}}{{#description}}/* {{{description}}} */{{/description}}
|
||||
{{#vars}}
|
||||
{{#description}}/* {{{description}}} */{{/description}}
|
||||
{{{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}}
|
||||
{{classname}}();
|
||||
|
||||
@ -17,20 +20,27 @@ class {{classname}} {
|
||||
{{name}} = json['{{name}}'] == null ? null : DateTime.parse(json['{{name}}']);
|
||||
{{/isDateTime}}
|
||||
{{^isDateTime}}
|
||||
{{name}} =
|
||||
{{#complexType}}
|
||||
{{#isListContainer}}{{complexType}}.listFromJson(json['{{name}}']){{/isListContainer}}{{^isListContainer}}
|
||||
{{#isMapContainer}}{{complexType}}.mapFromJson(json['{{name}}']){{/isMapContainer}}
|
||||
{{^isMapContainer}}new {{complexType}}.fromJson(json['{{name}}']){{/isMapContainer}}{{/isListContainer}}
|
||||
{{#isListContainer}}
|
||||
{{name}} = {{complexType}}.listFromJson(json['{{name}}']);
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
{{#isMapContainer}}
|
||||
{{name}} = {{complexType}}.mapFromJson(json['{{name}}']);
|
||||
{{/isMapContainer}}
|
||||
{{^isMapContainer}}
|
||||
{{name}} = new {{complexType}}.fromJson(json['{{name}}']);
|
||||
{{/isMapContainer}}
|
||||
{{/isListContainer}}
|
||||
{{/complexType}}
|
||||
{{^complexType}}
|
||||
{{#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}}
|
||||
json['{{name}}']
|
||||
{{name}} = json['{{name}}'];
|
||||
{{/isListContainer}}
|
||||
{{/complexType}};
|
||||
{{/complexType}}
|
||||
{{/isDateTime}}
|
||||
{{/vars}}
|
||||
}
|
||||
@ -38,7 +48,12 @@ class {{classname}} {
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
{{#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}}
|
||||
};
|
||||
}
|
||||
|
@ -2,6 +2,11 @@ part of {{pubName}}.api;
|
||||
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
{{#isEnum}}{{>enum}}{{/isEnum}}{{^isEnum}}{{>class}}{{/isEnum}}
|
||||
{{#isEnum}}
|
||||
{{>enum}}
|
||||
{{/isEnum}}
|
||||
{{^isEnum}}
|
||||
{{>class}}
|
||||
{{/isEnum}}
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
|
@ -1 +1 @@
|
||||
2.4.0-SNAPSHOT
|
||||
3.0.0-SNAPSHOT
|
@ -1,7 +1,7 @@
|
||||
# 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 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
|
||||
- Build package: org.openapitools.codegen.languages.DartClientCodegen
|
||||
|
@ -13,7 +13,7 @@ Name | Type | Description | Notes
|
||||
**quantity** | **int** | | [optional] [default to null]
|
||||
**shipDate** | [**DateTime**](DateTime.md) | | [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)
|
||||
|
||||
|
@ -312,8 +312,8 @@ try {
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**petId** | **int**| ID of pet that needs to be updated |
|
||||
**name** | **String**| Updated name of the pet | [optional]
|
||||
**status** | **String**| Updated status of the pet | [optional]
|
||||
**name** | **String**| Updated name of the pet | [optional] [default to null]
|
||||
**status** | **String**| Updated status of the pet | [optional] [default to null]
|
||||
|
||||
### Return type
|
||||
|
||||
@ -359,8 +359,8 @@ try {
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**petId** | **int**| ID of pet to update |
|
||||
**additionalMetadata** | **String**| Additional data to pass to server | [optional]
|
||||
**file** | **MultipartFile**| file to upload | [optional]
|
||||
**additionalMetadata** | **String**| Additional data to pass to server | [optional] [default to null]
|
||||
**file** | **MultipartFile**| file to upload | [optional] [default to null]
|
||||
|
||||
### Return type
|
||||
|
||||
|
@ -179,7 +179,7 @@ No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Content-Type**: 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)
|
||||
|
@ -56,7 +56,7 @@ No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Content-Type**: application/json
|
||||
- **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)
|
||||
@ -96,7 +96,7 @@ No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Content-Type**: application/json
|
||||
- **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)
|
||||
@ -136,7 +136,7 @@ No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Content-Type**: application/json
|
||||
- **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)
|
||||
@ -342,7 +342,7 @@ No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Content-Type**: application/json
|
||||
- **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)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
# 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_repo_id=$2
|
||||
|
@ -52,7 +52,6 @@ class PetApi {
|
||||
if(response.statusCode >= 400) {
|
||||
throw new ApiException(response.statusCode, response.body);
|
||||
} else if(response.body != null) {
|
||||
return ;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@ -103,7 +102,6 @@ class PetApi {
|
||||
if(response.statusCode >= 400) {
|
||||
throw new ApiException(response.statusCode, response.body);
|
||||
} else if(response.body != null) {
|
||||
return ;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@ -126,7 +124,7 @@ class PetApi {
|
||||
List<QueryParam> queryParams = [];
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
queryParams.addAll(_convertParametersForCollectionFormat("", "status", status));
|
||||
queryParams.addAll(_convertParametersForCollectionFormat("csv", "status", status));
|
||||
|
||||
List<String> contentTypes = [];
|
||||
|
||||
@ -154,7 +152,7 @@ class PetApi {
|
||||
if(response.statusCode >= 400) {
|
||||
throw new ApiException(response.statusCode, response.body);
|
||||
} 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 {
|
||||
return null;
|
||||
}
|
||||
@ -177,7 +175,7 @@ class PetApi {
|
||||
List<QueryParam> queryParams = [];
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
queryParams.addAll(_convertParametersForCollectionFormat("", "tags", tags));
|
||||
queryParams.addAll(_convertParametersForCollectionFormat("csv", "tags", tags));
|
||||
|
||||
List<String> contentTypes = [];
|
||||
|
||||
@ -205,7 +203,7 @@ class PetApi {
|
||||
if(response.statusCode >= 400) {
|
||||
throw new ApiException(response.statusCode, response.body);
|
||||
} 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 {
|
||||
return null;
|
||||
}
|
||||
@ -305,7 +303,6 @@ class PetApi {
|
||||
if(response.statusCode >= 400) {
|
||||
throw new ApiException(response.statusCode, response.body);
|
||||
} else if(response.body != null) {
|
||||
return ;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@ -367,7 +364,6 @@ class PetApi {
|
||||
if(response.statusCode >= 400) {
|
||||
throw new ApiException(response.statusCode, response.body);
|
||||
} else if(response.body != null) {
|
||||
return ;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
@ -52,7 +52,6 @@ class StoreApi {
|
||||
if(response.statusCode >= 400) {
|
||||
throw new ApiException(response.statusCode, response.body);
|
||||
} else if(response.body != null) {
|
||||
return ;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@ -99,7 +98,8 @@ class StoreApi {
|
||||
if(response.statusCode >= 400) {
|
||||
throw new ApiException(response.statusCode, response.body);
|
||||
} 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 {
|
||||
return null;
|
||||
}
|
||||
@ -173,7 +173,7 @@ class StoreApi {
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
|
||||
List<String> contentTypes = [];
|
||||
List<String> contentTypes = ["application/json"];
|
||||
|
||||
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
|
||||
List<String> authNames = [];
|
||||
|
@ -26,7 +26,7 @@ class UserApi {
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
|
||||
List<String> contentTypes = [];
|
||||
List<String> contentTypes = ["application/json"];
|
||||
|
||||
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
|
||||
List<String> authNames = [];
|
||||
@ -52,7 +52,6 @@ class UserApi {
|
||||
if(response.statusCode >= 400) {
|
||||
throw new ApiException(response.statusCode, response.body);
|
||||
} else if(response.body != null) {
|
||||
return ;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@ -76,7 +75,7 @@ class UserApi {
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
|
||||
List<String> contentTypes = [];
|
||||
List<String> contentTypes = ["application/json"];
|
||||
|
||||
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
|
||||
List<String> authNames = [];
|
||||
@ -102,7 +101,6 @@ class UserApi {
|
||||
if(response.statusCode >= 400) {
|
||||
throw new ApiException(response.statusCode, response.body);
|
||||
} else if(response.body != null) {
|
||||
return ;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@ -126,7 +124,7 @@ class UserApi {
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
|
||||
List<String> contentTypes = [];
|
||||
List<String> contentTypes = ["application/json"];
|
||||
|
||||
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
|
||||
List<String> authNames = [];
|
||||
@ -152,7 +150,6 @@ class UserApi {
|
||||
if(response.statusCode >= 400) {
|
||||
throw new ApiException(response.statusCode, response.body);
|
||||
} else if(response.body != null) {
|
||||
return ;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@ -202,7 +199,6 @@ class UserApi {
|
||||
if(response.statusCode >= 400) {
|
||||
throw new ApiException(response.statusCode, response.body);
|
||||
} else if(response.body != null) {
|
||||
return ;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@ -354,7 +350,6 @@ class UserApi {
|
||||
if(response.statusCode >= 400) {
|
||||
throw new ApiException(response.statusCode, response.body);
|
||||
} else if(response.body != null) {
|
||||
return ;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@ -381,7 +376,7 @@ class UserApi {
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
|
||||
List<String> contentTypes = [];
|
||||
List<String> contentTypes = ["application/json"];
|
||||
|
||||
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
|
||||
List<String> authNames = [];
|
||||
@ -407,7 +402,6 @@ class UserApi {
|
||||
if(response.statusCode >= 400) {
|
||||
throw new ApiException(response.statusCode, response.body);
|
||||
} else if(response.body != null) {
|
||||
return ;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
@ -4,12 +4,9 @@ class ApiResponse {
|
||||
|
||||
int code = null;
|
||||
|
||||
|
||||
String type = null;
|
||||
|
||||
|
||||
String message = null;
|
||||
|
||||
ApiResponse();
|
||||
|
||||
@override
|
||||
@ -19,12 +16,9 @@ class ApiResponse {
|
||||
|
||||
ApiResponse.fromJson(Map<String, dynamic> json) {
|
||||
if (json == null) return;
|
||||
code =
|
||||
json['code'];
|
||||
type =
|
||||
json['type'];
|
||||
message =
|
||||
json['message'];
|
||||
code = json['code'];
|
||||
type = json['type'];
|
||||
message = json['message'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@ -35,12 +29,8 @@ class ApiResponse {
|
||||
};
|
||||
}
|
||||
|
||||
static List<ApiResponse> listFromJson(List<Map<String, dynamic>> json) {
|
||||
var list = new List<ApiResponse>();
|
||||
if (json != null && json.length > 0) {
|
||||
json.forEach((Map<String, dynamic> value) => list.add(new ApiResponse.fromJson(value)));
|
||||
}
|
||||
return list;
|
||||
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) {
|
||||
|
@ -4,9 +4,7 @@ class Category {
|
||||
|
||||
int id = null;
|
||||
|
||||
|
||||
String name = null;
|
||||
|
||||
Category();
|
||||
|
||||
@override
|
||||
@ -16,10 +14,8 @@ class Category {
|
||||
|
||||
Category.fromJson(Map<String, dynamic> json) {
|
||||
if (json == null) return;
|
||||
id =
|
||||
json['id'];
|
||||
name =
|
||||
json['name'];
|
||||
id = json['id'];
|
||||
name = json['name'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@ -29,12 +25,8 @@ class Category {
|
||||
};
|
||||
}
|
||||
|
||||
static List<Category> listFromJson(List<Map<String, dynamic>> json) {
|
||||
var list = new List<Category>();
|
||||
if (json != null && json.length > 0) {
|
||||
json.forEach((Map<String, dynamic> value) => list.add(new Category.fromJson(value)));
|
||||
}
|
||||
return list;
|
||||
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) {
|
||||
|
@ -4,21 +4,16 @@ 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 = null;
|
||||
//enum statusEnum { placed, approved, delivered, };{
|
||||
|
||||
bool complete = false;
|
||||
Order();
|
||||
|
||||
@override
|
||||
@ -28,17 +23,12 @@ class Order {
|
||||
|
||||
Order.fromJson(Map<String, dynamic> json) {
|
||||
if (json == null) return;
|
||||
id =
|
||||
json['id'];
|
||||
petId =
|
||||
json['petId'];
|
||||
quantity =
|
||||
json['quantity'];
|
||||
id = json['id'];
|
||||
petId = json['petId'];
|
||||
quantity = json['quantity'];
|
||||
shipDate = json['shipDate'] == null ? null : DateTime.parse(json['shipDate']);
|
||||
status =
|
||||
json['status'];
|
||||
complete =
|
||||
json['complete'];
|
||||
status = json['status'];
|
||||
complete = json['complete'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@ -52,12 +42,8 @@ class Order {
|
||||
};
|
||||
}
|
||||
|
||||
static List<Order> listFromJson(List<Map<String, dynamic>> json) {
|
||||
var list = new List<Order>();
|
||||
if (json != null && json.length > 0) {
|
||||
json.forEach((Map<String, dynamic> value) => list.add(new Order.fromJson(value)));
|
||||
}
|
||||
return list;
|
||||
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) {
|
||||
|
@ -4,21 +4,16 @@ 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, };
|
||||
//enum statusEnum { available, pending, sold, };{
|
||||
Pet();
|
||||
|
||||
@override
|
||||
@ -28,22 +23,12 @@ class Pet {
|
||||
|
||||
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'];
|
||||
tags =
|
||||
Tag.listFromJson(json['tags'])
|
||||
;
|
||||
status =
|
||||
json['status'];
|
||||
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() {
|
||||
@ -57,12 +42,8 @@ class Pet {
|
||||
};
|
||||
}
|
||||
|
||||
static List<Pet> listFromJson(List<Map<String, dynamic>> json) {
|
||||
var list = new List<Pet>();
|
||||
if (json != null && json.length > 0) {
|
||||
json.forEach((Map<String, dynamic> value) => list.add(new Pet.fromJson(value)));
|
||||
}
|
||||
return list;
|
||||
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) {
|
||||
|
@ -4,9 +4,7 @@ class Tag {
|
||||
|
||||
int id = null;
|
||||
|
||||
|
||||
String name = null;
|
||||
|
||||
Tag();
|
||||
|
||||
@override
|
||||
@ -16,10 +14,8 @@ class Tag {
|
||||
|
||||
Tag.fromJson(Map<String, dynamic> json) {
|
||||
if (json == null) return;
|
||||
id =
|
||||
json['id'];
|
||||
name =
|
||||
json['name'];
|
||||
id = json['id'];
|
||||
name = json['name'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@ -29,12 +25,8 @@ class Tag {
|
||||
};
|
||||
}
|
||||
|
||||
static List<Tag> listFromJson(List<Map<String, dynamic>> json) {
|
||||
var list = new List<Tag>();
|
||||
if (json != null && json.length > 0) {
|
||||
json.forEach((Map<String, dynamic> value) => list.add(new Tag.fromJson(value)));
|
||||
}
|
||||
return list;
|
||||
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) {
|
||||
|
@ -4,27 +4,19 @@ 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
|
||||
@ -34,22 +26,14 @@ class User {
|
||||
|
||||
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'];
|
||||
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() {
|
||||
@ -65,12 +49,8 @@ class User {
|
||||
};
|
||||
}
|
||||
|
||||
static List<User> listFromJson(List<Map<String, dynamic>> json) {
|
||||
var list = new List<User>();
|
||||
if (json != null && json.length > 0) {
|
||||
json.forEach((Map<String, dynamic> value) => list.add(new User.fromJson(value)));
|
||||
}
|
||||
return list;
|
||||
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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user