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 | | | 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) **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** **API documentation generators** | **HTML**, **Confluence Wiki**
**Configuration files** | [**Apache2**](https://httpd.apache.org/) **Configuration files** | [**Apache2**](https://httpd.apache.org/)
@@ -516,7 +516,8 @@ Here is a list of template creators:
* C# (.NET 4.5 refactored): @jimschubert * C# (.NET 4.5 refactored): @jimschubert
* Clojure: @xhh * Clojure: @xhh
* Dart: @yissachar * Dart: @yissachar
* Dart (refactored in 2.4.0): @joernahrens * Dart (refactor): @joernahrens
* Dart 2: @swipesight
* Elixir: @niku * Elixir: @niku
* Elm: @trenneman * Elm: @trenneman
* Eiffel: @jvelilla * Eiffel: @jvelilla

View File

@@ -29,18 +29,18 @@ fi
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
# Generate non-browserClient # 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: # 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 java $JAVA_OPTS -jar $executable $ags
# Generate browserClient # 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 java $JAVA_OPTS -jar $executable $ags
# Generate non-browserClient and put it to the flutter sample app # 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 java $JAVA_OPTS -jar $executable $ags
# There is a proposal to allow importing different libraries depending on the environment: # 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" export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
# Generate non-browserClient # 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: # 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 $@" #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 java $JAVA_OPTS -jar $executable $ags
# Generate browserClient # 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 java $JAVA_OPTS -jar $executable $ags
# Generate non-browserClient and put it to the flutter sample app # 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 java $JAVA_OPTS -jar $executable $ags
# There is a proposal to allow importing different libraries depending on the environment: # 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.oas.models.media.*;
import io.swagger.v3.parser.util.SchemaTypeUtil; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
public class DartClientCodegen extends DefaultCodegen implements CodegenConfig { public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(DartClientCodegen.class); 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(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(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(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 @Override
@@ -142,13 +145,17 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override @Override
public String getHelp() { public String getHelp() {
return "Generates a Dart client library."; return "Generates a Dart (1.x or 2.x) client library.";
} }
@Override @Override
public void processOpts() { public void processOpts() {
super.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)) { if (additionalProperties.containsKey(BROWSER_CLIENT)) {
this.setBrowserClient(convertPropertyToBooleanAndWriteBack(BROWSER_CLIENT)); this.setBrowserClient(convertPropertyToBooleanAndWriteBack(BROWSER_CLIENT));
} else { } else {
@@ -193,11 +200,16 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
additionalProperties.put("modelDocPath", modelDocPath); additionalProperties.put("modelDocPath", modelDocPath);
final Object isSupportDart2 = additionalProperties.get(SUPPORT_DART2); final Object isSupportDart2 = additionalProperties.get(SUPPORT_DART2);
if (Boolean.TRUE.equals(isSupportDart2) || (isSupportDart2 instanceof String && Boolean.parseBoolean((String)isSupportDart2))) { if (Boolean.FALSE.equals(isSupportDart2) || (isSupportDart2 instanceof String && !Boolean.parseBoolean((String)isSupportDart2))) {
embeddedTemplateDir = templateDir = "dart2"; // dart 1.x
} else { LOGGER.info("Dart version: 1.x");
supportingFiles.add(new SupportingFile("analysis_options.mustache", "", ".analysis_options")); 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"; final String libFolder = sourceFolder + File.separator + "lib";
supportingFiles.add(new SupportingFile("pubspec.mustache", "", "pubspec.yaml")); supportingFiles.add(new SupportingFile("pubspec.mustache", "", "pubspec.yaml"));
supportingFiles.add(new SupportingFile("api_client.mustache", libFolder, "api_client.dart")); 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("/*", "/_*"); 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/tag.dart';
part 'model/user.dart'; part 'model/user.dart';
ApiClient defaultApiClient = new ApiClient(); ApiClient defaultApiClient = new ApiClient();

View File

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

View File

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

View File

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

View File

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

View File

@@ -8,7 +8,8 @@ class ApiException implements Exception {
ApiException(this.code, this.message); 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() { String toString() {
if (message == null) return "ApiException"; if (message == null) return "ApiException";

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,9 +1,8 @@
part of openapi.api; part of openapi.api;
class Category { class Category {
int id = null; int id = null;
String name = null; String name = null;
Category(); Category();
@@ -19,22 +18,22 @@ class Category {
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return { return {'id': id, 'name': name};
'id': id,
'name': name
};
} }
static List<Category> listFromJson(List<dynamic> json) { 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>(); var map = new Map<String, Category>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => map[key] = new Category.fromJson(value)); json.forEach((String key, Map<String, dynamic> value) =>
map[key] = new Category.fromJson(value));
} }
return map; return map;
} }
} }

View File

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

View File

@@ -1,15 +1,14 @@
part of openapi.api; part of openapi.api;
class Pet { class Pet {
int id = null; int id = null;
Category category = null; Category category = null;
String name = null; String name = null;
List<String> photoUrls = []; List<String> photoUrls = [];
List<Tag> tags = []; List<Tag> tags = [];
/* pet status in the store */ /* pet status in the store */
String status = null; String status = null;
@@ -26,7 +25,8 @@ class Pet {
id = json['id']; id = json['id'];
category = new Category.fromJson(json['category']); category = new Category.fromJson(json['category']);
name = json['name']; 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']); tags = Tag.listFromJson(json['tags']);
status = json['status']; status = json['status'];
} }
@@ -43,15 +43,17 @@ class Pet {
} }
static List<Pet> listFromJson(List<dynamic> json) { 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) { static Map<String, Pet> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, Pet>(); var map = new Map<String, Pet>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => map[key] = new Pet.fromJson(value)); json.forEach((String key, Map<String, dynamic> value) =>
map[key] = new Pet.fromJson(value));
} }
return map; return map;
} }
} }

View File

@@ -1,9 +1,8 @@
part of openapi.api; part of openapi.api;
class Tag { class Tag {
int id = null; int id = null;
String name = null; String name = null;
Tag(); Tag();
@@ -19,22 +18,21 @@ class Tag {
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return { return {'id': id, 'name': name};
'id': id,
'name': name
};
} }
static List<Tag> listFromJson(List<dynamic> json) { 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) { static Map<String, Tag> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, Tag>(); var map = new Map<String, Tag>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => map[key] = new Tag.fromJson(value)); json.forEach((String key, Map<String, dynamic> value) =>
map[key] = new Tag.fromJson(value));
} }
return map; return map;
} }
} }

View File

@@ -1,19 +1,18 @@
part of openapi.api; part of openapi.api;
class User { class User {
int id = null; int id = null;
String username = null; String username = null;
String firstName = null; String firstName = null;
String lastName = null; String lastName = null;
String email = null; String email = null;
String password = null; String password = null;
String phone = null; String phone = null;
/* User Status */ /* User Status */
int userStatus = null; int userStatus = null;
@@ -50,15 +49,17 @@ class User {
} }
static List<User> listFromJson(List<dynamic> json) { 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) { static Map<String, User> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, User>(); var map = new Map<String, User>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => map[key] = new User.fromJson(value)); json.forEach((String key, Map<String, dynamic> value) =>
map[key] = new User.fromJson(value));
} }
return map; 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/tag.dart';
part 'model/user.dart'; part 'model/user.dart';
ApiClient defaultApiClient = new ApiClient(); ApiClient defaultApiClient = new ApiClient();

View File

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

View File

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

View File

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

View File

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

View File

@@ -8,7 +8,8 @@ class ApiException implements Exception {
ApiException(this.code, this.message); 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() { String toString() {
if (message == null) return "ApiException"; if (message == null) return "ApiException";

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,9 +1,8 @@
part of openapi.api; part of openapi.api;
class Category { class Category {
int id = null; int id = null;
String name = null; String name = null;
Category(); Category();
@@ -19,22 +18,22 @@ class Category {
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return { return {'id': id, 'name': name};
'id': id,
'name': name
};
} }
static List<Category> listFromJson(List<dynamic> json) { 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>(); var map = new Map<String, Category>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => map[key] = new Category.fromJson(value)); json.forEach((String key, Map<String, dynamic> value) =>
map[key] = new Category.fromJson(value));
} }
return map; return map;
} }
} }

View File

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

View File

@@ -1,15 +1,14 @@
part of openapi.api; part of openapi.api;
class Pet { class Pet {
int id = null; int id = null;
Category category = null; Category category = null;
String name = null; String name = null;
List<String> photoUrls = []; List<String> photoUrls = [];
List<Tag> tags = []; List<Tag> tags = [];
/* pet status in the store */ /* pet status in the store */
String status = null; String status = null;
@@ -26,7 +25,8 @@ class Pet {
id = json['id']; id = json['id'];
category = new Category.fromJson(json['category']); category = new Category.fromJson(json['category']);
name = json['name']; 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']); tags = Tag.listFromJson(json['tags']);
status = json['status']; status = json['status'];
} }
@@ -43,15 +43,17 @@ class Pet {
} }
static List<Pet> listFromJson(List<dynamic> json) { 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) { static Map<String, Pet> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, Pet>(); var map = new Map<String, Pet>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => map[key] = new Pet.fromJson(value)); json.forEach((String key, Map<String, dynamic> value) =>
map[key] = new Pet.fromJson(value));
} }
return map; return map;
} }
} }

View File

@@ -1,9 +1,8 @@
part of openapi.api; part of openapi.api;
class Tag { class Tag {
int id = null; int id = null;
String name = null; String name = null;
Tag(); Tag();
@@ -19,22 +18,21 @@ class Tag {
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return { return {'id': id, 'name': name};
'id': id,
'name': name
};
} }
static List<Tag> listFromJson(List<dynamic> json) { 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) { static Map<String, Tag> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, Tag>(); var map = new Map<String, Tag>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => map[key] = new Tag.fromJson(value)); json.forEach((String key, Map<String, dynamic> value) =>
map[key] = new Tag.fromJson(value));
} }
return map; return map;
} }
} }

View File

@@ -1,19 +1,18 @@
part of openapi.api; part of openapi.api;
class User { class User {
int id = null; int id = null;
String username = null; String username = null;
String firstName = null; String firstName = null;
String lastName = null; String lastName = null;
String email = null; String email = null;
String password = null; String password = null;
String phone = null; String phone = null;
/* User Status */ /* User Status */
int userStatus = null; int userStatus = null;
@@ -50,15 +49,17 @@ class User {
} }
static List<User> listFromJson(List<dynamic> json) { 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) { static Map<String, User> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, User>(); var map = new Map<String, User>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => map[key] = new User.fromJson(value)); json.forEach((String key, Map<String, dynamic> value) =>
map[key] = new User.fromJson(value));
} }
return map; 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/tag.dart';
part 'model/user.dart'; part 'model/user.dart';
ApiClient defaultApiClient = new ApiClient(); ApiClient defaultApiClient = new ApiClient();

View File

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

View File

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

View File

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

View File

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

View File

@@ -8,7 +8,8 @@ class ApiException implements Exception {
ApiException(this.code, this.message); 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() { String toString() {
if (message == null) return "ApiException"; if (message == null) return "ApiException";

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,9 +1,8 @@
part of openapi.api; part of openapi.api;
class Category { class Category {
int id = null; int id = null;
String name = null; String name = null;
Category(); Category();
@@ -19,22 +18,22 @@ class Category {
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return { return {'id': id, 'name': name};
'id': id,
'name': name
};
} }
static List<Category> listFromJson(List<dynamic> json) { 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>(); var map = new Map<String, Category>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => map[key] = new Category.fromJson(value)); json.forEach((String key, Map<String, dynamic> value) =>
map[key] = new Category.fromJson(value));
} }
return map; return map;
} }
} }

View File

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

View File

@@ -1,15 +1,14 @@
part of openapi.api; part of openapi.api;
class Pet { class Pet {
int id = null; int id = null;
Category category = null; Category category = null;
String name = null; String name = null;
List<String> photoUrls = []; List<String> photoUrls = [];
List<Tag> tags = []; List<Tag> tags = [];
/* pet status in the store */ /* pet status in the store */
String status = null; String status = null;
@@ -26,7 +25,8 @@ class Pet {
id = json['id']; id = json['id'];
category = new Category.fromJson(json['category']); category = new Category.fromJson(json['category']);
name = json['name']; 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']); tags = Tag.listFromJson(json['tags']);
status = json['status']; status = json['status'];
} }
@@ -43,15 +43,17 @@ class Pet {
} }
static List<Pet> listFromJson(List<dynamic> json) { 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) { static Map<String, Pet> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, Pet>(); var map = new Map<String, Pet>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => map[key] = new Pet.fromJson(value)); json.forEach((String key, Map<String, dynamic> value) =>
map[key] = new Pet.fromJson(value));
} }
return map; return map;
} }
} }

View File

@@ -1,9 +1,8 @@
part of openapi.api; part of openapi.api;
class Tag { class Tag {
int id = null; int id = null;
String name = null; String name = null;
Tag(); Tag();
@@ -19,22 +18,21 @@ class Tag {
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return { return {'id': id, 'name': name};
'id': id,
'name': name
};
} }
static List<Tag> listFromJson(List<dynamic> json) { 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) { static Map<String, Tag> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, Tag>(); var map = new Map<String, Tag>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => map[key] = new Tag.fromJson(value)); json.forEach((String key, Map<String, dynamic> value) =>
map[key] = new Tag.fromJson(value));
} }
return map; return map;
} }
} }

View File

@@ -1,19 +1,18 @@
part of openapi.api; part of openapi.api;
class User { class User {
int id = null; int id = null;
String username = null; String username = null;
String firstName = null; String firstName = null;
String lastName = null; String lastName = null;
String email = null; String email = null;
String password = null; String password = null;
String phone = null; String phone = null;
/* User Status */ /* User Status */
int userStatus = null; int userStatus = null;
@@ -50,15 +49,17 @@ class User {
} }
static List<User> listFromJson(List<dynamic> json) { 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) { static Map<String, User> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, User>(); var map = new Map<String, User>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => map[key] = new User.fromJson(value)); json.forEach((String key, Map<String, dynamic> value) =>
map[key] = new User.fromJson(value));
} }
return map; 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/tag.dart';
part 'model/user.dart'; part 'model/user.dart';
ApiClient defaultApiClient = ApiClient(); ApiClient defaultApiClient = ApiClient();

View File

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

View File

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

View File

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

View File

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

View File

@@ -8,7 +8,8 @@ class ApiException implements Exception {
ApiException(this.code, this.message); 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() { String toString() {
if (message == null) return "ApiException"; if (message == null) return "ApiException";

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,9 +1,8 @@
part of openapi.api; part of openapi.api;
class Category { class Category {
int id = null; int id = null;
String name = null; String name = null;
Category(); Category();
@@ -19,22 +18,22 @@ class Category {
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return { return {'id': id, 'name': name};
'id': id,
'name': name
};
} }
static List<Category> listFromJson(List<dynamic> json) { 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>(); var map = new Map<String, Category>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => map[key] = new Category.fromJson(value)); json.forEach((String key, Map<String, dynamic> value) =>
map[key] = new Category.fromJson(value));
} }
return map; return map;
} }
} }

View File

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

View File

@@ -1,15 +1,14 @@
part of openapi.api; part of openapi.api;
class Pet { class Pet {
int id = null; int id = null;
Category category = null; Category category = null;
String name = null; String name = null;
List<String> photoUrls = []; List<String> photoUrls = [];
List<Tag> tags = []; List<Tag> tags = [];
/* pet status in the store */ /* pet status in the store */
String status = null; String status = null;
@@ -26,7 +25,9 @@ class Pet {
id = json['id']; id = json['id'];
category = new Category.fromJson(json['category']); category = new Category.fromJson(json['category']);
name = json['name']; 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']); tags = Tag.listFromJson(json['tags']);
status = json['status']; status = json['status'];
} }
@@ -43,15 +44,17 @@ class Pet {
} }
static List<Pet> listFromJson(List<dynamic> json) { 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) { static Map<String, Pet> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, Pet>(); var map = new Map<String, Pet>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => map[key] = new Pet.fromJson(value)); json.forEach((String key, Map<String, dynamic> value) =>
map[key] = new Pet.fromJson(value));
} }
return map; return map;
} }
} }

View File

@@ -1,9 +1,8 @@
part of openapi.api; part of openapi.api;
class Tag { class Tag {
int id = null; int id = null;
String name = null; String name = null;
Tag(); Tag();
@@ -19,22 +18,21 @@ class Tag {
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return { return {'id': id, 'name': name};
'id': id,
'name': name
};
} }
static List<Tag> listFromJson(List<dynamic> json) { 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) { static Map<String, Tag> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, Tag>(); var map = new Map<String, Tag>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => map[key] = new Tag.fromJson(value)); json.forEach((String key, Map<String, dynamic> value) =>
map[key] = new Tag.fromJson(value));
} }
return map; return map;
} }
} }

View File

@@ -1,19 +1,18 @@
part of openapi.api; part of openapi.api;
class User { class User {
int id = null; int id = null;
String username = null; String username = null;
String firstName = null; String firstName = null;
String lastName = null; String lastName = null;
String email = null; String email = null;
String password = null; String password = null;
String phone = null; String phone = null;
/* User Status */ /* User Status */
int userStatus = null; int userStatus = null;
@@ -50,15 +49,17 @@ class User {
} }
static List<User> listFromJson(List<dynamic> json) { 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) { static Map<String, User> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, User>(); var map = new Map<String, User>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => map[key] = new User.fromJson(value)); json.forEach((String key, Map<String, dynamic> value) =>
map[key] = new User.fromJson(value));
} }
return map; 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/tag.dart';
part 'model/user.dart'; part 'model/user.dart';
ApiClient defaultApiClient = ApiClient(); ApiClient defaultApiClient = ApiClient();

View File

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

View File

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

View File

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

View File

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

View File

@@ -8,7 +8,8 @@ class ApiException implements Exception {
ApiException(this.code, this.message); 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() { String toString() {
if (message == null) return "ApiException"; if (message == null) return "ApiException";

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,9 +1,8 @@
part of openapi.api; part of openapi.api;
class Category { class Category {
int id = null; int id = null;
String name = null; String name = null;
Category(); Category();
@@ -19,22 +18,22 @@ class Category {
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return { return {'id': id, 'name': name};
'id': id,
'name': name
};
} }
static List<Category> listFromJson(List<dynamic> json) { 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>(); var map = new Map<String, Category>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => map[key] = new Category.fromJson(value)); json.forEach((String key, Map<String, dynamic> value) =>
map[key] = new Category.fromJson(value));
} }
return map; return map;
} }
} }

View File

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

View File

@@ -1,15 +1,14 @@
part of openapi.api; part of openapi.api;
class Pet { class Pet {
int id = null; int id = null;
Category category = null; Category category = null;
String name = null; String name = null;
List<String> photoUrls = []; List<String> photoUrls = [];
List<Tag> tags = []; List<Tag> tags = [];
/* pet status in the store */ /* pet status in the store */
String status = null; String status = null;
@@ -26,7 +25,9 @@ class Pet {
id = json['id']; id = json['id'];
category = new Category.fromJson(json['category']); category = new Category.fromJson(json['category']);
name = json['name']; 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']); tags = Tag.listFromJson(json['tags']);
status = json['status']; status = json['status'];
} }
@@ -43,15 +44,17 @@ class Pet {
} }
static List<Pet> listFromJson(List<dynamic> json) { 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) { static Map<String, Pet> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, Pet>(); var map = new Map<String, Pet>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => map[key] = new Pet.fromJson(value)); json.forEach((String key, Map<String, dynamic> value) =>
map[key] = new Pet.fromJson(value));
} }
return map; return map;
} }
} }

View File

@@ -1,9 +1,8 @@
part of openapi.api; part of openapi.api;
class Tag { class Tag {
int id = null; int id = null;
String name = null; String name = null;
Tag(); Tag();
@@ -19,22 +18,21 @@ class Tag {
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return { return {'id': id, 'name': name};
'id': id,
'name': name
};
} }
static List<Tag> listFromJson(List<dynamic> json) { 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) { static Map<String, Tag> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, Tag>(); var map = new Map<String, Tag>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => map[key] = new Tag.fromJson(value)); json.forEach((String key, Map<String, dynamic> value) =>
map[key] = new Tag.fromJson(value));
} }
return map; return map;
} }
} }

View File

@@ -1,19 +1,18 @@
part of openapi.api; part of openapi.api;
class User { class User {
int id = null; int id = null;
String username = null; String username = null;
String firstName = null; String firstName = null;
String lastName = null; String lastName = null;
String email = null; String email = null;
String password = null; String password = null;
String phone = null; String phone = null;
/* User Status */ /* User Status */
int userStatus = null; int userStatus = null;
@@ -50,15 +49,17 @@ class User {
} }
static List<User> listFromJson(List<dynamic> json) { 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) { static Map<String, User> mapFromJson(Map<String, Map<String, dynamic>> json) {
var map = new Map<String, User>(); var map = new Map<String, User>();
if (json != null && json.length > 0) { if (json != null && json.length > 0) {
json.forEach((String key, Map<String, dynamic> value) => map[key] = new User.fromJson(value)); json.forEach((String key, Map<String, dynamic> value) =>
map[key] = new User.fromJson(value));
} }
return map; 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/tag.dart';
part 'model/user.dart'; part 'model/user.dart';
ApiClient defaultApiClient = ApiClient(); ApiClient defaultApiClient = ApiClient();

View File

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

View File

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

View File

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

View File

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

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