Set Dart2 as default, better format Dart code with dartfmt (#949)

* change dart default to v2

* add dart2 author

* add dartfmt to postProcess file in dart generator

* add dartfmt to format dart code
This commit is contained in:
William Cheng
2018-09-02 17:59:42 +08:00
committed by GitHub
parent a2acfe3be0
commit d9400caf69
113 changed files with 2633 additions and 3300 deletions

View File

@@ -42,7 +42,7 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se
| | Languages/Frameworks |
|-|-|
**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C#** (.net 2.0, 3.5 or later), **C++** (cpprest, Qt5, Tizen), **Clojure**, **Dart**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client), **Kotlin**, **Lua**, **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types) **Objective-C**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 6.x), Aurelia, Fetch, Inversify, jQuery, Node)
**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C#** (.net 2.0, 3.5 or later), **C++** (cpprest, Qt5, Tizen), **Clojure**, **Dart (1.x, 2.x)**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client), **Kotlin**, **Lua**, **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types) **Objective-C**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 6.x), Aurelia, Fetch, Inversify, jQuery, Node)
**Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed), **Erlang**, **Go**, **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples)), **Kotlin** (Spring Boot), **PHP** (Laravel, Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** (rust-server), **Scala** ([Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), Scalatra)
**API documentation generators** | **HTML**, **Confluence Wiki**
**Configuration files** | [**Apache2**](https://httpd.apache.org/)
@@ -516,7 +516,8 @@ Here is a list of template creators:
* C# (.NET 4.5 refactored): @jimschubert
* Clojure: @xhh
* Dart: @yissachar
* Dart (refactored in 2.4.0): @joernahrens
* Dart (refactor): @joernahrens
* Dart 2: @swipesight
* Elixir: @niku
* Elm: @trenneman
* Eiffel: @jvelilla

View File

@@ -29,18 +29,18 @@ fi
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
# Generate non-browserClient
ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart/openapi -DhideGenerationTimestamp=true -DbrowserClient=false $@"
ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart/openapi -DhideGenerationTimestamp=true -DbrowserClient=false --additional-properties supportDart2=false $@"
# then options to generate the library for vm would be:
#ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart/openapi_vm -DbrowserClient=false -DpubName=openapi_vm $@"
#ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart/openapi_vm -DbrowserClient=false -DpubName=openapi_vm --additional-properties supportDart2=false $@"
java $JAVA_OPTS -jar $executable $ags
# Generate browserClient
ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart/openapi-browser-client -DhideGenerationTimestamp=true -DbrowserClient=true $@"
ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart/openapi-browser-client -DhideGenerationTimestamp=true -DbrowserClient=true --additional-properties supportDart2=false $@"
java $JAVA_OPTS -jar $executable $ags
# Generate non-browserClient and put it to the flutter sample app
ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart/flutter_petstore/openapi -DhideGenerationTimestamp=true -DbrowserClient=false $@"
ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart/flutter_petstore/openapi -DhideGenerationTimestamp=true -DbrowserClient=false --additional-properties supportDart2=false $@"
java $JAVA_OPTS -jar $executable $ags
# There is a proposal to allow importing different libraries depending on the environment:

View File

@@ -29,18 +29,18 @@ fi
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
# Generate non-browserClient
ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart2/openapi -DhideGenerationTimestamp=true -DbrowserClient=false --additional-properties supportDart2=true $@"
ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart2/openapi -DhideGenerationTimestamp=true -DbrowserClient=false $@"
# then options to generate the library for vm would be:
#ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart2/openapi_vm -DbrowserClient=false -DpubName=openapi_vm $@"
java $JAVA_OPTS -jar $executable $ags
# Generate browserClient
ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart2/openapi-browser-client -DhideGenerationTimestamp=true -DbrowserClient=true --additional-properties supportDart2=true $@"
ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart2/openapi-browser-client -DhideGenerationTimestamp=true -DbrowserClient=true $@"
java $JAVA_OPTS -jar $executable $ags
# Generate non-browserClient and put it to the flutter sample app
ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart2/flutter_petstore/openapi -DhideGenerationTimestamp=true -DbrowserClient=false --additional-properties supportDart2=true $@"
ags="generate -t modules/openapi-generator/src/main/resources/dart -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart -o samples/client/petstore/dart2/flutter_petstore/openapi -DhideGenerationTimestamp=true -DbrowserClient=false $@"
java $JAVA_OPTS -jar $executable $ags
# There is a proposal to allow importing different libraries depending on the environment:

View File

@@ -29,17 +29,20 @@ import org.openapitools.codegen.utils.ModelUtils;
import io.swagger.v3.oas.models.media.*;
import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.io.FilenameUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(DartClientCodegen.class);
@@ -127,7 +130,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
cliOptions.add(new CliOption(PUB_DESCRIPTION, "Description in generated pubspec"));
cliOptions.add(new CliOption(USE_ENUM_EXTENSION, "Allow the 'x-enum-values' extension for enums"));
cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, "source folder for generated code"));
cliOptions.add(CliOption.newBoolean(SUPPORT_DART2, "support dart2").defaultValue(Boolean.FALSE.toString()));
cliOptions.add(CliOption.newBoolean(SUPPORT_DART2, "support dart2").defaultValue(Boolean.TRUE.toString()));
}
@Override
@@ -142,13 +145,17 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String getHelp() {
return "Generates a Dart client library.";
return "Generates a Dart (1.x or 2.x) client library.";
}
@Override
public void processOpts() {
super.processOpts();
if (StringUtils.isEmpty(System.getenv("DART_FMT_PATH"))) {
LOGGER.info("Environment variable DART_FMT_PATH not defined so the Dart code may not be properly formatted. To define it, try 'export DART_FMT_PATH=/usr/local/bin/dartfmt' (Linux/Mac)");
}
if (additionalProperties.containsKey(BROWSER_CLIENT)) {
this.setBrowserClient(convertPropertyToBooleanAndWriteBack(BROWSER_CLIENT));
} else {
@@ -193,11 +200,16 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
additionalProperties.put("modelDocPath", modelDocPath);
final Object isSupportDart2 = additionalProperties.get(SUPPORT_DART2);
if (Boolean.TRUE.equals(isSupportDart2) || (isSupportDart2 instanceof String && Boolean.parseBoolean((String)isSupportDart2))) {
embeddedTemplateDir = templateDir = "dart2";
} else {
if (Boolean.FALSE.equals(isSupportDart2) || (isSupportDart2 instanceof String && !Boolean.parseBoolean((String)isSupportDart2))) {
// dart 1.x
LOGGER.info("Dart version: 1.x");
supportingFiles.add(new SupportingFile("analysis_options.mustache", "", ".analysis_options"));
} else {
// dart 2.x
LOGGER.info("Dart version: 2.x");
embeddedTemplateDir = templateDir = "dart2";
}
final String libFolder = sourceFolder + File.separator + "lib";
supportingFiles.add(new SupportingFile("pubspec.mustache", "", "pubspec.yaml"));
supportingFiles.add(new SupportingFile("api_client.mustache", libFolder, "api_client.dart"));
@@ -496,4 +508,43 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
return input.replace("*/", "*_/").replace("/*", "/_*");
}
@Override
public void postProcessFile(File file, String fileType) {
if (file == null) {
return;
}
String dartFmtPath = System.getenv("DART_FMT_PATH");
if (StringUtils.isEmpty(dartFmtPath)) {
return; // skip if DART_FMT_PATH env variable is not defined
}
// only procees the following type (or we can simply rely on the file extension to check if it's a Dart file)
Set<String> supportedFileType = new HashSet<String>(
Arrays.asList(
"supporting-mustache",
"model-test",
"model",
"api-test",
"api"));
if (!supportedFileType.contains(fileType)) {
return;
}
// only process files with dart extension
if ("dart".equals(FilenameUtils.getExtension(file.toString()))) {
// currently only support "dartfmt -w yourcode.dart"
String command = dartFmtPath + " -w " + file.toString();
try {
Process p = Runtime.getRuntime().exec(command);
p.waitFor();
if (p.exitValue() != 0) {
LOGGER.error("Error running the command ({}): {}", command, p.exitValue());
}
} catch (Exception e) {
LOGGER.error("Error running the command ({}): {}", command, e.getMessage());
}
LOGGER.info("Successfully executed: " + command);
}
}
}

View File

@@ -1 +1 @@
3.0.0-SNAPSHOT
3.3.0-SNAPSHOT

View File

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

View File

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

View File

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

View File

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

View File

@@ -8,7 +8,6 @@ class QueryParam {
}
class ApiClient {
String basePath;
var client = new Client();
@@ -67,9 +66,11 @@ 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) {
@@ -94,7 +95,8 @@ 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,
@@ -102,20 +104,19 @@ 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;
headerParams.addAll(_defaultHeaderMap);
headerParams['Content-Type'] = contentType;
if(body is MultipartRequest) {
if (body is MultipartRequest) {
var request = new MultipartRequest(method, Uri.parse(url));
request.fields.addAll(body.fields);
request.files.addAll(body.files);
@@ -124,8 +125,10 @@ class ApiClient {
var response = await client.send(request);
return Response.fromStream(response);
} else {
var msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body);
switch(method) {
var msgBody = contentType == "application/x-www-form-urlencoded"
? formParams
: serialize(body);
switch (method) {
case "POST":
return client.post(url, headers: headerParams, body: msgBody);
case "PUT":
@@ -142,10 +145,12 @@ 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,7 +8,8 @@ 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,7 +28,8 @@ 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,7 +1,6 @@
part of openapi.api;
class ApiKeyAuth implements Authentication {
final String location;
final String paramName;
String apiKey;
@@ -10,7 +9,8 @@ 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,14 +1,15 @@
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,7 +1,6 @@
part of openapi.api;
class ApiResponse {
int code = null;
String type = null;
@@ -22,23 +21,22 @@ class ApiResponse {
}
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,7 +1,6 @@
part of openapi.api;
class Category {
int id = null;
String name = null;
@@ -19,22 +18,22 @@ class Category {
}
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,7 +1,6 @@
part of openapi.api;
class Order {
int id = null;
int petId = null;
@@ -26,7 +25,8 @@ class Order {
id = json['id'];
petId = json['petId'];
quantity = json['quantity'];
shipDate = json['shipDate'] == null ? null : DateTime.parse(json['shipDate']);
shipDate =
json['shipDate'] == null ? null : DateTime.parse(json['shipDate']);
status = json['status'];
complete = json['complete'];
}
@@ -43,15 +43,18 @@ 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,7 +1,6 @@
part of openapi.api;
class Pet {
int id = null;
Category category = null;
@@ -26,7 +25,8 @@ class Pet {
id = json['id'];
category = new Category.fromJson(json['category']);
name = json['name'];
photoUrls = (json['photoUrls'] as List).map((item) => item as String).toList();
photoUrls =
(json['photoUrls'] as List).map((item) => item as String).toList();
tags = Tag.listFromJson(json['tags']);
status = json['status'];
}
@@ -43,15 +43,17 @@ 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,7 +1,6 @@
part of openapi.api;
class Tag {
int id = null;
String name = null;
@@ -19,22 +18,21 @@ class Tag {
}
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,7 +1,6 @@
part of openapi.api;
class User {
int id = null;
String username = null;
@@ -50,15 +49,17 @@ 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.0.0-SNAPSHOT
3.3.0-SNAPSHOT

View File

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

View File

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

View File

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

View File

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

View File

@@ -8,7 +8,6 @@ class QueryParam {
}
class ApiClient {
String basePath;
var client = new BrowserClient();
@@ -67,9 +66,11 @@ 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) {
@@ -94,7 +95,8 @@ 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,
@@ -102,20 +104,19 @@ 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;
headerParams.addAll(_defaultHeaderMap);
headerParams['Content-Type'] = contentType;
if(body is MultipartRequest) {
if (body is MultipartRequest) {
var request = new MultipartRequest(method, Uri.parse(url));
request.fields.addAll(body.fields);
request.files.addAll(body.files);
@@ -124,8 +125,10 @@ class ApiClient {
var response = await client.send(request);
return Response.fromStream(response);
} else {
var msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body);
switch(method) {
var msgBody = contentType == "application/x-www-form-urlencoded"
? formParams
: serialize(body);
switch (method) {
case "POST":
return client.post(url, headers: headerParams, body: msgBody);
case "PUT":
@@ -142,10 +145,12 @@ 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,7 +8,8 @@ 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,7 +28,8 @@ 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,7 +1,6 @@
part of openapi.api;
class ApiKeyAuth implements Authentication {
final String location;
final String paramName;
String apiKey;
@@ -10,7 +9,8 @@ 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,14 +1,15 @@
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,7 +1,6 @@
part of openapi.api;
class ApiResponse {
int code = null;
String type = null;
@@ -22,23 +21,22 @@ class ApiResponse {
}
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,7 +1,6 @@
part of openapi.api;
class Category {
int id = null;
String name = null;
@@ -19,22 +18,22 @@ class Category {
}
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,7 +1,6 @@
part of openapi.api;
class Order {
int id = null;
int petId = null;
@@ -26,7 +25,8 @@ class Order {
id = json['id'];
petId = json['petId'];
quantity = json['quantity'];
shipDate = json['shipDate'] == null ? null : DateTime.parse(json['shipDate']);
shipDate =
json['shipDate'] == null ? null : DateTime.parse(json['shipDate']);
status = json['status'];
complete = json['complete'];
}
@@ -43,15 +43,18 @@ 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,7 +1,6 @@
part of openapi.api;
class Pet {
int id = null;
Category category = null;
@@ -26,7 +25,8 @@ class Pet {
id = json['id'];
category = new Category.fromJson(json['category']);
name = json['name'];
photoUrls = (json['photoUrls'] as List).map((item) => item as String).toList();
photoUrls =
(json['photoUrls'] as List).map((item) => item as String).toList();
tags = Tag.listFromJson(json['tags']);
status = json['status'];
}
@@ -43,15 +43,17 @@ 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,7 +1,6 @@
part of openapi.api;
class Tag {
int id = null;
String name = null;
@@ -19,22 +18,21 @@ class Tag {
}
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,7 +1,6 @@
part of openapi.api;
class User {
int id = null;
String username = null;
@@ -50,15 +49,17 @@ 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.0.0-SNAPSHOT
3.3.0-SNAPSHOT

View File

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

View File

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

View File

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

View File

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

View File

@@ -8,7 +8,6 @@ class QueryParam {
}
class ApiClient {
String basePath;
var client = new Client();
@@ -67,9 +66,11 @@ 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) {
@@ -94,7 +95,8 @@ 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,
@@ -102,20 +104,19 @@ 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;
headerParams.addAll(_defaultHeaderMap);
headerParams['Content-Type'] = contentType;
if(body is MultipartRequest) {
if (body is MultipartRequest) {
var request = new MultipartRequest(method, Uri.parse(url));
request.fields.addAll(body.fields);
request.files.addAll(body.files);
@@ -124,8 +125,10 @@ class ApiClient {
var response = await client.send(request);
return Response.fromStream(response);
} else {
var msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body);
switch(method) {
var msgBody = contentType == "application/x-www-form-urlencoded"
? formParams
: serialize(body);
switch (method) {
case "POST":
return client.post(url, headers: headerParams, body: msgBody);
case "PUT":
@@ -142,10 +145,12 @@ 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,7 +8,8 @@ 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,7 +28,8 @@ 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,7 +1,6 @@
part of openapi.api;
class ApiKeyAuth implements Authentication {
final String location;
final String paramName;
String apiKey;
@@ -10,7 +9,8 @@ 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,14 +1,15 @@
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,7 +1,6 @@
part of openapi.api;
class ApiResponse {
int code = null;
String type = null;
@@ -22,23 +21,22 @@ class ApiResponse {
}
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,7 +1,6 @@
part of openapi.api;
class Category {
int id = null;
String name = null;
@@ -19,22 +18,22 @@ class Category {
}
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,7 +1,6 @@
part of openapi.api;
class Order {
int id = null;
int petId = null;
@@ -26,7 +25,8 @@ class Order {
id = json['id'];
petId = json['petId'];
quantity = json['quantity'];
shipDate = json['shipDate'] == null ? null : DateTime.parse(json['shipDate']);
shipDate =
json['shipDate'] == null ? null : DateTime.parse(json['shipDate']);
status = json['status'];
complete = json['complete'];
}
@@ -43,15 +43,18 @@ 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,7 +1,6 @@
part of openapi.api;
class Pet {
int id = null;
Category category = null;
@@ -26,7 +25,8 @@ class Pet {
id = json['id'];
category = new Category.fromJson(json['category']);
name = json['name'];
photoUrls = (json['photoUrls'] as List).map((item) => item as String).toList();
photoUrls =
(json['photoUrls'] as List).map((item) => item as String).toList();
tags = Tag.listFromJson(json['tags']);
status = json['status'];
}
@@ -43,15 +43,17 @@ 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,7 +1,6 @@
part of openapi.api;
class Tag {
int id = null;
String name = null;
@@ -19,22 +18,21 @@ class Tag {
}
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,7 +1,6 @@
part of openapi.api;
class User {
int id = null;
String username = null;
@@ -50,15 +49,17 @@ 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.2.2-SNAPSHOT
3.3.0-SNAPSHOT

View File

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

View File

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

View File

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

View File

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

View File

@@ -8,7 +8,6 @@ class QueryParam {
}
class ApiClient {
String basePath;
var client = Client();
@@ -67,9 +66,11 @@ class ApiClient {
}
}
} 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) {
@@ -94,7 +95,8 @@ 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,
@@ -102,20 +104,19 @@ 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;
headerParams.addAll(_defaultHeaderMap);
headerParams['Content-Type'] = contentType;
if(body is MultipartRequest) {
if (body is MultipartRequest) {
var request = MultipartRequest(method, Uri.parse(url));
request.fields.addAll(body.fields);
request.files.addAll(body.files);
@@ -124,8 +125,10 @@ class ApiClient {
var response = await client.send(request);
return Response.fromStream(response);
} else {
var msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body);
switch(method) {
var msgBody = contentType == "application/x-www-form-urlencoded"
? formParams
: serialize(body);
switch (method) {
case "POST":
return client.post(url, headers: headerParams, body: msgBody);
case "PUT":
@@ -142,10 +145,12 @@ 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,7 +8,8 @@ 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,7 +28,8 @@ 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,7 +1,6 @@
part of openapi.api;
class ApiKeyAuth implements Authentication {
final String location;
final String paramName;
String apiKey;
@@ -10,7 +9,8 @@ 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,14 +1,15 @@
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,7 +6,8 @@ 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,7 +1,6 @@
part of openapi.api;
class ApiResponse {
int code = null;
String type = null;
@@ -22,23 +21,22 @@ class ApiResponse {
}
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,7 +1,6 @@
part of openapi.api;
class Category {
int id = null;
String name = null;
@@ -19,22 +18,22 @@ class Category {
}
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,7 +1,6 @@
part of openapi.api;
class Order {
int id = null;
int petId = null;
@@ -26,7 +25,8 @@ class Order {
id = json['id'];
petId = json['petId'];
quantity = json['quantity'];
shipDate = json['shipDate'] == null ? null : DateTime.parse(json['shipDate']);
shipDate =
json['shipDate'] == null ? null : DateTime.parse(json['shipDate']);
status = json['status'];
complete = json['complete'];
}
@@ -43,15 +43,18 @@ 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,7 +1,6 @@
part of openapi.api;
class Pet {
int id = null;
Category category = null;
@@ -26,7 +25,9 @@ class Pet {
id = json['id'];
category = new Category.fromJson(json['category']);
name = json['name'];
photoUrls = ((json['photoUrls'] ?? []) as List).map((item) => item as String).toList();
photoUrls = ((json['photoUrls'] ?? []) as List)
.map((item) => item as String)
.toList();
tags = Tag.listFromJson(json['tags']);
status = json['status'];
}
@@ -43,15 +44,17 @@ 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,7 +1,6 @@
part of openapi.api;
class Tag {
int id = null;
String name = null;
@@ -19,22 +18,21 @@ class Tag {
}
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,7 +1,6 @@
part of openapi.api;
class User {
int id = null;
String username = null;
@@ -50,15 +49,17 @@ 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.2.2-SNAPSHOT
3.3.0-SNAPSHOT

View File

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

View File

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

View File

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

View File

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

View File

@@ -8,7 +8,6 @@ class QueryParam {
}
class ApiClient {
String basePath;
var client = BrowserClient();
@@ -67,9 +66,11 @@ class ApiClient {
}
}
} 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) {
@@ -94,7 +95,8 @@ 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,
@@ -102,20 +104,19 @@ 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;
headerParams.addAll(_defaultHeaderMap);
headerParams['Content-Type'] = contentType;
if(body is MultipartRequest) {
if (body is MultipartRequest) {
var request = MultipartRequest(method, Uri.parse(url));
request.fields.addAll(body.fields);
request.files.addAll(body.files);
@@ -124,8 +125,10 @@ class ApiClient {
var response = await client.send(request);
return Response.fromStream(response);
} else {
var msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body);
switch(method) {
var msgBody = contentType == "application/x-www-form-urlencoded"
? formParams
: serialize(body);
switch (method) {
case "POST":
return client.post(url, headers: headerParams, body: msgBody);
case "PUT":
@@ -142,10 +145,12 @@ 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,7 +8,8 @@ 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,7 +28,8 @@ 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,7 +1,6 @@
part of openapi.api;
class ApiKeyAuth implements Authentication {
final String location;
final String paramName;
String apiKey;
@@ -10,7 +9,8 @@ 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,14 +1,15 @@
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,7 +6,8 @@ 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,7 +1,6 @@
part of openapi.api;
class ApiResponse {
int code = null;
String type = null;
@@ -22,23 +21,22 @@ class ApiResponse {
}
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,7 +1,6 @@
part of openapi.api;
class Category {
int id = null;
String name = null;
@@ -19,22 +18,22 @@ class Category {
}
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,7 +1,6 @@
part of openapi.api;
class Order {
int id = null;
int petId = null;
@@ -26,7 +25,8 @@ class Order {
id = json['id'];
petId = json['petId'];
quantity = json['quantity'];
shipDate = json['shipDate'] == null ? null : DateTime.parse(json['shipDate']);
shipDate =
json['shipDate'] == null ? null : DateTime.parse(json['shipDate']);
status = json['status'];
complete = json['complete'];
}
@@ -43,15 +43,18 @@ 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,7 +1,6 @@
part of openapi.api;
class Pet {
int id = null;
Category category = null;
@@ -26,7 +25,9 @@ class Pet {
id = json['id'];
category = new Category.fromJson(json['category']);
name = json['name'];
photoUrls = ((json['photoUrls'] ?? []) as List).map((item) => item as String).toList();
photoUrls = ((json['photoUrls'] ?? []) as List)
.map((item) => item as String)
.toList();
tags = Tag.listFromJson(json['tags']);
status = json['status'];
}
@@ -43,15 +44,17 @@ 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,7 +1,6 @@
part of openapi.api;
class Tag {
int id = null;
String name = null;
@@ -19,22 +18,21 @@ class Tag {
}
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,7 +1,6 @@
part of openapi.api;
class User {
int id = null;
String username = null;
@@ -50,15 +49,17 @@ 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.2.2-SNAPSHOT
3.3.0-SNAPSHOT

View File

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

View File

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

View File

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

View File

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

View File

@@ -8,7 +8,6 @@ class QueryParam {
}
class ApiClient {
String basePath;
var client = Client();
@@ -67,9 +66,11 @@ class ApiClient {
}
}
} 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) {
@@ -94,7 +95,8 @@ 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,
@@ -102,20 +104,19 @@ 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;
headerParams.addAll(_defaultHeaderMap);
headerParams['Content-Type'] = contentType;
if(body is MultipartRequest) {
if (body is MultipartRequest) {
var request = MultipartRequest(method, Uri.parse(url));
request.fields.addAll(body.fields);
request.files.addAll(body.files);
@@ -124,8 +125,10 @@ class ApiClient {
var response = await client.send(request);
return Response.fromStream(response);
} else {
var msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body);
switch(method) {
var msgBody = contentType == "application/x-www-form-urlencoded"
? formParams
: serialize(body);
switch (method) {
case "POST":
return client.post(url, headers: headerParams, body: msgBody);
case "PUT":
@@ -142,10 +145,12 @@ 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