[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) {
if (json == null) return;
{{#vars}}
if (json['{{baseName}}'] == null) {
{{name}} = null;
} else {
{{#isDateTime}}
{{name}} = json['{{baseName}}'] == null ? null : DateTime.parse(json['{{baseName}}']);
{{name}} = DateTime.parse(json['{{baseName}}']);
{{/isDateTime}}
{{#isDate}}
{{name}} = json['{{baseName}}'] == null ? null : DateTime.parse(json['{{baseName}}']);
{{name}} = DateTime.parse(json['{{baseName}}']);
{{/isDate}}
{{^isDateTime}}
{{^isDate}}
{{#complexType}}
{{#isListContainer}}
{{name}} = {{complexType}}.listFromJson(json['{{baseName}}']);
{{name}} = {{complexType}}.listFromJson(json['{{baseName}}']);
{{/isListContainer}}
{{^isListContainer}}
{{#isMapContainer}}
{{name}} = {{complexType}}.mapFromJson(json['{{baseName}}']);
{{name}} = {{complexType}}.mapFromJson(json['{{baseName}}']);
{{/isMapContainer}}
{{^isMapContainer}}
{{name}} = new {{complexType}}.fromJson(json['{{baseName}}']);
{{name}} = new {{complexType}}.fromJson(json['{{baseName}}']);
{{/isMapContainer}}
{{/isListContainer}}
{{/complexType}}
{{^complexType}}
{{#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}}
{{name}} = json['{{baseName}}'];
{{name}} = json['{{baseName}}'];
{{/isListContainer}}
{{/complexType}}
{{/isDate}}
{{/isDateTime}}
}
{{/vars}}
}

View File

@ -16,37 +16,41 @@ class {{classname}} {
{{classname}}.fromJson(Map<String, dynamic> json) {
if (json == null) return;
{{#vars}}
if (json['{{baseName}}'] == null) {
{{name}} = null;
} else {
{{#isDateTime}}
{{name}} = json['{{baseName}}'] == null ? null : DateTime.parse(json['{{baseName}}']);
{{name}} = DateTime.parse(json['{{baseName}}']);
{{/isDateTime}}
{{#isDate}}
{{name}} = json['{{baseName}}'] == null ? null : DateTime.parse(json['{{baseName}}']);
{{name}} = DateTime.parse(json['{{baseName}}']);
{{/isDate}}
{{^isDateTime}}
{{^isDate}}
{{#complexType}}
{{#isListContainer}}
{{name}} = {{complexType}}.listFromJson(json['{{baseName}}']);
{{name}} = {{complexType}}.listFromJson(json['{{baseName}}']);
{{/isListContainer}}
{{^isListContainer}}
{{#isMapContainer}}
{{name}} = {{complexType}}.mapFromJson(json['{{baseName}}']);
{{name}} = {{complexType}}.mapFromJson(json['{{baseName}}']);
{{/isMapContainer}}
{{^isMapContainer}}
{{name}} = new {{complexType}}.fromJson(json['{{baseName}}']);
{{name}} = new {{complexType}}.fromJson(json['{{baseName}}']);
{{/isMapContainer}}
{{/isListContainer}}
{{/complexType}}
{{^complexType}}
{{#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}}
{{name}} = json['{{baseName}}'];
{{name}} = json['{{baseName}}'];
{{/isListContainer}}
{{/complexType}}
{{/isDate}}
{{/isDateTime}}
}
{{/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';
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 {
api_instance.addPet(pet);
api_instance.addPet(body);
} catch (e) {
print("Exception when calling PetApi->addPet: $e\n");
}

View File

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

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)
# **placeOrder**
> Order placeOrder(order)
> Order placeOrder(body)
Place an order for a pet
@ -153,10 +153,10 @@ Place an order for a pet
import 'package:openapi/api.dart';
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 {
var result = api_instance.placeOrder(order);
var result = api_instance.placeOrder(body);
print(result);
} catch (e) {
print("Exception when calling StoreApi->placeOrder: $e\n");
@ -167,7 +167,7 @@ try {
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

View File

@ -20,7 +20,7 @@ Method | HTTP request | Description
# **createUser**
> createUser(user)
> createUser(body)
Create user
@ -31,10 +31,10 @@ This can only be done by the logged in user.
import 'package:openapi/api.dart';
var api_instance = new UserApi();
var user = new User(); // User | Created user object
var body = new User(); // User | Created user object
try {
api_instance.createUser(user);
api_instance.createUser(body);
} catch (e) {
print("Exception when calling UserApi->createUser: $e\n");
}
@ -44,7 +44,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**user** | [**User**](User.md)| Created user object |
**body** | [**User**](User.md)| Created user object |
### 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)
# **createUsersWithArrayInput**
> createUsersWithArrayInput(user)
> createUsersWithArrayInput(body)
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';
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 {
api_instance.createUsersWithArrayInput(user);
api_instance.createUsersWithArrayInput(body);
} catch (e) {
print("Exception when calling UserApi->createUsersWithArrayInput: $e\n");
}
@ -84,7 +84,7 @@ try {
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
@ -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)
# **createUsersWithListInput**
> createUsersWithListInput(user)
> createUsersWithListInput(body)
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';
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 {
api_instance.createUsersWithListInput(user);
api_instance.createUsersWithListInput(body);
} catch (e) {
print("Exception when calling UserApi->createUsersWithListInput: $e\n");
}
@ -124,7 +124,7 @@ try {
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
@ -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)
# **updateUser**
> updateUser(username, user)
> updateUser(username, body)
Updated user
@ -316,10 +316,10 @@ import 'package:openapi/api.dart';
var api_instance = new UserApi();
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 {
api_instance.updateUser(username, user);
api_instance.updateUser(username, body);
} catch (e) {
print("Exception when calling UserApi->updateUser: $e\n");
}
@ -330,7 +330,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,18 +1,19 @@
part of openapi.api;
class User {
int id = null;
String username = null;
String firstName = null;
String lastName = null;
String email = null;
String password = null;
String phone = null;
/* User Status */
int userStatus = null;
@ -25,14 +26,46 @@ class User {
User.fromJson(Map<String, dynamic> json) {
if (json == null) return;
id = json['id'];
username = json['username'];
firstName = json['firstName'];
lastName = json['lastName'];
email = json['email'];
password = json['password'];
phone = json['phone'];
userStatus = json['userStatus'];
if (json['id'] == null) {
id = null;
} else {
id = json['id'];
}
if (json['username'] == null) {
username = null;
} else {
username = json['username'];
}
if (json['firstName'] == null) {
firstName = null;
} else {
firstName = json['firstName'];
}
if (json['lastName'] == null) {
lastName = null;
} else {
lastName = json['lastName'];
}
if (json['email'] == null) {
email = null;
} else {
email = json['email'];
}
if (json['password'] == null) {
password = null;
} else {
password = json['password'];
}
if (json['phone'] == null) {
phone = null;
} else {
phone = json['phone'];
}
if (json['userStatus'] == null) {
userStatus = null;
} else {
userStatus = json['userStatus'];
}
}
Map<String, dynamic> toJson() {
@ -49,17 +82,15 @@ class User {
}
static List<User> listFromJson(List<dynamic> json) {
return json == null
? new List<User>()
: json.map((value) => new User.fromJson(value)).toList();
return json == null ? new List<User>() : json.map((value) => new User.fromJson(value)).toList();
}
static Map<String, User> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, User>();
if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) =>
map[key] = new User.fromJson(value));
json.forEach((String key, Map<String, dynamic> value) => map[key] = new User.fromJson(value));
}
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';
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 {
api_instance.addPet(pet);
api_instance.addPet(body);
} catch (e) {
print("Exception when calling PetApi->addPet: $e\n");
}

View File

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

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)
# **placeOrder**
> Order placeOrder(order)
> Order placeOrder(body)
Place an order for a pet
@ -153,10 +153,10 @@ Place an order for a pet
import 'package:openapi/api.dart';
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 {
var result = api_instance.placeOrder(order);
var result = api_instance.placeOrder(body);
print(result);
} catch (e) {
print("Exception when calling StoreApi->placeOrder: $e\n");
@ -167,7 +167,7 @@ try {
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

View File

@ -20,7 +20,7 @@ Method | HTTP request | Description
# **createUser**
> createUser(user)
> createUser(body)
Create user
@ -31,10 +31,10 @@ This can only be done by the logged in user.
import 'package:openapi/api.dart';
var api_instance = new UserApi();
var user = new User(); // User | Created user object
var body = new User(); // User | Created user object
try {
api_instance.createUser(user);
api_instance.createUser(body);
} catch (e) {
print("Exception when calling UserApi->createUser: $e\n");
}
@ -44,7 +44,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**user** | [**User**](User.md)| Created user object |
**body** | [**User**](User.md)| Created user object |
### 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)
# **createUsersWithArrayInput**
> createUsersWithArrayInput(user)
> createUsersWithArrayInput(body)
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';
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 {
api_instance.createUsersWithArrayInput(user);
api_instance.createUsersWithArrayInput(body);
} catch (e) {
print("Exception when calling UserApi->createUsersWithArrayInput: $e\n");
}
@ -84,7 +84,7 @@ try {
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
@ -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)
# **createUsersWithListInput**
> createUsersWithListInput(user)
> createUsersWithListInput(body)
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';
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 {
api_instance.createUsersWithListInput(user);
api_instance.createUsersWithListInput(body);
} catch (e) {
print("Exception when calling UserApi->createUsersWithListInput: $e\n");
}
@ -124,7 +124,7 @@ try {
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
@ -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)
# **updateUser**
> updateUser(username, user)
> updateUser(username, body)
Updated user
@ -316,10 +316,10 @@ import 'package:openapi/api.dart';
var api_instance = new UserApi();
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 {
api_instance.updateUser(username, user);
api_instance.updateUser(username, body);
} catch (e) {
print("Exception when calling UserApi->updateUser: $e\n");
}
@ -330,7 +330,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,18 +1,19 @@
part of openapi.api;
class User {
int id = null;
String username = null;
String firstName = null;
String lastName = null;
String email = null;
String password = null;
String phone = null;
/* User Status */
int userStatus = null;
@ -25,14 +26,46 @@ class User {
User.fromJson(Map<String, dynamic> json) {
if (json == null) return;
id = json['id'];
username = json['username'];
firstName = json['firstName'];
lastName = json['lastName'];
email = json['email'];
password = json['password'];
phone = json['phone'];
userStatus = json['userStatus'];
if (json['id'] == null) {
id = null;
} else {
id = json['id'];
}
if (json['username'] == null) {
username = null;
} else {
username = json['username'];
}
if (json['firstName'] == null) {
firstName = null;
} else {
firstName = json['firstName'];
}
if (json['lastName'] == null) {
lastName = null;
} else {
lastName = json['lastName'];
}
if (json['email'] == null) {
email = null;
} else {
email = json['email'];
}
if (json['password'] == null) {
password = null;
} else {
password = json['password'];
}
if (json['phone'] == null) {
phone = null;
} else {
phone = json['phone'];
}
if (json['userStatus'] == null) {
userStatus = null;
} else {
userStatus = json['userStatus'];
}
}
Map<String, dynamic> toJson() {
@ -49,17 +82,15 @@ class User {
}
static List<User> listFromJson(List<dynamic> json) {
return json == null
? new List<User>()
: json.map((value) => new User.fromJson(value)).toList();
return json == null ? new List<User>() : json.map((value) => new User.fromJson(value)).toList();
}
static Map<String, User> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, User>();
if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) =>
map[key] = new User.fromJson(value));
json.forEach((String key, Map<String, dynamic> value) => map[key] = new User.fromJson(value));
}
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';
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 {
api_instance.addPet(pet);
api_instance.addPet(body);
} catch (e) {
print("Exception when calling PetApi->addPet: $e\n");
}

View File

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

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)
# **placeOrder**
> Order placeOrder(order)
> Order placeOrder(body)
Place an order for a pet
@ -153,10 +153,10 @@ Place an order for a pet
import 'package:openapi/api.dart';
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 {
var result = api_instance.placeOrder(order);
var result = api_instance.placeOrder(body);
print(result);
} catch (e) {
print("Exception when calling StoreApi->placeOrder: $e\n");
@ -167,7 +167,7 @@ try {
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

View File

@ -20,7 +20,7 @@ Method | HTTP request | Description
# **createUser**
> createUser(user)
> createUser(body)
Create user
@ -31,10 +31,10 @@ This can only be done by the logged in user.
import 'package:openapi/api.dart';
var api_instance = new UserApi();
var user = new User(); // User | Created user object
var body = new User(); // User | Created user object
try {
api_instance.createUser(user);
api_instance.createUser(body);
} catch (e) {
print("Exception when calling UserApi->createUser: $e\n");
}
@ -44,7 +44,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**user** | [**User**](User.md)| Created user object |
**body** | [**User**](User.md)| Created user object |
### 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)
# **createUsersWithArrayInput**
> createUsersWithArrayInput(user)
> createUsersWithArrayInput(body)
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';
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 {
api_instance.createUsersWithArrayInput(user);
api_instance.createUsersWithArrayInput(body);
} catch (e) {
print("Exception when calling UserApi->createUsersWithArrayInput: $e\n");
}
@ -84,7 +84,7 @@ try {
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
@ -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)
# **createUsersWithListInput**
> createUsersWithListInput(user)
> createUsersWithListInput(body)
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';
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 {
api_instance.createUsersWithListInput(user);
api_instance.createUsersWithListInput(body);
} catch (e) {
print("Exception when calling UserApi->createUsersWithListInput: $e\n");
}
@ -124,7 +124,7 @@ try {
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
@ -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)
# **updateUser**
> updateUser(username, user)
> updateUser(username, body)
Updated user
@ -316,10 +316,10 @@ import 'package:openapi/api.dart';
var api_instance = new UserApi();
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 {
api_instance.updateUser(username, user);
api_instance.updateUser(username, body);
} catch (e) {
print("Exception when calling UserApi->updateUser: $e\n");
}
@ -330,7 +330,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,18 +1,19 @@
part of openapi.api;
class User {
int id = null;
String username = null;
String firstName = null;
String lastName = null;
String email = null;
String password = null;
String phone = null;
/* User Status */
int userStatus = null;
@ -25,14 +26,46 @@ class User {
User.fromJson(Map<String, dynamic> json) {
if (json == null) return;
id = json['id'];
username = json['username'];
firstName = json['firstName'];
lastName = json['lastName'];
email = json['email'];
password = json['password'];
phone = json['phone'];
userStatus = json['userStatus'];
if (json['id'] == null) {
id = null;
} else {
id = json['id'];
}
if (json['username'] == null) {
username = null;
} else {
username = json['username'];
}
if (json['firstName'] == null) {
firstName = null;
} else {
firstName = json['firstName'];
}
if (json['lastName'] == null) {
lastName = null;
} else {
lastName = json['lastName'];
}
if (json['email'] == null) {
email = null;
} else {
email = json['email'];
}
if (json['password'] == null) {
password = null;
} else {
password = json['password'];
}
if (json['phone'] == null) {
phone = null;
} else {
phone = json['phone'];
}
if (json['userStatus'] == null) {
userStatus = null;
} else {
userStatus = json['userStatus'];
}
}
Map<String, dynamic> toJson() {
@ -49,17 +82,15 @@ class User {
}
static List<User> listFromJson(List<dynamic> json) {
return json == null
? new List<User>()
: json.map((value) => new User.fromJson(value)).toList();
return json == null ? new List<User>() : json.map((value) => new User.fromJson(value)).toList();
}
static Map<String, User> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, User>();
if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) =>
map[key] = new User.fromJson(value));
json.forEach((String key, Map<String, dynamic> value) => map[key] = new User.fromJson(value));
}
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';
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 {
api_instance.addPet(pet);
api_instance.addPet(body);
} catch (e) {
print("Exception when calling PetApi->addPet: $e\n");
}

View File

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

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)
# **placeOrder**
> Order placeOrder(order)
> Order placeOrder(body)
Place an order for a pet
@ -153,10 +153,10 @@ Place an order for a pet
import 'package:openapi/api.dart';
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 {
var result = api_instance.placeOrder(order);
var result = api_instance.placeOrder(body);
print(result);
} catch (e) {
print("Exception when calling StoreApi->placeOrder: $e\n");
@ -167,7 +167,7 @@ try {
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

View File

@ -20,7 +20,7 @@ Method | HTTP request | Description
# **createUser**
> createUser(user)
> createUser(body)
Create user
@ -31,10 +31,10 @@ This can only be done by the logged in user.
import 'package:openapi/api.dart';
var api_instance = new UserApi();
var user = new User(); // User | Created user object
var body = new User(); // User | Created user object
try {
api_instance.createUser(user);
api_instance.createUser(body);
} catch (e) {
print("Exception when calling UserApi->createUser: $e\n");
}
@ -44,7 +44,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**user** | [**User**](User.md)| Created user object |
**body** | [**User**](User.md)| Created user object |
### 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)
# **createUsersWithArrayInput**
> createUsersWithArrayInput(user)
> createUsersWithArrayInput(body)
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';
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 {
api_instance.createUsersWithArrayInput(user);
api_instance.createUsersWithArrayInput(body);
} catch (e) {
print("Exception when calling UserApi->createUsersWithArrayInput: $e\n");
}
@ -84,7 +84,7 @@ try {
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
@ -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)
# **createUsersWithListInput**
> createUsersWithListInput(user)
> createUsersWithListInput(body)
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';
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 {
api_instance.createUsersWithListInput(user);
api_instance.createUsersWithListInput(body);
} catch (e) {
print("Exception when calling UserApi->createUsersWithListInput: $e\n");
}
@ -124,7 +124,7 @@ try {
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
@ -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)
# **updateUser**
> updateUser(username, user)
> updateUser(username, body)
Updated user
@ -316,10 +316,10 @@ import 'package:openapi/api.dart';
var api_instance = new UserApi();
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 {
api_instance.updateUser(username, user);
api_instance.updateUser(username, body);
} catch (e) {
print("Exception when calling UserApi->updateUser: $e\n");
}
@ -330,7 +330,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,18 +1,19 @@
part of openapi.api;
class User {
int id = null;
String username = null;
String firstName = null;
String lastName = null;
String email = null;
String password = null;
String phone = null;
/* User Status */
int userStatus = null;
@ -25,14 +26,46 @@ class User {
User.fromJson(Map<String, dynamic> json) {
if (json == null) return;
id = json['id'];
username = json['username'];
firstName = json['firstName'];
lastName = json['lastName'];
email = json['email'];
password = json['password'];
phone = json['phone'];
userStatus = json['userStatus'];
if (json['id'] == null) {
id = null;
} else {
id = json['id'];
}
if (json['username'] == null) {
username = null;
} else {
username = json['username'];
}
if (json['firstName'] == null) {
firstName = null;
} else {
firstName = json['firstName'];
}
if (json['lastName'] == null) {
lastName = null;
} else {
lastName = json['lastName'];
}
if (json['email'] == null) {
email = null;
} else {
email = json['email'];
}
if (json['password'] == null) {
password = null;
} else {
password = json['password'];
}
if (json['phone'] == null) {
phone = null;
} else {
phone = json['phone'];
}
if (json['userStatus'] == null) {
userStatus = null;
} else {
userStatus = json['userStatus'];
}
}
Map<String, dynamic> toJson() {
@ -49,17 +82,15 @@ class User {
}
static List<User> listFromJson(List<dynamic> json) {
return json == null
? new List<User>()
: json.map((value) => new User.fromJson(value)).toList();
return json == null ? new List<User>() : json.map((value) => new User.fromJson(value)).toList();
}
static Map<String, User> mapFromJson(Map<String, dynamic> json) {
var map = new Map<String, User>();
if (json != null && json.length > 0) {
json.forEach(
(String key, dynamic value) => map[key] = new User.fromJson(value));
json.forEach((String key, dynamic value) => map[key] = new User.fromJson(value));
}
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';
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 {
api_instance.addPet(pet);
api_instance.addPet(body);
} catch (e) {
print("Exception when calling PetApi->addPet: $e\n");
}

View File

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

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)
# **placeOrder**
> Order placeOrder(order)
> Order placeOrder(body)
Place an order for a pet
@ -153,10 +153,10 @@ Place an order for a pet
import 'package:openapi/api.dart';
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 {
var result = api_instance.placeOrder(order);
var result = api_instance.placeOrder(body);
print(result);
} catch (e) {
print("Exception when calling StoreApi->placeOrder: $e\n");
@ -167,7 +167,7 @@ try {
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

View File

@ -20,7 +20,7 @@ Method | HTTP request | Description
# **createUser**
> createUser(user)
> createUser(body)
Create user
@ -31,10 +31,10 @@ This can only be done by the logged in user.
import 'package:openapi/api.dart';
var api_instance = new UserApi();
var user = new User(); // User | Created user object
var body = new User(); // User | Created user object
try {
api_instance.createUser(user);
api_instance.createUser(body);
} catch (e) {
print("Exception when calling UserApi->createUser: $e\n");
}
@ -44,7 +44,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**user** | [**User**](User.md)| Created user object |
**body** | [**User**](User.md)| Created user object |
### 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)
# **createUsersWithArrayInput**
> createUsersWithArrayInput(user)
> createUsersWithArrayInput(body)
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';
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 {
api_instance.createUsersWithArrayInput(user);
api_instance.createUsersWithArrayInput(body);
} catch (e) {
print("Exception when calling UserApi->createUsersWithArrayInput: $e\n");
}
@ -84,7 +84,7 @@ try {
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
@ -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)
# **createUsersWithListInput**
> createUsersWithListInput(user)
> createUsersWithListInput(body)
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';
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 {
api_instance.createUsersWithListInput(user);
api_instance.createUsersWithListInput(body);
} catch (e) {
print("Exception when calling UserApi->createUsersWithListInput: $e\n");
}
@ -124,7 +124,7 @@ try {
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
@ -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)
# **updateUser**
> updateUser(username, user)
> updateUser(username, body)
Updated user
@ -316,10 +316,10 @@ import 'package:openapi/api.dart';
var api_instance = new UserApi();
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 {
api_instance.updateUser(username, user);
api_instance.updateUser(username, body);
} catch (e) {
print("Exception when calling UserApi->updateUser: $e\n");
}
@ -330,7 +330,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**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

View File

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

View File

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

View File

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

View File

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

View File

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

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