[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,11 +16,14 @@ 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}}
@@ -47,6 +50,7 @@ class {{classname}} {
{{/complexType}}
{{/isDate}}
{{/isDateTime}}
}
{{/vars}}
}

View File

@@ -16,11 +16,14 @@ 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}}
@@ -39,7 +42,7 @@ class {{classname}} {
{{/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}}'];
@@ -47,6 +50,7 @@ class {{classname}} {
{{/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;
@@ -8,12 +10,12 @@ 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
@@ -26,26 +28,34 @@ class PetApi {
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")) {
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) {
throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) {} else {
} else if(response.body != null) {
} else {
return;
}
}
/// Deletes a pet
///
///
@@ -58,9 +68,7 @@ class PetApi {
}
// 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")) {
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) {
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
@@ -108,35 +124,39 @@ class PetApi {
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")) {
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) {
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();
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.
@@ -155,35 +175,39 @@ class PetApi {
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")) {
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) {
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();
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
@@ -196,9 +220,7 @@ class PetApi {
}
// 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,18 +229,26 @@ 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")) {
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) {
throw new ApiException(response.statusCode, response.body);
@@ -228,16 +258,15 @@ class PetApi {
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
@@ -250,26 +279,34 @@ class PetApi {
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")) {
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) {
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
///
///
@@ -282,9 +319,7 @@ class PetApi {
}
// 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,8 +328,7 @@ 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")) {
@@ -308,27 +342,36 @@ 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) {
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
@@ -337,9 +380,7 @@ class PetApi {
}
// 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,8 +389,7 @@ 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")) {
@@ -364,15 +404,22 @@ 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) {
throw new ApiException(response.statusCode, response.body);

View File

@@ -1,5 +1,7 @@
part of openapi.api;
class StoreApi {
final ApiClient apiClient;
@@ -17,9 +19,7 @@ class StoreApi {
}
// 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")) {
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) {
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
@@ -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")) {
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) {
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>'));
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
@@ -102,9 +116,7 @@ class StoreApi {
}
// 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,18 +125,26 @@ 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")) {
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) {
throw new ApiException(response.statusCode, response.body);
@@ -134,16 +154,15 @@ class StoreApi {
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
@@ -156,18 +175,26 @@ 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")) {
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) {
throw new ApiException(response.statusCode, response.body);

View File

@@ -1,5 +1,7 @@
part of openapi.api;
class UserApi {
final ApiClient apiClient;
@@ -8,12 +10,12 @@ 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
@@ -26,35 +28,43 @@ 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")) {
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) {
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
@@ -67,35 +77,43 @@ 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")) {
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) {
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
@@ -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")) {
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) {
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.
@@ -140,9 +166,7 @@ class UserApi {
}
// 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,26 +175,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")) {
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) {
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
///
///
@@ -183,9 +215,7 @@ class UserApi {
}
// 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,18 +224,26 @@ 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")) {
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) {
throw new ApiException(response.statusCode, response.body);
@@ -215,7 +253,6 @@ class UserApi {
return null;
}
}
/// Logs user into the system
///
///
@@ -237,25 +274,31 @@ class UserApi {
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")) {
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) {
throw new ApiException(response.statusCode, response.body);
@@ -265,7 +308,6 @@ class UserApi {
return null;
}
}
/// Logs out current logged in user session
///
///
@@ -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")) {
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) {
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 (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")) {
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) {
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();
@@ -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,8 +94,7 @@ 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,
Future<Response> invokeAPI(String path,
String method,
Iterable<QueryParam> queryParams,
Object body,
@@ -104,12 +102,13 @@ class ApiClient {
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;
@@ -125,9 +124,7 @@ class ApiClient {
var response = await client.send(request);
return Response.fromStream(response);
} else {
var msgBody = contentType == "application/x-www-form-urlencoded"
? formParams
: serialize(body);
var msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body);
switch(method) {
case "POST":
return client.post(url, headers: headerParams, body: msgBody);
@@ -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

@@ -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);
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,6 +1,7 @@
part of openapi.api;
class ApiResponse {
int code = null;
String type = null;
@@ -15,28 +16,41 @@ class ApiResponse {
ApiResponse.fromJson(Map<String, dynamic> json) {
if (json == null) return;
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,6 +1,7 @@
part of openapi.api;
class Category {
int id = null;
String name = null;
@@ -13,27 +14,35 @@ class Category {
Category.fromJson(Map<String, dynamic> json) {
if (json == null) return;
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,6 +1,7 @@
part of openapi.api;
class Order {
int id = null;
int petId = null;
@@ -22,14 +23,37 @@ class Order {
Order.fromJson(Map<String, dynamic> json) {
if (json == null) return;
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'];
shipDate =
json['shipDate'] == null ? null : DateTime.parse(json['shipDate']);
}
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() {
return {
@@ -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,6 +1,7 @@
part of openapi.api;
class Pet {
int id = null;
Category category = null;
@@ -22,14 +23,37 @@ class Pet {
Pet.fromJson(Map<String, dynamic> json) {
if (json == null) return;
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'];
photoUrls =
(json['photoUrls'] as List).map((item) => item as String).toList();
}
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() {
return {
@@ -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,6 +1,7 @@
part of openapi.api;
class Tag {
int id = null;
String name = null;
@@ -13,26 +14,35 @@ class Tag {
Tag.fromJson(Map<String, dynamic> json) {
if (json == null) return;
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,6 +1,7 @@
part of openapi.api;
class User {
int id = null;
String username = null;
@@ -25,15 +26,47 @@ class User {
User.fromJson(Map<String, dynamic> json) {
if (json == null) return;
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() {
return {
@@ -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;
@@ -8,12 +10,12 @@ 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
@@ -26,26 +28,34 @@ class PetApi {
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")) {
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) {
throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) {} else {
} else if(response.body != null) {
} else {
return;
}
}
/// Deletes a pet
///
///
@@ -58,9 +68,7 @@ class PetApi {
}
// 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")) {
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) {
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
@@ -108,35 +124,39 @@ class PetApi {
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")) {
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) {
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();
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.
@@ -155,35 +175,39 @@ class PetApi {
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")) {
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) {
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();
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
@@ -196,9 +220,7 @@ class PetApi {
}
// 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,18 +229,26 @@ 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")) {
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) {
throw new ApiException(response.statusCode, response.body);
@@ -228,16 +258,15 @@ class PetApi {
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
@@ -250,26 +279,34 @@ class PetApi {
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")) {
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) {
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
///
///
@@ -282,9 +319,7 @@ class PetApi {
}
// 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,8 +328,7 @@ 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")) {
@@ -308,27 +342,36 @@ 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) {
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
@@ -337,9 +380,7 @@ class PetApi {
}
// 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,8 +389,7 @@ 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")) {
@@ -364,15 +404,22 @@ 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) {
throw new ApiException(response.statusCode, response.body);

View File

@@ -1,5 +1,7 @@
part of openapi.api;
class StoreApi {
final ApiClient apiClient;
@@ -17,9 +19,7 @@ class StoreApi {
}
// 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")) {
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) {
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
@@ -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")) {
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) {
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>'));
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
@@ -102,9 +116,7 @@ class StoreApi {
}
// 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,18 +125,26 @@ 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")) {
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) {
throw new ApiException(response.statusCode, response.body);
@@ -134,16 +154,15 @@ class StoreApi {
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
@@ -156,18 +175,26 @@ 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")) {
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) {
throw new ApiException(response.statusCode, response.body);

View File

@@ -1,5 +1,7 @@
part of openapi.api;
class UserApi {
final ApiClient apiClient;
@@ -8,12 +10,12 @@ 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
@@ -26,35 +28,43 @@ 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")) {
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) {
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
@@ -67,35 +77,43 @@ 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")) {
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) {
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
@@ -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")) {
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) {
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.
@@ -140,9 +166,7 @@ class UserApi {
}
// 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,26 +175,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")) {
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) {
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
///
///
@@ -183,9 +215,7 @@ class UserApi {
}
// 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,18 +224,26 @@ 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")) {
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) {
throw new ApiException(response.statusCode, response.body);
@@ -215,7 +253,6 @@ class UserApi {
return null;
}
}
/// Logs user into the system
///
///
@@ -237,25 +274,31 @@ class UserApi {
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")) {
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) {
throw new ApiException(response.statusCode, response.body);
@@ -265,7 +308,6 @@ class UserApi {
return null;
}
}
/// Logs out current logged in user session
///
///
@@ -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")) {
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) {
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 (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")) {
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) {
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();
@@ -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,8 +94,7 @@ 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,
Future<Response> invokeAPI(String path,
String method,
Iterable<QueryParam> queryParams,
Object body,
@@ -104,12 +102,13 @@ class ApiClient {
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;
@@ -125,9 +124,7 @@ class ApiClient {
var response = await client.send(request);
return Response.fromStream(response);
} else {
var msgBody = contentType == "application/x-www-form-urlencoded"
? formParams
: serialize(body);
var msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body);
switch(method) {
case "POST":
return client.post(url, headers: headerParams, body: msgBody);
@@ -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

@@ -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);
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,6 +1,7 @@
part of openapi.api;
class ApiResponse {
int code = null;
String type = null;
@@ -15,28 +16,41 @@ class ApiResponse {
ApiResponse.fromJson(Map<String, dynamic> json) {
if (json == null) return;
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,6 +1,7 @@
part of openapi.api;
class Category {
int id = null;
String name = null;
@@ -13,27 +14,35 @@ class Category {
Category.fromJson(Map<String, dynamic> json) {
if (json == null) return;
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,6 +1,7 @@
part of openapi.api;
class Order {
int id = null;
int petId = null;
@@ -22,14 +23,37 @@ class Order {
Order.fromJson(Map<String, dynamic> json) {
if (json == null) return;
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'];
shipDate =
json['shipDate'] == null ? null : DateTime.parse(json['shipDate']);
}
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() {
return {
@@ -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,6 +1,7 @@
part of openapi.api;
class Pet {
int id = null;
Category category = null;
@@ -22,14 +23,37 @@ class Pet {
Pet.fromJson(Map<String, dynamic> json) {
if (json == null) return;
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'];
photoUrls =
(json['photoUrls'] as List).map((item) => item as String).toList();
}
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() {
return {
@@ -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,6 +1,7 @@
part of openapi.api;
class Tag {
int id = null;
String name = null;
@@ -13,26 +14,35 @@ class Tag {
Tag.fromJson(Map<String, dynamic> json) {
if (json == null) return;
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,6 +1,7 @@
part of openapi.api;
class User {
int id = null;
String username = null;
@@ -25,15 +26,47 @@ class User {
User.fromJson(Map<String, dynamic> json) {
if (json == null) return;
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() {
return {
@@ -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;
@@ -8,12 +10,12 @@ 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
@@ -26,26 +28,34 @@ class PetApi {
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")) {
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) {
throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) {} else {
} else if(response.body != null) {
} else {
return;
}
}
/// Deletes a pet
///
///
@@ -58,9 +68,7 @@ class PetApi {
}
// 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")) {
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) {
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
@@ -108,35 +124,39 @@ class PetApi {
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")) {
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) {
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();
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.
@@ -155,35 +175,39 @@ class PetApi {
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")) {
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) {
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();
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
@@ -196,9 +220,7 @@ class PetApi {
}
// 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,18 +229,26 @@ 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")) {
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) {
throw new ApiException(response.statusCode, response.body);
@@ -228,16 +258,15 @@ class PetApi {
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
@@ -250,26 +279,34 @@ class PetApi {
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")) {
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) {
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
///
///
@@ -282,9 +319,7 @@ class PetApi {
}
// 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,8 +328,7 @@ 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")) {
@@ -308,27 +342,36 @@ 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) {
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
@@ -337,9 +380,7 @@ class PetApi {
}
// 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,8 +389,7 @@ 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")) {
@@ -364,15 +404,22 @@ 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) {
throw new ApiException(response.statusCode, response.body);

View File

@@ -1,5 +1,7 @@
part of openapi.api;
class StoreApi {
final ApiClient apiClient;
@@ -17,9 +19,7 @@ class StoreApi {
}
// 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")) {
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) {
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
@@ -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")) {
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) {
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>'));
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
@@ -102,9 +116,7 @@ class StoreApi {
}
// 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,18 +125,26 @@ 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")) {
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) {
throw new ApiException(response.statusCode, response.body);
@@ -134,16 +154,15 @@ class StoreApi {
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
@@ -156,18 +175,26 @@ 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")) {
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) {
throw new ApiException(response.statusCode, response.body);

View File

@@ -1,5 +1,7 @@
part of openapi.api;
class UserApi {
final ApiClient apiClient;
@@ -8,12 +10,12 @@ 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
@@ -26,35 +28,43 @@ 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")) {
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) {
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
@@ -67,35 +77,43 @@ 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")) {
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) {
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
@@ -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")) {
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) {
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.
@@ -140,9 +166,7 @@ class UserApi {
}
// 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,26 +175,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")) {
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) {
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
///
///
@@ -183,9 +215,7 @@ class UserApi {
}
// 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,18 +224,26 @@ 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")) {
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) {
throw new ApiException(response.statusCode, response.body);
@@ -215,7 +253,6 @@ class UserApi {
return null;
}
}
/// Logs user into the system
///
///
@@ -237,25 +274,31 @@ class UserApi {
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")) {
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) {
throw new ApiException(response.statusCode, response.body);
@@ -265,7 +308,6 @@ class UserApi {
return null;
}
}
/// Logs out current logged in user session
///
///
@@ -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")) {
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) {
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 (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")) {
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) {
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();
@@ -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,8 +94,7 @@ 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,
Future<Response> invokeAPI(String path,
String method,
Iterable<QueryParam> queryParams,
Object body,
@@ -104,12 +102,13 @@ class ApiClient {
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;
@@ -125,9 +124,7 @@ class ApiClient {
var response = await client.send(request);
return Response.fromStream(response);
} else {
var msgBody = contentType == "application/x-www-form-urlencoded"
? formParams
: serialize(body);
var msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body);
switch(method) {
case "POST":
return client.post(url, headers: headerParams, body: msgBody);
@@ -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

@@ -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);
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,6 +1,7 @@
part of openapi.api;
class ApiResponse {
int code = null;
String type = null;
@@ -15,28 +16,41 @@ class ApiResponse {
ApiResponse.fromJson(Map<String, dynamic> json) {
if (json == null) return;
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,6 +1,7 @@
part of openapi.api;
class Category {
int id = null;
String name = null;
@@ -13,27 +14,35 @@ class Category {
Category.fromJson(Map<String, dynamic> json) {
if (json == null) return;
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,6 +1,7 @@
part of openapi.api;
class Order {
int id = null;
int petId = null;
@@ -22,14 +23,37 @@ class Order {
Order.fromJson(Map<String, dynamic> json) {
if (json == null) return;
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'];
shipDate =
json['shipDate'] == null ? null : DateTime.parse(json['shipDate']);
}
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() {
return {
@@ -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,6 +1,7 @@
part of openapi.api;
class Pet {
int id = null;
Category category = null;
@@ -22,14 +23,37 @@ class Pet {
Pet.fromJson(Map<String, dynamic> json) {
if (json == null) return;
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'];
photoUrls =
(json['photoUrls'] as List).map((item) => item as String).toList();
}
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() {
return {
@@ -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,6 +1,7 @@
part of openapi.api;
class Tag {
int id = null;
String name = null;
@@ -13,26 +14,35 @@ class Tag {
Tag.fromJson(Map<String, dynamic> json) {
if (json == null) return;
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,6 +1,7 @@
part of openapi.api;
class User {
int id = null;
String username = null;
@@ -25,15 +26,47 @@ class User {
User.fromJson(Map<String, dynamic> json) {
if (json == null) return;
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() {
return {
@@ -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;
@@ -8,12 +10,12 @@ 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
@@ -26,26 +28,34 @@ class PetApi {
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")) {
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) {
throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) {} else {
} else if(response.body != null) {
} else {
return;
}
}
/// Deletes a pet
///
///
@@ -58,9 +68,7 @@ class PetApi {
}
// 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")) {
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) {
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
@@ -108,35 +124,39 @@ class PetApi {
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")) {
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) {
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();
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.
@@ -155,35 +175,39 @@ class PetApi {
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")) {
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) {
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();
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
@@ -196,9 +220,7 @@ class PetApi {
}
// 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,18 +229,26 @@ 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")) {
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) {
throw new ApiException(response.statusCode, response.body);
@@ -228,16 +258,15 @@ class PetApi {
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
@@ -250,26 +279,34 @@ class PetApi {
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")) {
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) {
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
///
///
@@ -282,9 +319,7 @@ class PetApi {
}
// 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,8 +328,7 @@ 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")) {
@@ -308,27 +342,36 @@ 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) {
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
@@ -337,9 +380,7 @@ class PetApi {
}
// 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,8 +389,7 @@ 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")) {
@@ -364,15 +404,22 @@ 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) {
throw new ApiException(response.statusCode, response.body);

View File

@@ -1,5 +1,7 @@
part of openapi.api;
class StoreApi {
final ApiClient apiClient;
@@ -17,9 +19,7 @@ class StoreApi {
}
// 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")) {
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) {
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
@@ -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")) {
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) {
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>'));
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
@@ -102,9 +116,7 @@ class StoreApi {
}
// 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,18 +125,26 @@ 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")) {
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) {
throw new ApiException(response.statusCode, response.body);
@@ -134,16 +154,15 @@ class StoreApi {
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
@@ -156,18 +175,26 @@ 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")) {
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) {
throw new ApiException(response.statusCode, response.body);

View File

@@ -1,5 +1,7 @@
part of openapi.api;
class UserApi {
final ApiClient apiClient;
@@ -8,12 +10,12 @@ 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
@@ -26,35 +28,43 @@ 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")) {
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) {
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
@@ -67,35 +77,43 @@ 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")) {
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) {
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
@@ -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")) {
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) {
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.
@@ -140,9 +166,7 @@ class UserApi {
}
// 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,26 +175,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")) {
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) {
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
///
///
@@ -183,9 +215,7 @@ class UserApi {
}
// 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,18 +224,26 @@ 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")) {
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) {
throw new ApiException(response.statusCode, response.body);
@@ -215,7 +253,6 @@ class UserApi {
return null;
}
}
/// Logs user into the system
///
///
@@ -237,25 +274,31 @@ class UserApi {
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")) {
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) {
throw new ApiException(response.statusCode, response.body);
@@ -265,7 +308,6 @@ class UserApi {
return null;
}
}
/// Logs out current logged in user session
///
///
@@ -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")) {
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) {
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 (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")) {
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) {
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();
@@ -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,8 +94,7 @@ 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,
Future<Response> invokeAPI(String path,
String method,
Iterable<QueryParam> queryParams,
Object body,
@@ -104,12 +102,13 @@ class ApiClient {
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;
@@ -125,9 +124,7 @@ class ApiClient {
var response = await client.send(request);
return Response.fromStream(response);
} else {
var msgBody = contentType == "application/x-www-form-urlencoded"
? formParams
: serialize(body);
var msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body);
switch(method) {
case "POST":
return client.post(url, headers: headerParams, body: msgBody);
@@ -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

@@ -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);
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,6 +1,7 @@
part of openapi.api;
class ApiResponse {
int code = null;
String type = null;
@@ -15,27 +16,41 @@ class ApiResponse {
ApiResponse.fromJson(Map<String, dynamic> json) {
if (json == null) return;
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,6 +1,7 @@
part of openapi.api;
class Category {
int id = null;
String name = null;
@@ -13,26 +14,35 @@ class Category {
Category.fromJson(Map<String, dynamic> json) {
if (json == null) return;
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,6 +1,7 @@
part of openapi.api;
class Order {
int id = null;
int petId = null;
@@ -22,14 +23,37 @@ class Order {
Order.fromJson(Map<String, dynamic> json) {
if (json == null) return;
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'];
shipDate =
json['shipDate'] == null ? null : DateTime.parse(json['shipDate']);
}
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() {
return {
@@ -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,6 +1,7 @@
part of openapi.api;
class Pet {
int id = null;
Category category = null;
@@ -22,15 +23,37 @@ class Pet {
Pet.fromJson(Map<String, dynamic> json) {
if (json == null) return;
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'];
photoUrls = ((json['photoUrls'] ?? []) as List)
.map((item) => item as String)
.toList();
}
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() {
return {
@@ -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,6 +1,7 @@
part of openapi.api;
class Tag {
int id = null;
String name = null;
@@ -13,26 +14,35 @@ class Tag {
Tag.fromJson(Map<String, dynamic> json) {
if (json == null) return;
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,6 +1,7 @@
part of openapi.api;
class User {
int id = null;
String username = null;
@@ -25,15 +26,47 @@ class User {
User.fromJson(Map<String, dynamic> json) {
if (json == null) return;
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() {
return {
@@ -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;
@@ -8,12 +10,12 @@ 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
@@ -26,26 +28,34 @@ class PetApi {
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")) {
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) {
throw new ApiException(response.statusCode, response.body);
} else if (response.body != null) {} else {
} else if(response.body != null) {
} else {
return;
}
}
/// Deletes a pet
///
///
@@ -58,9 +68,7 @@ class PetApi {
}
// 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")) {
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) {
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
@@ -108,35 +124,39 @@ class PetApi {
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")) {
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) {
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();
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.
@@ -155,35 +175,39 @@ class PetApi {
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")) {
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) {
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();
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
@@ -196,9 +220,7 @@ class PetApi {
}
// 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,18 +229,26 @@ 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")) {
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) {
throw new ApiException(response.statusCode, response.body);
@@ -228,16 +258,15 @@ class PetApi {
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
@@ -250,26 +279,34 @@ class PetApi {
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")) {
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) {
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
///
///
@@ -282,9 +319,7 @@ class PetApi {
}
// 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,8 +328,7 @@ 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")) {
@@ -308,27 +342,36 @@ 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) {
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
@@ -337,9 +380,7 @@ class PetApi {
}
// 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,8 +389,7 @@ 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")) {
@@ -364,15 +404,22 @@ 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) {
throw new ApiException(response.statusCode, response.body);

View File

@@ -1,5 +1,7 @@
part of openapi.api;
class StoreApi {
final ApiClient apiClient;
@@ -17,9 +19,7 @@ class StoreApi {
}
// 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")) {
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) {
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
@@ -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")) {
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) {
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>'));
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
@@ -102,9 +116,7 @@ class StoreApi {
}
// 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,18 +125,26 @@ 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")) {
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) {
throw new ApiException(response.statusCode, response.body);
@@ -134,16 +154,15 @@ class StoreApi {
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
@@ -156,18 +175,26 @@ 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")) {
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) {
throw new ApiException(response.statusCode, response.body);

View File

@@ -1,5 +1,7 @@
part of openapi.api;
class UserApi {
final ApiClient apiClient;
@@ -8,12 +10,12 @@ 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
@@ -26,35 +28,43 @@ 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")) {
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) {
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
@@ -67,35 +77,43 @@ 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")) {
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) {
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
@@ -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")) {
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) {
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.
@@ -140,9 +166,7 @@ class UserApi {
}
// 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,26 +175,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")) {
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) {
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
///
///
@@ -183,9 +215,7 @@ class UserApi {
}
// 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,18 +224,26 @@ 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")) {
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) {
throw new ApiException(response.statusCode, response.body);
@@ -215,7 +253,6 @@ class UserApi {
return null;
}
}
/// Logs user into the system
///
///
@@ -237,25 +274,31 @@ class UserApi {
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")) {
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) {
throw new ApiException(response.statusCode, response.body);
@@ -265,7 +308,6 @@ class UserApi {
return null;
}
}
/// Logs out current logged in user session
///
///
@@ -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")) {
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) {
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 (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")) {
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) {
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();
@@ -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,8 +94,7 @@ 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,
Future<Response> invokeAPI(String path,
String method,
Iterable<QueryParam> queryParams,
Object body,
@@ -104,12 +102,13 @@ class ApiClient {
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;
@@ -125,9 +124,7 @@ class ApiClient {
var response = await client.send(request);
return Response.fromStream(response);
} else {
var msgBody = contentType == "application/x-www-form-urlencoded"
? formParams
: serialize(body);
var msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body);
switch(method) {
case "POST":
return client.post(url, headers: headerParams, body: msgBody);
@@ -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