mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-06 10:35:25 +00:00
dart codegen improvements (#3440)
* fix: query params may be ints as well don't assume query params are Strings or List<String>s * fix dart: use correct type for QueryParams type is Iterable, not List only check params for != null if they haven't been checked already add some casts to make strong mode happy update petstore * feat dart: enable strong mode * feat dart: generate both browser and vm library move petstore client into subdirectory and reference generated libraries using path in pubspec.yaml * feat dart: refactor petstore test. The new layout resembles a real project. petstore test is now strong mode compatible. * feat: add DateTimerParser transformer * feat: improved exception reporting * feat[dart]: handle patch requests * fix[dart]: typo * fix dart: remove findPetsByTag test; enable strong-mode find pets by tag call is deprecated and returns 500 generated library is now strong mode compatible
This commit is contained in:
parent
a1e7c517d3
commit
bf17a91275
@ -26,9 +26,16 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l dart -o samples/client/petstore/dart"
|
||||
|
||||
# for dart vm lib generation:
|
||||
#ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l dart -o samples/client/petstore/dart --additional-properties browserClient=false"
|
||||
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l dart -o samples/client/petstore/dart/swagger"
|
||||
|
||||
# then options to generate the library for vm would be:
|
||||
#ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l dart -o samples/client/petstore/dart/swagger_vm -DbrowserClient=false -DpubName=swagger_vm"
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
# There is a proposal to allow importing different libraries depending on the environment:
|
||||
# https://github.com/munificent/dep-interface-libraries
|
||||
# When this is implemented there will only be one library.
|
||||
|
||||
# The current petstore test will then work for both: the browser library and the vm library.
|
||||
|
||||
|
@ -140,6 +140,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
final String libFolder = sourceFolder + File.separator + "lib";
|
||||
supportingFiles.add(new SupportingFile("pubspec.mustache", "", "pubspec.yaml"));
|
||||
supportingFiles.add(new SupportingFile("analysis_options.mustache", "", ".analysis_options"));
|
||||
supportingFiles.add(new SupportingFile("api_client.mustache", libFolder, "api_client.dart"));
|
||||
supportingFiles.add(new SupportingFile("api_exception.mustache", libFolder, "api_exception.dart"));
|
||||
supportingFiles.add(new SupportingFile("api_helper.mustache", libFolder, "api_helper.dart"));
|
||||
|
@ -0,0 +1,2 @@
|
||||
analyzer:
|
||||
strong-mode: true
|
@ -36,9 +36,13 @@ class {{classname}} {
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
{{#queryParams}}
|
||||
if("null" != {{paramName}}) {
|
||||
{{^required}}
|
||||
if({{paramName}} != null) {
|
||||
{{/required}}
|
||||
queryParams.addAll(_convertParametersForCollectionFormat("{{collectionFormat}}", "{{baseName}}", {{paramName}}));
|
||||
{{^required}}
|
||||
}
|
||||
{{/required}}
|
||||
{{/queryParams}}
|
||||
{{#headerParams}}headerParams["{{baseName}}"] = {{paramName}};
|
||||
{{/headerParams}}
|
||||
@ -84,7 +88,7 @@ class {{classname}} {
|
||||
if(response.statusCode >= 400) {
|
||||
throw new ApiException(response.statusCode, response.body);
|
||||
} else if(response.body != null) {
|
||||
return {{#returnType}} apiClient.deserialize(response.body, '{{{returnType}}}') {{/returnType}};
|
||||
return {{#returnType}}apiClient.deserialize(response.body, '{{{returnType}}}') as {{{returnType}}} {{/returnType}};
|
||||
} else {
|
||||
return {{#returnType}}null{{/returnType}};
|
||||
}
|
||||
|
@ -15,7 +15,8 @@ class ApiClient {
|
||||
Map<String, String> _defaultHeaderMap = {};
|
||||
Map<String, Authentication> _authentications = {};
|
||||
|
||||
final dson = new Dartson.JSON();
|
||||
final dson = new Dartson.JSON()
|
||||
..addTransformer(new DateTimeParser(), DateTime);
|
||||
final DateFormat _dateFormatter = new DateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
|
||||
|
||||
final _RegList = new RegExp(r'^List<(.*)>$');
|
||||
@ -72,20 +73,18 @@ class ApiClient {
|
||||
Match match;
|
||||
if (value is List &&
|
||||
(match = _RegList.firstMatch(targetType)) != null) {
|
||||
var valueL = value as List;
|
||||
var newTargetType = match[1];
|
||||
return valueL.map((v) => _deserialize(v, newTargetType)).toList();
|
||||
return value.map((v) => _deserialize(v, newTargetType)).toList();
|
||||
} else if (value is Map &&
|
||||
(match = _RegMap.firstMatch(targetType)) != null) {
|
||||
var valueM = value as Map;
|
||||
var newTargetType = match[1];
|
||||
return new Map.fromIterables(valueM.keys,
|
||||
valueM.values.map((v) => _deserialize(v, newTargetType)));
|
||||
return new Map.fromIterables(value.keys,
|
||||
value.values.map((v) => _deserialize(v, newTargetType)));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
// Just throw the ApiException below
|
||||
} catch (e, stack) {
|
||||
throw new ApiException.withInner(500, 'Exception during deserialization.', e, stack);
|
||||
}
|
||||
throw new ApiException(500, 'Could not find a suitable class for deserialization');
|
||||
}
|
||||
@ -116,7 +115,7 @@ class ApiClient {
|
||||
// If collectionFormat is 'multi' a key might appear multiple times.
|
||||
Future<Response> invokeAPI(String path,
|
||||
String method,
|
||||
List<QueryParam> queryParams,
|
||||
Iterable<QueryParam> queryParams,
|
||||
Object body,
|
||||
Map<String, String> headerParams,
|
||||
Map<String, String> formParams,
|
||||
@ -152,6 +151,8 @@ class ApiClient {
|
||||
return client.put(url, headers: headerParams, body: msgBody);
|
||||
case "DELETE":
|
||||
return client.delete(url, headers: headerParams);
|
||||
case "PATCH":
|
||||
return client.patch(url, headers: headerParams, body: msgBody);
|
||||
default:
|
||||
return client.get(url, headers: headerParams);
|
||||
}
|
||||
|
@ -3,7 +3,21 @@ part of {{pubName}}.api;
|
||||
class ApiException implements Exception {
|
||||
int code = 0;
|
||||
String message = null;
|
||||
Exception innerException = null;
|
||||
StackTrace stackTrace = null;
|
||||
|
||||
ApiException(this.code, this.message);
|
||||
|
||||
}
|
||||
ApiException.withInner(this.code, this.message, this.innerException, this.stackTrace);
|
||||
|
||||
String toString() {
|
||||
if (message == null) return "ApiException";
|
||||
|
||||
if (innerException == null) {
|
||||
return "ApiException $code: $message";
|
||||
}
|
||||
|
||||
return "ApiException $code: $message (Inner exception: ${innerException})\n\n" +
|
||||
stackTrace.toString();
|
||||
}
|
||||
}
|
||||
|
@ -3,19 +3,19 @@ part of {{pubName}}.api;
|
||||
const _delimiters = const {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'};
|
||||
|
||||
// port from Java version
|
||||
List<QueryParam> _convertParametersForCollectionFormat(
|
||||
Iterable<QueryParam> _convertParametersForCollectionFormat(
|
||||
String collectionFormat, String name, dynamic value) {
|
||||
var params = [];
|
||||
var params = <QueryParam>[];
|
||||
|
||||
// preconditions
|
||||
if (name == null || name.isEmpty || value == null) return params;
|
||||
|
||||
if (value is! List) {
|
||||
params.add(new QueryParam(name, value as String));
|
||||
params.add(new QueryParam(name, '$value'));
|
||||
return params;
|
||||
}
|
||||
|
||||
List<String> values = value as List<String>;
|
||||
List values = value as List;
|
||||
|
||||
// get the collection format
|
||||
collectionFormat = (collectionFormat == null || collectionFormat.isEmpty)
|
||||
@ -23,7 +23,7 @@ List<QueryParam> _convertParametersForCollectionFormat(
|
||||
: collectionFormat; // default: csv
|
||||
|
||||
if (collectionFormat == "multi") {
|
||||
return values.map((v) => new QueryParam(name, v));
|
||||
return values.map((v) => new QueryParam(name, '$v'));
|
||||
}
|
||||
|
||||
String delimiter = _delimiters[collectionFormat] ?? ",";
|
||||
|
@ -5,6 +5,7 @@ import 'dart:convert';{{#browserClient}}
|
||||
import 'package:http/browser_client.dart';{{/browserClient}}
|
||||
import 'package:http/http.dart';
|
||||
import 'package:dartson/dartson.dart';
|
||||
import 'package:dartson/transformers/date_time.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
part 'api_client.dart';
|
||||
|
2
samples/client/petstore/dart/.analysis_options
Normal file
2
samples/client/petstore/dart/.analysis_options
Normal file
@ -0,0 +1,2 @@
|
||||
analyzer:
|
||||
strong-mode: true
|
23
samples/client/petstore/dart/.swagger-codegen-ignore
Normal file
23
samples/client/petstore/dart/.swagger-codegen-ignore
Normal file
@ -0,0 +1,23 @@
|
||||
# Swagger Codegen Ignore
|
||||
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
@ -1,9 +0,0 @@
|
||||
part of api;
|
||||
|
||||
class ApiException implements Exception {
|
||||
int code = 0;
|
||||
String message = null;
|
||||
|
||||
ApiException(this.code, this.message);
|
||||
|
||||
}
|
2
samples/client/petstore/dart/petstore/.analysis_options
Normal file
2
samples/client/petstore/dart/petstore/.analysis_options
Normal file
@ -0,0 +1,2 @@
|
||||
analyzer:
|
||||
strong-mode: true
|
9
samples/client/petstore/dart/petstore/pubspec.yaml
Normal file
9
samples/client/petstore/dart/petstore/pubspec.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
name: petstore_client
|
||||
version: 1.0.0
|
||||
description: Petstore client using swagger API library
|
||||
dependencies:
|
||||
swagger:
|
||||
path: ../swagger
|
||||
|
||||
dev_dependencies:
|
||||
guinness: '^0.1.17'
|
1
samples/client/petstore/dart/petstore/test/browser/packages
Symbolic link
1
samples/client/petstore/dart/petstore/test/browser/packages
Symbolic link
@ -0,0 +1 @@
|
||||
../../packages
|
@ -71,34 +71,6 @@ testPetApi() {
|
||||
});
|
||||
});
|
||||
|
||||
it('finds pets by tag', () async {
|
||||
var snowyId = newId();
|
||||
var grumpyId = newId();
|
||||
var snowyTags = [
|
||||
new Tag()
|
||||
..id = newId()
|
||||
..name = 'terrier'
|
||||
];
|
||||
var grumpyTags = [
|
||||
new Tag()
|
||||
..id = newId()
|
||||
..name = 'grumpy'
|
||||
];
|
||||
await petApi.addPet(new Pet()
|
||||
..id = snowyId
|
||||
..name = 'Snowy'
|
||||
..tags = snowyTags);
|
||||
await petApi.addPet(new Pet()
|
||||
..id = grumpyId
|
||||
..name = 'Grumpy Cat'
|
||||
..tags = grumpyTags);
|
||||
|
||||
var pets = await petApi.findPetsByTags(['grumpy']);
|
||||
var petIds = pets.map((pet) => pet.id).toList();
|
||||
expect(petIds).toContain(grumpyId);
|
||||
expect(petIds).not.toContain(snowyId);
|
||||
});
|
||||
|
||||
it('uploads a pet image', () async {
|
||||
var id = newId();
|
||||
await petApi.addPet(new Pet()..id = id);
|
@ -1,178 +0,0 @@
|
||||
# Generated by pub
|
||||
# See http://pub.dartlang.org/doc/glossary.html#lockfile
|
||||
packages:
|
||||
analyzer:
|
||||
description:
|
||||
name: analyzer
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.26.4"
|
||||
args:
|
||||
description:
|
||||
name: args
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.13.4+2"
|
||||
async:
|
||||
description:
|
||||
name: async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.11.0"
|
||||
barback:
|
||||
description:
|
||||
name: barback
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.15.2+8"
|
||||
browser:
|
||||
description:
|
||||
name: browser
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.10.0+2"
|
||||
charcode:
|
||||
description:
|
||||
name: charcode
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
collection:
|
||||
description:
|
||||
name: collection
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.9.0"
|
||||
csslib:
|
||||
description:
|
||||
name: csslib
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.13.2"
|
||||
dartson:
|
||||
description:
|
||||
name: dartson
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.5"
|
||||
glob:
|
||||
description:
|
||||
name: glob
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.3"
|
||||
guinness:
|
||||
description:
|
||||
name: guinness
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.18"
|
||||
html:
|
||||
description:
|
||||
name: html
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.12.2+2"
|
||||
http:
|
||||
description:
|
||||
name: http
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.11.3+8"
|
||||
http_parser:
|
||||
description:
|
||||
name: http_parser
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.2"
|
||||
intl:
|
||||
description:
|
||||
name: intl
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.12.7+1"
|
||||
logging:
|
||||
description:
|
||||
name: logging
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.11.3"
|
||||
package_config:
|
||||
description:
|
||||
name: package_config
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.5"
|
||||
path:
|
||||
description:
|
||||
name: path
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.9"
|
||||
petitparser:
|
||||
description:
|
||||
name: petitparser
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.5.3"
|
||||
plugin:
|
||||
description:
|
||||
name: plugin
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.0"
|
||||
pool:
|
||||
description:
|
||||
name: pool
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.4"
|
||||
source_maps:
|
||||
description:
|
||||
name: source_maps
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.10.1+1"
|
||||
source_span:
|
||||
description:
|
||||
name: source_span
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.3"
|
||||
stack_trace:
|
||||
description:
|
||||
name: stack_trace
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.6.6"
|
||||
string_scanner:
|
||||
description:
|
||||
name: string_scanner
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
unittest:
|
||||
description:
|
||||
name: unittest
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.11.6+4"
|
||||
utf:
|
||||
description:
|
||||
name: utf
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.9.0+3"
|
||||
watcher:
|
||||
description:
|
||||
name: watcher
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.9.7+2"
|
||||
yaml:
|
||||
description:
|
||||
name: yaml
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.10"
|
||||
sdk: ">=1.14.0 <2.0.0"
|
2
samples/client/petstore/dart/swagger/.analysis_options
Normal file
2
samples/client/petstore/dart/swagger/.analysis_options
Normal file
@ -0,0 +1,2 @@
|
||||
analyzer:
|
||||
strong-mode: true
|
27
samples/client/petstore/dart/swagger/.gitignore
vendored
Normal file
27
samples/client/petstore/dart/swagger/.gitignore
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
# See https://www.dartlang.org/tools/private-files.html
|
||||
|
||||
# Files and directories created by pub
|
||||
.buildlog
|
||||
.packages
|
||||
.project
|
||||
.pub/
|
||||
build/
|
||||
**/packages/
|
||||
|
||||
# Files created by dart2js
|
||||
# (Most Dart developers will use pub build to compile Dart, use/modify these
|
||||
# rules if you intend to use dart2js directly
|
||||
# Convention is to use extension '.dart.js' for Dart compiled to Javascript to
|
||||
# differentiate from explicit Javascript files)
|
||||
*.dart.js
|
||||
*.part.js
|
||||
*.js.deps
|
||||
*.js.map
|
||||
*.info.json
|
||||
|
||||
# Directory created by dartdoc
|
||||
doc/api/
|
||||
|
||||
# Don't commit pubspec lock file
|
||||
# (Library packages only! Remove pattern if developing an application package)
|
||||
pubspec.lock
|
201
samples/client/petstore/dart/swagger/LICENSE
Normal file
201
samples/client/petstore/dart/swagger/LICENSE
Normal file
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
@ -1,10 +1,11 @@
|
||||
library api;
|
||||
library swagger.api;
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'package:http/browser_client.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:dartson/dartson.dart';
|
||||
import 'package:dartson/transformers/date_time.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
part 'api_client.dart';
|
@ -1,9 +1,8 @@
|
||||
part of api;
|
||||
part of swagger.api;
|
||||
|
||||
|
||||
|
||||
class PetApi {
|
||||
String basePath = "http://petstore.swagger.io/v2";
|
||||
final ApiClient apiClient;
|
||||
|
||||
PetApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
@ -46,8 +45,7 @@ class PetApi {
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(basePath,
|
||||
path,
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'POST',
|
||||
queryParams,
|
||||
postBody,
|
||||
@ -103,8 +101,7 @@ class PetApi {
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(basePath,
|
||||
path,
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'DELETE',
|
||||
queryParams,
|
||||
postBody,
|
||||
@ -143,9 +140,7 @@ class PetApi {
|
||||
List<QueryParam> queryParams = [];
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
if("null" != status) {
|
||||
queryParams.addAll(_convertParametersForCollectionFormat("csv", "status", status));
|
||||
}
|
||||
|
||||
List<String> contentTypes = [];
|
||||
|
||||
@ -162,8 +157,7 @@ class PetApi {
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(basePath,
|
||||
path,
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
@ -175,7 +169,7 @@ class PetApi {
|
||||
if(response.statusCode >= 400) {
|
||||
throw new ApiException(response.statusCode, response.body);
|
||||
} else if(response.body != null) {
|
||||
return apiClient.deserialize(response.body, 'List<Pet>') ;
|
||||
return apiClient.deserialize(response.body, 'List<Pet>') as List<Pet> ;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -202,9 +196,7 @@ class PetApi {
|
||||
List<QueryParam> queryParams = [];
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
if("null" != tags) {
|
||||
queryParams.addAll(_convertParametersForCollectionFormat("csv", "tags", tags));
|
||||
}
|
||||
|
||||
List<String> contentTypes = [];
|
||||
|
||||
@ -221,8 +213,7 @@ class PetApi {
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(basePath,
|
||||
path,
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
@ -234,7 +225,7 @@ class PetApi {
|
||||
if(response.statusCode >= 400) {
|
||||
throw new ApiException(response.statusCode, response.body);
|
||||
} else if(response.body != null) {
|
||||
return apiClient.deserialize(response.body, 'List<Pet>') ;
|
||||
return apiClient.deserialize(response.body, 'List<Pet>') as List<Pet> ;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -277,8 +268,7 @@ class PetApi {
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(basePath,
|
||||
path,
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
@ -290,7 +280,7 @@ class PetApi {
|
||||
if(response.statusCode >= 400) {
|
||||
throw new ApiException(response.statusCode, response.body);
|
||||
} else if(response.body != null) {
|
||||
return apiClient.deserialize(response.body, 'Pet') ;
|
||||
return apiClient.deserialize(response.body, 'Pet') as Pet ;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -333,8 +323,7 @@ class PetApi {
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(basePath,
|
||||
path,
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'PUT',
|
||||
queryParams,
|
||||
postBody,
|
||||
@ -403,8 +392,7 @@ if (status != null)
|
||||
formParams['status'] = apiClient.parameterToString(status);
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(basePath,
|
||||
path,
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'POST',
|
||||
queryParams,
|
||||
postBody,
|
||||
@ -473,8 +461,7 @@ if (status != null)
|
||||
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(basePath,
|
||||
path,
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'POST',
|
||||
queryParams,
|
||||
postBody,
|
||||
@ -486,7 +473,7 @@ if (status != null)
|
||||
if(response.statusCode >= 400) {
|
||||
throw new ApiException(response.statusCode, response.body);
|
||||
} else if(response.body != null) {
|
||||
return apiClient.deserialize(response.body, 'ApiResponse') ;
|
||||
return apiClient.deserialize(response.body, 'ApiResponse') as ApiResponse ;
|
||||
} else {
|
||||
return null;
|
||||
}
|
@ -1,9 +1,8 @@
|
||||
part of api;
|
||||
part of swagger.api;
|
||||
|
||||
|
||||
|
||||
class StoreApi {
|
||||
String basePath = "http://petstore.swagger.io/v2";
|
||||
final ApiClient apiClient;
|
||||
|
||||
StoreApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
@ -46,8 +45,7 @@ class StoreApi {
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(basePath,
|
||||
path,
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'DELETE',
|
||||
queryParams,
|
||||
postBody,
|
||||
@ -99,8 +97,7 @@ class StoreApi {
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(basePath,
|
||||
path,
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
@ -112,7 +109,7 @@ class StoreApi {
|
||||
if(response.statusCode >= 400) {
|
||||
throw new ApiException(response.statusCode, response.body);
|
||||
} else if(response.body != null) {
|
||||
return apiClient.deserialize(response.body, 'Map<String, int>') ;
|
||||
return apiClient.deserialize(response.body, 'Map<String, int>') as Map<String, int> ;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -155,8 +152,7 @@ class StoreApi {
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(basePath,
|
||||
path,
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
@ -168,7 +164,7 @@ class StoreApi {
|
||||
if(response.statusCode >= 400) {
|
||||
throw new ApiException(response.statusCode, response.body);
|
||||
} else if(response.body != null) {
|
||||
return apiClient.deserialize(response.body, 'Order') ;
|
||||
return apiClient.deserialize(response.body, 'Order') as Order ;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -211,8 +207,7 @@ class StoreApi {
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(basePath,
|
||||
path,
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'POST',
|
||||
queryParams,
|
||||
postBody,
|
||||
@ -224,7 +219,7 @@ class StoreApi {
|
||||
if(response.statusCode >= 400) {
|
||||
throw new ApiException(response.statusCode, response.body);
|
||||
} else if(response.body != null) {
|
||||
return apiClient.deserialize(response.body, 'Order') ;
|
||||
return apiClient.deserialize(response.body, 'Order') as Order ;
|
||||
} else {
|
||||
return null;
|
||||
}
|
@ -1,9 +1,8 @@
|
||||
part of api;
|
||||
part of swagger.api;
|
||||
|
||||
|
||||
|
||||
class UserApi {
|
||||
String basePath = "http://petstore.swagger.io/v2";
|
||||
final ApiClient apiClient;
|
||||
|
||||
UserApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
@ -46,8 +45,7 @@ class UserApi {
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(basePath,
|
||||
path,
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'POST',
|
||||
queryParams,
|
||||
postBody,
|
||||
@ -102,8 +100,7 @@ class UserApi {
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(basePath,
|
||||
path,
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'POST',
|
||||
queryParams,
|
||||
postBody,
|
||||
@ -158,8 +155,7 @@ class UserApi {
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(basePath,
|
||||
path,
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'POST',
|
||||
queryParams,
|
||||
postBody,
|
||||
@ -214,8 +210,7 @@ class UserApi {
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(basePath,
|
||||
path,
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'DELETE',
|
||||
queryParams,
|
||||
postBody,
|
||||
@ -270,8 +265,7 @@ class UserApi {
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(basePath,
|
||||
path,
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
@ -283,7 +277,7 @@ class UserApi {
|
||||
if(response.statusCode >= 400) {
|
||||
throw new ApiException(response.statusCode, response.body);
|
||||
} else if(response.body != null) {
|
||||
return apiClient.deserialize(response.body, 'User') ;
|
||||
return apiClient.deserialize(response.body, 'User') as User ;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -313,12 +307,8 @@ class UserApi {
|
||||
List<QueryParam> queryParams = [];
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
if("null" != username) {
|
||||
queryParams.addAll(_convertParametersForCollectionFormat("", "username", username));
|
||||
}
|
||||
if("null" != password) {
|
||||
queryParams.addAll(_convertParametersForCollectionFormat("", "password", password));
|
||||
}
|
||||
|
||||
List<String> contentTypes = [];
|
||||
|
||||
@ -335,8 +325,7 @@ class UserApi {
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(basePath,
|
||||
path,
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
@ -348,7 +337,7 @@ class UserApi {
|
||||
if(response.statusCode >= 400) {
|
||||
throw new ApiException(response.statusCode, response.body);
|
||||
} else if(response.body != null) {
|
||||
return apiClient.deserialize(response.body, 'String') ;
|
||||
return apiClient.deserialize(response.body, 'String') as String ;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -388,8 +377,7 @@ class UserApi {
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(basePath,
|
||||
path,
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
@ -447,8 +435,7 @@ class UserApi {
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(basePath,
|
||||
path,
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'PUT',
|
||||
queryParams,
|
||||
postBody,
|
@ -1,4 +1,4 @@
|
||||
part of api;
|
||||
part of swagger.api;
|
||||
|
||||
class QueryParam {
|
||||
String name;
|
||||
@ -9,18 +9,20 @@ class QueryParam {
|
||||
|
||||
class ApiClient {
|
||||
|
||||
String basePath;
|
||||
var client = new BrowserClient();
|
||||
|
||||
Map<String, String> _defaultHeaderMap = {};
|
||||
Map<String, Authentication> _authentications = {};
|
||||
|
||||
final dson = new Dartson.JSON();
|
||||
final dson = new Dartson.JSON()
|
||||
..addTransformer(new DateTimeParser(), DateTime);
|
||||
final DateFormat _dateFormatter = new DateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
|
||||
|
||||
final _RegList = new RegExp(r'^List<(.*)>$');
|
||||
final _RegMap = new RegExp(r'^Map<String,(.*)>$');
|
||||
|
||||
ApiClient() {
|
||||
ApiClient({this.basePath: "http://petstore.swagger.io/v2"}) {
|
||||
// Setup authentications (key: authentication name, value: authentication).
|
||||
_authentications['petstore_auth'] = new OAuth();
|
||||
_authentications['api_key'] = new ApiKeyAuth("header", "api_key");
|
||||
@ -76,20 +78,18 @@ class ApiClient {
|
||||
Match match;
|
||||
if (value is List &&
|
||||
(match = _RegList.firstMatch(targetType)) != null) {
|
||||
var valueL = value as List;
|
||||
var newTargetType = match[1];
|
||||
return valueL.map((v) => _deserialize(v, newTargetType)).toList();
|
||||
return value.map((v) => _deserialize(v, newTargetType)).toList();
|
||||
} else if (value is Map &&
|
||||
(match = _RegMap.firstMatch(targetType)) != null) {
|
||||
var valueM = value as Map;
|
||||
var newTargetType = match[1];
|
||||
return new Map.fromIterables(valueM.keys,
|
||||
valueM.values.map((v) => _deserialize(v, newTargetType)));
|
||||
return new Map.fromIterables(value.keys,
|
||||
value.values.map((v) => _deserialize(v, newTargetType)));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
// Just throw the ApiException below
|
||||
} catch (e, stack) {
|
||||
throw new ApiException.withInner(500, 'Exception during deserialization.', e, stack);
|
||||
}
|
||||
throw new ApiException(500, 'Could not find a suitable class for deserialization');
|
||||
}
|
||||
@ -118,10 +118,9 @@ class ApiClient {
|
||||
|
||||
// We don't use a Map<String, String> for queryParams.
|
||||
// If collectionFormat is 'multi' a key might appear multiple times.
|
||||
Future<Response> invokeAPI(String host,
|
||||
String path,
|
||||
Future<Response> invokeAPI(String path,
|
||||
String method,
|
||||
List<QueryParam> queryParams,
|
||||
Iterable<QueryParam> queryParams,
|
||||
Object body,
|
||||
Map<String, String> headerParams,
|
||||
Map<String, String> formParams,
|
||||
@ -135,7 +134,7 @@ class ApiClient {
|
||||
'?' + ps.join('&') :
|
||||
'';
|
||||
|
||||
String url = host + path + queryString;
|
||||
String url = basePath + path + queryString;
|
||||
|
||||
headerParams.addAll(_defaultHeaderMap);
|
||||
headerParams['Content-Type'] = contentType;
|
||||
@ -157,6 +156,8 @@ class ApiClient {
|
||||
return client.put(url, headers: headerParams, body: msgBody);
|
||||
case "DELETE":
|
||||
return client.delete(url, headers: headerParams);
|
||||
case "PATCH":
|
||||
return client.patch(url, headers: headerParams, body: msgBody);
|
||||
default:
|
||||
return client.get(url, headers: headerParams);
|
||||
}
|
23
samples/client/petstore/dart/swagger/lib/api_exception.dart
Normal file
23
samples/client/petstore/dart/swagger/lib/api_exception.dart
Normal file
@ -0,0 +1,23 @@
|
||||
part of swagger.api;
|
||||
|
||||
class ApiException implements Exception {
|
||||
int code = 0;
|
||||
String message = null;
|
||||
Exception innerException = null;
|
||||
StackTrace stackTrace = null;
|
||||
|
||||
ApiException(this.code, this.message);
|
||||
|
||||
ApiException.withInner(this.code, this.message, this.innerException, this.stackTrace);
|
||||
|
||||
String toString() {
|
||||
if (message == null) return "ApiException";
|
||||
|
||||
if (innerException == null) {
|
||||
return "ApiException $code: $message";
|
||||
}
|
||||
|
||||
return "ApiException $code: $message (Inner exception: ${innerException})\n\n" +
|
||||
stackTrace.toString();
|
||||
}
|
||||
}
|
@ -1,21 +1,21 @@
|
||||
part of api;
|
||||
part of swagger.api;
|
||||
|
||||
const _delimiters = const {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'};
|
||||
|
||||
// port from Java version
|
||||
List<QueryParam> _convertParametersForCollectionFormat(
|
||||
Iterable<QueryParam> _convertParametersForCollectionFormat(
|
||||
String collectionFormat, String name, dynamic value) {
|
||||
var params = [];
|
||||
var params = <QueryParam>[];
|
||||
|
||||
// preconditions
|
||||
if (name == null || name.isEmpty || value == null) return params;
|
||||
|
||||
if (value is! List) {
|
||||
params.add(new QueryParam(name, value as String));
|
||||
params.add(new QueryParam(name, '$value'));
|
||||
return params;
|
||||
}
|
||||
|
||||
List<String> values = value as List<String>;
|
||||
List values = value as List;
|
||||
|
||||
// get the collection format
|
||||
collectionFormat = (collectionFormat == null || collectionFormat.isEmpty)
|
||||
@ -23,7 +23,7 @@ List<QueryParam> _convertParametersForCollectionFormat(
|
||||
: collectionFormat; // default: csv
|
||||
|
||||
if (collectionFormat == "multi") {
|
||||
return values.map((v) => new QueryParam(name, v));
|
||||
return values.map((v) => new QueryParam(name, '$v'));
|
||||
}
|
||||
|
||||
String delimiter = _delimiters[collectionFormat] ?? ",";
|
@ -1,4 +1,4 @@
|
||||
part of api;
|
||||
part of swagger.api;
|
||||
|
||||
class ApiKeyAuth implements Authentication {
|
||||
|
@ -1,4 +1,4 @@
|
||||
part of api;
|
||||
part of swagger.api;
|
||||
|
||||
abstract class Authentication {
|
||||
|
@ -1,4 +1,4 @@
|
||||
part of api;
|
||||
part of swagger.api;
|
||||
|
||||
class HttpBasicAuth implements Authentication {
|
||||
|
@ -1,4 +1,4 @@
|
||||
part of api;
|
||||
part of swagger.api;
|
||||
|
||||
class OAuth implements Authentication {
|
||||
|
@ -1,4 +1,4 @@
|
||||
part of api;
|
||||
part of swagger.api;
|
||||
|
||||
|
||||
@Entity()
|
@ -1,4 +1,4 @@
|
||||
part of api;
|
||||
part of swagger.api;
|
||||
|
||||
|
||||
@Entity()
|
@ -1,4 +1,4 @@
|
||||
part of api;
|
||||
part of swagger.api;
|
||||
|
||||
|
||||
@Entity()
|
@ -1,4 +1,4 @@
|
||||
part of api;
|
||||
part of swagger.api;
|
||||
|
||||
|
||||
@Entity()
|
@ -1,4 +1,4 @@
|
||||
part of api;
|
||||
part of swagger.api;
|
||||
|
||||
|
||||
@Entity()
|
@ -1,4 +1,4 @@
|
||||
part of api;
|
||||
part of swagger.api;
|
||||
|
||||
|
||||
@Entity()
|
Loading…
Reference in New Issue
Block a user