[DART] fix: set fields to null if json value is null. (#1798)

* fix: set fields to null if json value is null.

* rebuild dart2 petstore

* rebuild dart petstore

* rebuild petstore

* [DART]fix: set fields to null if json value is null.
This commit is contained in:
d3v-cl
2019-01-08 17:26:46 +01:00
committed by William Cheng
parent 293066bb0d
commit 9ccf872290
134 changed files with 4342 additions and 2945 deletions

View File

@@ -16,37 +16,41 @@ class {{classname}} {
{{classname}}.fromJson(Map<String, dynamic> json) { {{classname}}.fromJson(Map<String, dynamic> json) {
if (json == null) return; if (json == null) return;
{{#vars}} {{#vars}}
if (json['{{baseName}}'] == null) {
{{name}} = null;
} else {
{{#isDateTime}} {{#isDateTime}}
{{name}} = json['{{baseName}}'] == null ? null : DateTime.parse(json['{{baseName}}']); {{name}} = DateTime.parse(json['{{baseName}}']);
{{/isDateTime}} {{/isDateTime}}
{{#isDate}} {{#isDate}}
{{name}} = json['{{baseName}}'] == null ? null : DateTime.parse(json['{{baseName}}']); {{name}} = DateTime.parse(json['{{baseName}}']);
{{/isDate}} {{/isDate}}
{{^isDateTime}} {{^isDateTime}}
{{^isDate}} {{^isDate}}
{{#complexType}} {{#complexType}}
{{#isListContainer}} {{#isListContainer}}
{{name}} = {{complexType}}.listFromJson(json['{{baseName}}']); {{name}} = {{complexType}}.listFromJson(json['{{baseName}}']);
{{/isListContainer}} {{/isListContainer}}
{{^isListContainer}} {{^isListContainer}}
{{#isMapContainer}} {{#isMapContainer}}
{{name}} = {{complexType}}.mapFromJson(json['{{baseName}}']); {{name}} = {{complexType}}.mapFromJson(json['{{baseName}}']);
{{/isMapContainer}} {{/isMapContainer}}
{{^isMapContainer}} {{^isMapContainer}}
{{name}} = new {{complexType}}.fromJson(json['{{baseName}}']); {{name}} = new {{complexType}}.fromJson(json['{{baseName}}']);
{{/isMapContainer}} {{/isMapContainer}}
{{/isListContainer}} {{/isListContainer}}
{{/complexType}} {{/complexType}}
{{^complexType}} {{^complexType}}
{{#isListContainer}} {{#isListContainer}}
{{name}} = (json['{{baseName}}'] as List).map((item) => item as {{items.datatype}}).toList(); {{name}} = (json['{{baseName}}'] as List).map((item) => item as {{items.datatype}}).toList();
{{/isListContainer}} {{/isListContainer}}
{{^isListContainer}} {{^isListContainer}}
{{name}} = json['{{baseName}}']; {{name}} = json['{{baseName}}'];
{{/isListContainer}} {{/isListContainer}}
{{/complexType}} {{/complexType}}
{{/isDate}} {{/isDate}}
{{/isDateTime}} {{/isDateTime}}
}
{{/vars}} {{/vars}}
} }

View File

@@ -16,37 +16,41 @@ class {{classname}} {
{{classname}}.fromJson(Map<String, dynamic> json) { {{classname}}.fromJson(Map<String, dynamic> json) {
if (json == null) return; if (json == null) return;
{{#vars}} {{#vars}}
if (json['{{baseName}}'] == null) {
{{name}} = null;
} else {
{{#isDateTime}} {{#isDateTime}}
{{name}} = json['{{baseName}}'] == null ? null : DateTime.parse(json['{{baseName}}']); {{name}} = DateTime.parse(json['{{baseName}}']);
{{/isDateTime}} {{/isDateTime}}
{{#isDate}} {{#isDate}}
{{name}} = json['{{baseName}}'] == null ? null : DateTime.parse(json['{{baseName}}']); {{name}} = DateTime.parse(json['{{baseName}}']);
{{/isDate}} {{/isDate}}
{{^isDateTime}} {{^isDateTime}}
{{^isDate}} {{^isDate}}
{{#complexType}} {{#complexType}}
{{#isListContainer}} {{#isListContainer}}
{{name}} = {{complexType}}.listFromJson(json['{{baseName}}']); {{name}} = {{complexType}}.listFromJson(json['{{baseName}}']);
{{/isListContainer}} {{/isListContainer}}
{{^isListContainer}} {{^isListContainer}}
{{#isMapContainer}} {{#isMapContainer}}
{{name}} = {{complexType}}.mapFromJson(json['{{baseName}}']); {{name}} = {{complexType}}.mapFromJson(json['{{baseName}}']);
{{/isMapContainer}} {{/isMapContainer}}
{{^isMapContainer}} {{^isMapContainer}}
{{name}} = new {{complexType}}.fromJson(json['{{baseName}}']); {{name}} = new {{complexType}}.fromJson(json['{{baseName}}']);
{{/isMapContainer}} {{/isMapContainer}}
{{/isListContainer}} {{/isListContainer}}
{{/complexType}} {{/complexType}}
{{^complexType}} {{^complexType}}
{{#isListContainer}} {{#isListContainer}}
{{name}} = ((json['{{baseName}}'] ?? []) as List).map((item) => item as {{items.datatype}}).toList(); {{name}} = (json['{{baseName}}'] as List).map((item) => item as {{items.datatype}}).toList();
{{/isListContainer}} {{/isListContainer}}
{{^isListContainer}} {{^isListContainer}}
{{name}} = json['{{baseName}}']; {{name}} = json['{{baseName}}'];
{{/isListContainer}} {{/isListContainer}}
{{/complexType}} {{/complexType}}
{{/isDate}} {{/isDate}}
{{/isDateTime}} {{/isDateTime}}
}
{{/vars}} {{/vars}}
} }

View File

@@ -1 +1 @@
3.3.1-SNAPSHOT 4.0.0-SNAPSHOT

View File

@@ -47,10 +47,10 @@ import 'package:openapi/api.dart';
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
var api_instance = new PetApi(); var api_instance = new PetApi();
var pet = new Pet(); // Pet | Pet object that needs to be added to the store var body = new Pet(); // Pet | Pet object that needs to be added to the store
try { try {
api_instance.addPet(pet); api_instance.addPet(body);
} catch (e) { } catch (e) {
print("Exception when calling PetApi->addPet: $e\n"); print("Exception when calling PetApi->addPet: $e\n");
} }

View File

@@ -20,7 +20,7 @@ Method | HTTP request | Description
# **addPet** # **addPet**
> addPet(pet) > addPet(body)
Add a new pet to the store Add a new pet to the store
@@ -31,10 +31,10 @@ import 'package:openapi/api.dart';
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
var api_instance = new PetApi(); var api_instance = new PetApi();
var pet = new Pet(); // Pet | Pet object that needs to be added to the store var body = new Pet(); // Pet | Pet object that needs to be added to the store
try { try {
api_instance.addPet(pet); api_instance.addPet(body);
} catch (e) { } catch (e) {
print("Exception when calling PetApi->addPet: $e\n"); print("Exception when calling PetApi->addPet: $e\n");
} }
@@ -44,7 +44,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
### Return type ### Return type
@@ -243,7 +243,7 @@ Name | Type | Description | Notes
[[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)
# **updatePet** # **updatePet**
> updatePet(pet) > updatePet(body)
Update an existing pet Update an existing pet
@@ -254,10 +254,10 @@ import 'package:openapi/api.dart';
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
var api_instance = new PetApi(); var api_instance = new PetApi();
var pet = new Pet(); // Pet | Pet object that needs to be added to the store var body = new Pet(); // Pet | Pet object that needs to be added to the store
try { try {
api_instance.updatePet(pet); api_instance.updatePet(body);
} catch (e) { } catch (e) {
print("Exception when calling PetApi->updatePet: $e\n"); print("Exception when calling PetApi->updatePet: $e\n");
} }
@@ -267,7 +267,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
### Return type ### Return type

View File

@@ -144,7 +144,7 @@ No authorization required
[[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)
# **placeOrder** # **placeOrder**
> Order placeOrder(order) > Order placeOrder(body)
Place an order for a pet Place an order for a pet
@@ -153,10 +153,10 @@ Place an order for a pet
import 'package:openapi/api.dart'; import 'package:openapi/api.dart';
var api_instance = new StoreApi(); var api_instance = new StoreApi();
var order = new Order(); // Order | order placed for purchasing the pet var body = new Order(); // Order | order placed for purchasing the pet
try { try {
var result = api_instance.placeOrder(order); var result = api_instance.placeOrder(body);
print(result); print(result);
} catch (e) { } catch (e) {
print("Exception when calling StoreApi->placeOrder: $e\n"); print("Exception when calling StoreApi->placeOrder: $e\n");
@@ -167,7 +167,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**order** | [**Order**](Order.md)| order placed for purchasing the pet | **body** | [**Order**](Order.md)| order placed for purchasing the pet |
### Return type ### Return type

View File

@@ -20,7 +20,7 @@ Method | HTTP request | Description
# **createUser** # **createUser**
> createUser(user) > createUser(body)
Create user Create user
@@ -31,10 +31,10 @@ This can only be done by the logged in user.
import 'package:openapi/api.dart'; import 'package:openapi/api.dart';
var api_instance = new UserApi(); var api_instance = new UserApi();
var user = new User(); // User | Created user object var body = new User(); // User | Created user object
try { try {
api_instance.createUser(user); api_instance.createUser(body);
} catch (e) { } catch (e) {
print("Exception when calling UserApi->createUser: $e\n"); print("Exception when calling UserApi->createUser: $e\n");
} }
@@ -44,7 +44,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**user** | [**User**](User.md)| Created user object | **body** | [**User**](User.md)| Created user object |
### Return type ### Return type
@@ -62,7 +62,7 @@ No authorization required
[[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)
# **createUsersWithArrayInput** # **createUsersWithArrayInput**
> createUsersWithArrayInput(user) > createUsersWithArrayInput(body)
Creates list of users with given input array Creates list of users with given input array
@@ -71,10 +71,10 @@ Creates list of users with given input array
import 'package:openapi/api.dart'; import 'package:openapi/api.dart';
var api_instance = new UserApi(); var api_instance = new UserApi();
var user = [new List&lt;User&gt;()]; // List<User> | List of user object var body = [new List&lt;User&gt;()]; // List<User> | List of user object
try { try {
api_instance.createUsersWithArrayInput(user); api_instance.createUsersWithArrayInput(body);
} catch (e) { } catch (e) {
print("Exception when calling UserApi->createUsersWithArrayInput: $e\n"); print("Exception when calling UserApi->createUsersWithArrayInput: $e\n");
} }
@@ -84,7 +84,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**user** | [**List&lt;User&gt;**](List.md)| List of user object | **body** | [**List&lt;User&gt;**](List.md)| List of user object |
### Return type ### Return type
@@ -102,7 +102,7 @@ No authorization required
[[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)
# **createUsersWithListInput** # **createUsersWithListInput**
> createUsersWithListInput(user) > createUsersWithListInput(body)
Creates list of users with given input array Creates list of users with given input array
@@ -111,10 +111,10 @@ Creates list of users with given input array
import 'package:openapi/api.dart'; import 'package:openapi/api.dart';
var api_instance = new UserApi(); var api_instance = new UserApi();
var user = [new List&lt;User&gt;()]; // List<User> | List of user object var body = [new List&lt;User&gt;()]; // List<User> | List of user object
try { try {
api_instance.createUsersWithListInput(user); api_instance.createUsersWithListInput(body);
} catch (e) { } catch (e) {
print("Exception when calling UserApi->createUsersWithListInput: $e\n"); print("Exception when calling UserApi->createUsersWithListInput: $e\n");
} }
@@ -124,7 +124,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**user** | [**List&lt;User&gt;**](List.md)| List of user object | **body** | [**List&lt;User&gt;**](List.md)| List of user object |
### Return type ### Return type
@@ -304,7 +304,7 @@ No authorization required
[[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)
# **updateUser** # **updateUser**
> updateUser(username, user) > updateUser(username, body)
Updated user Updated user
@@ -316,10 +316,10 @@ import 'package:openapi/api.dart';
var api_instance = new UserApi(); var api_instance = new UserApi();
var username = username_example; // String | name that need to be deleted var username = username_example; // String | name that need to be deleted
var user = new User(); // User | Updated user object var body = new User(); // User | Updated user object
try { try {
api_instance.updateUser(username, user); api_instance.updateUser(username, body);
} catch (e) { } catch (e) {
print("Exception when calling UserApi->updateUser: $e\n"); print("Exception when calling UserApi->updateUser: $e\n");
} }
@@ -330,7 +330,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**username** | **String**| name that need to be deleted | [default to null] **username** | **String**| name that need to be deleted | [default to null]
**user** | [**User**](User.md)| Updated user object | **body** | [**User**](User.md)| Updated user object |
### Return type ### Return type

View File

@@ -23,4 +23,5 @@ part 'model/pet.dart';
part 'model/tag.dart'; part 'model/tag.dart';
part 'model/user.dart'; part 'model/user.dart';
ApiClient defaultApiClient = new ApiClient(); ApiClient defaultApiClient = new ApiClient();

View File

@@ -1,5 +1,7 @@
part of openapi.api; part of openapi.api;
class PetApi { class PetApi {
final ApiClient apiClient; final ApiClient apiClient;
@@ -7,60 +9,66 @@ class PetApi {
/// Add a new pet to the store /// Add a new pet to the store
/// ///
/// ///
Future addPet(Pet pet) async { Future addPet(Pet body) async {
Object postBody = pet; Object postBody = body;
// verify required params are set // verify required params are set
if (pet == null) { if(body == null) {
throw new ApiException(400, "Missing required param: pet"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/pet".replaceAll("{format}", "json"); String path = "/pet".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
List<String> contentTypes = ["application/json", "application/xml"]; List<String> contentTypes = ["application/json","application/xml"];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Deletes a pet /// Deletes a pet
/// ///
/// ///
Future deletePet(int petId, {String apiKey}) async { Future deletePet(int petId, { String apiKey }) async {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (petId == null) { if(petId == null) {
throw new ApiException(400, "Missing required param: petId"); throw new ApiException(400, "Missing required param: petId");
} }
// create path and map variables // create path and map variables
String path = "/pet/{petId}" String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "petId" + "}", petId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -70,26 +78,34 @@ class PetApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'DELETE',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Finds Pets by status /// Finds Pets by status
/// ///
/// Multiple status values can be provided with comma separated strings /// Multiple status values can be provided with comma separated strings
@@ -97,46 +113,50 @@ class PetApi {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (status == null) { if(status == null) {
throw new ApiException(400, "Missing required param: status"); throw new ApiException(400, "Missing required param: status");
} }
// create path and map variables // create path and map variables
String path = "/pet/findByStatus".replaceAll("{format}", "json"); String path = "/pet/findByStatus".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
queryParams queryParams.addAll(_convertParametersForCollectionFormat("csv", "status", status));
.addAll(_convertParametersForCollectionFormat("csv", "status", status));
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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) return (apiClient.deserialize(response.body, 'List<Pet>') as List).map((item) => item as Pet).toList();
.map((item) => item as Pet)
.toList();
} else { } else {
return null; return null;
} }
} }
/// Finds Pets by tags /// Finds Pets by tags
/// ///
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
@@ -144,46 +164,50 @@ class PetApi {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (tags == null) { if(tags == null) {
throw new ApiException(400, "Missing required param: tags"); throw new ApiException(400, "Missing required param: tags");
} }
// create path and map variables // create path and map variables
String path = "/pet/findByTags".replaceAll("{format}", "json"); String path = "/pet/findByTags".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
queryParams queryParams.addAll(_convertParametersForCollectionFormat("csv", "tags", tags));
.addAll(_convertParametersForCollectionFormat("csv", "tags", tags));
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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) return (apiClient.deserialize(response.body, 'List<Pet>') as List).map((item) => item as Pet).toList();
.map((item) => item as Pet)
.toList();
} else { } else {
return null; return null;
} }
} }
/// Find pet by ID /// Find pet by ID
/// ///
/// Returns a single pet /// Returns a single pet
@@ -191,14 +215,12 @@ class PetApi {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (petId == null) { if(petId == null) {
throw new ApiException(400, "Missing required param: petId"); throw new ApiException(400, "Missing required param: petId");
} }
// create path and map variables // create path and map variables
String path = "/pet/{petId}" String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "petId" + "}", petId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -207,84 +229,97 @@ class PetApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["api_key"]; List<String> authNames = ["api_key"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'Pet') as Pet; return apiClient.deserialize(response.body, 'Pet') as Pet;
} else { } else {
return null; return null;
} }
} }
/// Update an existing pet /// Update an existing pet
/// ///
/// ///
Future updatePet(Pet pet) async { Future updatePet(Pet body) async {
Object postBody = pet; Object postBody = body;
// verify required params are set // verify required params are set
if (pet == null) { if(body == null) {
throw new ApiException(400, "Missing required param: pet"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/pet".replaceAll("{format}", "json"); String path = "/pet".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
List<String> contentTypes = ["application/json", "application/xml"]; List<String> contentTypes = ["application/json","application/xml"];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'PUT', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'PUT',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Updates a pet in the store with form data /// Updates a pet in the store with form data
/// ///
/// ///
Future updatePetWithForm(int petId, {String name, String status}) async { Future updatePetWithForm(int petId, { String name, String status }) async {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (petId == null) { if(petId == null) {
throw new ApiException(400, "Missing required param: petId"); throw new ApiException(400, "Missing required param: petId");
} }
// create path and map variables // create path and map variables
String path = "/pet/{petId}" String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "petId" + "}", petId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -293,11 +328,10 @@ class PetApi {
List<String> contentTypes = ["application/x-www-form-urlencoded"]; List<String> contentTypes = ["application/x-www-form-urlencoded"];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (name != null) { if (name != null) {
@@ -308,38 +342,45 @@ class PetApi {
hasFields = true; hasFields = true;
mp.fields['status'] = parameterToString(status); mp.fields['status'] = parameterToString(status);
} }
if (hasFields) postBody = mp; if(hasFields)
} else { postBody = mp;
if (name != null) formParams['name'] = parameterToString(name); }
if (status != null) formParams['status'] = parameterToString(status); else {
if (name != null)
formParams['name'] = parameterToString(name);
if (status != null)
formParams['status'] = parameterToString(status);
} }
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// uploads an image /// uploads an image
/// ///
/// ///
Future<ApiResponse> uploadFile(int petId, Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async {
{String additionalMetadata, MultipartFile file}) async {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (petId == null) { if(petId == null) {
throw new ApiException(400, "Missing required param: petId"); throw new ApiException(400, "Missing required param: petId");
} }
// create path and map variables // create path and map variables
String path = "/pet/{petId}/uploadImage" String path = "/pet/{petId}/uploadImage".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "petId" + "}", petId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -348,11 +389,10 @@ class PetApi {
List<String> contentTypes = ["multipart/form-data"]; List<String> contentTypes = ["multipart/form-data"];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (additionalMetadata != null) { if (additionalMetadata != null) {
@@ -364,19 +404,26 @@ class PetApi {
mp.fields['file'] = file.field; mp.fields['file'] = file.field;
mp.files.add(file); mp.files.add(file);
} }
if (hasFields) postBody = mp; if(hasFields)
} else { postBody = mp;
}
else {
if (additionalMetadata != null) if (additionalMetadata != null)
formParams['additionalMetadata'] = formParams['additionalMetadata'] = parameterToString(additionalMetadata);
parameterToString(additionalMetadata);
} }
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'ApiResponse') as ApiResponse; return apiClient.deserialize(response.body, 'ApiResponse') as ApiResponse;
} else { } else {
return null; return null;

View File

@@ -1,5 +1,7 @@
part of openapi.api; part of openapi.api;
class StoreApi { class StoreApi {
final ApiClient apiClient; final ApiClient apiClient;
@@ -12,14 +14,12 @@ class StoreApi {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (orderId == null) { if(orderId == null) {
throw new ApiException(400, "Missing required param: orderId"); throw new ApiException(400, "Missing required param: orderId");
} }
// create path and map variables // create path and map variables
String path = "/store/order/{orderId}" String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "orderId" + "}", orderId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -28,26 +28,34 @@ class StoreApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'DELETE',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Returns pet inventories by status /// Returns pet inventories by status
/// ///
/// Returns a map of status codes to quantities /// Returns a map of status codes to quantities
@@ -57,7 +65,7 @@ class StoreApi {
// verify required params are set // verify required params are set
// create path and map variables // create path and map variables
String path = "/store/inventory".replaceAll("{format}", "json"); String path = "/store/inventory".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -66,30 +74,36 @@ class StoreApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["api_key"]; List<String> authNames = ["api_key"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 new Map<String, int>.from( return new Map<String, int>.from(apiClient.deserialize(response.body, 'Map<String, int>'));
apiClient.deserialize(response.body, 'Map<String, int>')); ;
;
} else { } else {
return null; return null;
} }
} }
/// Find purchase order by ID /// Find purchase order by ID
/// ///
/// For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions /// For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
@@ -97,14 +111,12 @@ class StoreApi {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (orderId == null) { if(orderId == null) {
throw new ApiException(400, "Missing required param: orderId"); throw new ApiException(400, "Missing required param: orderId");
} }
// create path and map variables // create path and map variables
String path = "/store/order/{orderId}" String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "orderId" + "}", orderId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -113,41 +125,48 @@ class StoreApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'Order') as Order; return apiClient.deserialize(response.body, 'Order') as Order;
} else { } else {
return null; return null;
} }
} }
/// Place an order for a pet /// Place an order for a pet
/// ///
/// ///
Future<Order> placeOrder(Order order) async { Future<Order> placeOrder(Order body) async {
Object postBody = order; Object postBody = body;
// verify required params are set // verify required params are set
if (order == null) { if(body == null) {
throw new ApiException(400, "Missing required param: order"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/store/order".replaceAll("{format}", "json"); String path = "/store/order".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -156,22 +175,30 @@ class StoreApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'Order') as Order; return apiClient.deserialize(response.body, 'Order') as Order;
} else { } else {
return null; return null;

View File

@@ -1,5 +1,7 @@
part of openapi.api; part of openapi.api;
class UserApi { class UserApi {
final ApiClient apiClient; final ApiClient apiClient;
@@ -8,16 +10,16 @@ class UserApi {
/// Create user /// Create user
/// ///
/// This can only be done by the logged in user. /// This can only be done by the logged in user.
Future createUser(User user) async { Future createUser(User body) async {
Object postBody = user; Object postBody = body;
// verify required params are set // verify required params are set
if (user == null) { if(body == null) {
throw new ApiException(400, "Missing required param: user"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/user".replaceAll("{format}", "json"); String path = "/user".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -26,39 +28,47 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Creates list of users with given input array /// Creates list of users with given input array
/// ///
/// ///
Future createUsersWithArrayInput(List<User> user) async { Future createUsersWithArrayInput(List<User> body) async {
Object postBody = user; Object postBody = body;
// verify required params are set // verify required params are set
if (user == null) { if(body == null) {
throw new ApiException(400, "Missing required param: user"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/user/createWithArray".replaceAll("{format}", "json"); String path = "/user/createWithArray".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -67,39 +77,47 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Creates list of users with given input array /// Creates list of users with given input array
/// ///
/// ///
Future createUsersWithListInput(List<User> user) async { Future createUsersWithListInput(List<User> body) async {
Object postBody = user; Object postBody = body;
// verify required params are set // verify required params are set
if (user == null) { if(body == null) {
throw new ApiException(400, "Missing required param: user"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/user/createWithList".replaceAll("{format}", "json"); String path = "/user/createWithList".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -108,26 +126,34 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Delete user /// Delete user
/// ///
/// This can only be done by the logged in user. /// This can only be done by the logged in user.
@@ -135,14 +161,12 @@ class UserApi {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (username == null) { if(username == null) {
throw new ApiException(400, "Missing required param: username"); throw new ApiException(400, "Missing required param: username");
} }
// create path and map variables // create path and map variables
String path = "/user/{username}" String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "username" + "}", username.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -151,41 +175,47 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'DELETE',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Get user by user name /// Get user by user name
/// ///
/// ///
Future<User> getUserByName(String username) async { Future<User> getUserByName(String username) async {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (username == null) { if(username == null) {
throw new ApiException(400, "Missing required param: username"); throw new ApiException(400, "Missing required param: username");
} }
// create path and map variables // create path and map variables
String path = "/user/{username}" String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "username" + "}", username.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -194,88 +224,100 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'User') as User; return apiClient.deserialize(response.body, 'User') as User;
} else { } else {
return null; return null;
} }
} }
/// Logs user into the system /// Logs user into the system
/// ///
/// ///
Future<String> loginUser(String username, String password) async { Future<String> loginUser(String username, String password) async {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (username == null) { if(username == null) {
throw new ApiException(400, "Missing required param: username"); throw new ApiException(400, "Missing required param: username");
} }
if (password == null) { if(password == null) {
throw new ApiException(400, "Missing required param: password"); throw new ApiException(400, "Missing required param: password");
} }
// create path and map variables // create path and map variables
String path = "/user/login".replaceAll("{format}", "json"); String path = "/user/login".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
queryParams.addAll( queryParams.addAll(_convertParametersForCollectionFormat("", "username", username));
_convertParametersForCollectionFormat("", "username", username)); queryParams.addAll(_convertParametersForCollectionFormat("", "password", password));
queryParams.addAll(
_convertParametersForCollectionFormat("", "password", password));
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'String') as String; return apiClient.deserialize(response.body, 'String') as String;
} else { } else {
return null; return null;
} }
} }
/// Logs out current logged in user session /// Logs out current logged in user session
/// ///
/// ///
Future logoutUser() async { Future logoutUser() async {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
// create path and map variables // create path and map variables
String path = "/user/logout".replaceAll("{format}", "json"); String path = "/user/logout".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -284,44 +326,50 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Updated user /// Updated user
/// ///
/// This can only be done by the logged in user. /// This can only be done by the logged in user.
Future updateUser(String username, User user) async { Future updateUser(String username, User body) async {
Object postBody = user; Object postBody = body;
// verify required params are set // verify required params are set
if (username == null) { if(username == null) {
throw new ApiException(400, "Missing required param: username"); throw new ApiException(400, "Missing required param: username");
} }
if (user == null) { if(body == null) {
throw new ApiException(400, "Missing required param: user"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/user/{username}" String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "username" + "}", username.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -330,22 +378,31 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'PUT', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'PUT',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }

View File

@@ -8,6 +8,7 @@ class QueryParam {
} }
class ApiClient { class ApiClient {
String basePath; String basePath;
var client = new Client(); var client = new Client();
@@ -24,7 +25,7 @@ class ApiClient {
} }
void addDefaultHeader(String key, String value) { void addDefaultHeader(String key, String value) {
_defaultHeaderMap[key] = value; _defaultHeaderMap[key] = value;
} }
dynamic _deserialize(dynamic value, String targetType) { dynamic _deserialize(dynamic value, String targetType) {
@@ -66,11 +67,9 @@ class ApiClient {
} }
} }
} catch (e, stack) { } catch (e, stack) {
throw new ApiException.withInner( throw new ApiException.withInner(500, 'Exception during deserialization.', e, stack);
500, 'Exception during deserialization.', e, stack);
} }
throw new ApiException( throw new ApiException(500, 'Could not find a suitable class for deserialization');
500, 'Could not find a suitable class for deserialization');
} }
dynamic deserialize(String json, String targetType) { dynamic deserialize(String json, String targetType) {
@@ -95,28 +94,28 @@ class ApiClient {
// We don't use a Map<String, String> for queryParams. // We don't use a Map<String, String> for queryParams.
// If collectionFormat is 'multi' a key might appear multiple times. // If collectionFormat is 'multi' a key might appear multiple times.
Future<Response> invokeAPI( Future<Response> invokeAPI(String path,
String path, String method,
String method, Iterable<QueryParam> queryParams,
Iterable<QueryParam> queryParams, Object body,
Object body, Map<String, String> headerParams,
Map<String, String> headerParams, Map<String, String> formParams,
Map<String, String> formParams, String contentType,
String contentType, List<String> authNames) async {
List<String> authNames) async {
_updateParamsForAuth(authNames, queryParams, headerParams); _updateParamsForAuth(authNames, queryParams, headerParams);
var ps = queryParams var ps = queryParams.where((p) => p.value != null).map((p) => '${p.name}=${p.value}');
.where((p) => p.value != null) String queryString = ps.isNotEmpty ?
.map((p) => '${p.name}=${p.value}'); '?' + ps.join('&') :
String queryString = ps.isNotEmpty ? '?' + ps.join('&') : ''; '';
String url = basePath + path + queryString; String url = basePath + path + queryString;
headerParams.addAll(_defaultHeaderMap); headerParams.addAll(_defaultHeaderMap);
headerParams['Content-Type'] = contentType; headerParams['Content-Type'] = contentType;
if (body is MultipartRequest) { if(body is MultipartRequest) {
var request = new MultipartRequest(method, Uri.parse(url)); var request = new MultipartRequest(method, Uri.parse(url));
request.fields.addAll(body.fields); request.fields.addAll(body.fields);
request.files.addAll(body.files); request.files.addAll(body.files);
@@ -125,10 +124,8 @@ class ApiClient {
var response = await client.send(request); var response = await client.send(request);
return Response.fromStream(response); return Response.fromStream(response);
} else { } else {
var msgBody = contentType == "application/x-www-form-urlencoded" var msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body);
? formParams switch(method) {
: serialize(body);
switch (method) {
case "POST": case "POST":
return client.post(url, headers: headerParams, body: msgBody); return client.post(url, headers: headerParams, body: msgBody);
case "PUT": case "PUT":
@@ -145,12 +142,10 @@ class ApiClient {
/// Update query and header parameters based on authentication settings. /// Update query and header parameters based on authentication settings.
/// @param authNames The authentications to apply /// @param authNames The authentications to apply
void _updateParamsForAuth(List<String> authNames, void _updateParamsForAuth(List<String> authNames, List<QueryParam> queryParams, Map<String, String> headerParams) {
List<QueryParam> queryParams, Map<String, String> headerParams) {
authNames.forEach((authName) { authNames.forEach((authName) {
Authentication auth = _authentications[authName]; Authentication auth = _authentications[authName];
if (auth == null) if (auth == null) throw new ArgumentError("Authentication undefined: " + authName);
throw new ArgumentError("Authentication undefined: " + authName);
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams);
}); });
} }

View File

@@ -8,8 +8,7 @@ class ApiException implements Exception {
ApiException(this.code, this.message); ApiException(this.code, this.message);
ApiException.withInner( ApiException.withInner(this.code, this.message, this.innerException, this.stackTrace);
this.code, this.message, this.innerException, this.stackTrace);
String toString() { String toString() {
if (message == null) return "ApiException"; if (message == null) return "ApiException";

View File

@@ -4,7 +4,7 @@ const _delimiters = const {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'};
// port from Java version // port from Java version
Iterable<QueryParam> _convertParametersForCollectionFormat( Iterable<QueryParam> _convertParametersForCollectionFormat(
String collectionFormat, String name, dynamic value) { String collectionFormat, String name, dynamic value) {
var params = <QueryParam>[]; var params = <QueryParam>[];
// preconditions // preconditions
@@ -19,8 +19,8 @@ Iterable<QueryParam> _convertParametersForCollectionFormat(
// get the collection format // get the collection format
collectionFormat = (collectionFormat == null || collectionFormat.isEmpty) collectionFormat = (collectionFormat == null || collectionFormat.isEmpty)
? "csv" ? "csv"
: collectionFormat; // default: csv : collectionFormat; // default: csv
if (collectionFormat == "multi") { if (collectionFormat == "multi") {
return values.map((v) => new QueryParam(name, parameterToString(v))); return values.map((v) => new QueryParam(name, parameterToString(v)));
@@ -28,8 +28,7 @@ Iterable<QueryParam> _convertParametersForCollectionFormat(
String delimiter = _delimiters[collectionFormat] ?? ","; String delimiter = _delimiters[collectionFormat] ?? ",";
params.add(new QueryParam( params.add(new QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter)));
name, values.map((v) => parameterToString(v)).join(delimiter)));
return params; return params;
} }

View File

@@ -1,6 +1,7 @@
part of openapi.api; part of openapi.api;
class ApiKeyAuth implements Authentication { class ApiKeyAuth implements Authentication {
final String location; final String location;
final String paramName; final String paramName;
String apiKey; String apiKey;
@@ -9,8 +10,7 @@ class ApiKeyAuth implements Authentication {
ApiKeyAuth(this.location, this.paramName); ApiKeyAuth(this.location, this.paramName);
@override @override
void applyToParams( void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
List<QueryParam> queryParams, Map<String, String> headerParams) {
String value; String value;
if (apiKeyPrefix != null) { if (apiKeyPrefix != null) {
value = '$apiKeyPrefix $apiKey'; value = '$apiKeyPrefix $apiKey';

View File

@@ -1,7 +1,7 @@
part of openapi.api; part of openapi.api;
abstract class Authentication { abstract class Authentication {
/// Apply authentication settings to header and query params.
void applyToParams( /// Apply authentication settings to header and query params.
List<QueryParam> queryParams, Map<String, String> headerParams); void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams);
} }

View File

@@ -1,15 +1,14 @@
part of openapi.api; part of openapi.api;
class HttpBasicAuth implements Authentication { class HttpBasicAuth implements Authentication {
String username; String username;
String password; String password;
@override @override
void applyToParams( void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
List<QueryParam> queryParams, Map<String, String> headerParams) { String str = (username == null ? "" : username) + ":" + (password == null ? "" : password);
String str = (username == null ? "" : username) +
":" +
(password == null ? "" : password);
headerParams["Authorization"] = "Basic " + BASE64.encode(UTF8.encode(str)); headerParams["Authorization"] = "Basic " + BASE64.encode(UTF8.encode(str));
} }
}
}

View File

@@ -3,11 +3,11 @@ part of openapi.api;
class OAuth implements Authentication { class OAuth implements Authentication {
String accessToken; String accessToken;
OAuth({this.accessToken}) {} OAuth({this.accessToken}) {
}
@override @override
void applyToParams( void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
List<QueryParam> queryParams, Map<String, String> headerParams) {
if (accessToken != null) { if (accessToken != null) {
headerParams["Authorization"] = "Bearer " + accessToken; headerParams["Authorization"] = "Bearer " + accessToken;
} }

View File

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

View File

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

View File

@@ -1,17 +1,18 @@
part of openapi.api; part of openapi.api;
class Order { 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 = false; bool complete = false;
Order(); Order();
@@ -22,13 +23,36 @@ class Order {
Order.fromJson(Map<String, dynamic> json) { Order.fromJson(Map<String, dynamic> json) {
if (json == null) return; if (json == null) return;
id = json['id']; if (json['id'] == null) {
petId = json['petId']; id = null;
quantity = json['quantity']; } else {
shipDate = id = json['id'];
json['shipDate'] == null ? null : DateTime.parse(json['shipDate']); }
status = json['status']; if (json['petId'] == null) {
complete = json['complete']; 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'];
}
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@@ -43,18 +67,15 @@ class Order {
} }
static List<Order> listFromJson(List<dynamic> json) { static List<Order> listFromJson(List<dynamic> json) {
return json == null return json == null ? new List<Order>() : json.map((value) => new Order.fromJson(value)).toList();
? new List<Order>()
: json.map((value) => new Order.fromJson(value)).toList();
} }
static Map<String, Order> mapFromJson( static Map<String, Order> mapFromJson(Map<String, Map<String, dynamic>> json) {
Map<String, Map<String, dynamic>> json) {
var map = new Map<String, Order>(); var map = new Map<String, Order>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => json.forEach((String key, Map<String, dynamic> value) => map[key] = new Order.fromJson(value));
map[key] = new Order.fromJson(value));
} }
return map; return map;
} }
} }

View File

@@ -1,14 +1,15 @@
part of openapi.api; part of openapi.api;
class Pet { 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;
@@ -22,13 +23,36 @@ class Pet {
Pet.fromJson(Map<String, dynamic> json) { Pet.fromJson(Map<String, dynamic> json) {
if (json == null) return; if (json == null) return;
id = json['id']; if (json['id'] == null) {
category = new Category.fromJson(json['category']); id = null;
name = json['name']; } else {
photoUrls = id = json['id'];
(json['photoUrls'] as List).map((item) => item as String).toList(); }
tags = Tag.listFromJson(json['tags']); if (json['category'] == null) {
status = json['status']; 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'];
}
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@@ -43,17 +67,15 @@ class Pet {
} }
static List<Pet> listFromJson(List<dynamic> json) { static List<Pet> listFromJson(List<dynamic> json) {
return json == null return json == null ? new List<Pet>() : json.map((value) => new Pet.fromJson(value)).toList();
? new List<Pet>()
: json.map((value) => new Pet.fromJson(value)).toList();
} }
static Map<String, Pet> mapFromJson(Map<String, Map<String, dynamic>> json) { static Map<String, Pet> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, Pet>(); var map = new Map<String, Pet>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => json.forEach((String key, Map<String, dynamic> value) => map[key] = new Pet.fromJson(value));
map[key] = new Pet.fromJson(value));
} }
return map; return map;
} }
} }

View File

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

View File

@@ -1,18 +1,19 @@
part of openapi.api; part of openapi.api;
class User { 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;
@@ -25,14 +26,46 @@ class User {
User.fromJson(Map<String, dynamic> json) { User.fromJson(Map<String, dynamic> json) {
if (json == null) return; if (json == null) return;
id = json['id']; if (json['id'] == null) {
username = json['username']; id = null;
firstName = json['firstName']; } else {
lastName = json['lastName']; id = json['id'];
email = json['email']; }
password = json['password']; if (json['username'] == null) {
phone = json['phone']; username = null;
userStatus = json['userStatus']; } 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'];
}
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@@ -49,17 +82,15 @@ class User {
} }
static List<User> listFromJson(List<dynamic> json) { static List<User> listFromJson(List<dynamic> json) {
return json == null return json == null ? new List<User>() : json.map((value) => new User.fromJson(value)).toList();
? new List<User>()
: json.map((value) => new User.fromJson(value)).toList();
} }
static Map<String, User> mapFromJson(Map<String, Map<String, dynamic>> json) { static Map<String, User> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, User>(); var map = new Map<String, User>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => json.forEach((String key, Map<String, dynamic> value) => map[key] = new User.fromJson(value));
map[key] = new User.fromJson(value));
} }
return map; return map;
} }
} }

View File

@@ -1 +1 @@
3.3.1-SNAPSHOT 4.0.0-SNAPSHOT

View File

@@ -47,10 +47,10 @@ import 'package:openapi/api.dart';
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
var api_instance = new PetApi(); var api_instance = new PetApi();
var pet = new Pet(); // Pet | Pet object that needs to be added to the store var body = new Pet(); // Pet | Pet object that needs to be added to the store
try { try {
api_instance.addPet(pet); api_instance.addPet(body);
} catch (e) { } catch (e) {
print("Exception when calling PetApi->addPet: $e\n"); print("Exception when calling PetApi->addPet: $e\n");
} }

View File

@@ -20,7 +20,7 @@ Method | HTTP request | Description
# **addPet** # **addPet**
> addPet(pet) > addPet(body)
Add a new pet to the store Add a new pet to the store
@@ -31,10 +31,10 @@ import 'package:openapi/api.dart';
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
var api_instance = new PetApi(); var api_instance = new PetApi();
var pet = new Pet(); // Pet | Pet object that needs to be added to the store var body = new Pet(); // Pet | Pet object that needs to be added to the store
try { try {
api_instance.addPet(pet); api_instance.addPet(body);
} catch (e) { } catch (e) {
print("Exception when calling PetApi->addPet: $e\n"); print("Exception when calling PetApi->addPet: $e\n");
} }
@@ -44,7 +44,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
### Return type ### Return type
@@ -243,7 +243,7 @@ Name | Type | Description | Notes
[[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)
# **updatePet** # **updatePet**
> updatePet(pet) > updatePet(body)
Update an existing pet Update an existing pet
@@ -254,10 +254,10 @@ import 'package:openapi/api.dart';
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
var api_instance = new PetApi(); var api_instance = new PetApi();
var pet = new Pet(); // Pet | Pet object that needs to be added to the store var body = new Pet(); // Pet | Pet object that needs to be added to the store
try { try {
api_instance.updatePet(pet); api_instance.updatePet(body);
} catch (e) { } catch (e) {
print("Exception when calling PetApi->updatePet: $e\n"); print("Exception when calling PetApi->updatePet: $e\n");
} }
@@ -267,7 +267,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
### Return type ### Return type

View File

@@ -144,7 +144,7 @@ No authorization required
[[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)
# **placeOrder** # **placeOrder**
> Order placeOrder(order) > Order placeOrder(body)
Place an order for a pet Place an order for a pet
@@ -153,10 +153,10 @@ Place an order for a pet
import 'package:openapi/api.dart'; import 'package:openapi/api.dart';
var api_instance = new StoreApi(); var api_instance = new StoreApi();
var order = new Order(); // Order | order placed for purchasing the pet var body = new Order(); // Order | order placed for purchasing the pet
try { try {
var result = api_instance.placeOrder(order); var result = api_instance.placeOrder(body);
print(result); print(result);
} catch (e) { } catch (e) {
print("Exception when calling StoreApi->placeOrder: $e\n"); print("Exception when calling StoreApi->placeOrder: $e\n");
@@ -167,7 +167,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**order** | [**Order**](Order.md)| order placed for purchasing the pet | **body** | [**Order**](Order.md)| order placed for purchasing the pet |
### Return type ### Return type

View File

@@ -20,7 +20,7 @@ Method | HTTP request | Description
# **createUser** # **createUser**
> createUser(user) > createUser(body)
Create user Create user
@@ -31,10 +31,10 @@ This can only be done by the logged in user.
import 'package:openapi/api.dart'; import 'package:openapi/api.dart';
var api_instance = new UserApi(); var api_instance = new UserApi();
var user = new User(); // User | Created user object var body = new User(); // User | Created user object
try { try {
api_instance.createUser(user); api_instance.createUser(body);
} catch (e) { } catch (e) {
print("Exception when calling UserApi->createUser: $e\n"); print("Exception when calling UserApi->createUser: $e\n");
} }
@@ -44,7 +44,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**user** | [**User**](User.md)| Created user object | **body** | [**User**](User.md)| Created user object |
### Return type ### Return type
@@ -62,7 +62,7 @@ No authorization required
[[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)
# **createUsersWithArrayInput** # **createUsersWithArrayInput**
> createUsersWithArrayInput(user) > createUsersWithArrayInput(body)
Creates list of users with given input array Creates list of users with given input array
@@ -71,10 +71,10 @@ Creates list of users with given input array
import 'package:openapi/api.dart'; import 'package:openapi/api.dart';
var api_instance = new UserApi(); var api_instance = new UserApi();
var user = [new List&lt;User&gt;()]; // List<User> | List of user object var body = [new List&lt;User&gt;()]; // List<User> | List of user object
try { try {
api_instance.createUsersWithArrayInput(user); api_instance.createUsersWithArrayInput(body);
} catch (e) { } catch (e) {
print("Exception when calling UserApi->createUsersWithArrayInput: $e\n"); print("Exception when calling UserApi->createUsersWithArrayInput: $e\n");
} }
@@ -84,7 +84,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**user** | [**List&lt;User&gt;**](List.md)| List of user object | **body** | [**List&lt;User&gt;**](List.md)| List of user object |
### Return type ### Return type
@@ -102,7 +102,7 @@ No authorization required
[[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)
# **createUsersWithListInput** # **createUsersWithListInput**
> createUsersWithListInput(user) > createUsersWithListInput(body)
Creates list of users with given input array Creates list of users with given input array
@@ -111,10 +111,10 @@ Creates list of users with given input array
import 'package:openapi/api.dart'; import 'package:openapi/api.dart';
var api_instance = new UserApi(); var api_instance = new UserApi();
var user = [new List&lt;User&gt;()]; // List<User> | List of user object var body = [new List&lt;User&gt;()]; // List<User> | List of user object
try { try {
api_instance.createUsersWithListInput(user); api_instance.createUsersWithListInput(body);
} catch (e) { } catch (e) {
print("Exception when calling UserApi->createUsersWithListInput: $e\n"); print("Exception when calling UserApi->createUsersWithListInput: $e\n");
} }
@@ -124,7 +124,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**user** | [**List&lt;User&gt;**](List.md)| List of user object | **body** | [**List&lt;User&gt;**](List.md)| List of user object |
### Return type ### Return type
@@ -304,7 +304,7 @@ No authorization required
[[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)
# **updateUser** # **updateUser**
> updateUser(username, user) > updateUser(username, body)
Updated user Updated user
@@ -316,10 +316,10 @@ import 'package:openapi/api.dart';
var api_instance = new UserApi(); var api_instance = new UserApi();
var username = username_example; // String | name that need to be deleted var username = username_example; // String | name that need to be deleted
var user = new User(); // User | Updated user object var body = new User(); // User | Updated user object
try { try {
api_instance.updateUser(username, user); api_instance.updateUser(username, body);
} catch (e) { } catch (e) {
print("Exception when calling UserApi->updateUser: $e\n"); print("Exception when calling UserApi->updateUser: $e\n");
} }
@@ -330,7 +330,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**username** | **String**| name that need to be deleted | [default to null] **username** | **String**| name that need to be deleted | [default to null]
**user** | [**User**](User.md)| Updated user object | **body** | [**User**](User.md)| Updated user object |
### Return type ### Return type

View File

@@ -24,4 +24,5 @@ part 'model/pet.dart';
part 'model/tag.dart'; part 'model/tag.dart';
part 'model/user.dart'; part 'model/user.dart';
ApiClient defaultApiClient = new ApiClient(); ApiClient defaultApiClient = new ApiClient();

View File

@@ -1,5 +1,7 @@
part of openapi.api; part of openapi.api;
class PetApi { class PetApi {
final ApiClient apiClient; final ApiClient apiClient;
@@ -7,60 +9,66 @@ class PetApi {
/// Add a new pet to the store /// Add a new pet to the store
/// ///
/// ///
Future addPet(Pet pet) async { Future addPet(Pet body) async {
Object postBody = pet; Object postBody = body;
// verify required params are set // verify required params are set
if (pet == null) { if(body == null) {
throw new ApiException(400, "Missing required param: pet"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/pet".replaceAll("{format}", "json"); String path = "/pet".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
List<String> contentTypes = ["application/json", "application/xml"]; List<String> contentTypes = ["application/json","application/xml"];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Deletes a pet /// Deletes a pet
/// ///
/// ///
Future deletePet(int petId, {String apiKey}) async { Future deletePet(int petId, { String apiKey }) async {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (petId == null) { if(petId == null) {
throw new ApiException(400, "Missing required param: petId"); throw new ApiException(400, "Missing required param: petId");
} }
// create path and map variables // create path and map variables
String path = "/pet/{petId}" String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "petId" + "}", petId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -70,26 +78,34 @@ class PetApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'DELETE',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Finds Pets by status /// Finds Pets by status
/// ///
/// Multiple status values can be provided with comma separated strings /// Multiple status values can be provided with comma separated strings
@@ -97,46 +113,50 @@ class PetApi {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (status == null) { if(status == null) {
throw new ApiException(400, "Missing required param: status"); throw new ApiException(400, "Missing required param: status");
} }
// create path and map variables // create path and map variables
String path = "/pet/findByStatus".replaceAll("{format}", "json"); String path = "/pet/findByStatus".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
queryParams queryParams.addAll(_convertParametersForCollectionFormat("csv", "status", status));
.addAll(_convertParametersForCollectionFormat("csv", "status", status));
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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) return (apiClient.deserialize(response.body, 'List<Pet>') as List).map((item) => item as Pet).toList();
.map((item) => item as Pet)
.toList();
} else { } else {
return null; return null;
} }
} }
/// Finds Pets by tags /// Finds Pets by tags
/// ///
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
@@ -144,46 +164,50 @@ class PetApi {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (tags == null) { if(tags == null) {
throw new ApiException(400, "Missing required param: tags"); throw new ApiException(400, "Missing required param: tags");
} }
// create path and map variables // create path and map variables
String path = "/pet/findByTags".replaceAll("{format}", "json"); String path = "/pet/findByTags".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
queryParams queryParams.addAll(_convertParametersForCollectionFormat("csv", "tags", tags));
.addAll(_convertParametersForCollectionFormat("csv", "tags", tags));
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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) return (apiClient.deserialize(response.body, 'List<Pet>') as List).map((item) => item as Pet).toList();
.map((item) => item as Pet)
.toList();
} else { } else {
return null; return null;
} }
} }
/// Find pet by ID /// Find pet by ID
/// ///
/// Returns a single pet /// Returns a single pet
@@ -191,14 +215,12 @@ class PetApi {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (petId == null) { if(petId == null) {
throw new ApiException(400, "Missing required param: petId"); throw new ApiException(400, "Missing required param: petId");
} }
// create path and map variables // create path and map variables
String path = "/pet/{petId}" String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "petId" + "}", petId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -207,84 +229,97 @@ class PetApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["api_key"]; List<String> authNames = ["api_key"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'Pet') as Pet; return apiClient.deserialize(response.body, 'Pet') as Pet;
} else { } else {
return null; return null;
} }
} }
/// Update an existing pet /// Update an existing pet
/// ///
/// ///
Future updatePet(Pet pet) async { Future updatePet(Pet body) async {
Object postBody = pet; Object postBody = body;
// verify required params are set // verify required params are set
if (pet == null) { if(body == null) {
throw new ApiException(400, "Missing required param: pet"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/pet".replaceAll("{format}", "json"); String path = "/pet".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
List<String> contentTypes = ["application/json", "application/xml"]; List<String> contentTypes = ["application/json","application/xml"];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'PUT', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'PUT',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Updates a pet in the store with form data /// Updates a pet in the store with form data
/// ///
/// ///
Future updatePetWithForm(int petId, {String name, String status}) async { Future updatePetWithForm(int petId, { String name, String status }) async {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (petId == null) { if(petId == null) {
throw new ApiException(400, "Missing required param: petId"); throw new ApiException(400, "Missing required param: petId");
} }
// create path and map variables // create path and map variables
String path = "/pet/{petId}" String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "petId" + "}", petId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -293,11 +328,10 @@ class PetApi {
List<String> contentTypes = ["application/x-www-form-urlencoded"]; List<String> contentTypes = ["application/x-www-form-urlencoded"];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (name != null) { if (name != null) {
@@ -308,38 +342,45 @@ class PetApi {
hasFields = true; hasFields = true;
mp.fields['status'] = parameterToString(status); mp.fields['status'] = parameterToString(status);
} }
if (hasFields) postBody = mp; if(hasFields)
} else { postBody = mp;
if (name != null) formParams['name'] = parameterToString(name); }
if (status != null) formParams['status'] = parameterToString(status); else {
if (name != null)
formParams['name'] = parameterToString(name);
if (status != null)
formParams['status'] = parameterToString(status);
} }
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// uploads an image /// uploads an image
/// ///
/// ///
Future<ApiResponse> uploadFile(int petId, Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async {
{String additionalMetadata, MultipartFile file}) async {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (petId == null) { if(petId == null) {
throw new ApiException(400, "Missing required param: petId"); throw new ApiException(400, "Missing required param: petId");
} }
// create path and map variables // create path and map variables
String path = "/pet/{petId}/uploadImage" String path = "/pet/{petId}/uploadImage".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "petId" + "}", petId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -348,11 +389,10 @@ class PetApi {
List<String> contentTypes = ["multipart/form-data"]; List<String> contentTypes = ["multipart/form-data"];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (additionalMetadata != null) { if (additionalMetadata != null) {
@@ -364,19 +404,26 @@ class PetApi {
mp.fields['file'] = file.field; mp.fields['file'] = file.field;
mp.files.add(file); mp.files.add(file);
} }
if (hasFields) postBody = mp; if(hasFields)
} else { postBody = mp;
}
else {
if (additionalMetadata != null) if (additionalMetadata != null)
formParams['additionalMetadata'] = formParams['additionalMetadata'] = parameterToString(additionalMetadata);
parameterToString(additionalMetadata);
} }
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'ApiResponse') as ApiResponse; return apiClient.deserialize(response.body, 'ApiResponse') as ApiResponse;
} else { } else {
return null; return null;

View File

@@ -1,5 +1,7 @@
part of openapi.api; part of openapi.api;
class StoreApi { class StoreApi {
final ApiClient apiClient; final ApiClient apiClient;
@@ -12,14 +14,12 @@ class StoreApi {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (orderId == null) { if(orderId == null) {
throw new ApiException(400, "Missing required param: orderId"); throw new ApiException(400, "Missing required param: orderId");
} }
// create path and map variables // create path and map variables
String path = "/store/order/{orderId}" String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "orderId" + "}", orderId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -28,26 +28,34 @@ class StoreApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'DELETE',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Returns pet inventories by status /// Returns pet inventories by status
/// ///
/// Returns a map of status codes to quantities /// Returns a map of status codes to quantities
@@ -57,7 +65,7 @@ class StoreApi {
// verify required params are set // verify required params are set
// create path and map variables // create path and map variables
String path = "/store/inventory".replaceAll("{format}", "json"); String path = "/store/inventory".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -66,30 +74,36 @@ class StoreApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["api_key"]; List<String> authNames = ["api_key"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 new Map<String, int>.from( return new Map<String, int>.from(apiClient.deserialize(response.body, 'Map<String, int>'));
apiClient.deserialize(response.body, 'Map<String, int>')); ;
;
} else { } else {
return null; return null;
} }
} }
/// Find purchase order by ID /// Find purchase order by ID
/// ///
/// For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions /// For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
@@ -97,14 +111,12 @@ class StoreApi {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (orderId == null) { if(orderId == null) {
throw new ApiException(400, "Missing required param: orderId"); throw new ApiException(400, "Missing required param: orderId");
} }
// create path and map variables // create path and map variables
String path = "/store/order/{orderId}" String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "orderId" + "}", orderId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -113,41 +125,48 @@ class StoreApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'Order') as Order; return apiClient.deserialize(response.body, 'Order') as Order;
} else { } else {
return null; return null;
} }
} }
/// Place an order for a pet /// Place an order for a pet
/// ///
/// ///
Future<Order> placeOrder(Order order) async { Future<Order> placeOrder(Order body) async {
Object postBody = order; Object postBody = body;
// verify required params are set // verify required params are set
if (order == null) { if(body == null) {
throw new ApiException(400, "Missing required param: order"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/store/order".replaceAll("{format}", "json"); String path = "/store/order".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -156,22 +175,30 @@ class StoreApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'Order') as Order; return apiClient.deserialize(response.body, 'Order') as Order;
} else { } else {
return null; return null;

View File

@@ -1,5 +1,7 @@
part of openapi.api; part of openapi.api;
class UserApi { class UserApi {
final ApiClient apiClient; final ApiClient apiClient;
@@ -8,16 +10,16 @@ class UserApi {
/// Create user /// Create user
/// ///
/// This can only be done by the logged in user. /// This can only be done by the logged in user.
Future createUser(User user) async { Future createUser(User body) async {
Object postBody = user; Object postBody = body;
// verify required params are set // verify required params are set
if (user == null) { if(body == null) {
throw new ApiException(400, "Missing required param: user"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/user".replaceAll("{format}", "json"); String path = "/user".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -26,39 +28,47 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Creates list of users with given input array /// Creates list of users with given input array
/// ///
/// ///
Future createUsersWithArrayInput(List<User> user) async { Future createUsersWithArrayInput(List<User> body) async {
Object postBody = user; Object postBody = body;
// verify required params are set // verify required params are set
if (user == null) { if(body == null) {
throw new ApiException(400, "Missing required param: user"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/user/createWithArray".replaceAll("{format}", "json"); String path = "/user/createWithArray".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -67,39 +77,47 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Creates list of users with given input array /// Creates list of users with given input array
/// ///
/// ///
Future createUsersWithListInput(List<User> user) async { Future createUsersWithListInput(List<User> body) async {
Object postBody = user; Object postBody = body;
// verify required params are set // verify required params are set
if (user == null) { if(body == null) {
throw new ApiException(400, "Missing required param: user"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/user/createWithList".replaceAll("{format}", "json"); String path = "/user/createWithList".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -108,26 +126,34 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Delete user /// Delete user
/// ///
/// This can only be done by the logged in user. /// This can only be done by the logged in user.
@@ -135,14 +161,12 @@ class UserApi {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (username == null) { if(username == null) {
throw new ApiException(400, "Missing required param: username"); throw new ApiException(400, "Missing required param: username");
} }
// create path and map variables // create path and map variables
String path = "/user/{username}" String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "username" + "}", username.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -151,41 +175,47 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'DELETE',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Get user by user name /// Get user by user name
/// ///
/// ///
Future<User> getUserByName(String username) async { Future<User> getUserByName(String username) async {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (username == null) { if(username == null) {
throw new ApiException(400, "Missing required param: username"); throw new ApiException(400, "Missing required param: username");
} }
// create path and map variables // create path and map variables
String path = "/user/{username}" String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "username" + "}", username.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -194,88 +224,100 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'User') as User; return apiClient.deserialize(response.body, 'User') as User;
} else { } else {
return null; return null;
} }
} }
/// Logs user into the system /// Logs user into the system
/// ///
/// ///
Future<String> loginUser(String username, String password) async { Future<String> loginUser(String username, String password) async {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (username == null) { if(username == null) {
throw new ApiException(400, "Missing required param: username"); throw new ApiException(400, "Missing required param: username");
} }
if (password == null) { if(password == null) {
throw new ApiException(400, "Missing required param: password"); throw new ApiException(400, "Missing required param: password");
} }
// create path and map variables // create path and map variables
String path = "/user/login".replaceAll("{format}", "json"); String path = "/user/login".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
queryParams.addAll( queryParams.addAll(_convertParametersForCollectionFormat("", "username", username));
_convertParametersForCollectionFormat("", "username", username)); queryParams.addAll(_convertParametersForCollectionFormat("", "password", password));
queryParams.addAll(
_convertParametersForCollectionFormat("", "password", password));
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'String') as String; return apiClient.deserialize(response.body, 'String') as String;
} else { } else {
return null; return null;
} }
} }
/// Logs out current logged in user session /// Logs out current logged in user session
/// ///
/// ///
Future logoutUser() async { Future logoutUser() async {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
// create path and map variables // create path and map variables
String path = "/user/logout".replaceAll("{format}", "json"); String path = "/user/logout".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -284,44 +326,50 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Updated user /// Updated user
/// ///
/// This can only be done by the logged in user. /// This can only be done by the logged in user.
Future updateUser(String username, User user) async { Future updateUser(String username, User body) async {
Object postBody = user; Object postBody = body;
// verify required params are set // verify required params are set
if (username == null) { if(username == null) {
throw new ApiException(400, "Missing required param: username"); throw new ApiException(400, "Missing required param: username");
} }
if (user == null) { if(body == null) {
throw new ApiException(400, "Missing required param: user"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/user/{username}" String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "username" + "}", username.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -330,22 +378,31 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'PUT', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'PUT',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }

View File

@@ -8,6 +8,7 @@ class QueryParam {
} }
class ApiClient { class ApiClient {
String basePath; String basePath;
var client = new BrowserClient(); var client = new BrowserClient();
@@ -24,7 +25,7 @@ class ApiClient {
} }
void addDefaultHeader(String key, String value) { void addDefaultHeader(String key, String value) {
_defaultHeaderMap[key] = value; _defaultHeaderMap[key] = value;
} }
dynamic _deserialize(dynamic value, String targetType) { dynamic _deserialize(dynamic value, String targetType) {
@@ -66,11 +67,9 @@ class ApiClient {
} }
} }
} catch (e, stack) { } catch (e, stack) {
throw new ApiException.withInner( throw new ApiException.withInner(500, 'Exception during deserialization.', e, stack);
500, 'Exception during deserialization.', e, stack);
} }
throw new ApiException( throw new ApiException(500, 'Could not find a suitable class for deserialization');
500, 'Could not find a suitable class for deserialization');
} }
dynamic deserialize(String json, String targetType) { dynamic deserialize(String json, String targetType) {
@@ -95,28 +94,28 @@ class ApiClient {
// We don't use a Map<String, String> for queryParams. // We don't use a Map<String, String> for queryParams.
// If collectionFormat is 'multi' a key might appear multiple times. // If collectionFormat is 'multi' a key might appear multiple times.
Future<Response> invokeAPI( Future<Response> invokeAPI(String path,
String path, String method,
String method, Iterable<QueryParam> queryParams,
Iterable<QueryParam> queryParams, Object body,
Object body, Map<String, String> headerParams,
Map<String, String> headerParams, Map<String, String> formParams,
Map<String, String> formParams, String contentType,
String contentType, List<String> authNames) async {
List<String> authNames) async {
_updateParamsForAuth(authNames, queryParams, headerParams); _updateParamsForAuth(authNames, queryParams, headerParams);
var ps = queryParams var ps = queryParams.where((p) => p.value != null).map((p) => '${p.name}=${p.value}');
.where((p) => p.value != null) String queryString = ps.isNotEmpty ?
.map((p) => '${p.name}=${p.value}'); '?' + ps.join('&') :
String queryString = ps.isNotEmpty ? '?' + ps.join('&') : ''; '';
String url = basePath + path + queryString; String url = basePath + path + queryString;
headerParams.addAll(_defaultHeaderMap); headerParams.addAll(_defaultHeaderMap);
headerParams['Content-Type'] = contentType; headerParams['Content-Type'] = contentType;
if (body is MultipartRequest) { if(body is MultipartRequest) {
var request = new MultipartRequest(method, Uri.parse(url)); var request = new MultipartRequest(method, Uri.parse(url));
request.fields.addAll(body.fields); request.fields.addAll(body.fields);
request.files.addAll(body.files); request.files.addAll(body.files);
@@ -125,10 +124,8 @@ class ApiClient {
var response = await client.send(request); var response = await client.send(request);
return Response.fromStream(response); return Response.fromStream(response);
} else { } else {
var msgBody = contentType == "application/x-www-form-urlencoded" var msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body);
? formParams switch(method) {
: serialize(body);
switch (method) {
case "POST": case "POST":
return client.post(url, headers: headerParams, body: msgBody); return client.post(url, headers: headerParams, body: msgBody);
case "PUT": case "PUT":
@@ -145,12 +142,10 @@ class ApiClient {
/// Update query and header parameters based on authentication settings. /// Update query and header parameters based on authentication settings.
/// @param authNames The authentications to apply /// @param authNames The authentications to apply
void _updateParamsForAuth(List<String> authNames, void _updateParamsForAuth(List<String> authNames, List<QueryParam> queryParams, Map<String, String> headerParams) {
List<QueryParam> queryParams, Map<String, String> headerParams) {
authNames.forEach((authName) { authNames.forEach((authName) {
Authentication auth = _authentications[authName]; Authentication auth = _authentications[authName];
if (auth == null) if (auth == null) throw new ArgumentError("Authentication undefined: " + authName);
throw new ArgumentError("Authentication undefined: " + authName);
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams);
}); });
} }

View File

@@ -8,8 +8,7 @@ class ApiException implements Exception {
ApiException(this.code, this.message); ApiException(this.code, this.message);
ApiException.withInner( ApiException.withInner(this.code, this.message, this.innerException, this.stackTrace);
this.code, this.message, this.innerException, this.stackTrace);
String toString() { String toString() {
if (message == null) return "ApiException"; if (message == null) return "ApiException";

View File

@@ -4,7 +4,7 @@ const _delimiters = const {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'};
// port from Java version // port from Java version
Iterable<QueryParam> _convertParametersForCollectionFormat( Iterable<QueryParam> _convertParametersForCollectionFormat(
String collectionFormat, String name, dynamic value) { String collectionFormat, String name, dynamic value) {
var params = <QueryParam>[]; var params = <QueryParam>[];
// preconditions // preconditions
@@ -19,8 +19,8 @@ Iterable<QueryParam> _convertParametersForCollectionFormat(
// get the collection format // get the collection format
collectionFormat = (collectionFormat == null || collectionFormat.isEmpty) collectionFormat = (collectionFormat == null || collectionFormat.isEmpty)
? "csv" ? "csv"
: collectionFormat; // default: csv : collectionFormat; // default: csv
if (collectionFormat == "multi") { if (collectionFormat == "multi") {
return values.map((v) => new QueryParam(name, parameterToString(v))); return values.map((v) => new QueryParam(name, parameterToString(v)));
@@ -28,8 +28,7 @@ Iterable<QueryParam> _convertParametersForCollectionFormat(
String delimiter = _delimiters[collectionFormat] ?? ","; String delimiter = _delimiters[collectionFormat] ?? ",";
params.add(new QueryParam( params.add(new QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter)));
name, values.map((v) => parameterToString(v)).join(delimiter)));
return params; return params;
} }

View File

@@ -1,6 +1,7 @@
part of openapi.api; part of openapi.api;
class ApiKeyAuth implements Authentication { class ApiKeyAuth implements Authentication {
final String location; final String location;
final String paramName; final String paramName;
String apiKey; String apiKey;
@@ -9,8 +10,7 @@ class ApiKeyAuth implements Authentication {
ApiKeyAuth(this.location, this.paramName); ApiKeyAuth(this.location, this.paramName);
@override @override
void applyToParams( void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
List<QueryParam> queryParams, Map<String, String> headerParams) {
String value; String value;
if (apiKeyPrefix != null) { if (apiKeyPrefix != null) {
value = '$apiKeyPrefix $apiKey'; value = '$apiKeyPrefix $apiKey';

View File

@@ -1,7 +1,7 @@
part of openapi.api; part of openapi.api;
abstract class Authentication { abstract class Authentication {
/// Apply authentication settings to header and query params.
void applyToParams( /// Apply authentication settings to header and query params.
List<QueryParam> queryParams, Map<String, String> headerParams); void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams);
} }

View File

@@ -1,15 +1,14 @@
part of openapi.api; part of openapi.api;
class HttpBasicAuth implements Authentication { class HttpBasicAuth implements Authentication {
String username; String username;
String password; String password;
@override @override
void applyToParams( void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
List<QueryParam> queryParams, Map<String, String> headerParams) { String str = (username == null ? "" : username) + ":" + (password == null ? "" : password);
String str = (username == null ? "" : username) +
":" +
(password == null ? "" : password);
headerParams["Authorization"] = "Basic " + BASE64.encode(UTF8.encode(str)); headerParams["Authorization"] = "Basic " + BASE64.encode(UTF8.encode(str));
} }
}
}

View File

@@ -3,11 +3,11 @@ part of openapi.api;
class OAuth implements Authentication { class OAuth implements Authentication {
String accessToken; String accessToken;
OAuth({this.accessToken}) {} OAuth({this.accessToken}) {
}
@override @override
void applyToParams( void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
List<QueryParam> queryParams, Map<String, String> headerParams) {
if (accessToken != null) { if (accessToken != null) {
headerParams["Authorization"] = "Bearer " + accessToken; headerParams["Authorization"] = "Bearer " + accessToken;
} }

View File

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

View File

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

View File

@@ -1,17 +1,18 @@
part of openapi.api; part of openapi.api;
class Order { 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 = false; bool complete = false;
Order(); Order();
@@ -22,13 +23,36 @@ class Order {
Order.fromJson(Map<String, dynamic> json) { Order.fromJson(Map<String, dynamic> json) {
if (json == null) return; if (json == null) return;
id = json['id']; if (json['id'] == null) {
petId = json['petId']; id = null;
quantity = json['quantity']; } else {
shipDate = id = json['id'];
json['shipDate'] == null ? null : DateTime.parse(json['shipDate']); }
status = json['status']; if (json['petId'] == null) {
complete = json['complete']; 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'];
}
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@@ -43,18 +67,15 @@ class Order {
} }
static List<Order> listFromJson(List<dynamic> json) { static List<Order> listFromJson(List<dynamic> json) {
return json == null return json == null ? new List<Order>() : json.map((value) => new Order.fromJson(value)).toList();
? new List<Order>()
: json.map((value) => new Order.fromJson(value)).toList();
} }
static Map<String, Order> mapFromJson( static Map<String, Order> mapFromJson(Map<String, Map<String, dynamic>> json) {
Map<String, Map<String, dynamic>> json) {
var map = new Map<String, Order>(); var map = new Map<String, Order>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => json.forEach((String key, Map<String, dynamic> value) => map[key] = new Order.fromJson(value));
map[key] = new Order.fromJson(value));
} }
return map; return map;
} }
} }

View File

@@ -1,14 +1,15 @@
part of openapi.api; part of openapi.api;
class Pet { 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;
@@ -22,13 +23,36 @@ class Pet {
Pet.fromJson(Map<String, dynamic> json) { Pet.fromJson(Map<String, dynamic> json) {
if (json == null) return; if (json == null) return;
id = json['id']; if (json['id'] == null) {
category = new Category.fromJson(json['category']); id = null;
name = json['name']; } else {
photoUrls = id = json['id'];
(json['photoUrls'] as List).map((item) => item as String).toList(); }
tags = Tag.listFromJson(json['tags']); if (json['category'] == null) {
status = json['status']; 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'];
}
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@@ -43,17 +67,15 @@ class Pet {
} }
static List<Pet> listFromJson(List<dynamic> json) { static List<Pet> listFromJson(List<dynamic> json) {
return json == null return json == null ? new List<Pet>() : json.map((value) => new Pet.fromJson(value)).toList();
? new List<Pet>()
: json.map((value) => new Pet.fromJson(value)).toList();
} }
static Map<String, Pet> mapFromJson(Map<String, Map<String, dynamic>> json) { static Map<String, Pet> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, Pet>(); var map = new Map<String, Pet>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => json.forEach((String key, Map<String, dynamic> value) => map[key] = new Pet.fromJson(value));
map[key] = new Pet.fromJson(value));
} }
return map; return map;
} }
} }

View File

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

View File

@@ -1,18 +1,19 @@
part of openapi.api; part of openapi.api;
class User { 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;
@@ -25,14 +26,46 @@ class User {
User.fromJson(Map<String, dynamic> json) { User.fromJson(Map<String, dynamic> json) {
if (json == null) return; if (json == null) return;
id = json['id']; if (json['id'] == null) {
username = json['username']; id = null;
firstName = json['firstName']; } else {
lastName = json['lastName']; id = json['id'];
email = json['email']; }
password = json['password']; if (json['username'] == null) {
phone = json['phone']; username = null;
userStatus = json['userStatus']; } 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'];
}
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@@ -49,17 +82,15 @@ class User {
} }
static List<User> listFromJson(List<dynamic> json) { static List<User> listFromJson(List<dynamic> json) {
return json == null return json == null ? new List<User>() : json.map((value) => new User.fromJson(value)).toList();
? new List<User>()
: json.map((value) => new User.fromJson(value)).toList();
} }
static Map<String, User> mapFromJson(Map<String, Map<String, dynamic>> json) { static Map<String, User> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, User>(); var map = new Map<String, User>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => json.forEach((String key, Map<String, dynamic> value) => map[key] = new User.fromJson(value));
map[key] = new User.fromJson(value));
} }
return map; return map;
} }
} }

View File

@@ -1 +1 @@
3.3.1-SNAPSHOT 4.0.0-SNAPSHOT

View File

@@ -47,10 +47,10 @@ import 'package:openapi/api.dart';
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
var api_instance = new PetApi(); var api_instance = new PetApi();
var pet = new Pet(); // Pet | Pet object that needs to be added to the store var body = new Pet(); // Pet | Pet object that needs to be added to the store
try { try {
api_instance.addPet(pet); api_instance.addPet(body);
} catch (e) { } catch (e) {
print("Exception when calling PetApi->addPet: $e\n"); print("Exception when calling PetApi->addPet: $e\n");
} }

View File

@@ -20,7 +20,7 @@ Method | HTTP request | Description
# **addPet** # **addPet**
> addPet(pet) > addPet(body)
Add a new pet to the store Add a new pet to the store
@@ -31,10 +31,10 @@ import 'package:openapi/api.dart';
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
var api_instance = new PetApi(); var api_instance = new PetApi();
var pet = new Pet(); // Pet | Pet object that needs to be added to the store var body = new Pet(); // Pet | Pet object that needs to be added to the store
try { try {
api_instance.addPet(pet); api_instance.addPet(body);
} catch (e) { } catch (e) {
print("Exception when calling PetApi->addPet: $e\n"); print("Exception when calling PetApi->addPet: $e\n");
} }
@@ -44,7 +44,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
### Return type ### Return type
@@ -243,7 +243,7 @@ Name | Type | Description | Notes
[[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)
# **updatePet** # **updatePet**
> updatePet(pet) > updatePet(body)
Update an existing pet Update an existing pet
@@ -254,10 +254,10 @@ import 'package:openapi/api.dart';
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
var api_instance = new PetApi(); var api_instance = new PetApi();
var pet = new Pet(); // Pet | Pet object that needs to be added to the store var body = new Pet(); // Pet | Pet object that needs to be added to the store
try { try {
api_instance.updatePet(pet); api_instance.updatePet(body);
} catch (e) { } catch (e) {
print("Exception when calling PetApi->updatePet: $e\n"); print("Exception when calling PetApi->updatePet: $e\n");
} }
@@ -267,7 +267,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
### Return type ### Return type

View File

@@ -144,7 +144,7 @@ No authorization required
[[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)
# **placeOrder** # **placeOrder**
> Order placeOrder(order) > Order placeOrder(body)
Place an order for a pet Place an order for a pet
@@ -153,10 +153,10 @@ Place an order for a pet
import 'package:openapi/api.dart'; import 'package:openapi/api.dart';
var api_instance = new StoreApi(); var api_instance = new StoreApi();
var order = new Order(); // Order | order placed for purchasing the pet var body = new Order(); // Order | order placed for purchasing the pet
try { try {
var result = api_instance.placeOrder(order); var result = api_instance.placeOrder(body);
print(result); print(result);
} catch (e) { } catch (e) {
print("Exception when calling StoreApi->placeOrder: $e\n"); print("Exception when calling StoreApi->placeOrder: $e\n");
@@ -167,7 +167,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**order** | [**Order**](Order.md)| order placed for purchasing the pet | **body** | [**Order**](Order.md)| order placed for purchasing the pet |
### Return type ### Return type

View File

@@ -20,7 +20,7 @@ Method | HTTP request | Description
# **createUser** # **createUser**
> createUser(user) > createUser(body)
Create user Create user
@@ -31,10 +31,10 @@ This can only be done by the logged in user.
import 'package:openapi/api.dart'; import 'package:openapi/api.dart';
var api_instance = new UserApi(); var api_instance = new UserApi();
var user = new User(); // User | Created user object var body = new User(); // User | Created user object
try { try {
api_instance.createUser(user); api_instance.createUser(body);
} catch (e) { } catch (e) {
print("Exception when calling UserApi->createUser: $e\n"); print("Exception when calling UserApi->createUser: $e\n");
} }
@@ -44,7 +44,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**user** | [**User**](User.md)| Created user object | **body** | [**User**](User.md)| Created user object |
### Return type ### Return type
@@ -62,7 +62,7 @@ No authorization required
[[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)
# **createUsersWithArrayInput** # **createUsersWithArrayInput**
> createUsersWithArrayInput(user) > createUsersWithArrayInput(body)
Creates list of users with given input array Creates list of users with given input array
@@ -71,10 +71,10 @@ Creates list of users with given input array
import 'package:openapi/api.dart'; import 'package:openapi/api.dart';
var api_instance = new UserApi(); var api_instance = new UserApi();
var user = [new List&lt;User&gt;()]; // List<User> | List of user object var body = [new List&lt;User&gt;()]; // List<User> | List of user object
try { try {
api_instance.createUsersWithArrayInput(user); api_instance.createUsersWithArrayInput(body);
} catch (e) { } catch (e) {
print("Exception when calling UserApi->createUsersWithArrayInput: $e\n"); print("Exception when calling UserApi->createUsersWithArrayInput: $e\n");
} }
@@ -84,7 +84,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**user** | [**List&lt;User&gt;**](List.md)| List of user object | **body** | [**List&lt;User&gt;**](List.md)| List of user object |
### Return type ### Return type
@@ -102,7 +102,7 @@ No authorization required
[[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)
# **createUsersWithListInput** # **createUsersWithListInput**
> createUsersWithListInput(user) > createUsersWithListInput(body)
Creates list of users with given input array Creates list of users with given input array
@@ -111,10 +111,10 @@ Creates list of users with given input array
import 'package:openapi/api.dart'; import 'package:openapi/api.dart';
var api_instance = new UserApi(); var api_instance = new UserApi();
var user = [new List&lt;User&gt;()]; // List<User> | List of user object var body = [new List&lt;User&gt;()]; // List<User> | List of user object
try { try {
api_instance.createUsersWithListInput(user); api_instance.createUsersWithListInput(body);
} catch (e) { } catch (e) {
print("Exception when calling UserApi->createUsersWithListInput: $e\n"); print("Exception when calling UserApi->createUsersWithListInput: $e\n");
} }
@@ -124,7 +124,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**user** | [**List&lt;User&gt;**](List.md)| List of user object | **body** | [**List&lt;User&gt;**](List.md)| List of user object |
### Return type ### Return type
@@ -304,7 +304,7 @@ No authorization required
[[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)
# **updateUser** # **updateUser**
> updateUser(username, user) > updateUser(username, body)
Updated user Updated user
@@ -316,10 +316,10 @@ import 'package:openapi/api.dart';
var api_instance = new UserApi(); var api_instance = new UserApi();
var username = username_example; // String | name that need to be deleted var username = username_example; // String | name that need to be deleted
var user = new User(); // User | Updated user object var body = new User(); // User | Updated user object
try { try {
api_instance.updateUser(username, user); api_instance.updateUser(username, body);
} catch (e) { } catch (e) {
print("Exception when calling UserApi->updateUser: $e\n"); print("Exception when calling UserApi->updateUser: $e\n");
} }
@@ -330,7 +330,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**username** | **String**| name that need to be deleted | [default to null] **username** | **String**| name that need to be deleted | [default to null]
**user** | [**User**](User.md)| Updated user object | **body** | [**User**](User.md)| Updated user object |
### Return type ### Return type

View File

@@ -23,4 +23,5 @@ part 'model/pet.dart';
part 'model/tag.dart'; part 'model/tag.dart';
part 'model/user.dart'; part 'model/user.dart';
ApiClient defaultApiClient = new ApiClient(); ApiClient defaultApiClient = new ApiClient();

View File

@@ -1,5 +1,7 @@
part of openapi.api; part of openapi.api;
class PetApi { class PetApi {
final ApiClient apiClient; final ApiClient apiClient;
@@ -7,60 +9,66 @@ class PetApi {
/// Add a new pet to the store /// Add a new pet to the store
/// ///
/// ///
Future addPet(Pet pet) async { Future addPet(Pet body) async {
Object postBody = pet; Object postBody = body;
// verify required params are set // verify required params are set
if (pet == null) { if(body == null) {
throw new ApiException(400, "Missing required param: pet"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/pet".replaceAll("{format}", "json"); String path = "/pet".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
List<String> contentTypes = ["application/json", "application/xml"]; List<String> contentTypes = ["application/json","application/xml"];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Deletes a pet /// Deletes a pet
/// ///
/// ///
Future deletePet(int petId, {String apiKey}) async { Future deletePet(int petId, { String apiKey }) async {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (petId == null) { if(petId == null) {
throw new ApiException(400, "Missing required param: petId"); throw new ApiException(400, "Missing required param: petId");
} }
// create path and map variables // create path and map variables
String path = "/pet/{petId}" String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "petId" + "}", petId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -70,26 +78,34 @@ class PetApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'DELETE',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Finds Pets by status /// Finds Pets by status
/// ///
/// Multiple status values can be provided with comma separated strings /// Multiple status values can be provided with comma separated strings
@@ -97,46 +113,50 @@ class PetApi {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (status == null) { if(status == null) {
throw new ApiException(400, "Missing required param: status"); throw new ApiException(400, "Missing required param: status");
} }
// create path and map variables // create path and map variables
String path = "/pet/findByStatus".replaceAll("{format}", "json"); String path = "/pet/findByStatus".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
queryParams queryParams.addAll(_convertParametersForCollectionFormat("csv", "status", status));
.addAll(_convertParametersForCollectionFormat("csv", "status", status));
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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) return (apiClient.deserialize(response.body, 'List<Pet>') as List).map((item) => item as Pet).toList();
.map((item) => item as Pet)
.toList();
} else { } else {
return null; return null;
} }
} }
/// Finds Pets by tags /// Finds Pets by tags
/// ///
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
@@ -144,46 +164,50 @@ class PetApi {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (tags == null) { if(tags == null) {
throw new ApiException(400, "Missing required param: tags"); throw new ApiException(400, "Missing required param: tags");
} }
// create path and map variables // create path and map variables
String path = "/pet/findByTags".replaceAll("{format}", "json"); String path = "/pet/findByTags".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
queryParams queryParams.addAll(_convertParametersForCollectionFormat("csv", "tags", tags));
.addAll(_convertParametersForCollectionFormat("csv", "tags", tags));
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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) return (apiClient.deserialize(response.body, 'List<Pet>') as List).map((item) => item as Pet).toList();
.map((item) => item as Pet)
.toList();
} else { } else {
return null; return null;
} }
} }
/// Find pet by ID /// Find pet by ID
/// ///
/// Returns a single pet /// Returns a single pet
@@ -191,14 +215,12 @@ class PetApi {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (petId == null) { if(petId == null) {
throw new ApiException(400, "Missing required param: petId"); throw new ApiException(400, "Missing required param: petId");
} }
// create path and map variables // create path and map variables
String path = "/pet/{petId}" String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "petId" + "}", petId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -207,84 +229,97 @@ class PetApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["api_key"]; List<String> authNames = ["api_key"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'Pet') as Pet; return apiClient.deserialize(response.body, 'Pet') as Pet;
} else { } else {
return null; return null;
} }
} }
/// Update an existing pet /// Update an existing pet
/// ///
/// ///
Future updatePet(Pet pet) async { Future updatePet(Pet body) async {
Object postBody = pet; Object postBody = body;
// verify required params are set // verify required params are set
if (pet == null) { if(body == null) {
throw new ApiException(400, "Missing required param: pet"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/pet".replaceAll("{format}", "json"); String path = "/pet".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
List<String> contentTypes = ["application/json", "application/xml"]; List<String> contentTypes = ["application/json","application/xml"];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'PUT', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'PUT',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Updates a pet in the store with form data /// Updates a pet in the store with form data
/// ///
/// ///
Future updatePetWithForm(int petId, {String name, String status}) async { Future updatePetWithForm(int petId, { String name, String status }) async {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (petId == null) { if(petId == null) {
throw new ApiException(400, "Missing required param: petId"); throw new ApiException(400, "Missing required param: petId");
} }
// create path and map variables // create path and map variables
String path = "/pet/{petId}" String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "petId" + "}", petId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -293,11 +328,10 @@ class PetApi {
List<String> contentTypes = ["application/x-www-form-urlencoded"]; List<String> contentTypes = ["application/x-www-form-urlencoded"];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (name != null) { if (name != null) {
@@ -308,38 +342,45 @@ class PetApi {
hasFields = true; hasFields = true;
mp.fields['status'] = parameterToString(status); mp.fields['status'] = parameterToString(status);
} }
if (hasFields) postBody = mp; if(hasFields)
} else { postBody = mp;
if (name != null) formParams['name'] = parameterToString(name); }
if (status != null) formParams['status'] = parameterToString(status); else {
if (name != null)
formParams['name'] = parameterToString(name);
if (status != null)
formParams['status'] = parameterToString(status);
} }
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// uploads an image /// uploads an image
/// ///
/// ///
Future<ApiResponse> uploadFile(int petId, Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async {
{String additionalMetadata, MultipartFile file}) async {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (petId == null) { if(petId == null) {
throw new ApiException(400, "Missing required param: petId"); throw new ApiException(400, "Missing required param: petId");
} }
// create path and map variables // create path and map variables
String path = "/pet/{petId}/uploadImage" String path = "/pet/{petId}/uploadImage".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "petId" + "}", petId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -348,11 +389,10 @@ class PetApi {
List<String> contentTypes = ["multipart/form-data"]; List<String> contentTypes = ["multipart/form-data"];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (additionalMetadata != null) { if (additionalMetadata != null) {
@@ -364,19 +404,26 @@ class PetApi {
mp.fields['file'] = file.field; mp.fields['file'] = file.field;
mp.files.add(file); mp.files.add(file);
} }
if (hasFields) postBody = mp; if(hasFields)
} else { postBody = mp;
}
else {
if (additionalMetadata != null) if (additionalMetadata != null)
formParams['additionalMetadata'] = formParams['additionalMetadata'] = parameterToString(additionalMetadata);
parameterToString(additionalMetadata);
} }
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'ApiResponse') as ApiResponse; return apiClient.deserialize(response.body, 'ApiResponse') as ApiResponse;
} else { } else {
return null; return null;

View File

@@ -1,5 +1,7 @@
part of openapi.api; part of openapi.api;
class StoreApi { class StoreApi {
final ApiClient apiClient; final ApiClient apiClient;
@@ -12,14 +14,12 @@ class StoreApi {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (orderId == null) { if(orderId == null) {
throw new ApiException(400, "Missing required param: orderId"); throw new ApiException(400, "Missing required param: orderId");
} }
// create path and map variables // create path and map variables
String path = "/store/order/{orderId}" String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "orderId" + "}", orderId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -28,26 +28,34 @@ class StoreApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'DELETE',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Returns pet inventories by status /// Returns pet inventories by status
/// ///
/// Returns a map of status codes to quantities /// Returns a map of status codes to quantities
@@ -57,7 +65,7 @@ class StoreApi {
// verify required params are set // verify required params are set
// create path and map variables // create path and map variables
String path = "/store/inventory".replaceAll("{format}", "json"); String path = "/store/inventory".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -66,30 +74,36 @@ class StoreApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["api_key"]; List<String> authNames = ["api_key"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 new Map<String, int>.from( return new Map<String, int>.from(apiClient.deserialize(response.body, 'Map<String, int>'));
apiClient.deserialize(response.body, 'Map<String, int>')); ;
;
} else { } else {
return null; return null;
} }
} }
/// Find purchase order by ID /// Find purchase order by ID
/// ///
/// For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions /// For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
@@ -97,14 +111,12 @@ class StoreApi {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (orderId == null) { if(orderId == null) {
throw new ApiException(400, "Missing required param: orderId"); throw new ApiException(400, "Missing required param: orderId");
} }
// create path and map variables // create path and map variables
String path = "/store/order/{orderId}" String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "orderId" + "}", orderId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -113,41 +125,48 @@ class StoreApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'Order') as Order; return apiClient.deserialize(response.body, 'Order') as Order;
} else { } else {
return null; return null;
} }
} }
/// Place an order for a pet /// Place an order for a pet
/// ///
/// ///
Future<Order> placeOrder(Order order) async { Future<Order> placeOrder(Order body) async {
Object postBody = order; Object postBody = body;
// verify required params are set // verify required params are set
if (order == null) { if(body == null) {
throw new ApiException(400, "Missing required param: order"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/store/order".replaceAll("{format}", "json"); String path = "/store/order".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -156,22 +175,30 @@ class StoreApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'Order') as Order; return apiClient.deserialize(response.body, 'Order') as Order;
} else { } else {
return null; return null;

View File

@@ -1,5 +1,7 @@
part of openapi.api; part of openapi.api;
class UserApi { class UserApi {
final ApiClient apiClient; final ApiClient apiClient;
@@ -8,16 +10,16 @@ class UserApi {
/// Create user /// Create user
/// ///
/// This can only be done by the logged in user. /// This can only be done by the logged in user.
Future createUser(User user) async { Future createUser(User body) async {
Object postBody = user; Object postBody = body;
// verify required params are set // verify required params are set
if (user == null) { if(body == null) {
throw new ApiException(400, "Missing required param: user"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/user".replaceAll("{format}", "json"); String path = "/user".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -26,39 +28,47 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Creates list of users with given input array /// Creates list of users with given input array
/// ///
/// ///
Future createUsersWithArrayInput(List<User> user) async { Future createUsersWithArrayInput(List<User> body) async {
Object postBody = user; Object postBody = body;
// verify required params are set // verify required params are set
if (user == null) { if(body == null) {
throw new ApiException(400, "Missing required param: user"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/user/createWithArray".replaceAll("{format}", "json"); String path = "/user/createWithArray".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -67,39 +77,47 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Creates list of users with given input array /// Creates list of users with given input array
/// ///
/// ///
Future createUsersWithListInput(List<User> user) async { Future createUsersWithListInput(List<User> body) async {
Object postBody = user; Object postBody = body;
// verify required params are set // verify required params are set
if (user == null) { if(body == null) {
throw new ApiException(400, "Missing required param: user"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/user/createWithList".replaceAll("{format}", "json"); String path = "/user/createWithList".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -108,26 +126,34 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Delete user /// Delete user
/// ///
/// This can only be done by the logged in user. /// This can only be done by the logged in user.
@@ -135,14 +161,12 @@ class UserApi {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (username == null) { if(username == null) {
throw new ApiException(400, "Missing required param: username"); throw new ApiException(400, "Missing required param: username");
} }
// create path and map variables // create path and map variables
String path = "/user/{username}" String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "username" + "}", username.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -151,41 +175,47 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'DELETE',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Get user by user name /// Get user by user name
/// ///
/// ///
Future<User> getUserByName(String username) async { Future<User> getUserByName(String username) async {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (username == null) { if(username == null) {
throw new ApiException(400, "Missing required param: username"); throw new ApiException(400, "Missing required param: username");
} }
// create path and map variables // create path and map variables
String path = "/user/{username}" String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "username" + "}", username.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -194,88 +224,100 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'User') as User; return apiClient.deserialize(response.body, 'User') as User;
} else { } else {
return null; return null;
} }
} }
/// Logs user into the system /// Logs user into the system
/// ///
/// ///
Future<String> loginUser(String username, String password) async { Future<String> loginUser(String username, String password) async {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
if (username == null) { if(username == null) {
throw new ApiException(400, "Missing required param: username"); throw new ApiException(400, "Missing required param: username");
} }
if (password == null) { if(password == null) {
throw new ApiException(400, "Missing required param: password"); throw new ApiException(400, "Missing required param: password");
} }
// create path and map variables // create path and map variables
String path = "/user/login".replaceAll("{format}", "json"); String path = "/user/login".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
queryParams.addAll( queryParams.addAll(_convertParametersForCollectionFormat("", "username", username));
_convertParametersForCollectionFormat("", "username", username)); queryParams.addAll(_convertParametersForCollectionFormat("", "password", password));
queryParams.addAll(
_convertParametersForCollectionFormat("", "password", password));
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'String') as String; return apiClient.deserialize(response.body, 'String') as String;
} else { } else {
return null; return null;
} }
} }
/// Logs out current logged in user session /// Logs out current logged in user session
/// ///
/// ///
Future logoutUser() async { Future logoutUser() async {
Object postBody = null; Object postBody = null;
// verify required params are set // verify required params are set
// create path and map variables // create path and map variables
String path = "/user/logout".replaceAll("{format}", "json"); String path = "/user/logout".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -284,44 +326,50 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Updated user /// Updated user
/// ///
/// This can only be done by the logged in user. /// This can only be done by the logged in user.
Future updateUser(String username, User user) async { Future updateUser(String username, User body) async {
Object postBody = user; Object postBody = body;
// verify required params are set // verify required params are set
if (username == null) { if(username == null) {
throw new ApiException(400, "Missing required param: username"); throw new ApiException(400, "Missing required param: username");
} }
if (user == null) { if(body == null) {
throw new ApiException(400, "Missing required param: user"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/user/{username}" String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "username" + "}", username.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -330,22 +378,31 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'PUT', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'PUT',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }

View File

@@ -8,6 +8,7 @@ class QueryParam {
} }
class ApiClient { class ApiClient {
String basePath; String basePath;
var client = new Client(); var client = new Client();
@@ -24,7 +25,7 @@ class ApiClient {
} }
void addDefaultHeader(String key, String value) { void addDefaultHeader(String key, String value) {
_defaultHeaderMap[key] = value; _defaultHeaderMap[key] = value;
} }
dynamic _deserialize(dynamic value, String targetType) { dynamic _deserialize(dynamic value, String targetType) {
@@ -66,11 +67,9 @@ class ApiClient {
} }
} }
} catch (e, stack) { } catch (e, stack) {
throw new ApiException.withInner( throw new ApiException.withInner(500, 'Exception during deserialization.', e, stack);
500, 'Exception during deserialization.', e, stack);
} }
throw new ApiException( throw new ApiException(500, 'Could not find a suitable class for deserialization');
500, 'Could not find a suitable class for deserialization');
} }
dynamic deserialize(String json, String targetType) { dynamic deserialize(String json, String targetType) {
@@ -95,28 +94,28 @@ class ApiClient {
// We don't use a Map<String, String> for queryParams. // We don't use a Map<String, String> for queryParams.
// If collectionFormat is 'multi' a key might appear multiple times. // If collectionFormat is 'multi' a key might appear multiple times.
Future<Response> invokeAPI( Future<Response> invokeAPI(String path,
String path, String method,
String method, Iterable<QueryParam> queryParams,
Iterable<QueryParam> queryParams, Object body,
Object body, Map<String, String> headerParams,
Map<String, String> headerParams, Map<String, String> formParams,
Map<String, String> formParams, String contentType,
String contentType, List<String> authNames) async {
List<String> authNames) async {
_updateParamsForAuth(authNames, queryParams, headerParams); _updateParamsForAuth(authNames, queryParams, headerParams);
var ps = queryParams var ps = queryParams.where((p) => p.value != null).map((p) => '${p.name}=${p.value}');
.where((p) => p.value != null) String queryString = ps.isNotEmpty ?
.map((p) => '${p.name}=${p.value}'); '?' + ps.join('&') :
String queryString = ps.isNotEmpty ? '?' + ps.join('&') : ''; '';
String url = basePath + path + queryString; String url = basePath + path + queryString;
headerParams.addAll(_defaultHeaderMap); headerParams.addAll(_defaultHeaderMap);
headerParams['Content-Type'] = contentType; headerParams['Content-Type'] = contentType;
if (body is MultipartRequest) { if(body is MultipartRequest) {
var request = new MultipartRequest(method, Uri.parse(url)); var request = new MultipartRequest(method, Uri.parse(url));
request.fields.addAll(body.fields); request.fields.addAll(body.fields);
request.files.addAll(body.files); request.files.addAll(body.files);
@@ -125,10 +124,8 @@ class ApiClient {
var response = await client.send(request); var response = await client.send(request);
return Response.fromStream(response); return Response.fromStream(response);
} else { } else {
var msgBody = contentType == "application/x-www-form-urlencoded" var msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body);
? formParams switch(method) {
: serialize(body);
switch (method) {
case "POST": case "POST":
return client.post(url, headers: headerParams, body: msgBody); return client.post(url, headers: headerParams, body: msgBody);
case "PUT": case "PUT":
@@ -145,12 +142,10 @@ class ApiClient {
/// Update query and header parameters based on authentication settings. /// Update query and header parameters based on authentication settings.
/// @param authNames The authentications to apply /// @param authNames The authentications to apply
void _updateParamsForAuth(List<String> authNames, void _updateParamsForAuth(List<String> authNames, List<QueryParam> queryParams, Map<String, String> headerParams) {
List<QueryParam> queryParams, Map<String, String> headerParams) {
authNames.forEach((authName) { authNames.forEach((authName) {
Authentication auth = _authentications[authName]; Authentication auth = _authentications[authName];
if (auth == null) if (auth == null) throw new ArgumentError("Authentication undefined: " + authName);
throw new ArgumentError("Authentication undefined: " + authName);
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams);
}); });
} }

View File

@@ -8,8 +8,7 @@ class ApiException implements Exception {
ApiException(this.code, this.message); ApiException(this.code, this.message);
ApiException.withInner( ApiException.withInner(this.code, this.message, this.innerException, this.stackTrace);
this.code, this.message, this.innerException, this.stackTrace);
String toString() { String toString() {
if (message == null) return "ApiException"; if (message == null) return "ApiException";

View File

@@ -4,7 +4,7 @@ const _delimiters = const {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'};
// port from Java version // port from Java version
Iterable<QueryParam> _convertParametersForCollectionFormat( Iterable<QueryParam> _convertParametersForCollectionFormat(
String collectionFormat, String name, dynamic value) { String collectionFormat, String name, dynamic value) {
var params = <QueryParam>[]; var params = <QueryParam>[];
// preconditions // preconditions
@@ -19,8 +19,8 @@ Iterable<QueryParam> _convertParametersForCollectionFormat(
// get the collection format // get the collection format
collectionFormat = (collectionFormat == null || collectionFormat.isEmpty) collectionFormat = (collectionFormat == null || collectionFormat.isEmpty)
? "csv" ? "csv"
: collectionFormat; // default: csv : collectionFormat; // default: csv
if (collectionFormat == "multi") { if (collectionFormat == "multi") {
return values.map((v) => new QueryParam(name, parameterToString(v))); return values.map((v) => new QueryParam(name, parameterToString(v)));
@@ -28,8 +28,7 @@ Iterable<QueryParam> _convertParametersForCollectionFormat(
String delimiter = _delimiters[collectionFormat] ?? ","; String delimiter = _delimiters[collectionFormat] ?? ",";
params.add(new QueryParam( params.add(new QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter)));
name, values.map((v) => parameterToString(v)).join(delimiter)));
return params; return params;
} }

View File

@@ -1,6 +1,7 @@
part of openapi.api; part of openapi.api;
class ApiKeyAuth implements Authentication { class ApiKeyAuth implements Authentication {
final String location; final String location;
final String paramName; final String paramName;
String apiKey; String apiKey;
@@ -9,8 +10,7 @@ class ApiKeyAuth implements Authentication {
ApiKeyAuth(this.location, this.paramName); ApiKeyAuth(this.location, this.paramName);
@override @override
void applyToParams( void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
List<QueryParam> queryParams, Map<String, String> headerParams) {
String value; String value;
if (apiKeyPrefix != null) { if (apiKeyPrefix != null) {
value = '$apiKeyPrefix $apiKey'; value = '$apiKeyPrefix $apiKey';

View File

@@ -1,7 +1,7 @@
part of openapi.api; part of openapi.api;
abstract class Authentication { abstract class Authentication {
/// Apply authentication settings to header and query params.
void applyToParams( /// Apply authentication settings to header and query params.
List<QueryParam> queryParams, Map<String, String> headerParams); void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams);
} }

View File

@@ -1,15 +1,14 @@
part of openapi.api; part of openapi.api;
class HttpBasicAuth implements Authentication { class HttpBasicAuth implements Authentication {
String username; String username;
String password; String password;
@override @override
void applyToParams( void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
List<QueryParam> queryParams, Map<String, String> headerParams) { String str = (username == null ? "" : username) + ":" + (password == null ? "" : password);
String str = (username == null ? "" : username) +
":" +
(password == null ? "" : password);
headerParams["Authorization"] = "Basic " + BASE64.encode(UTF8.encode(str)); headerParams["Authorization"] = "Basic " + BASE64.encode(UTF8.encode(str));
} }
}
}

View File

@@ -3,11 +3,11 @@ part of openapi.api;
class OAuth implements Authentication { class OAuth implements Authentication {
String accessToken; String accessToken;
OAuth({this.accessToken}) {} OAuth({this.accessToken}) {
}
@override @override
void applyToParams( void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
List<QueryParam> queryParams, Map<String, String> headerParams) {
if (accessToken != null) { if (accessToken != null) {
headerParams["Authorization"] = "Bearer " + accessToken; headerParams["Authorization"] = "Bearer " + accessToken;
} }

View File

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

View File

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

View File

@@ -1,17 +1,18 @@
part of openapi.api; part of openapi.api;
class Order { 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 = false; bool complete = false;
Order(); Order();
@@ -22,13 +23,36 @@ class Order {
Order.fromJson(Map<String, dynamic> json) { Order.fromJson(Map<String, dynamic> json) {
if (json == null) return; if (json == null) return;
id = json['id']; if (json['id'] == null) {
petId = json['petId']; id = null;
quantity = json['quantity']; } else {
shipDate = id = json['id'];
json['shipDate'] == null ? null : DateTime.parse(json['shipDate']); }
status = json['status']; if (json['petId'] == null) {
complete = json['complete']; 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'];
}
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@@ -43,18 +67,15 @@ class Order {
} }
static List<Order> listFromJson(List<dynamic> json) { static List<Order> listFromJson(List<dynamic> json) {
return json == null return json == null ? new List<Order>() : json.map((value) => new Order.fromJson(value)).toList();
? new List<Order>()
: json.map((value) => new Order.fromJson(value)).toList();
} }
static Map<String, Order> mapFromJson( static Map<String, Order> mapFromJson(Map<String, Map<String, dynamic>> json) {
Map<String, Map<String, dynamic>> json) {
var map = new Map<String, Order>(); var map = new Map<String, Order>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => json.forEach((String key, Map<String, dynamic> value) => map[key] = new Order.fromJson(value));
map[key] = new Order.fromJson(value));
} }
return map; return map;
} }
} }

View File

@@ -1,14 +1,15 @@
part of openapi.api; part of openapi.api;
class Pet { 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;
@@ -22,13 +23,36 @@ class Pet {
Pet.fromJson(Map<String, dynamic> json) { Pet.fromJson(Map<String, dynamic> json) {
if (json == null) return; if (json == null) return;
id = json['id']; if (json['id'] == null) {
category = new Category.fromJson(json['category']); id = null;
name = json['name']; } else {
photoUrls = id = json['id'];
(json['photoUrls'] as List).map((item) => item as String).toList(); }
tags = Tag.listFromJson(json['tags']); if (json['category'] == null) {
status = json['status']; 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'];
}
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@@ -43,17 +67,15 @@ class Pet {
} }
static List<Pet> listFromJson(List<dynamic> json) { static List<Pet> listFromJson(List<dynamic> json) {
return json == null return json == null ? new List<Pet>() : json.map((value) => new Pet.fromJson(value)).toList();
? new List<Pet>()
: json.map((value) => new Pet.fromJson(value)).toList();
} }
static Map<String, Pet> mapFromJson(Map<String, Map<String, dynamic>> json) { static Map<String, Pet> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, Pet>(); var map = new Map<String, Pet>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => json.forEach((String key, Map<String, dynamic> value) => map[key] = new Pet.fromJson(value));
map[key] = new Pet.fromJson(value));
} }
return map; return map;
} }
} }

View File

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

View File

@@ -1,18 +1,19 @@
part of openapi.api; part of openapi.api;
class User { 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;
@@ -25,14 +26,46 @@ class User {
User.fromJson(Map<String, dynamic> json) { User.fromJson(Map<String, dynamic> json) {
if (json == null) return; if (json == null) return;
id = json['id']; if (json['id'] == null) {
username = json['username']; id = null;
firstName = json['firstName']; } else {
lastName = json['lastName']; id = json['id'];
email = json['email']; }
password = json['password']; if (json['username'] == null) {
phone = json['phone']; username = null;
userStatus = json['userStatus']; } 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'];
}
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@@ -49,17 +82,15 @@ class User {
} }
static List<User> listFromJson(List<dynamic> json) { static List<User> listFromJson(List<dynamic> json) {
return json == null return json == null ? new List<User>() : json.map((value) => new User.fromJson(value)).toList();
? new List<User>()
: json.map((value) => new User.fromJson(value)).toList();
} }
static Map<String, User> mapFromJson(Map<String, Map<String, dynamic>> json) { static Map<String, User> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, User>(); var map = new Map<String, User>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => json.forEach((String key, Map<String, dynamic> value) => map[key] = new User.fromJson(value));
map[key] = new User.fromJson(value));
} }
return map; return map;
} }
} }

View File

@@ -1 +1 @@
3.3.1-SNAPSHOT 4.0.0-SNAPSHOT

View File

@@ -47,10 +47,10 @@ import 'package:openapi/api.dart';
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
var api_instance = new PetApi(); var api_instance = new PetApi();
var pet = new Pet(); // Pet | Pet object that needs to be added to the store var body = new Pet(); // Pet | Pet object that needs to be added to the store
try { try {
api_instance.addPet(pet); api_instance.addPet(body);
} catch (e) { } catch (e) {
print("Exception when calling PetApi->addPet: $e\n"); print("Exception when calling PetApi->addPet: $e\n");
} }

View File

@@ -20,7 +20,7 @@ Method | HTTP request | Description
# **addPet** # **addPet**
> addPet(pet) > addPet(body)
Add a new pet to the store Add a new pet to the store
@@ -31,10 +31,10 @@ import 'package:openapi/api.dart';
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
var api_instance = new PetApi(); var api_instance = new PetApi();
var pet = new Pet(); // Pet | Pet object that needs to be added to the store var body = new Pet(); // Pet | Pet object that needs to be added to the store
try { try {
api_instance.addPet(pet); api_instance.addPet(body);
} catch (e) { } catch (e) {
print("Exception when calling PetApi->addPet: $e\n"); print("Exception when calling PetApi->addPet: $e\n");
} }
@@ -44,7 +44,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
### Return type ### Return type
@@ -243,7 +243,7 @@ Name | Type | Description | Notes
[[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)
# **updatePet** # **updatePet**
> updatePet(pet) > updatePet(body)
Update an existing pet Update an existing pet
@@ -254,10 +254,10 @@ import 'package:openapi/api.dart';
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
var api_instance = new PetApi(); var api_instance = new PetApi();
var pet = new Pet(); // Pet | Pet object that needs to be added to the store var body = new Pet(); // Pet | Pet object that needs to be added to the store
try { try {
api_instance.updatePet(pet); api_instance.updatePet(body);
} catch (e) { } catch (e) {
print("Exception when calling PetApi->updatePet: $e\n"); print("Exception when calling PetApi->updatePet: $e\n");
} }
@@ -267,7 +267,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
### Return type ### Return type

View File

@@ -144,7 +144,7 @@ No authorization required
[[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)
# **placeOrder** # **placeOrder**
> Order placeOrder(order) > Order placeOrder(body)
Place an order for a pet Place an order for a pet
@@ -153,10 +153,10 @@ Place an order for a pet
import 'package:openapi/api.dart'; import 'package:openapi/api.dart';
var api_instance = new StoreApi(); var api_instance = new StoreApi();
var order = new Order(); // Order | order placed for purchasing the pet var body = new Order(); // Order | order placed for purchasing the pet
try { try {
var result = api_instance.placeOrder(order); var result = api_instance.placeOrder(body);
print(result); print(result);
} catch (e) { } catch (e) {
print("Exception when calling StoreApi->placeOrder: $e\n"); print("Exception when calling StoreApi->placeOrder: $e\n");
@@ -167,7 +167,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**order** | [**Order**](Order.md)| order placed for purchasing the pet | **body** | [**Order**](Order.md)| order placed for purchasing the pet |
### Return type ### Return type

View File

@@ -20,7 +20,7 @@ Method | HTTP request | Description
# **createUser** # **createUser**
> createUser(user) > createUser(body)
Create user Create user
@@ -31,10 +31,10 @@ This can only be done by the logged in user.
import 'package:openapi/api.dart'; import 'package:openapi/api.dart';
var api_instance = new UserApi(); var api_instance = new UserApi();
var user = new User(); // User | Created user object var body = new User(); // User | Created user object
try { try {
api_instance.createUser(user); api_instance.createUser(body);
} catch (e) { } catch (e) {
print("Exception when calling UserApi->createUser: $e\n"); print("Exception when calling UserApi->createUser: $e\n");
} }
@@ -44,7 +44,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**user** | [**User**](User.md)| Created user object | **body** | [**User**](User.md)| Created user object |
### Return type ### Return type
@@ -62,7 +62,7 @@ No authorization required
[[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)
# **createUsersWithArrayInput** # **createUsersWithArrayInput**
> createUsersWithArrayInput(user) > createUsersWithArrayInput(body)
Creates list of users with given input array Creates list of users with given input array
@@ -71,10 +71,10 @@ Creates list of users with given input array
import 'package:openapi/api.dart'; import 'package:openapi/api.dart';
var api_instance = new UserApi(); var api_instance = new UserApi();
var user = [new List&lt;User&gt;()]; // List<User> | List of user object var body = [new List&lt;User&gt;()]; // List<User> | List of user object
try { try {
api_instance.createUsersWithArrayInput(user); api_instance.createUsersWithArrayInput(body);
} catch (e) { } catch (e) {
print("Exception when calling UserApi->createUsersWithArrayInput: $e\n"); print("Exception when calling UserApi->createUsersWithArrayInput: $e\n");
} }
@@ -84,7 +84,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**user** | [**List&lt;User&gt;**](List.md)| List of user object | **body** | [**List&lt;User&gt;**](List.md)| List of user object |
### Return type ### Return type
@@ -102,7 +102,7 @@ No authorization required
[[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)
# **createUsersWithListInput** # **createUsersWithListInput**
> createUsersWithListInput(user) > createUsersWithListInput(body)
Creates list of users with given input array Creates list of users with given input array
@@ -111,10 +111,10 @@ Creates list of users with given input array
import 'package:openapi/api.dart'; import 'package:openapi/api.dart';
var api_instance = new UserApi(); var api_instance = new UserApi();
var user = [new List&lt;User&gt;()]; // List<User> | List of user object var body = [new List&lt;User&gt;()]; // List<User> | List of user object
try { try {
api_instance.createUsersWithListInput(user); api_instance.createUsersWithListInput(body);
} catch (e) { } catch (e) {
print("Exception when calling UserApi->createUsersWithListInput: $e\n"); print("Exception when calling UserApi->createUsersWithListInput: $e\n");
} }
@@ -124,7 +124,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**user** | [**List&lt;User&gt;**](List.md)| List of user object | **body** | [**List&lt;User&gt;**](List.md)| List of user object |
### Return type ### Return type
@@ -304,7 +304,7 @@ No authorization required
[[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)
# **updateUser** # **updateUser**
> updateUser(username, user) > updateUser(username, body)
Updated user Updated user
@@ -316,10 +316,10 @@ import 'package:openapi/api.dart';
var api_instance = new UserApi(); var api_instance = new UserApi();
var username = username_example; // String | name that need to be deleted var username = username_example; // String | name that need to be deleted
var user = new User(); // User | Updated user object var body = new User(); // User | Updated user object
try { try {
api_instance.updateUser(username, user); api_instance.updateUser(username, body);
} catch (e) { } catch (e) {
print("Exception when calling UserApi->updateUser: $e\n"); print("Exception when calling UserApi->updateUser: $e\n");
} }
@@ -330,7 +330,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**username** | **String**| name that need to be deleted | [default to null] **username** | **String**| name that need to be deleted | [default to null]
**user** | [**User**](User.md)| Updated user object | **body** | [**User**](User.md)| Updated user object |
### Return type ### Return type

View File

@@ -23,4 +23,5 @@ part 'model/pet.dart';
part 'model/tag.dart'; part 'model/tag.dart';
part 'model/user.dart'; part 'model/user.dart';
ApiClient defaultApiClient = ApiClient(); ApiClient defaultApiClient = ApiClient();

View File

@@ -1,5 +1,7 @@
part of openapi.api; part of openapi.api;
class PetApi { class PetApi {
final ApiClient apiClient; final ApiClient apiClient;
@@ -7,60 +9,66 @@ class PetApi {
/// Add a new pet to the store /// Add a new pet to the store
/// ///
/// ///
Future addPet(Pet pet) async { Future addPet(Pet body) async {
Object postBody = pet; Object postBody = body;
// verify required params are set // verify required params are set
if (pet == null) { if(body == null) {
throw new ApiException(400, "Missing required param: pet"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/pet".replaceAll("{format}", "json"); String path = "/pet".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
List<String> contentTypes = ["application/json", "application/xml"]; List<String> contentTypes = ["application/json","application/xml"];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Deletes a pet /// Deletes a pet
/// ///
/// ///
Future deletePet(int petId, {String apiKey}) async { Future deletePet(int petId, { String apiKey }) async {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
if (petId == null) { if(petId == null) {
throw new ApiException(400, "Missing required param: petId"); throw new ApiException(400, "Missing required param: petId");
} }
// create path and map variables // create path and map variables
String path = "/pet/{petId}" String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "petId" + "}", petId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -70,26 +78,34 @@ class PetApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'DELETE',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Finds Pets by status /// Finds Pets by status
/// ///
/// Multiple status values can be provided with comma separated strings /// Multiple status values can be provided with comma separated strings
@@ -97,46 +113,50 @@ class PetApi {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
if (status == null) { if(status == null) {
throw new ApiException(400, "Missing required param: status"); throw new ApiException(400, "Missing required param: status");
} }
// create path and map variables // create path and map variables
String path = "/pet/findByStatus".replaceAll("{format}", "json"); String path = "/pet/findByStatus".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
queryParams queryParams.addAll(_convertParametersForCollectionFormat("csv", "status", status));
.addAll(_convertParametersForCollectionFormat("csv", "status", status));
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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) return (apiClient.deserialize(response.body, 'List<Pet>') as List).map((item) => item as Pet).toList();
.map((item) => item as Pet)
.toList();
} else { } else {
return null; return null;
} }
} }
/// Finds Pets by tags /// Finds Pets by tags
/// ///
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
@@ -144,46 +164,50 @@ class PetApi {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
if (tags == null) { if(tags == null) {
throw new ApiException(400, "Missing required param: tags"); throw new ApiException(400, "Missing required param: tags");
} }
// create path and map variables // create path and map variables
String path = "/pet/findByTags".replaceAll("{format}", "json"); String path = "/pet/findByTags".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
queryParams queryParams.addAll(_convertParametersForCollectionFormat("csv", "tags", tags));
.addAll(_convertParametersForCollectionFormat("csv", "tags", tags));
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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) return (apiClient.deserialize(response.body, 'List<Pet>') as List).map((item) => item as Pet).toList();
.map((item) => item as Pet)
.toList();
} else { } else {
return null; return null;
} }
} }
/// Find pet by ID /// Find pet by ID
/// ///
/// Returns a single pet /// Returns a single pet
@@ -191,14 +215,12 @@ class PetApi {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
if (petId == null) { if(petId == null) {
throw new ApiException(400, "Missing required param: petId"); throw new ApiException(400, "Missing required param: petId");
} }
// create path and map variables // create path and map variables
String path = "/pet/{petId}" String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "petId" + "}", petId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -207,84 +229,97 @@ class PetApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["api_key"]; List<String> authNames = ["api_key"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'Pet') as Pet; return apiClient.deserialize(response.body, 'Pet') as Pet;
} else { } else {
return null; return null;
} }
} }
/// Update an existing pet /// Update an existing pet
/// ///
/// ///
Future updatePet(Pet pet) async { Future updatePet(Pet body) async {
Object postBody = pet; Object postBody = body;
// verify required params are set // verify required params are set
if (pet == null) { if(body == null) {
throw new ApiException(400, "Missing required param: pet"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/pet".replaceAll("{format}", "json"); String path = "/pet".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
List<String> contentTypes = ["application/json", "application/xml"]; List<String> contentTypes = ["application/json","application/xml"];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'PUT', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'PUT',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Updates a pet in the store with form data /// Updates a pet in the store with form data
/// ///
/// ///
Future updatePetWithForm(int petId, {String name, String status}) async { Future updatePetWithForm(int petId, { String name, String status }) async {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
if (petId == null) { if(petId == null) {
throw new ApiException(400, "Missing required param: petId"); throw new ApiException(400, "Missing required param: petId");
} }
// create path and map variables // create path and map variables
String path = "/pet/{petId}" String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "petId" + "}", petId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -293,11 +328,10 @@ class PetApi {
List<String> contentTypes = ["application/x-www-form-urlencoded"]; List<String> contentTypes = ["application/x-www-form-urlencoded"];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (name != null) { if (name != null) {
@@ -308,38 +342,45 @@ class PetApi {
hasFields = true; hasFields = true;
mp.fields['status'] = parameterToString(status); mp.fields['status'] = parameterToString(status);
} }
if (hasFields) postBody = mp; if(hasFields)
} else { postBody = mp;
if (name != null) formParams['name'] = parameterToString(name); }
if (status != null) formParams['status'] = parameterToString(status); else {
if (name != null)
formParams['name'] = parameterToString(name);
if (status != null)
formParams['status'] = parameterToString(status);
} }
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// uploads an image /// uploads an image
/// ///
/// ///
Future<ApiResponse> uploadFile(int petId, Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async {
{String additionalMetadata, MultipartFile file}) async {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
if (petId == null) { if(petId == null) {
throw new ApiException(400, "Missing required param: petId"); throw new ApiException(400, "Missing required param: petId");
} }
// create path and map variables // create path and map variables
String path = "/pet/{petId}/uploadImage" String path = "/pet/{petId}/uploadImage".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "petId" + "}", petId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -348,11 +389,10 @@ class PetApi {
List<String> contentTypes = ["multipart/form-data"]; List<String> contentTypes = ["multipart/form-data"];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (additionalMetadata != null) { if (additionalMetadata != null) {
@@ -364,19 +404,26 @@ class PetApi {
mp.fields['file'] = file.field; mp.fields['file'] = file.field;
mp.files.add(file); mp.files.add(file);
} }
if (hasFields) postBody = mp; if(hasFields)
} else { postBody = mp;
}
else {
if (additionalMetadata != null) if (additionalMetadata != null)
formParams['additionalMetadata'] = formParams['additionalMetadata'] = parameterToString(additionalMetadata);
parameterToString(additionalMetadata);
} }
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'ApiResponse') as ApiResponse; return apiClient.deserialize(response.body, 'ApiResponse') as ApiResponse;
} else { } else {
return null; return null;

View File

@@ -1,5 +1,7 @@
part of openapi.api; part of openapi.api;
class StoreApi { class StoreApi {
final ApiClient apiClient; final ApiClient apiClient;
@@ -12,14 +14,12 @@ class StoreApi {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
if (orderId == null) { if(orderId == null) {
throw new ApiException(400, "Missing required param: orderId"); throw new ApiException(400, "Missing required param: orderId");
} }
// create path and map variables // create path and map variables
String path = "/store/order/{orderId}" String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "orderId" + "}", orderId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -28,26 +28,34 @@ class StoreApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'DELETE',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Returns pet inventories by status /// Returns pet inventories by status
/// ///
/// Returns a map of status codes to quantities /// Returns a map of status codes to quantities
@@ -57,7 +65,7 @@ class StoreApi {
// verify required params are set // verify required params are set
// create path and map variables // create path and map variables
String path = "/store/inventory".replaceAll("{format}", "json"); String path = "/store/inventory".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -66,30 +74,36 @@ class StoreApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["api_key"]; List<String> authNames = ["api_key"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 new Map<String, int>.from( return new Map<String, int>.from(apiClient.deserialize(response.body, 'Map<String, int>'));
apiClient.deserialize(response.body, 'Map<String, int>')); ;
;
} else { } else {
return null; return null;
} }
} }
/// Find purchase order by ID /// Find purchase order by ID
/// ///
/// For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions /// For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
@@ -97,14 +111,12 @@ class StoreApi {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
if (orderId == null) { if(orderId == null) {
throw new ApiException(400, "Missing required param: orderId"); throw new ApiException(400, "Missing required param: orderId");
} }
// create path and map variables // create path and map variables
String path = "/store/order/{orderId}" String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "orderId" + "}", orderId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -113,41 +125,48 @@ class StoreApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'Order') as Order; return apiClient.deserialize(response.body, 'Order') as Order;
} else { } else {
return null; return null;
} }
} }
/// Place an order for a pet /// Place an order for a pet
/// ///
/// ///
Future<Order> placeOrder(Order order) async { Future<Order> placeOrder(Order body) async {
Object postBody = order; Object postBody = body;
// verify required params are set // verify required params are set
if (order == null) { if(body == null) {
throw new ApiException(400, "Missing required param: order"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/store/order".replaceAll("{format}", "json"); String path = "/store/order".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -156,22 +175,30 @@ class StoreApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'Order') as Order; return apiClient.deserialize(response.body, 'Order') as Order;
} else { } else {
return null; return null;

View File

@@ -1,5 +1,7 @@
part of openapi.api; part of openapi.api;
class UserApi { class UserApi {
final ApiClient apiClient; final ApiClient apiClient;
@@ -8,16 +10,16 @@ class UserApi {
/// Create user /// Create user
/// ///
/// This can only be done by the logged in user. /// This can only be done by the logged in user.
Future createUser(User user) async { Future createUser(User body) async {
Object postBody = user; Object postBody = body;
// verify required params are set // verify required params are set
if (user == null) { if(body == null) {
throw new ApiException(400, "Missing required param: user"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/user".replaceAll("{format}", "json"); String path = "/user".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -26,39 +28,47 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Creates list of users with given input array /// Creates list of users with given input array
/// ///
/// ///
Future createUsersWithArrayInput(List<User> user) async { Future createUsersWithArrayInput(List<User> body) async {
Object postBody = user; Object postBody = body;
// verify required params are set // verify required params are set
if (user == null) { if(body == null) {
throw new ApiException(400, "Missing required param: user"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/user/createWithArray".replaceAll("{format}", "json"); String path = "/user/createWithArray".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -67,39 +77,47 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Creates list of users with given input array /// Creates list of users with given input array
/// ///
/// ///
Future createUsersWithListInput(List<User> user) async { Future createUsersWithListInput(List<User> body) async {
Object postBody = user; Object postBody = body;
// verify required params are set // verify required params are set
if (user == null) { if(body == null) {
throw new ApiException(400, "Missing required param: user"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/user/createWithList".replaceAll("{format}", "json"); String path = "/user/createWithList".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -108,26 +126,34 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Delete user /// Delete user
/// ///
/// This can only be done by the logged in user. /// This can only be done by the logged in user.
@@ -135,14 +161,12 @@ class UserApi {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
if (username == null) { if(username == null) {
throw new ApiException(400, "Missing required param: username"); throw new ApiException(400, "Missing required param: username");
} }
// create path and map variables // create path and map variables
String path = "/user/{username}" String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "username" + "}", username.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -151,41 +175,47 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'DELETE',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Get user by user name /// Get user by user name
/// ///
/// ///
Future<User> getUserByName(String username) async { Future<User> getUserByName(String username) async {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
if (username == null) { if(username == null) {
throw new ApiException(400, "Missing required param: username"); throw new ApiException(400, "Missing required param: username");
} }
// create path and map variables // create path and map variables
String path = "/user/{username}" String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "username" + "}", username.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -194,88 +224,100 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'User') as User; return apiClient.deserialize(response.body, 'User') as User;
} else { } else {
return null; return null;
} }
} }
/// Logs user into the system /// Logs user into the system
/// ///
/// ///
Future<String> loginUser(String username, String password) async { Future<String> loginUser(String username, String password) async {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
if (username == null) { if(username == null) {
throw new ApiException(400, "Missing required param: username"); throw new ApiException(400, "Missing required param: username");
} }
if (password == null) { if(password == null) {
throw new ApiException(400, "Missing required param: password"); throw new ApiException(400, "Missing required param: password");
} }
// create path and map variables // create path and map variables
String path = "/user/login".replaceAll("{format}", "json"); String path = "/user/login".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
queryParams.addAll( queryParams.addAll(_convertParametersForCollectionFormat("", "username", username));
_convertParametersForCollectionFormat("", "username", username)); queryParams.addAll(_convertParametersForCollectionFormat("", "password", password));
queryParams.addAll(
_convertParametersForCollectionFormat("", "password", password));
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'String') as String; return apiClient.deserialize(response.body, 'String') as String;
} else { } else {
return null; return null;
} }
} }
/// Logs out current logged in user session /// Logs out current logged in user session
/// ///
/// ///
Future logoutUser() async { Future logoutUser() async {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
// create path and map variables // create path and map variables
String path = "/user/logout".replaceAll("{format}", "json"); String path = "/user/logout".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -284,44 +326,50 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Updated user /// Updated user
/// ///
/// This can only be done by the logged in user. /// This can only be done by the logged in user.
Future updateUser(String username, User user) async { Future updateUser(String username, User body) async {
Object postBody = user; Object postBody = body;
// verify required params are set // verify required params are set
if (username == null) { if(username == null) {
throw new ApiException(400, "Missing required param: username"); throw new ApiException(400, "Missing required param: username");
} }
if (user == null) { if(body == null) {
throw new ApiException(400, "Missing required param: user"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/user/{username}" String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "username" + "}", username.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -330,22 +378,31 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'PUT', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'PUT',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }

View File

@@ -8,6 +8,7 @@ class QueryParam {
} }
class ApiClient { class ApiClient {
String basePath; String basePath;
var client = Client(); var client = Client();
@@ -24,7 +25,7 @@ class ApiClient {
} }
void addDefaultHeader(String key, String value) { void addDefaultHeader(String key, String value) {
_defaultHeaderMap[key] = value; _defaultHeaderMap[key] = value;
} }
dynamic _deserialize(dynamic value, String targetType) { dynamic _deserialize(dynamic value, String targetType) {
@@ -66,11 +67,9 @@ class ApiClient {
} }
} }
} on Exception catch (e, stack) { } on Exception catch (e, stack) {
throw ApiException.withInner( throw ApiException.withInner(500, 'Exception during deserialization.', e, stack);
500, 'Exception during deserialization.', e, stack);
} }
throw ApiException( throw ApiException(500, 'Could not find a suitable class for deserialization');
500, 'Could not find a suitable class for deserialization');
} }
dynamic deserialize(String json, String targetType) { dynamic deserialize(String json, String targetType) {
@@ -95,28 +94,28 @@ class ApiClient {
// We don't use a Map<String, String> for queryParams. // We don't use a Map<String, String> for queryParams.
// If collectionFormat is 'multi' a key might appear multiple times. // If collectionFormat is 'multi' a key might appear multiple times.
Future<Response> invokeAPI( Future<Response> invokeAPI(String path,
String path, String method,
String method, Iterable<QueryParam> queryParams,
Iterable<QueryParam> queryParams, Object body,
Object body, Map<String, String> headerParams,
Map<String, String> headerParams, Map<String, String> formParams,
Map<String, String> formParams, String contentType,
String contentType, List<String> authNames) async {
List<String> authNames) async {
_updateParamsForAuth(authNames, queryParams, headerParams); _updateParamsForAuth(authNames, queryParams, headerParams);
var ps = queryParams var ps = queryParams.where((p) => p.value != null).map((p) => '${p.name}=${p.value}');
.where((p) => p.value != null) String queryString = ps.isNotEmpty ?
.map((p) => '${p.name}=${p.value}'); '?' + ps.join('&') :
String queryString = ps.isNotEmpty ? '?' + ps.join('&') : ''; '';
String url = basePath + path + queryString; String url = basePath + path + queryString;
headerParams.addAll(_defaultHeaderMap); headerParams.addAll(_defaultHeaderMap);
headerParams['Content-Type'] = contentType; headerParams['Content-Type'] = contentType;
if (body is MultipartRequest) { if(body is MultipartRequest) {
var request = MultipartRequest(method, Uri.parse(url)); var request = MultipartRequest(method, Uri.parse(url));
request.fields.addAll(body.fields); request.fields.addAll(body.fields);
request.files.addAll(body.files); request.files.addAll(body.files);
@@ -125,10 +124,8 @@ class ApiClient {
var response = await client.send(request); var response = await client.send(request);
return Response.fromStream(response); return Response.fromStream(response);
} else { } else {
var msgBody = contentType == "application/x-www-form-urlencoded" var msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body);
? formParams switch(method) {
: serialize(body);
switch (method) {
case "POST": case "POST":
return client.post(url, headers: headerParams, body: msgBody); return client.post(url, headers: headerParams, body: msgBody);
case "PUT": case "PUT":
@@ -145,12 +142,10 @@ class ApiClient {
/// Update query and header parameters based on authentication settings. /// Update query and header parameters based on authentication settings.
/// @param authNames The authentications to apply /// @param authNames The authentications to apply
void _updateParamsForAuth(List<String> authNames, void _updateParamsForAuth(List<String> authNames, List<QueryParam> queryParams, Map<String, String> headerParams) {
List<QueryParam> queryParams, Map<String, String> headerParams) {
authNames.forEach((authName) { authNames.forEach((authName) {
Authentication auth = _authentications[authName]; Authentication auth = _authentications[authName];
if (auth == null) if (auth == null) throw ArgumentError("Authentication undefined: " + authName);
throw ArgumentError("Authentication undefined: " + authName);
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams);
}); });
} }

View File

@@ -8,8 +8,7 @@ class ApiException implements Exception {
ApiException(this.code, this.message); ApiException(this.code, this.message);
ApiException.withInner( ApiException.withInner(this.code, this.message, this.innerException, this.stackTrace);
this.code, this.message, this.innerException, this.stackTrace);
String toString() { String toString() {
if (message == null) return "ApiException"; if (message == null) return "ApiException";

View File

@@ -4,7 +4,7 @@ const _delimiters = const {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'};
// port from Java version // port from Java version
Iterable<QueryParam> _convertParametersForCollectionFormat( Iterable<QueryParam> _convertParametersForCollectionFormat(
String collectionFormat, String name, dynamic value) { String collectionFormat, String name, dynamic value) {
var params = <QueryParam>[]; var params = <QueryParam>[];
// preconditions // preconditions
@@ -19,8 +19,8 @@ Iterable<QueryParam> _convertParametersForCollectionFormat(
// get the collection format // get the collection format
collectionFormat = (collectionFormat == null || collectionFormat.isEmpty) collectionFormat = (collectionFormat == null || collectionFormat.isEmpty)
? "csv" ? "csv"
: collectionFormat; // default: csv : collectionFormat; // default: csv
if (collectionFormat == "multi") { if (collectionFormat == "multi") {
return values.map((v) => QueryParam(name, parameterToString(v))); return values.map((v) => QueryParam(name, parameterToString(v)));
@@ -28,8 +28,7 @@ Iterable<QueryParam> _convertParametersForCollectionFormat(
String delimiter = _delimiters[collectionFormat] ?? ","; String delimiter = _delimiters[collectionFormat] ?? ",";
params.add(QueryParam( params.add(QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter)));
name, values.map((v) => parameterToString(v)).join(delimiter)));
return params; return params;
} }

View File

@@ -1,6 +1,7 @@
part of openapi.api; part of openapi.api;
class ApiKeyAuth implements Authentication { class ApiKeyAuth implements Authentication {
final String location; final String location;
final String paramName; final String paramName;
String apiKey; String apiKey;
@@ -9,8 +10,7 @@ class ApiKeyAuth implements Authentication {
ApiKeyAuth(this.location, this.paramName); ApiKeyAuth(this.location, this.paramName);
@override @override
void applyToParams( void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
List<QueryParam> queryParams, Map<String, String> headerParams) {
String value; String value;
if (apiKeyPrefix != null) { if (apiKeyPrefix != null) {
value = '$apiKeyPrefix $apiKey'; value = '$apiKeyPrefix $apiKey';

View File

@@ -1,7 +1,7 @@
part of openapi.api; part of openapi.api;
abstract class Authentication { abstract class Authentication {
/// Apply authentication settings to header and query params.
void applyToParams( /// Apply authentication settings to header and query params.
List<QueryParam> queryParams, Map<String, String> headerParams); void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams);
} }

View File

@@ -1,15 +1,14 @@
part of openapi.api; part of openapi.api;
class HttpBasicAuth implements Authentication { class HttpBasicAuth implements Authentication {
String username; String username;
String password; String password;
@override @override
void applyToParams( void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
List<QueryParam> queryParams, Map<String, String> headerParams) { String str = (username == null ? "" : username) + ":" + (password == null ? "" : password);
String str = (username == null ? "" : username) +
":" +
(password == null ? "" : password);
headerParams["Authorization"] = "Basic " + base64.encode(utf8.encode(str)); headerParams["Authorization"] = "Basic " + base64.encode(utf8.encode(str));
} }
} }

View File

@@ -6,8 +6,7 @@ class OAuth implements Authentication {
OAuth({this.accessToken}); OAuth({this.accessToken});
@override @override
void applyToParams( void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
List<QueryParam> queryParams, Map<String, String> headerParams) {
if (accessToken != null) { if (accessToken != null) {
headerParams["Authorization"] = "Bearer " + accessToken; headerParams["Authorization"] = "Bearer " + accessToken;
} }

View File

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

View File

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

View File

@@ -1,17 +1,18 @@
part of openapi.api; part of openapi.api;
class Order { 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 = false; bool complete = false;
Order(); Order();
@@ -22,13 +23,36 @@ class Order {
Order.fromJson(Map<String, dynamic> json) { Order.fromJson(Map<String, dynamic> json) {
if (json == null) return; if (json == null) return;
id = json['id']; if (json['id'] == null) {
petId = json['petId']; id = null;
quantity = json['quantity']; } else {
shipDate = id = json['id'];
json['shipDate'] == null ? null : DateTime.parse(json['shipDate']); }
status = json['status']; if (json['petId'] == null) {
complete = json['complete']; 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'];
}
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@@ -43,17 +67,15 @@ class Order {
} }
static List<Order> listFromJson(List<dynamic> json) { static List<Order> listFromJson(List<dynamic> json) {
return json == null return json == null ? new List<Order>() : json.map((value) => new Order.fromJson(value)).toList();
? new List<Order>()
: json.map((value) => new Order.fromJson(value)).toList();
} }
static Map<String, Order> mapFromJson(Map<String, dynamic> json) { static Map<String, Order> mapFromJson(Map<String, dynamic> json) {
var map = new Map<String, Order>(); var map = new Map<String, Order>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach( json.forEach((String key, dynamic value) => map[key] = new Order.fromJson(value));
(String key, dynamic value) => map[key] = new Order.fromJson(value));
} }
return map; return map;
} }
} }

View File

@@ -1,14 +1,15 @@
part of openapi.api; part of openapi.api;
class Pet { 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;
@@ -22,14 +23,36 @@ class Pet {
Pet.fromJson(Map<String, dynamic> json) { Pet.fromJson(Map<String, dynamic> json) {
if (json == null) return; if (json == null) return;
id = json['id']; if (json['id'] == null) {
category = new Category.fromJson(json['category']); id = null;
name = json['name']; } else {
photoUrls = ((json['photoUrls'] ?? []) as List) id = json['id'];
.map((item) => item as String) }
.toList(); if (json['category'] == null) {
tags = Tag.listFromJson(json['tags']); category = null;
status = json['status']; } 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'];
}
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@@ -44,17 +67,15 @@ class Pet {
} }
static List<Pet> listFromJson(List<dynamic> json) { static List<Pet> listFromJson(List<dynamic> json) {
return json == null return json == null ? new List<Pet>() : json.map((value) => new Pet.fromJson(value)).toList();
? new List<Pet>()
: json.map((value) => new Pet.fromJson(value)).toList();
} }
static Map<String, Pet> mapFromJson(Map<String, dynamic> json) { static Map<String, Pet> mapFromJson(Map<String, dynamic> json) {
var map = new Map<String, Pet>(); var map = new Map<String, Pet>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach( json.forEach((String key, dynamic value) => map[key] = new Pet.fromJson(value));
(String key, dynamic value) => map[key] = new Pet.fromJson(value));
} }
return map; return map;
} }
} }

View File

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

View File

@@ -1,18 +1,19 @@
part of openapi.api; part of openapi.api;
class User { 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;
@@ -25,14 +26,46 @@ class User {
User.fromJson(Map<String, dynamic> json) { User.fromJson(Map<String, dynamic> json) {
if (json == null) return; if (json == null) return;
id = json['id']; if (json['id'] == null) {
username = json['username']; id = null;
firstName = json['firstName']; } else {
lastName = json['lastName']; id = json['id'];
email = json['email']; }
password = json['password']; if (json['username'] == null) {
phone = json['phone']; username = null;
userStatus = json['userStatus']; } 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'];
}
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@@ -49,17 +82,15 @@ class User {
} }
static List<User> listFromJson(List<dynamic> json) { static List<User> listFromJson(List<dynamic> json) {
return json == null return json == null ? new List<User>() : json.map((value) => new User.fromJson(value)).toList();
? new List<User>()
: json.map((value) => new User.fromJson(value)).toList();
} }
static Map<String, User> mapFromJson(Map<String, dynamic> json) { static Map<String, User> mapFromJson(Map<String, dynamic> json) {
var map = new Map<String, User>(); var map = new Map<String, User>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach( json.forEach((String key, dynamic value) => map[key] = new User.fromJson(value));
(String key, dynamic value) => map[key] = new User.fromJson(value));
} }
return map; return map;
} }
} }

View File

@@ -1 +1 @@
3.3.1-SNAPSHOT 4.0.0-SNAPSHOT

View File

@@ -47,10 +47,10 @@ import 'package:openapi/api.dart';
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
var api_instance = new PetApi(); var api_instance = new PetApi();
var pet = new Pet(); // Pet | Pet object that needs to be added to the store var body = new Pet(); // Pet | Pet object that needs to be added to the store
try { try {
api_instance.addPet(pet); api_instance.addPet(body);
} catch (e) { } catch (e) {
print("Exception when calling PetApi->addPet: $e\n"); print("Exception when calling PetApi->addPet: $e\n");
} }

View File

@@ -20,7 +20,7 @@ Method | HTTP request | Description
# **addPet** # **addPet**
> addPet(pet) > addPet(body)
Add a new pet to the store Add a new pet to the store
@@ -31,10 +31,10 @@ import 'package:openapi/api.dart';
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
var api_instance = new PetApi(); var api_instance = new PetApi();
var pet = new Pet(); // Pet | Pet object that needs to be added to the store var body = new Pet(); // Pet | Pet object that needs to be added to the store
try { try {
api_instance.addPet(pet); api_instance.addPet(body);
} catch (e) { } catch (e) {
print("Exception when calling PetApi->addPet: $e\n"); print("Exception when calling PetApi->addPet: $e\n");
} }
@@ -44,7 +44,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
### Return type ### Return type
@@ -243,7 +243,7 @@ Name | Type | Description | Notes
[[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)
# **updatePet** # **updatePet**
> updatePet(pet) > updatePet(body)
Update an existing pet Update an existing pet
@@ -254,10 +254,10 @@ import 'package:openapi/api.dart';
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
var api_instance = new PetApi(); var api_instance = new PetApi();
var pet = new Pet(); // Pet | Pet object that needs to be added to the store var body = new Pet(); // Pet | Pet object that needs to be added to the store
try { try {
api_instance.updatePet(pet); api_instance.updatePet(body);
} catch (e) { } catch (e) {
print("Exception when calling PetApi->updatePet: $e\n"); print("Exception when calling PetApi->updatePet: $e\n");
} }
@@ -267,7 +267,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
### Return type ### Return type

View File

@@ -144,7 +144,7 @@ No authorization required
[[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)
# **placeOrder** # **placeOrder**
> Order placeOrder(order) > Order placeOrder(body)
Place an order for a pet Place an order for a pet
@@ -153,10 +153,10 @@ Place an order for a pet
import 'package:openapi/api.dart'; import 'package:openapi/api.dart';
var api_instance = new StoreApi(); var api_instance = new StoreApi();
var order = new Order(); // Order | order placed for purchasing the pet var body = new Order(); // Order | order placed for purchasing the pet
try { try {
var result = api_instance.placeOrder(order); var result = api_instance.placeOrder(body);
print(result); print(result);
} catch (e) { } catch (e) {
print("Exception when calling StoreApi->placeOrder: $e\n"); print("Exception when calling StoreApi->placeOrder: $e\n");
@@ -167,7 +167,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**order** | [**Order**](Order.md)| order placed for purchasing the pet | **body** | [**Order**](Order.md)| order placed for purchasing the pet |
### Return type ### Return type

View File

@@ -20,7 +20,7 @@ Method | HTTP request | Description
# **createUser** # **createUser**
> createUser(user) > createUser(body)
Create user Create user
@@ -31,10 +31,10 @@ This can only be done by the logged in user.
import 'package:openapi/api.dart'; import 'package:openapi/api.dart';
var api_instance = new UserApi(); var api_instance = new UserApi();
var user = new User(); // User | Created user object var body = new User(); // User | Created user object
try { try {
api_instance.createUser(user); api_instance.createUser(body);
} catch (e) { } catch (e) {
print("Exception when calling UserApi->createUser: $e\n"); print("Exception when calling UserApi->createUser: $e\n");
} }
@@ -44,7 +44,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**user** | [**User**](User.md)| Created user object | **body** | [**User**](User.md)| Created user object |
### Return type ### Return type
@@ -62,7 +62,7 @@ No authorization required
[[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)
# **createUsersWithArrayInput** # **createUsersWithArrayInput**
> createUsersWithArrayInput(user) > createUsersWithArrayInput(body)
Creates list of users with given input array Creates list of users with given input array
@@ -71,10 +71,10 @@ Creates list of users with given input array
import 'package:openapi/api.dart'; import 'package:openapi/api.dart';
var api_instance = new UserApi(); var api_instance = new UserApi();
var user = [new List&lt;User&gt;()]; // List<User> | List of user object var body = [new List&lt;User&gt;()]; // List<User> | List of user object
try { try {
api_instance.createUsersWithArrayInput(user); api_instance.createUsersWithArrayInput(body);
} catch (e) { } catch (e) {
print("Exception when calling UserApi->createUsersWithArrayInput: $e\n"); print("Exception when calling UserApi->createUsersWithArrayInput: $e\n");
} }
@@ -84,7 +84,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**user** | [**List&lt;User&gt;**](List.md)| List of user object | **body** | [**List&lt;User&gt;**](List.md)| List of user object |
### Return type ### Return type
@@ -102,7 +102,7 @@ No authorization required
[[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)
# **createUsersWithListInput** # **createUsersWithListInput**
> createUsersWithListInput(user) > createUsersWithListInput(body)
Creates list of users with given input array Creates list of users with given input array
@@ -111,10 +111,10 @@ Creates list of users with given input array
import 'package:openapi/api.dart'; import 'package:openapi/api.dart';
var api_instance = new UserApi(); var api_instance = new UserApi();
var user = [new List&lt;User&gt;()]; // List<User> | List of user object var body = [new List&lt;User&gt;()]; // List<User> | List of user object
try { try {
api_instance.createUsersWithListInput(user); api_instance.createUsersWithListInput(body);
} catch (e) { } catch (e) {
print("Exception when calling UserApi->createUsersWithListInput: $e\n"); print("Exception when calling UserApi->createUsersWithListInput: $e\n");
} }
@@ -124,7 +124,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**user** | [**List&lt;User&gt;**](List.md)| List of user object | **body** | [**List&lt;User&gt;**](List.md)| List of user object |
### Return type ### Return type
@@ -304,7 +304,7 @@ No authorization required
[[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)
# **updateUser** # **updateUser**
> updateUser(username, user) > updateUser(username, body)
Updated user Updated user
@@ -316,10 +316,10 @@ import 'package:openapi/api.dart';
var api_instance = new UserApi(); var api_instance = new UserApi();
var username = username_example; // String | name that need to be deleted var username = username_example; // String | name that need to be deleted
var user = new User(); // User | Updated user object var body = new User(); // User | Updated user object
try { try {
api_instance.updateUser(username, user); api_instance.updateUser(username, body);
} catch (e) { } catch (e) {
print("Exception when calling UserApi->updateUser: $e\n"); print("Exception when calling UserApi->updateUser: $e\n");
} }
@@ -330,7 +330,7 @@ try {
Name | Type | Description | Notes Name | Type | Description | Notes
------------- | ------------- | ------------- | ------------- ------------- | ------------- | ------------- | -------------
**username** | **String**| name that need to be deleted | [default to null] **username** | **String**| name that need to be deleted | [default to null]
**user** | [**User**](User.md)| Updated user object | **body** | [**User**](User.md)| Updated user object |
### Return type ### Return type

View File

@@ -24,4 +24,5 @@ part 'model/pet.dart';
part 'model/tag.dart'; part 'model/tag.dart';
part 'model/user.dart'; part 'model/user.dart';
ApiClient defaultApiClient = ApiClient(); ApiClient defaultApiClient = ApiClient();

View File

@@ -1,5 +1,7 @@
part of openapi.api; part of openapi.api;
class PetApi { class PetApi {
final ApiClient apiClient; final ApiClient apiClient;
@@ -7,60 +9,66 @@ class PetApi {
/// Add a new pet to the store /// Add a new pet to the store
/// ///
/// ///
Future addPet(Pet pet) async { Future addPet(Pet body) async {
Object postBody = pet; Object postBody = body;
// verify required params are set // verify required params are set
if (pet == null) { if(body == null) {
throw new ApiException(400, "Missing required param: pet"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/pet".replaceAll("{format}", "json"); String path = "/pet".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
List<String> contentTypes = ["application/json", "application/xml"]; List<String> contentTypes = ["application/json","application/xml"];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Deletes a pet /// Deletes a pet
/// ///
/// ///
Future deletePet(int petId, {String apiKey}) async { Future deletePet(int petId, { String apiKey }) async {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
if (petId == null) { if(petId == null) {
throw new ApiException(400, "Missing required param: petId"); throw new ApiException(400, "Missing required param: petId");
} }
// create path and map variables // create path and map variables
String path = "/pet/{petId}" String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "petId" + "}", petId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -70,26 +78,34 @@ class PetApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'DELETE',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Finds Pets by status /// Finds Pets by status
/// ///
/// Multiple status values can be provided with comma separated strings /// Multiple status values can be provided with comma separated strings
@@ -97,46 +113,50 @@ class PetApi {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
if (status == null) { if(status == null) {
throw new ApiException(400, "Missing required param: status"); throw new ApiException(400, "Missing required param: status");
} }
// create path and map variables // create path and map variables
String path = "/pet/findByStatus".replaceAll("{format}", "json"); String path = "/pet/findByStatus".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
queryParams queryParams.addAll(_convertParametersForCollectionFormat("csv", "status", status));
.addAll(_convertParametersForCollectionFormat("csv", "status", status));
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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) return (apiClient.deserialize(response.body, 'List<Pet>') as List).map((item) => item as Pet).toList();
.map((item) => item as Pet)
.toList();
} else { } else {
return null; return null;
} }
} }
/// Finds Pets by tags /// Finds Pets by tags
/// ///
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
@@ -144,46 +164,50 @@ class PetApi {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
if (tags == null) { if(tags == null) {
throw new ApiException(400, "Missing required param: tags"); throw new ApiException(400, "Missing required param: tags");
} }
// create path and map variables // create path and map variables
String path = "/pet/findByTags".replaceAll("{format}", "json"); String path = "/pet/findByTags".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
queryParams queryParams.addAll(_convertParametersForCollectionFormat("csv", "tags", tags));
.addAll(_convertParametersForCollectionFormat("csv", "tags", tags));
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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) return (apiClient.deserialize(response.body, 'List<Pet>') as List).map((item) => item as Pet).toList();
.map((item) => item as Pet)
.toList();
} else { } else {
return null; return null;
} }
} }
/// Find pet by ID /// Find pet by ID
/// ///
/// Returns a single pet /// Returns a single pet
@@ -191,14 +215,12 @@ class PetApi {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
if (petId == null) { if(petId == null) {
throw new ApiException(400, "Missing required param: petId"); throw new ApiException(400, "Missing required param: petId");
} }
// create path and map variables // create path and map variables
String path = "/pet/{petId}" String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "petId" + "}", petId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -207,84 +229,97 @@ class PetApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["api_key"]; List<String> authNames = ["api_key"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'Pet') as Pet; return apiClient.deserialize(response.body, 'Pet') as Pet;
} else { } else {
return null; return null;
} }
} }
/// Update an existing pet /// Update an existing pet
/// ///
/// ///
Future updatePet(Pet pet) async { Future updatePet(Pet body) async {
Object postBody = pet; Object postBody = body;
// verify required params are set // verify required params are set
if (pet == null) { if(body == null) {
throw new ApiException(400, "Missing required param: pet"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/pet".replaceAll("{format}", "json"); String path = "/pet".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
List<String> contentTypes = ["application/json", "application/xml"]; List<String> contentTypes = ["application/json","application/xml"];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'PUT', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'PUT',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Updates a pet in the store with form data /// Updates a pet in the store with form data
/// ///
/// ///
Future updatePetWithForm(int petId, {String name, String status}) async { Future updatePetWithForm(int petId, { String name, String status }) async {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
if (petId == null) { if(petId == null) {
throw new ApiException(400, "Missing required param: petId"); throw new ApiException(400, "Missing required param: petId");
} }
// create path and map variables // create path and map variables
String path = "/pet/{petId}" String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "petId" + "}", petId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -293,11 +328,10 @@ class PetApi {
List<String> contentTypes = ["application/x-www-form-urlencoded"]; List<String> contentTypes = ["application/x-www-form-urlencoded"];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (name != null) { if (name != null) {
@@ -308,38 +342,45 @@ class PetApi {
hasFields = true; hasFields = true;
mp.fields['status'] = parameterToString(status); mp.fields['status'] = parameterToString(status);
} }
if (hasFields) postBody = mp; if(hasFields)
} else { postBody = mp;
if (name != null) formParams['name'] = parameterToString(name); }
if (status != null) formParams['status'] = parameterToString(status); else {
if (name != null)
formParams['name'] = parameterToString(name);
if (status != null)
formParams['status'] = parameterToString(status);
} }
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// uploads an image /// uploads an image
/// ///
/// ///
Future<ApiResponse> uploadFile(int petId, Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async {
{String additionalMetadata, MultipartFile file}) async {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
if (petId == null) { if(petId == null) {
throw new ApiException(400, "Missing required param: petId"); throw new ApiException(400, "Missing required param: petId");
} }
// create path and map variables // create path and map variables
String path = "/pet/{petId}/uploadImage" String path = "/pet/{petId}/uploadImage".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "petId" + "}", petId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -348,11 +389,10 @@ class PetApi {
List<String> contentTypes = ["multipart/form-data"]; List<String> contentTypes = ["multipart/form-data"];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["petstore_auth"]; List<String> authNames = ["petstore_auth"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (additionalMetadata != null) { if (additionalMetadata != null) {
@@ -364,19 +404,26 @@ class PetApi {
mp.fields['file'] = file.field; mp.fields['file'] = file.field;
mp.files.add(file); mp.files.add(file);
} }
if (hasFields) postBody = mp; if(hasFields)
} else { postBody = mp;
}
else {
if (additionalMetadata != null) if (additionalMetadata != null)
formParams['additionalMetadata'] = formParams['additionalMetadata'] = parameterToString(additionalMetadata);
parameterToString(additionalMetadata);
} }
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'ApiResponse') as ApiResponse; return apiClient.deserialize(response.body, 'ApiResponse') as ApiResponse;
} else { } else {
return null; return null;

View File

@@ -1,5 +1,7 @@
part of openapi.api; part of openapi.api;
class StoreApi { class StoreApi {
final ApiClient apiClient; final ApiClient apiClient;
@@ -12,14 +14,12 @@ class StoreApi {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
if (orderId == null) { if(orderId == null) {
throw new ApiException(400, "Missing required param: orderId"); throw new ApiException(400, "Missing required param: orderId");
} }
// create path and map variables // create path and map variables
String path = "/store/order/{orderId}" String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "orderId" + "}", orderId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -28,26 +28,34 @@ class StoreApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'DELETE',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Returns pet inventories by status /// Returns pet inventories by status
/// ///
/// Returns a map of status codes to quantities /// Returns a map of status codes to quantities
@@ -57,7 +65,7 @@ class StoreApi {
// verify required params are set // verify required params are set
// create path and map variables // create path and map variables
String path = "/store/inventory".replaceAll("{format}", "json"); String path = "/store/inventory".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -66,30 +74,36 @@ class StoreApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = ["api_key"]; List<String> authNames = ["api_key"];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 new Map<String, int>.from( return new Map<String, int>.from(apiClient.deserialize(response.body, 'Map<String, int>'));
apiClient.deserialize(response.body, 'Map<String, int>')); ;
;
} else { } else {
return null; return null;
} }
} }
/// Find purchase order by ID /// Find purchase order by ID
/// ///
/// For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions /// For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
@@ -97,14 +111,12 @@ class StoreApi {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
if (orderId == null) { if(orderId == null) {
throw new ApiException(400, "Missing required param: orderId"); throw new ApiException(400, "Missing required param: orderId");
} }
// create path and map variables // create path and map variables
String path = "/store/order/{orderId}" String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "orderId" + "}", orderId.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -113,41 +125,48 @@ class StoreApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'Order') as Order; return apiClient.deserialize(response.body, 'Order') as Order;
} else { } else {
return null; return null;
} }
} }
/// Place an order for a pet /// Place an order for a pet
/// ///
/// ///
Future<Order> placeOrder(Order order) async { Future<Order> placeOrder(Order body) async {
Object postBody = order; Object postBody = body;
// verify required params are set // verify required params are set
if (order == null) { if(body == null) {
throw new ApiException(400, "Missing required param: order"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/store/order".replaceAll("{format}", "json"); String path = "/store/order".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -156,22 +175,30 @@ class StoreApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'Order') as Order; return apiClient.deserialize(response.body, 'Order') as Order;
} else { } else {
return null; return null;

View File

@@ -1,5 +1,7 @@
part of openapi.api; part of openapi.api;
class UserApi { class UserApi {
final ApiClient apiClient; final ApiClient apiClient;
@@ -8,16 +10,16 @@ class UserApi {
/// Create user /// Create user
/// ///
/// This can only be done by the logged in user. /// This can only be done by the logged in user.
Future createUser(User user) async { Future createUser(User body) async {
Object postBody = user; Object postBody = body;
// verify required params are set // verify required params are set
if (user == null) { if(body == null) {
throw new ApiException(400, "Missing required param: user"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/user".replaceAll("{format}", "json"); String path = "/user".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -26,39 +28,47 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Creates list of users with given input array /// Creates list of users with given input array
/// ///
/// ///
Future createUsersWithArrayInput(List<User> user) async { Future createUsersWithArrayInput(List<User> body) async {
Object postBody = user; Object postBody = body;
// verify required params are set // verify required params are set
if (user == null) { if(body == null) {
throw new ApiException(400, "Missing required param: user"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/user/createWithArray".replaceAll("{format}", "json"); String path = "/user/createWithArray".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -67,39 +77,47 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Creates list of users with given input array /// Creates list of users with given input array
/// ///
/// ///
Future createUsersWithListInput(List<User> user) async { Future createUsersWithListInput(List<User> body) async {
Object postBody = user; Object postBody = body;
// verify required params are set // verify required params are set
if (user == null) { if(body == null) {
throw new ApiException(400, "Missing required param: user"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/user/createWithList".replaceAll("{format}", "json"); String path = "/user/createWithList".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -108,26 +126,34 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'POST', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'POST',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Delete user /// Delete user
/// ///
/// This can only be done by the logged in user. /// This can only be done by the logged in user.
@@ -135,14 +161,12 @@ class UserApi {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
if (username == null) { if(username == null) {
throw new ApiException(400, "Missing required param: username"); throw new ApiException(400, "Missing required param: username");
} }
// create path and map variables // create path and map variables
String path = "/user/{username}" String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "username" + "}", username.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -151,41 +175,47 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, var response = await apiClient.invokeAPI(path,
postBody, headerParams, formParams, contentType, authNames); 'DELETE',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Get user by user name /// Get user by user name
/// ///
/// ///
Future<User> getUserByName(String username) async { Future<User> getUserByName(String username) async {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
if (username == null) { if(username == null) {
throw new ApiException(400, "Missing required param: username"); throw new ApiException(400, "Missing required param: username");
} }
// create path and map variables // create path and map variables
String path = "/user/{username}" String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "username" + "}", username.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -194,88 +224,100 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'User') as User; return apiClient.deserialize(response.body, 'User') as User;
} else { } else {
return null; return null;
} }
} }
/// Logs user into the system /// Logs user into the system
/// ///
/// ///
Future<String> loginUser(String username, String password) async { Future<String> loginUser(String username, String password) async {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
if (username == null) { if(username == null) {
throw new ApiException(400, "Missing required param: username"); throw new ApiException(400, "Missing required param: username");
} }
if (password == null) { if(password == null) {
throw new ApiException(400, "Missing required param: password"); throw new ApiException(400, "Missing required param: password");
} }
// create path and map variables // create path and map variables
String path = "/user/login".replaceAll("{format}", "json"); String path = "/user/login".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
Map<String, String> headerParams = {}; Map<String, String> headerParams = {};
Map<String, String> formParams = {}; Map<String, String> formParams = {};
queryParams.addAll( queryParams.addAll(_convertParametersForCollectionFormat("", "username", username));
_convertParametersForCollectionFormat("", "username", username)); queryParams.addAll(_convertParametersForCollectionFormat("", "password", password));
queryParams.addAll(
_convertParametersForCollectionFormat("", "password", password));
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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, 'String') as String; return apiClient.deserialize(response.body, 'String') as String;
} else { } else {
return null; return null;
} }
} }
/// Logs out current logged in user session /// Logs out current logged in user session
/// ///
/// ///
Future logoutUser() async { Future logoutUser() async {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
// create path and map variables // create path and map variables
String path = "/user/logout".replaceAll("{format}", "json"); String path = "/user/logout".replaceAll("{format}","json");
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -284,44 +326,50 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'GET',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }
/// Updated user /// Updated user
/// ///
/// This can only be done by the logged in user. /// This can only be done by the logged in user.
Future updateUser(String username, User user) async { Future updateUser(String username, User body) async {
Object postBody = user; Object postBody = body;
// verify required params are set // verify required params are set
if (username == null) { if(username == null) {
throw new ApiException(400, "Missing required param: username"); throw new ApiException(400, "Missing required param: username");
} }
if (user == null) { if(body == null) {
throw new ApiException(400, "Missing required param: user"); throw new ApiException(400, "Missing required param: body");
} }
// create path and map variables // create path and map variables
String path = "/user/{username}" String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString());
.replaceAll("{format}", "json")
.replaceAll("{" + "username" + "}", username.toString());
// query params // query params
List<QueryParam> queryParams = []; List<QueryParam> queryParams = [];
@@ -330,22 +378,31 @@ class UserApi {
List<String> contentTypes = []; List<String> contentTypes = [];
String contentType = String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
contentTypes.length > 0 ? contentTypes[0] : "application/json";
List<String> authNames = []; List<String> authNames = [];
if (contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false; bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null); MultipartRequest mp = new MultipartRequest(null, null);
if (hasFields) postBody = mp; if(hasFields)
} else {} postBody = mp;
}
else {
}
var response = await apiClient.invokeAPI(path, 'PUT', queryParams, postBody, var response = await apiClient.invokeAPI(path,
headerParams, formParams, contentType, authNames); 'PUT',
queryParams,
postBody,
headerParams,
formParams,
contentType,
authNames);
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 { } else if(response.body != null) {
} else {
return; return;
} }
} }

View File

@@ -8,6 +8,7 @@ class QueryParam {
} }
class ApiClient { class ApiClient {
String basePath; String basePath;
var client = BrowserClient(); var client = BrowserClient();
@@ -24,7 +25,7 @@ class ApiClient {
} }
void addDefaultHeader(String key, String value) { void addDefaultHeader(String key, String value) {
_defaultHeaderMap[key] = value; _defaultHeaderMap[key] = value;
} }
dynamic _deserialize(dynamic value, String targetType) { dynamic _deserialize(dynamic value, String targetType) {
@@ -66,11 +67,9 @@ class ApiClient {
} }
} }
} on Exception catch (e, stack) { } on Exception catch (e, stack) {
throw ApiException.withInner( throw ApiException.withInner(500, 'Exception during deserialization.', e, stack);
500, 'Exception during deserialization.', e, stack);
} }
throw ApiException( throw ApiException(500, 'Could not find a suitable class for deserialization');
500, 'Could not find a suitable class for deserialization');
} }
dynamic deserialize(String json, String targetType) { dynamic deserialize(String json, String targetType) {
@@ -95,28 +94,28 @@ class ApiClient {
// We don't use a Map<String, String> for queryParams. // We don't use a Map<String, String> for queryParams.
// If collectionFormat is 'multi' a key might appear multiple times. // If collectionFormat is 'multi' a key might appear multiple times.
Future<Response> invokeAPI( Future<Response> invokeAPI(String path,
String path, String method,
String method, Iterable<QueryParam> queryParams,
Iterable<QueryParam> queryParams, Object body,
Object body, Map<String, String> headerParams,
Map<String, String> headerParams, Map<String, String> formParams,
Map<String, String> formParams, String contentType,
String contentType, List<String> authNames) async {
List<String> authNames) async {
_updateParamsForAuth(authNames, queryParams, headerParams); _updateParamsForAuth(authNames, queryParams, headerParams);
var ps = queryParams var ps = queryParams.where((p) => p.value != null).map((p) => '${p.name}=${p.value}');
.where((p) => p.value != null) String queryString = ps.isNotEmpty ?
.map((p) => '${p.name}=${p.value}'); '?' + ps.join('&') :
String queryString = ps.isNotEmpty ? '?' + ps.join('&') : ''; '';
String url = basePath + path + queryString; String url = basePath + path + queryString;
headerParams.addAll(_defaultHeaderMap); headerParams.addAll(_defaultHeaderMap);
headerParams['Content-Type'] = contentType; headerParams['Content-Type'] = contentType;
if (body is MultipartRequest) { if(body is MultipartRequest) {
var request = MultipartRequest(method, Uri.parse(url)); var request = MultipartRequest(method, Uri.parse(url));
request.fields.addAll(body.fields); request.fields.addAll(body.fields);
request.files.addAll(body.files); request.files.addAll(body.files);
@@ -125,10 +124,8 @@ class ApiClient {
var response = await client.send(request); var response = await client.send(request);
return Response.fromStream(response); return Response.fromStream(response);
} else { } else {
var msgBody = contentType == "application/x-www-form-urlencoded" var msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body);
? formParams switch(method) {
: serialize(body);
switch (method) {
case "POST": case "POST":
return client.post(url, headers: headerParams, body: msgBody); return client.post(url, headers: headerParams, body: msgBody);
case "PUT": case "PUT":
@@ -145,12 +142,10 @@ class ApiClient {
/// Update query and header parameters based on authentication settings. /// Update query and header parameters based on authentication settings.
/// @param authNames The authentications to apply /// @param authNames The authentications to apply
void _updateParamsForAuth(List<String> authNames, void _updateParamsForAuth(List<String> authNames, List<QueryParam> queryParams, Map<String, String> headerParams) {
List<QueryParam> queryParams, Map<String, String> headerParams) {
authNames.forEach((authName) { authNames.forEach((authName) {
Authentication auth = _authentications[authName]; Authentication auth = _authentications[authName];
if (auth == null) if (auth == null) throw ArgumentError("Authentication undefined: " + authName);
throw ArgumentError("Authentication undefined: " + authName);
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams);
}); });
} }

Some files were not shown because too many files have changed in this diff Show More