forked from loafle/openapi-generator-original
feat: improve / fix deserialization by parsing type String
* added api_helper.dart for a helper function. * defaultApiClient is now a variable instead of a static field inside ApiClient * a lot of functions inside ApiClient are no longer static. * optional params are now named params (needed to introduce a justIgnoreFlag as hack) * queryParams now support the multi format and are therefore no longer a Map<String, String>, but a List<QueryParam> * renamed apiException.mustache to api_exception.mustache to conform with other file names. * removed unused import: 'dart:html' * removed 'package:crypto/crypto.dart' dependency. 'dart:convert' has a base64 converter now. * use null-aware operator for apiClient assignment in xxxApi constructors. * enable testStoreApi (which returned a Future nobody waited for) * fix types in tests. Some ids were passed as Strings instead of ints. * adapt tests to use the optional named arguments (for optional query args) * generate random ids in tests. Otherwise insertion will always succeed if the test has been called once.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
part of api;
|
||||
|
||||
const _delimiters = const {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'};
|
||||
|
||||
// port from Java version
|
||||
List<QueryParam> _convertParametersForCollectionFormat(
|
||||
String collectionFormat, String name, dynamic value) {
|
||||
var params = [];
|
||||
|
||||
// preconditions
|
||||
if (name == null || name.isEmpty || value == null) return params;
|
||||
|
||||
if (value is! List) {
|
||||
params.add(new QueryParam(name, value as String));
|
||||
return params;
|
||||
}
|
||||
|
||||
List<String> values = value as List<String>;
|
||||
|
||||
// get the collection format
|
||||
collectionFormat = (collectionFormat == null || collectionFormat.isEmpty)
|
||||
? "csv"
|
||||
: collectionFormat; // default: csv
|
||||
|
||||
if (collectionFormat == "multi") {
|
||||
return values.map((v) => new QueryParam(name, v));
|
||||
}
|
||||
|
||||
String delimiter = _delimiters[collectionFormat] ?? ",";
|
||||
|
||||
params.add(new QueryParam(name, values.join(delimiter)));
|
||||
return params;
|
||||
}
|
||||
Reference in New Issue
Block a user