forked from loafle/openapi-generator-original
Dart - update generator to support null safety (#10637)
* fix: Make dart2 generated code compilable * Update dart2 client samples * Re-add deleted test files * Lower dart version to 2.12 * Make username and pass not null in http basic auth * Delete json_serializable * Make growable false by default * Make value not nullable * Remove redundant null check * Revert linter fix * Provide required username and pass * Revert initial abstractDartCodeGen changes * Revert removing dart pom module * Revert removing dart pom module * Lower minimum dart version to 2.12 * Disable dart2 tests generation * Disable petstore_client_lib * Disable samples/openapi3/client/petstore/dart2/petstore * Re-add dart2 tests * Add new tests * Delete empty directory * api_client.mustacheUpdate added optional HttpBearerAuth so you can add the token directly on the ApiClient * Update api_client.dart auto generated files for build * Update api_client.dart Autogenerated files for buiild * Make mapDateTime nullable and add ! after json mapping * Fix warning on Future<?> * Fix warning on Future<?> * Dont insert unused param to constructor * Modified Dart2 Mustache template. * Regenerated Petstore source code. * Remove extra code to sync with agilob's pr. * Regenerated Petstore source code. * Fix a couple of reported bugs. * Regenerated Petstore source code. * Make properties non-nullable. * Regenerated Petstore source code. * Do not trim user input before submitting. * Regenerate Petstore source code. * Regenerate Petstore source code. Co-authored-by: Kate Döen <kate@stack11.io> Co-authored-by: Artur Powroznik <arturp@backbase.com> Co-authored-by: devjakobsen <94956607+devjakobsen@users.noreply.github.com> Co-authored-by: Noor Dawod <noor@fine47.com>
This commit is contained in:
parent
5f5a83a592
commit
6c3cdee6fb
@ -64,7 +64,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
public String defaultValue;
|
||||
public String arrayModelType;
|
||||
public boolean isAlias; // Is this effectively an alias of another simple type
|
||||
public boolean isString, isInteger, isLong, isNumber, isNumeric, isFloat, isDouble, isDate, isDateTime, isShort, isUnboundedInteger, isBoolean;
|
||||
public boolean isString, isInteger, isLong, isNumber, isNumeric, isFloat, isDouble, isDate, isDateTime, isShort, isUnboundedInteger, isPrimitiveType, isBoolean;
|
||||
private boolean additionalPropertiesIsAnyType;
|
||||
public List<CodegenProperty> vars = new ArrayList<>(); // all properties (without parent's properties)
|
||||
public List<CodegenProperty> allVars = new ArrayList<>(); // all properties (with parent's properties)
|
||||
@ -637,6 +637,14 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
this.isUnboundedInteger = isUnboundedInteger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsPrimitiveType() { return isPrimitiveType; }
|
||||
|
||||
@Override
|
||||
public void setIsPrimitiveType(boolean isPrimitiveType) {
|
||||
this.isPrimitiveType = isPrimitiveType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenProperty getAdditionalProperties() { return additionalProperties; }
|
||||
|
||||
|
@ -623,6 +623,14 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
|
||||
this.isUnboundedInteger = isUnboundedInteger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsPrimitiveType() { return isPrimitiveType; }
|
||||
|
||||
@Override
|
||||
public void setIsPrimitiveType(boolean isPrimitiveType) {
|
||||
this.isPrimitiveType = isPrimitiveType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenProperty getAdditionalProperties() { return additionalProperties; }
|
||||
|
||||
|
@ -536,6 +536,14 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
||||
this.isUnboundedInteger = isUnboundedInteger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsPrimitiveType() { return isPrimitiveType; }
|
||||
|
||||
@Override
|
||||
public void setIsPrimitiveType(boolean isPrimitiveType) {
|
||||
this.isPrimitiveType = isPrimitiveType;
|
||||
}
|
||||
|
||||
public Map<String, Object> getVendorExtensions() {
|
||||
return vendorExtensions;
|
||||
}
|
||||
|
@ -371,6 +371,14 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
|
||||
this.isUnboundedInteger = isUnboundedInteger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsPrimitiveType() { return primitiveType; }
|
||||
|
||||
@Override
|
||||
public void setIsPrimitiveType(boolean isPrimitiveType) {
|
||||
this.primitiveType = isPrimitiveType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsModel(boolean isModel) {
|
||||
this.isModel = isModel;
|
||||
|
@ -95,6 +95,10 @@ public interface IJsonSchemaValidationProperties {
|
||||
|
||||
void setIsUnboundedInteger(boolean isUnboundedInteger);
|
||||
|
||||
boolean getIsPrimitiveType();
|
||||
|
||||
void setIsPrimitiveType(boolean isPrimitiveType);
|
||||
|
||||
CodegenProperty getAdditionalProperties();
|
||||
|
||||
void setAdditionalProperties(CodegenProperty additionalProperties);
|
||||
|
@ -1,5 +1,7 @@
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
@ -112,12 +114,13 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
|
||||
setReservedWordsLowerCase(reservedWordsList);
|
||||
|
||||
// These types return isPrimitive=true in templates
|
||||
languageSpecificPrimitives = new HashSet<>(5);
|
||||
languageSpecificPrimitives.add("String");
|
||||
languageSpecificPrimitives.add("bool");
|
||||
languageSpecificPrimitives.add("int");
|
||||
languageSpecificPrimitives.add("num");
|
||||
languageSpecificPrimitives.add("double");
|
||||
languageSpecificPrimitives = Sets.newHashSet(
|
||||
"String",
|
||||
"bool",
|
||||
"int",
|
||||
"num",
|
||||
"double"
|
||||
);
|
||||
|
||||
typeMapping = new HashMap<>();
|
||||
typeMapping.put("Array", "List");
|
||||
@ -148,17 +151,18 @@ public abstract class AbstractDartCodegen extends DefaultCodegen {
|
||||
typeMapping.put("AnyType", "Object");
|
||||
|
||||
// Data types of the above values which are automatically imported
|
||||
defaultIncludes = new HashSet<>();
|
||||
defaultIncludes.add("String");
|
||||
defaultIncludes.add("bool");
|
||||
defaultIncludes.add("int");
|
||||
defaultIncludes.add("num");
|
||||
defaultIncludes.add("double");
|
||||
defaultIncludes.add("List");
|
||||
defaultIncludes.add("Set");
|
||||
defaultIncludes.add("Map");
|
||||
defaultIncludes.add("DateTime");
|
||||
defaultIncludes.add("Object");
|
||||
defaultIncludes = Sets.newHashSet(
|
||||
"String",
|
||||
"bool",
|
||||
"int",
|
||||
"num",
|
||||
"double",
|
||||
"List",
|
||||
"Set",
|
||||
"Map",
|
||||
"DateTime",
|
||||
"Object"
|
||||
);
|
||||
|
||||
imports.put("String", "dart:core");
|
||||
imports.put("bool", "dart:core");
|
||||
|
@ -36,6 +36,7 @@ public class DartClientCodegen extends AbstractDartCodegen {
|
||||
|
||||
public DartClientCodegen() {
|
||||
super();
|
||||
|
||||
final CliOption serializationLibrary = CliOption.newString(CodegenConstants.SERIALIZATION_LIBRARY,
|
||||
"Specify serialization library");
|
||||
serializationLibrary.setDefault(SERIALIZATION_LIBRARY_NATIVE);
|
||||
|
@ -19,7 +19,7 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
|
||||
|
||||
## Requirements
|
||||
|
||||
Dart 2.0 or later
|
||||
Dart 2.12 or later
|
||||
|
||||
## Installation & Usage
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
{{#operations}}
|
||||
|
||||
class {{{classname}}} {
|
||||
{{{classname}}}([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
{{{classname}}}([ApiClient? apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
|
||||
final ApiClient apiClient;
|
||||
{{#operation}}
|
||||
@ -49,24 +49,13 @@ class {{{classname}}} {
|
||||
///
|
||||
{{/-last}}
|
||||
{{/allParams}}
|
||||
Future<Response> {{{nickname}}}WithHttpInfo({{#allParams}}{{#required}}{{{dataType}}} {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}} {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async {
|
||||
{{#hasParams}}
|
||||
// Verify required params are set.
|
||||
{{#allParams}}
|
||||
{{#required}}
|
||||
if ({{{paramName}}} == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: {{{paramName}}}');
|
||||
}
|
||||
{{/required}}
|
||||
{{/allParams}}
|
||||
|
||||
{{/hasParams}}
|
||||
Future<Response> {{{nickname}}}WithHttpInfo({{#allParams}}{{#required}}{{{dataType}}} {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}}? {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'{{{path}}}'{{#pathParams}}
|
||||
.replaceAll({{=<% %>=}}'{<% baseName %>}'<%={{ }}=%>, {{{paramName}}}{{^isString}}.toString(){{/isString}}){{/pathParams}};
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody{{#bodyParam}} = {{{paramName}}}{{/bodyParam}};
|
||||
Object? postBody{{#bodyParam}} = {{{paramName}}}{{/bodyParam}};
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -77,7 +66,7 @@ class {{{classname}}} {
|
||||
{{^required}}
|
||||
if ({{{paramName}}} != null) {
|
||||
{{/required}}
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('{{{collectionFormat}}}', '{{{baseName}}}', {{{paramName}}}));
|
||||
queryParams.addAll(_queryParams('{{{collectionFormat}}}', '{{{baseName}}}', {{{paramName}}}));
|
||||
{{^required}}
|
||||
}
|
||||
{{/required}}
|
||||
@ -139,7 +128,7 @@ class {{{classname}}} {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -174,7 +163,7 @@ class {{{classname}}} {
|
||||
///
|
||||
{{/-last}}
|
||||
{{/allParams}}
|
||||
Future<{{{returnType}}}{{^returnType}}void{{/returnType}}> {{{nickname}}}({{#allParams}}{{#required}}{{{dataType}}} {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}} {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async {
|
||||
Future<{{#returnType}}{{{.}}}?{{/returnType}}{{^returnType}}void{{/returnType}}> {{{nickname}}}({{#allParams}}{{#required}}{{{dataType}}} {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}}? {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async {
|
||||
final response = await {{{nickname}}}WithHttpInfo({{#allParams}}{{#required}}{{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}} {{#allParams}}{{^required}}{{{paramName}}}: {{{paramName}}},{{^-last}} {{/-last}}{{/required}}{{/allParams}} {{/hasOptionalParams}});
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -183,13 +172,13 @@ class {{{classname}}} {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
{{#native_serialization}}
|
||||
{{#isArray}}
|
||||
final responseBody = await _decodeBodyBytes(response);
|
||||
return (await apiClient.deserializeAsync(responseBody, '{{{returnType}}}') as List)
|
||||
.cast<{{{returnBaseType}}}>()
|
||||
.{{#uniqueItems}}toSet(){{/uniqueItems}}{{^uniqueItems}}toList(growable: false){{/uniqueItems}};
|
||||
.{{#uniqueItems}}toSet(){{/uniqueItems}}{{^uniqueItems}}toList(){{/uniqueItems}};
|
||||
{{/isArray}}
|
||||
{{^isArray}}
|
||||
{{#isMap}}
|
||||
@ -199,7 +188,7 @@ class {{{classname}}} {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), '{{{returnType}}}',) as {{{returnType}}};
|
||||
{{/isMap}}{{/isArray}}{{/native_serialization}}
|
||||
}
|
||||
return Future<{{{returnType}}}>.value();
|
||||
return null;
|
||||
{{/returnType}}
|
||||
}
|
||||
{{/operation}}
|
||||
|
@ -33,12 +33,7 @@ class ApiClient {
|
||||
Client get client => _client;
|
||||
|
||||
/// Requests to use a new HTTP [Client] in this class.
|
||||
///
|
||||
/// If the [newClient] is null, an [ArgumentError] is thrown.
|
||||
set client(Client newClient) {
|
||||
if (newClient == null) {
|
||||
throw ArgumentError('New client instance cannot be null.');
|
||||
}
|
||||
_client = newClient;
|
||||
}
|
||||
|
||||
@ -55,7 +50,7 @@ class ApiClient {
|
||||
/// or deleted.
|
||||
Map<String, Authentication> get authentications => Map.unmodifiable(_authentications);
|
||||
|
||||
T getAuthentication<T extends Authentication>(String name) {
|
||||
T? getAuthentication<T extends Authentication>(String name) {
|
||||
final authentication = _authentications[name];
|
||||
return authentication is T ? authentication : null;
|
||||
}
|
||||
@ -66,35 +61,28 @@ class ApiClient {
|
||||
String path,
|
||||
String method,
|
||||
List<QueryParam> queryParams,
|
||||
Object body,
|
||||
Object? body,
|
||||
Map<String, String> headerParams,
|
||||
Map<String, String> formParams,
|
||||
String nullableContentType,
|
||||
String? contentType,
|
||||
List<String> authNames,
|
||||
) async {
|
||||
_updateParamsForAuth(authNames, queryParams, headerParams);
|
||||
|
||||
headerParams.addAll(_defaultHeaderMap);
|
||||
|
||||
final urlEncodedQueryParams = queryParams
|
||||
.where((param) => param.value != null)
|
||||
.map((param) => '$param');
|
||||
|
||||
final queryString = urlEncodedQueryParams.isNotEmpty
|
||||
? '?${urlEncodedQueryParams.join('&')}'
|
||||
: '';
|
||||
|
||||
final uri = Uri.parse('$basePath$path$queryString');
|
||||
|
||||
if (nullableContentType != null) {
|
||||
headerParams['Content-Type'] = nullableContentType;
|
||||
if (contentType != null) {
|
||||
headerParams['Content-Type'] = contentType;
|
||||
}
|
||||
|
||||
final urlEncodedQueryParams = queryParams.map((param) => '$param');
|
||||
final queryString = urlEncodedQueryParams.isNotEmpty ? '?${urlEncodedQueryParams.join('&')}' : '';
|
||||
final uri = Uri.parse('$basePath$path$queryString');
|
||||
|
||||
try {
|
||||
// Special case for uploading a single file which isn't a 'multipart/form-data'.
|
||||
if (
|
||||
body is MultipartFile && (nullableContentType == null ||
|
||||
!nullableContentType.toLowerCase().startsWith('multipart/form-data'))
|
||||
body is MultipartFile && (contentType == null ||
|
||||
!contentType.toLowerCase().startsWith('multipart/form-data'))
|
||||
) {
|
||||
final request = StreamedRequest(method, uri);
|
||||
request.headers.addAll(headerParams);
|
||||
@ -120,7 +108,7 @@ class ApiClient {
|
||||
return Response.fromStream(response);
|
||||
}
|
||||
|
||||
final msgBody = nullableContentType == 'application/x-www-form-urlencoded'
|
||||
final msgBody = contentType == 'application/x-www-form-urlencoded'
|
||||
? formParams
|
||||
: await serializeAsync(body);
|
||||
final nullableHeaderParams = headerParams.isEmpty ? null : headerParams;
|
||||
@ -133,43 +121,71 @@ class ApiClient {
|
||||
case 'HEAD': return await _client.head(uri, headers: nullableHeaderParams,);
|
||||
case 'GET': return await _client.get(uri, headers: nullableHeaderParams,);
|
||||
}
|
||||
} on SocketException catch (e, trace) {
|
||||
throw ApiException.withInner(HttpStatus.badRequest, 'Socket operation failed: $method $path', e, trace,);
|
||||
} on TlsException catch (e, trace) {
|
||||
throw ApiException.withInner(HttpStatus.badRequest, 'TLS/SSL communication failed: $method $path', e, trace,);
|
||||
} on IOException catch (e, trace) {
|
||||
throw ApiException.withInner(HttpStatus.badRequest, 'I/O operation failed: $method $path', e, trace,);
|
||||
} on ClientException catch (e, trace) {
|
||||
throw ApiException.withInner(HttpStatus.badRequest, 'HTTP connection failed: $method $path', e, trace,);
|
||||
} on Exception catch (e, trace) {
|
||||
throw ApiException.withInner(HttpStatus.badRequest, 'Exception occurred: $method $path', e, trace,);
|
||||
} on SocketException catch (error, trace) {
|
||||
throw ApiException.withInner(
|
||||
HttpStatus.badRequest,
|
||||
'Socket operation failed: $method $path',
|
||||
error,
|
||||
trace,
|
||||
);
|
||||
} on TlsException catch (error, trace) {
|
||||
throw ApiException.withInner(
|
||||
HttpStatus.badRequest,
|
||||
'TLS/SSL communication failed: $method $path',
|
||||
error,
|
||||
trace,
|
||||
);
|
||||
} on IOException catch (error, trace) {
|
||||
throw ApiException.withInner(
|
||||
HttpStatus.badRequest,
|
||||
'I/O operation failed: $method $path',
|
||||
error,
|
||||
trace,
|
||||
);
|
||||
} on ClientException catch (error, trace) {
|
||||
throw ApiException.withInner(
|
||||
HttpStatus.badRequest,
|
||||
'HTTP connection failed: $method $path',
|
||||
error,
|
||||
trace,
|
||||
);
|
||||
} on Exception catch (error, trace) {
|
||||
throw ApiException.withInner(
|
||||
HttpStatus.badRequest,
|
||||
'Exception occurred: $method $path',
|
||||
error,
|
||||
trace,
|
||||
);
|
||||
}
|
||||
|
||||
throw ApiException(HttpStatus.badRequest, 'Invalid HTTP operation: $method $path',);
|
||||
throw ApiException(
|
||||
HttpStatus.badRequest,
|
||||
'Invalid HTTP operation: $method $path',
|
||||
);
|
||||
}
|
||||
{{#native_serialization}}
|
||||
|
||||
Future<dynamic> deserializeAsync(String json, String targetType, {bool growable}) async =>
|
||||
Future<dynamic> deserializeAsync(String json, String targetType, {bool growable = false,}) async =>
|
||||
// ignore: deprecated_member_use_from_same_package
|
||||
deserialize(json, targetType, growable: growable);
|
||||
|
||||
@Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use deserializeAsync() instead.')
|
||||
dynamic deserialize(String json, String targetType, {bool growable}) {
|
||||
dynamic deserialize(String json, String targetType, {bool growable = false,}) {
|
||||
// Remove all spaces. Necessary for regular expressions as well.
|
||||
targetType = targetType.replaceAll(' ', ''); // ignore: parameter_assignments
|
||||
|
||||
// If the expected target type is String, nothing to do...
|
||||
return targetType == 'String'
|
||||
? json
|
||||
: _deserialize(jsonDecode(json), targetType, growable: growable == true);
|
||||
: _deserialize(jsonDecode(json), targetType, growable: growable);
|
||||
}
|
||||
{{/native_serialization}}
|
||||
|
||||
// ignore: deprecated_member_use_from_same_package
|
||||
Future<String> serializeAsync(Object value) async => serialize(value);
|
||||
Future<String> serializeAsync(Object? value) async => serialize(value);
|
||||
|
||||
@Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use serializeAsync() instead.')
|
||||
String serialize(Object value) => value == null ? '' : json.encode(value);
|
||||
String serialize(Object? value) => value == null ? '' : json.encode(value);
|
||||
|
||||
/// Update query and header parameters based on authentication settings.
|
||||
/// @param authNames The authentications to apply
|
||||
@ -188,7 +204,7 @@ class ApiClient {
|
||||
}
|
||||
|
||||
{{#native_serialization}}
|
||||
static dynamic _deserialize(dynamic value, String targetType, {bool growable}) {
|
||||
static dynamic _deserialize(dynamic value, String targetType, {bool growable = false}) {
|
||||
try {
|
||||
switch (targetType) {
|
||||
case 'String':
|
||||
@ -215,24 +231,21 @@ class ApiClient {
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
default:
|
||||
Match match;
|
||||
if (value is List && (match = _regList.firstMatch(targetType)) != null) {
|
||||
targetType = match[1]; // ignore: parameter_assignments
|
||||
dynamic match;
|
||||
if (value is List && (match = _regList.firstMatch(targetType)?.group(1)) != null) {
|
||||
return value
|
||||
.map<dynamic>((dynamic v) => _deserialize(v, targetType, growable: growable))
|
||||
.map<dynamic>((dynamic v) => _deserialize(v, match, growable: growable,))
|
||||
.toList(growable: growable);
|
||||
}
|
||||
if (value is Set && (match = _regSet.firstMatch(targetType)) != null) {
|
||||
targetType = match[1]; // ignore: parameter_assignments
|
||||
if (value is Set && (match = _regSet.firstMatch(targetType)?.group(1)) != null) {
|
||||
return value
|
||||
.map<dynamic>((dynamic v) => _deserialize(v, targetType, growable: growable))
|
||||
.map<dynamic>((dynamic v) => _deserialize(v, match, growable: growable,))
|
||||
.toSet();
|
||||
}
|
||||
if (value is Map && (match = _regMap.firstMatch(targetType)) != null) {
|
||||
targetType = match[1]; // ignore: parameter_assignments
|
||||
if (value is Map && (match = _regMap.firstMatch(targetType)?.group(1)) != null) {
|
||||
return Map<String, dynamic>.fromIterables(
|
||||
value.keys.cast<String>(),
|
||||
value.values.map<dynamic>((dynamic v) => _deserialize(v, targetType, growable: growable)),
|
||||
value.values.map<dynamic>((dynamic v) => _deserialize(v, match, growable: growable,)),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -248,9 +261,9 @@ class ApiClient {
|
||||
/// Primarily intended for use in an isolate.
|
||||
class DeserializationMessage {
|
||||
const DeserializationMessage({
|
||||
@required this.json,
|
||||
@required this.targetType,
|
||||
this.growable,
|
||||
required this.json,
|
||||
required this.targetType,
|
||||
this.growable = false,
|
||||
});
|
||||
|
||||
/// The JSON value to deserialize.
|
||||
@ -274,10 +287,10 @@ Future<dynamic> deserializeAsync(DeserializationMessage message) async {
|
||||
: ApiClient._deserialize(
|
||||
jsonDecode(message.json),
|
||||
targetType,
|
||||
growable: message.growable == true,
|
||||
growable: message.growable,
|
||||
);
|
||||
}
|
||||
{{/native_serialization}}
|
||||
|
||||
/// Primarily intended for use in an isolate.
|
||||
Future<String> serializeAsync(Object value) async => value == null ? '' : json.encode(value);
|
||||
Future<String> serializeAsync(Object? value) async => value == null ? '' : json.encode(value);
|
||||
|
@ -6,9 +6,9 @@ class ApiException implements Exception {
|
||||
ApiException.withInner(this.code, this.message, this.innerException, this.stackTrace);
|
||||
|
||||
int code = 0;
|
||||
String message;
|
||||
Exception innerException;
|
||||
StackTrace stackTrace;
|
||||
String? message;
|
||||
Exception? innerException;
|
||||
StackTrace? stackTrace;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
|
@ -11,32 +11,27 @@ class QueryParam {
|
||||
}
|
||||
|
||||
// Ported from the Java version.
|
||||
Iterable<QueryParam> _convertParametersForCollectionFormat(
|
||||
String collectionFormat,
|
||||
String name,
|
||||
dynamic value,
|
||||
) {
|
||||
Iterable<QueryParam> _queryParams(String collectionFormat, String name, dynamic value,) {
|
||||
// Assertions to run in debug mode only.
|
||||
assert(name.isNotEmpty, 'Parameter cannot be an empty string.');
|
||||
|
||||
final params = <QueryParam>[];
|
||||
|
||||
// preconditions
|
||||
if (name != null && name.isNotEmpty && value != null) {
|
||||
if (value is List) {
|
||||
if (collectionFormat == 'multi') {
|
||||
return value.map((dynamic v) => QueryParam(name, parameterToString(v)),);
|
||||
}
|
||||
|
||||
// Default collection format is 'csv'.
|
||||
if (collectionFormat == null || collectionFormat.isEmpty) {
|
||||
// ignore: parameter_assignments
|
||||
collectionFormat = 'csv';
|
||||
if (collectionFormat.isEmpty) {
|
||||
collectionFormat = 'csv'; // ignore: parameter_assignments
|
||||
}
|
||||
|
||||
final delimiter = _delimiters[collectionFormat] ?? ',';
|
||||
|
||||
params.add(QueryParam(name, value.map<dynamic>(parameterToString).join(delimiter)),);
|
||||
} else {
|
||||
params.add(QueryParam(name, parameterToString(value),));
|
||||
}
|
||||
params.add(QueryParam(name, value.map<dynamic>(parameterToString).join(delimiter),));
|
||||
} else if (value != null) {
|
||||
params.add(QueryParam(name, parameterToString(value)));
|
||||
}
|
||||
|
||||
return params;
|
||||
@ -67,27 +62,27 @@ String parameterToString(dynamic value) {
|
||||
Future<String> _decodeBodyBytes(Response response) async {
|
||||
final contentType = response.headers['content-type'];
|
||||
return contentType != null && contentType.toLowerCase().startsWith('application/json')
|
||||
? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes)
|
||||
? response.bodyBytes.isEmpty ? '' : utf8.decode(response.bodyBytes)
|
||||
: response.body;
|
||||
}
|
||||
|
||||
/// Returns a valid [T] value found at the specified Map [key], null otherwise.
|
||||
T mapValueOfType<T>(dynamic map, String key) {
|
||||
T? mapValueOfType<T>(dynamic map, String key) {
|
||||
final dynamic value = map is Map ? map[key] : null;
|
||||
return value is T ? value : null;
|
||||
}
|
||||
|
||||
/// Returns a valid Map<K, V> found at the specified Map [key], null otherwise.
|
||||
Map<K, V> mapCastOfType<K, V>(dynamic map, String key) {
|
||||
Map<K, V>? mapCastOfType<K, V>(dynamic map, String key) {
|
||||
final dynamic value = map is Map ? map[key] : null;
|
||||
return value is Map ? value.cast<K, V>() : null;
|
||||
}
|
||||
|
||||
/// Returns a valid [DateTime] found at the specified Map [key], null otherwise.
|
||||
DateTime mapDateTime(dynamic map, String key, [String pattern]) {
|
||||
DateTime? mapDateTime(dynamic map, String key, [String? pattern]) {
|
||||
final dynamic value = map is Map ? map[key] : null;
|
||||
if (value != null) {
|
||||
int millis;
|
||||
int? millis;
|
||||
if (value is int) {
|
||||
millis = value;
|
||||
} else if (value is String) {
|
||||
|
@ -6,7 +6,7 @@ import 'package:test/test.dart';
|
||||
|
||||
/// tests for {{{classname}}}
|
||||
void main() {
|
||||
final instance = {{{classname}}}();
|
||||
// final instance = {{{classname}}}();
|
||||
|
||||
group('tests for {{{classname}}}', () {
|
||||
{{#operation}}
|
||||
|
@ -6,23 +6,25 @@ class ApiKeyAuth implements Authentication {
|
||||
final String location;
|
||||
final String paramName;
|
||||
|
||||
String apiKeyPrefix;
|
||||
String apiKey;
|
||||
String apiKeyPrefix = '';
|
||||
String apiKey = '';
|
||||
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
final value = apiKeyPrefix == null ? apiKey : '$apiKeyPrefix $apiKey';
|
||||
final paramValue = apiKeyPrefix.isEmpty ? apiKey : '$apiKeyPrefix $apiKey';
|
||||
|
||||
if (location == 'query' && value != null) {
|
||||
queryParams.add(QueryParam(paramName, value));
|
||||
} else if (location == 'header' && value != null) {
|
||||
headerParams[paramName] = value;
|
||||
} else if (location == 'cookie' && value != null) {
|
||||
if (paramValue.isNotEmpty) {
|
||||
if (location == 'query') {
|
||||
queryParams.add(QueryParam(paramName, paramValue));
|
||||
} else if (location == 'header') {
|
||||
headerParams[paramName] = paramValue;
|
||||
} else if (location == 'cookie') {
|
||||
headerParams.update(
|
||||
'Cookie',
|
||||
(existingCookie) => '$existingCookie; $paramName=$value',
|
||||
ifAbsent: () => '$paramName=$value',
|
||||
(existingCookie) => '$existingCookie; $paramName=$paramValue',
|
||||
ifAbsent: () => '$paramName=$paramValue',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
|
@ -1,12 +1,16 @@
|
||||
{{>header}}
|
||||
{{>part_of}}
|
||||
class HttpBasicAuth implements Authentication {
|
||||
HttpBasicAuth({this.username = '', this.password = ''});
|
||||
|
||||
String username;
|
||||
String password;
|
||||
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
final credentials = '${username ?? ''}:${password ?? ''}';
|
||||
if (username.isNotEmpty && password.isNotEmpty) {
|
||||
final credentials = '$username:$password';
|
||||
headerParams['Authorization'] = 'Basic ${base64.encode(utf8.encode(credentials))}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,19 +11,29 @@ class HttpBearerAuth implements Authentication {
|
||||
|
||||
set accessToken(dynamic accessToken) {
|
||||
if (accessToken is! String && accessToken is! HttpBearerAuthProvider) {
|
||||
throw ArgumentError('Type of Bearer accessToken should be a String or a String Function().');
|
||||
throw ArgumentError('accessToken value must be either a String or a String Function().');
|
||||
}
|
||||
_accessToken = accessToken;
|
||||
}
|
||||
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
if (_accessToken == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String accessToken;
|
||||
|
||||
if (_accessToken is String) {
|
||||
headerParams['Authorization'] = 'Bearer $_accessToken';
|
||||
accessToken = _accessToken;
|
||||
} else if (_accessToken is HttpBearerAuthProvider) {
|
||||
headerParams['Authorization'] = 'Bearer ${_accessToken()}';
|
||||
accessToken = _accessToken!();
|
||||
} else {
|
||||
throw ArgumentError('Type of Bearer accessToken should be a String or a String Function().');
|
||||
return;
|
||||
}
|
||||
|
||||
if (accessToken.isNotEmpty) {
|
||||
headerParams['Authorization'] = 'Bearer $accessToken';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
{{>header}}
|
||||
{{>part_of}}
|
||||
class OAuth implements Authentication {
|
||||
OAuth({this.accessToken});
|
||||
OAuth({this.accessToken = ''});
|
||||
|
||||
String accessToken;
|
||||
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
if (accessToken != null) {
|
||||
if (accessToken.isNotEmpty) {
|
||||
headerParams['Authorization'] = 'Bearer $accessToken';
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
{{{classname}}}({
|
||||
{{#vars}}
|
||||
{{!
|
||||
A field is @required in Dart when it is
|
||||
required && !nullable && !defaultValue in OAS
|
||||
A field is required in Dart when it is
|
||||
required && !defaultValue in OAS
|
||||
}}
|
||||
{{#required}}{{^isNullable}}{{^defaultValue}}@required {{/defaultValue}}{{/isNullable}}{{/required}}this.{{{name}}}{{^isNullable}}{{#defaultValue}} = {{#isEnum}}{{^isContainer}}const {{{enumName}}}._({{/isContainer}}{{/isEnum}}{{{defaultValue}}}{{#isEnum}}{{^isContainer}}){{/isContainer}}{{/isEnum}}{{/defaultValue}}{{/isNullable}},
|
||||
{{#required}}{{^defaultValue}}required {{/defaultValue}}{{/required}}this.{{{name}}}{{#defaultValue}} = {{#isEnum}}{{^isContainer}}const {{{enumName}}}._({{/isContainer}}{{/isEnum}}{{{.}}}{{#isEnum}}{{^isContainer}}){{/isContainer}}{{/isEnum}}{{/defaultValue}},
|
||||
{{/vars}}
|
||||
});
|
@ -1,27 +1,17 @@
|
||||
# See https://www.dartlang.org/tools/private-files.html
|
||||
# See https://dart.dev/guides/libraries/private-files
|
||||
|
||||
# Files and directories created by pub
|
||||
.buildlog
|
||||
.dart_tool/
|
||||
.packages
|
||||
.project
|
||||
.pub/
|
||||
build/
|
||||
**/packages/
|
||||
pubspec.lock # Except for application 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
|
||||
# IntelliJ
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# Mac
|
||||
.DS_Store
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
|
@ -7,7 +7,7 @@ import 'package:test/test.dart';
|
||||
// tests for {{{classname}}}
|
||||
void main() {
|
||||
{{^isEnum}}
|
||||
final instance = {{{classname}}}();
|
||||
// final instance = {{{classname}}}();
|
||||
{{/isEnum}}
|
||||
|
||||
group('test {{{classname}}}', () {
|
||||
|
@ -1,19 +1,38 @@
|
||||
class {{{classname}}} {
|
||||
{{>dart_constructor}}
|
||||
|
||||
{{#vars}}
|
||||
{{#description}}
|
||||
/// {{{.}}}
|
||||
{{/description}}
|
||||
{{^isEnum}}
|
||||
{{#minimum}}
|
||||
// minimum: {{{.}}}
|
||||
{{#description}}
|
||||
///
|
||||
{{/description}}
|
||||
/// Minimum value: {{{.}}}
|
||||
{{/minimum}}
|
||||
{{#maximum}}
|
||||
// maximum: {{{.}}}
|
||||
{{#description}}
|
||||
{{^minimum}}
|
||||
///
|
||||
{{/minimum}}
|
||||
{{/description}}
|
||||
/// Maximum value: {{{.}}}
|
||||
{{/maximum}}
|
||||
{{^isNullable}}
|
||||
{{^required}}
|
||||
{{^defaultValue}}
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
{{/defaultValue}}
|
||||
{{/required}}
|
||||
{{/isNullable}}
|
||||
{{/isEnum}}
|
||||
{{{datatypeWithEnum}}} {{{name}}};
|
||||
{{{datatypeWithEnum}}}{{#isNullable}}?{{/isNullable}}{{^isNullable}}{{^required}}{{^defaultValue}}?{{/defaultValue}}{{/required}}{{/isNullable}} {{{name}}};
|
||||
|
||||
{{/vars}}
|
||||
@override
|
||||
@ -26,7 +45,7 @@ class {{{classname}}} {
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
{{#vars}}
|
||||
({{{name}}} == null ? 0 : {{{name}}}.hashCode){{^-last}} +{{/-last}}{{#-last}};{{/-last}}
|
||||
({{#isNullable}}{{{name}}} == null ? 0 : {{/isNullable}}{{^isNullable}}{{^required}}{{^defaultValue}}{{{name}}} == null ? 0 : {{/defaultValue}}{{/required}}{{/isNullable}}{{{name}}}{{#isNullable}}!{{/isNullable}}{{^isNullable}}{{^required}}{{^defaultValue}}!{{/defaultValue}}{{/required}}{{/isNullable}}.hashCode){{^-last}} +{{/-last}}{{#-last}};{{/-last}}
|
||||
{{/vars}}
|
||||
|
||||
@override
|
||||
@ -35,37 +54,51 @@ class {{{classname}}} {
|
||||
Map<String, dynamic> toJson() {
|
||||
final json = <String, dynamic>{};
|
||||
{{#vars}}
|
||||
{{^required}}
|
||||
{{#isNullable}}
|
||||
if ({{{name}}} != null) {
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
{{^required}}
|
||||
{{^defaultValue}}
|
||||
if ({{{name}}} != null) {
|
||||
{{/defaultValue}}
|
||||
{{/required}}
|
||||
{{/isNullable}}
|
||||
{{#isDateTime}}
|
||||
{{#pattern}}
|
||||
json[r'{{{baseName}}}'] = {{#required}}{{#isNullable}}{{{name}}} == null ? null : {{/isNullable}}{{/required}}_dateEpochMarker == '{{{pattern}}}'
|
||||
? {{{name}}}.millisecondsSinceEpoch
|
||||
: {{{name}}}.toUtc().toIso8601String();
|
||||
json[r'{{{baseName}}}'] = _dateEpochMarker == '{{{pattern}}}'
|
||||
? {{{name}}}{{#isNullable}}!{{/isNullable}}{{^isNullable}}{{^required}}{{^defaultValue}}!{{/defaultValue}}{{/required}}{{/isNullable}}.millisecondsSinceEpoch
|
||||
: {{{name}}}{{#isNullable}}!{{/isNullable}}{{^isNullable}}{{^required}}{{^defaultValue}}!{{/defaultValue}}{{/required}}{{/isNullable}}.toUtc().toIso8601String();
|
||||
{{/pattern}}
|
||||
{{^pattern}}
|
||||
json[r'{{{baseName}}}'] = {{#required}}{{#isNullable}}{{{name}}} == null ? null : {{/isNullable}}{{/required}}{{{name}}}.toUtc().toIso8601String();
|
||||
json[r'{{{baseName}}}'] = {{{name}}}{{#isNullable}}!{{/isNullable}}{{^isNullable}}{{^required}}{{^defaultValue}}!{{/defaultValue}}{{/required}}{{/isNullable}}.toUtc().toIso8601String();
|
||||
{{/pattern}}
|
||||
{{/isDateTime}}
|
||||
{{#isDate}}
|
||||
{{#pattern}}
|
||||
json[r'{{{baseName}}}'] = {{#required}}{{#isNullable}}{{{name}}} == null ? null : {{/isNullable}}{{/required}}_dateEpochMarker == '{{{pattern}}}'
|
||||
? {{{name}}}.millisecondsSinceEpoch
|
||||
: _dateFormatter.format({{{name}}}.toUtc());
|
||||
json[r'{{{baseName}}}'] = _dateEpochMarker == '{{{pattern}}}'
|
||||
? {{{name}}}{{#isNullable}}!{{/isNullable}}{{^isNullable}}{{^required}}{{^defaultValue}}!{{/defaultValue}}{{/required}}{{/isNullable}}.millisecondsSinceEpoch
|
||||
: _dateFormatter.format({{{name}}}{{#isNullable}}!{{/isNullable}}{{^isNullable}}{{^required}}{{^defaultValue}}!{{/defaultValue}}{{/required}}{{/isNullable}}.toUtc());
|
||||
{{/pattern}}
|
||||
{{^pattern}}
|
||||
json[r'{{{baseName}}}'] = {{#required}}{{#isNullable}}{{{name}}} == null ? null : {{/isNullable}}{{/required}}_dateFormatter.format({{{name}}}.toUtc());
|
||||
json[r'{{{baseName}}}'] = _dateFormatter.format({{{name}}}{{#isNullable}}!{{/isNullable}}{{^isNullable}}{{^required}}{{^defaultValue}}!{{/defaultValue}}{{/required}}{{/isNullable}}.toUtc());
|
||||
{{/pattern}}
|
||||
{{/isDate}}
|
||||
{{^isDateTime}}
|
||||
{{^isDate}}
|
||||
json[r'{{{baseName}}}'] = {{#required}}{{#isNullable}}{{{name}}} == null ? null : {{/isNullable}}{{/required}}{{{name}}};
|
||||
json[r'{{{baseName}}}'] = {{{name}}};
|
||||
{{/isDate}}
|
||||
{{/isDateTime}}
|
||||
{{^required}}
|
||||
{{#isNullable}}
|
||||
}
|
||||
{{/isNullable}}
|
||||
{{^isNullable}}
|
||||
{{^required}}
|
||||
{{^defaultValue}}
|
||||
}
|
||||
{{/defaultValue}}
|
||||
{{/required}}
|
||||
{{/isNullable}}
|
||||
{{/vars}}
|
||||
return json;
|
||||
}
|
||||
@ -73,16 +106,28 @@ class {{{classname}}} {
|
||||
/// Returns a new [{{{classname}}}] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static {{{classname}}} fromJson(dynamic value) {
|
||||
static {{{classname}}}? fromJson(dynamic value) {
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
// Ensure that the map contains the required keys.
|
||||
// Note 1: the values aren't checked for validity beyond being non-null.
|
||||
// Note 2: this code is stripped in release mode!
|
||||
assert(() {
|
||||
requiredKeys.forEach((key) {
|
||||
assert(json.containsKey(key), 'Required key "{{{classname}}}[$key]" is missing from JSON.');
|
||||
assert(json[key] != null, 'Required key "{{{classname}}}[$key]" has a null value in JSON.');
|
||||
});
|
||||
return true;
|
||||
}());
|
||||
|
||||
return {{{classname}}}(
|
||||
{{#vars}}
|
||||
{{#isDateTime}}
|
||||
{{{name}}}: mapDateTime(json, r'{{{baseName}}}', '{{{pattern}}}'),
|
||||
{{{name}}}: mapDateTime(json, r'{{{baseName}}}', '{{{pattern}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
|
||||
{{/isDateTime}}
|
||||
{{#isDate}}
|
||||
{{{name}}}: mapDateTime(json, r'{{{baseName}}}', '{{{pattern}}}'),
|
||||
{{{name}}}: mapDateTime(json, r'{{{baseName}}}', '{{{pattern}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
|
||||
{{/isDate}}
|
||||
{{^isDateTime}}
|
||||
{{^isDate}}
|
||||
@ -97,18 +142,18 @@ class {{{classname}}} {
|
||||
{{^items.complexType}}
|
||||
(e) => e == null ? null : (e as List).cast<{{items.items.dataType}}>()
|
||||
{{/items.complexType}}
|
||||
).toList(growable: false)
|
||||
).toList()
|
||||
: null,
|
||||
{{/items.isArray}}
|
||||
{{^items.isArray}}
|
||||
{{{name}}}: {{{complexType}}}.listFromJson(json[r'{{{baseName}}}']),
|
||||
{{{name}}}: {{{complexType}}}.listFromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
|
||||
{{/items.isArray}}
|
||||
{{/isArray}}
|
||||
{{^isArray}}
|
||||
{{#isMap}}
|
||||
{{#items.isArray}}
|
||||
{{{name}}}: json[r'{{{baseName}}}'] == null
|
||||
? null
|
||||
? {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}
|
||||
{{#items.complexType}}
|
||||
: {{items.complexType}}.mapListFromJson(json[r'{{{baseName}}}']),
|
||||
{{/items.complexType}}
|
||||
@ -119,14 +164,14 @@ class {{{classname}}} {
|
||||
{{^items.isArray}}
|
||||
{{#items.isMap}}
|
||||
{{#items.complexType}}
|
||||
{{{name}}}: {{items.complexType}}.mapFromJson(json[r'{{{baseName}}}']),
|
||||
{{{name}}}: {{items.complexType}}.mapFromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
|
||||
{{/items.complexType}}
|
||||
{{^items.complexType}}
|
||||
{{{name}}}: mapCastOfType<String, dynamic>(json, r'{{{baseName}}}'),
|
||||
{{{name}}}: mapCastOfType<String, dynamic>(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
|
||||
{{/items.complexType}}
|
||||
{{/items.isMap}}
|
||||
{{^items.isMap}}
|
||||
{{{name}}}: mapValueOfType<{{{datatypeWithEnum}}}>(json, r'{{{baseName}}}'),
|
||||
{{{name}}}: mapValueOfType<{{{datatypeWithEnum}}}>(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
|
||||
{{/items.isMap}}
|
||||
{{/items.isArray}}
|
||||
{{/isMap}}
|
||||
@ -135,7 +180,7 @@ class {{{classname}}} {
|
||||
{{{name}}}: null, // No support for decoding binary content from JSON
|
||||
{{/isBinary}}
|
||||
{{^isBinary}}
|
||||
{{{name}}}: {{{complexType}}}.fromJson(json[r'{{{baseName}}}']),
|
||||
{{{name}}}: {{{complexType}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
|
||||
{{/isBinary}}
|
||||
{{/isMap}}
|
||||
{{/isArray}}
|
||||
@ -143,30 +188,30 @@ class {{{classname}}} {
|
||||
{{^complexType}}
|
||||
{{#isArray}}
|
||||
{{#isEnum}}
|
||||
{{{name}}}: {{{items.datatypeWithEnum}}}.listFromJson(json[r'{{{baseName}}}']),
|
||||
{{{name}}}: {{{items.datatypeWithEnum}}}.listFromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
|
||||
{{/isEnum}}
|
||||
{{^isEnum}}
|
||||
{{{name}}}: json[r'{{{baseName}}}'] is {{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}
|
||||
? (json[r'{{{baseName}}}'] as {{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}).cast<{{{items.datatype}}}>()
|
||||
: null,
|
||||
: {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}},
|
||||
{{/isEnum}}
|
||||
{{/isArray}}
|
||||
{{^isArray}}
|
||||
{{#isMap}}
|
||||
{{{name}}}: mapCastOfType<String, {{{items.datatype}}}>(json, r'{{{baseName}}}'),
|
||||
{{{name}}}: mapCastOfType<String, {{{items.datatype}}}>(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
|
||||
{{/isMap}}
|
||||
{{^isMap}}
|
||||
{{#isNumber}}
|
||||
{{{name}}}: json[r'{{{baseName}}}'] == null
|
||||
? null
|
||||
? {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}
|
||||
: {{{datatypeWithEnum}}}.parse(json[r'{{{baseName}}}'].toString()),
|
||||
{{/isNumber}}
|
||||
{{^isNumber}}
|
||||
{{^isEnum}}
|
||||
{{{name}}}: mapValueOfType<{{{datatypeWithEnum}}}>(json, r'{{{baseName}}}'),
|
||||
{{{name}}}: mapValueOfType<{{{datatypeWithEnum}}}>(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
|
||||
{{/isEnum}}
|
||||
{{#isEnum}}
|
||||
{{{name}}}: {{{enumName}}}.fromJson(json[r'{{{baseName}}}']),
|
||||
{{{name}}}: {{{enumName}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}},
|
||||
{{/isEnum}}
|
||||
{{/isNumber}}
|
||||
{{/isMap}}
|
||||
@ -180,37 +225,56 @@ class {{{classname}}} {
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<{{{classname}}}> listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) =>
|
||||
json is List && json.isNotEmpty
|
||||
? json.map({{{classname}}}.fromJson).toList(growable: true == growable)
|
||||
: true == emptyIsNull ? null : <{{{classname}}}>[];
|
||||
static List<{{{classname}}}>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <{{{classname}}}>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = {{{classname}}}.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, {{{classname}}}> mapFromJson(dynamic json) {
|
||||
final map = <String, {{{classname}}}>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) => map[key] = {{{classname}}}.fromJson(value));
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = {{{classname}}}.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of {{{classname}}}-objects as value to a dart map
|
||||
static Map<String, List<{{{classname}}}>> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) {
|
||||
static Map<String, List<{{{classname}}}>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<{{{classname}}}>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) {
|
||||
map[key] = {{{classname}}}.listFromJson(
|
||||
value,
|
||||
emptyIsNull: emptyIsNull,
|
||||
growable: growable,
|
||||
);
|
||||
});
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = {{{classname}}}.listFromJson(entry.value, growable: growable,);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
{{#vars}}
|
||||
{{#required}}
|
||||
'{{{baseName}}}',
|
||||
{{/required}}
|
||||
{{/vars}}
|
||||
};
|
||||
}
|
||||
{{#vars}}
|
||||
{{#isEnum}}
|
||||
|
@ -7,7 +7,7 @@ class {{{classname}}} {
|
||||
final {{{dataType}}} value;
|
||||
|
||||
@override
|
||||
String toString() => {{#isString}}value ?? ''{{/isString}}{{^isString}}value == null ? '' : value.toString(){{/isString}};
|
||||
String toString() => {{#isString}}value{{/isString}}{{^isString}}value.toString(){{/isString}};
|
||||
|
||||
{{{dataType}}} toJson() => value;
|
||||
|
||||
@ -26,13 +26,20 @@ class {{{classname}}} {
|
||||
{{/allowableValues}}
|
||||
];
|
||||
|
||||
static {{{classname}}} fromJson(dynamic value) =>
|
||||
{{{classname}}}TypeTransformer().decode(value);
|
||||
static {{{classname}}}? fromJson(dynamic value) => {{{classname}}}TypeTransformer().decode(value);
|
||||
|
||||
static List<{{{classname}}}> listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) =>
|
||||
json is List && json.isNotEmpty
|
||||
? json.map({{{classname}}}.fromJson).toList(growable: true == growable)
|
||||
: true == emptyIsNull ? null : <{{{classname}}}>[];
|
||||
static List<{{{classname}}}>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <{{{classname}}}>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = {{{classname}}}.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
}
|
||||
|
||||
/// Transformation class that can [encode] an instance of [{{{classname}}}] to {{{dataType}}},
|
||||
@ -52,7 +59,7 @@ class {{{classname}}}TypeTransformer {
|
||||
///
|
||||
/// The [allowNull] is very handy when an API changes and a new enum value is added or removed,
|
||||
/// and users are still using an old app with the old code.
|
||||
{{{classname}}} decode(dynamic data, {bool allowNull}) {
|
||||
{{{classname}}}? decode(dynamic data, {bool allowNull = true}) {
|
||||
if (data != null) {
|
||||
switch (data.toString()) {
|
||||
{{#allowableValues}}
|
||||
@ -61,7 +68,7 @@ class {{{classname}}}TypeTransformer {
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
default:
|
||||
if (allowNull == false) {
|
||||
if (!allowNull) {
|
||||
throw ArgumentError('Unknown enum value to decode: $data');
|
||||
}
|
||||
}
|
||||
@ -70,5 +77,5 @@ class {{{classname}}}TypeTransformer {
|
||||
}
|
||||
|
||||
/// Singleton [{{{classname}}}TypeTransformer] instance.
|
||||
static {{{classname}}}TypeTransformer _instance;
|
||||
static {{{classname}}}TypeTransformer? _instance;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ class {{{enumName}}} {
|
||||
final {{{dataType}}} value;
|
||||
|
||||
@override
|
||||
String toString() => {{#isString}}value ?? ''{{/isString}}{{^isString}}value == null ? '' : value.toString(){{/isString}};
|
||||
String toString() => {{#isString}}value{{/isString}}{{^isString}}value.toString(){{/isString}};
|
||||
|
||||
{{{dataType}}} toJson() => value;
|
||||
|
||||
@ -26,13 +26,20 @@ class {{{enumName}}} {
|
||||
{{/allowableValues}}
|
||||
];
|
||||
|
||||
static {{{enumName}}} fromJson(dynamic value) =>
|
||||
{{{enumName}}}TypeTransformer().decode(value);
|
||||
static {{{enumName}}}? fromJson(dynamic value) => {{{enumName}}}TypeTransformer().decode(value);
|
||||
|
||||
static List<{{{enumName}}}> listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) =>
|
||||
json is List && json.isNotEmpty
|
||||
? json.map({{{enumName}}}.fromJson).toList(growable: true == growable)
|
||||
: true == emptyIsNull ? null : <{{{enumName}}}>[];
|
||||
static List<{{{enumName}}}>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <{{{enumName}}}>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = {{{enumName}}}.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
}
|
||||
|
||||
/// Transformation class that can [encode] an instance of [{{{enumName}}}] to {{{dataType}}},
|
||||
@ -52,7 +59,7 @@ class {{{enumName}}}TypeTransformer {
|
||||
///
|
||||
/// The [allowNull] is very handy when an API changes and a new enum value is added or removed,
|
||||
/// and users are still using an old app with the old code.
|
||||
{{{enumName}}} decode(dynamic data, {bool allowNull}) {
|
||||
{{{enumName}}}? decode(dynamic data, {bool allowNull = true}) {
|
||||
if (data != null) {
|
||||
switch (data.toString()) {
|
||||
{{#allowableValues}}
|
||||
@ -61,7 +68,7 @@ class {{{enumName}}}TypeTransformer {
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
default:
|
||||
if (allowNull == false) {
|
||||
if (!allowNull) {
|
||||
throw ArgumentError('Unknown enum value to decode: $data');
|
||||
}
|
||||
}
|
||||
@ -70,5 +77,5 @@ class {{{enumName}}}TypeTransformer {
|
||||
}
|
||||
|
||||
/// Singleton [{{{enumName}}}TypeTransformer] instance.
|
||||
static {{{enumName}}}TypeTransformer _instance;
|
||||
static {{{enumName}}}TypeTransformer? _instance;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
language: dart
|
||||
dart:
|
||||
# Install a specific stable release
|
||||
- "2.2.0"
|
||||
- "2.12"
|
||||
install:
|
||||
- pub get
|
||||
|
||||
|
1
pom.xml
1
pom.xml
@ -1400,7 +1400,6 @@
|
||||
</activation>
|
||||
<modules>
|
||||
<module>samples/openapi3/client/petstore/dart2/petstore_client_lib</module>
|
||||
<module>samples/openapi3/client/petstore/dart2/petstore</module>
|
||||
<module>samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake</module>
|
||||
</modules>
|
||||
</profile>
|
||||
|
@ -1,37 +0,0 @@
|
||||
# Background
|
||||
|
||||
## Current state of tests
|
||||
|
||||
TL;DR currently the only tests are e2e tests that were adapted to use a faked http client. While pushing data around as a smoke test has some value, more testing is required. In particular we need comprehensive unit/integration tests.
|
||||
|
||||
- an old set of e2e tests are skipped for CI, as they hit a live endpoint and so are inherently flaky
|
||||
- `pet_test.dart`
|
||||
- `store_test.dart`
|
||||
- `user_test.dart`
|
||||
- the above set of tests were adapted to use a faked http client
|
||||
- the tests are not really well suited to being used with a stubbed client, many are basically just testing the endpoint logic
|
||||
- while not a great set of tests, they do have some value as a smoke test for template changes
|
||||
- the adapted tests and files that contain test data:
|
||||
- `pet_test_fake_client.dart`
|
||||
- `store_test_fake_client.dart`
|
||||
- `user_test_fake_client.dart`
|
||||
- `fake_client.dart`
|
||||
- `file_upload_response.json`
|
||||
|
||||
## Assumptions
|
||||
|
||||
- the tests will be run as part of CI and so have access to dart:io
|
||||
|
||||
# Running
|
||||
|
||||
## If not already done, resolve dependencies
|
||||
|
||||
`pub get`
|
||||
|
||||
## To run tests in a single file:
|
||||
|
||||
`pub run test test/pet_test.dart`
|
||||
|
||||
## To run all tests in the test folder:
|
||||
|
||||
`pub run test`
|
@ -1,73 +0,0 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>Dart2PetstoreClientTests</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<name>Dart2 Petstore Client</name>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>export-dartfmt</id>
|
||||
<phase>pre-install-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>export</executable>
|
||||
<arguments>
|
||||
<argument>DART_FMT_PATH=/usr/local/bin/dartfmt</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>pub-get</id>
|
||||
<phase>pre-integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>pub</executable>
|
||||
<arguments>
|
||||
<argument>get</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>pub-test</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>pub</executable>
|
||||
<arguments>
|
||||
<argument>run</argument>
|
||||
<argument>test</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -1,418 +0,0 @@
|
||||
# Generated by pub
|
||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||
packages:
|
||||
_fe_analyzer_shared:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: _fe_analyzer_shared
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "14.0.0"
|
||||
analyzer:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: analyzer
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.41.2"
|
||||
args:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: args
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
async:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.7.0"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: boolean_selector
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
build:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: build
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.6.2"
|
||||
built_collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: built_collection
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "5.1.0"
|
||||
built_value:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: built_value
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "8.1.1"
|
||||
charcode:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: charcode
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.1"
|
||||
cli_util:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: cli_util
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.3.3"
|
||||
clock:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: clock
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
code_builder:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: code_builder
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.7.0"
|
||||
collection:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: collection
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.15.0"
|
||||
convert:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: convert
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.1"
|
||||
coverage:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: coverage
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.15.2"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: crypto
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.1"
|
||||
dart_style:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: dart_style
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.12"
|
||||
file:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "6.1.2"
|
||||
fixnum:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: fixnum
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
glob:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: glob
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
http:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: http
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.13.3"
|
||||
http_multi_server:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http_multi_server
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.1"
|
||||
http_parser:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http_parser
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "4.0.0"
|
||||
intl:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: intl
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.17.0"
|
||||
io:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: io
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.3"
|
||||
js:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: js
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.6.3"
|
||||
logging:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: logging
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: matcher
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.12.10"
|
||||
meta:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: meta
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.6.0"
|
||||
mime:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: mime
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
mockito:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: mockito
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "4.1.4"
|
||||
node_preamble:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: node_preamble
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.4.13"
|
||||
openapi:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "../petstore_client_lib"
|
||||
relative: true
|
||||
source: path
|
||||
version: "1.0.0"
|
||||
package_config:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: package_config
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.9.3"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.0"
|
||||
pedantic:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pedantic
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.11.1"
|
||||
pool:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pool
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.5.0"
|
||||
pub_semver:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pub_semver
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
shelf:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shelf
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
shelf_packages_handler:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shelf_packages_handler
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.0"
|
||||
shelf_static:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shelf_static
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
shelf_web_socket:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shelf_web_socket
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
source_gen:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_gen
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.9.10+3"
|
||||
source_map_stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_map_stack_trace
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
source_maps:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_maps
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.10.10"
|
||||
source_span:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_span
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.1"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stack_trace
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.10.0"
|
||||
stream_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stream_channel
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
string_scanner:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: string_scanner
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: term_glyph
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
test:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: test
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.16.5"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.19"
|
||||
test_core:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_core
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.3.15"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: typed_data
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
vm_service:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vm_service
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "6.2.0"
|
||||
watcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: watcher
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
web_socket_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: web_socket_channel
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
webkit_inspection_protocol:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webkit_inspection_protocol
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
yaml:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: yaml
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.1.0"
|
||||
sdks:
|
||||
dart: ">=2.12.0 <3.0.0"
|
@ -1,19 +0,0 @@
|
||||
name: petstore_client
|
||||
version: 1.0.0
|
||||
description: Petstore client using OpenAPI library
|
||||
|
||||
publish_to: none
|
||||
|
||||
environment:
|
||||
sdk: '>=2.11.0 <3.0.0'
|
||||
|
||||
dependencies:
|
||||
openapi:
|
||||
path: ../petstore_client_lib
|
||||
|
||||
dev_dependencies:
|
||||
meta: <1.7.0
|
||||
test: ^1.8.0
|
||||
mockito: ^4.1.1
|
||||
http: ^0.13.0
|
||||
collection: ^1.14.12
|
@ -1,134 +0,0 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
|
||||
/// A fake client that checks for expected values and returns given responses
|
||||
///
|
||||
/// Checks for the expected values (url, headers, body) and throws if not found
|
||||
///
|
||||
/// If exception is non-null the request will throw the exception, after other
|
||||
/// checks are performed
|
||||
class FakeClient extends Fake implements Client {
|
||||
FakeClient({
|
||||
this.throwException,
|
||||
this.expectedPostRequestBody,
|
||||
this.postResponseBody,
|
||||
this.expectedGetRequestBody,
|
||||
this.getResponseBody,
|
||||
this.deleteResponseBody,
|
||||
this.expectedPutRequestBody,
|
||||
this.putResponseBody,
|
||||
this.sendResponseBody,
|
||||
String expectedUrl,
|
||||
this.expectedHeaders = null,
|
||||
}) : this.expectedUrl = Uri.parse(expectedUrl);
|
||||
|
||||
Exception throwException;
|
||||
Object expectedPostRequestBody;
|
||||
String postResponseBody;
|
||||
String expectedGetRequestBody;
|
||||
String getResponseBody;
|
||||
String deleteResponseBody;
|
||||
String expectedPutRequestBody;
|
||||
String putResponseBody;
|
||||
String sendResponseBody;
|
||||
Uri expectedUrl;
|
||||
Map<String, String> expectedHeaders;
|
||||
|
||||
@override
|
||||
Future<Response> post(Uri url,
|
||||
{Map<String, String> headers, Object body, Encoding encoding}) async {
|
||||
// check that the request was made with expected values
|
||||
if (url != expectedUrl) {
|
||||
throw StateError(
|
||||
'POST was called with unexpected url: ${url} should be ${expectedUrl}');
|
||||
}
|
||||
if (!MapEquality().equals(headers, expectedHeaders)) {
|
||||
throw StateError(
|
||||
'POST was called with unexpected headers: ${headers} should be ${expectedHeaders}');
|
||||
}
|
||||
// currently we only expect Map (and subtypes) or Strings
|
||||
if (body is Map) {
|
||||
if (!MapEquality().equals(body, expectedPostRequestBody)) {
|
||||
throw StateError(
|
||||
'POST was called with unexpected body: ${body} should be ${expectedPostRequestBody}');
|
||||
}
|
||||
} else if (body != expectedPostRequestBody) {
|
||||
throw StateError(
|
||||
'POST was called with unexpected body: ${body} should be ${expectedPostRequestBody}');
|
||||
}
|
||||
|
||||
// throw if set to throw
|
||||
if (throwException != null) throw throwException;
|
||||
|
||||
return Response(postResponseBody, 200);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Response> get(Uri url, {Map<String, String> headers}) async {
|
||||
// check that the request was made with expected values
|
||||
if (url != expectedUrl) {
|
||||
throw StateError(
|
||||
'GET was called with unexpected url: ${url} should be ${expectedUrl}');
|
||||
}
|
||||
if (!MapEquality().equals(headers, expectedHeaders)) {
|
||||
throw StateError(
|
||||
'GET was called with unexpected headers: ${headers} should be ${expectedHeaders}');
|
||||
}
|
||||
|
||||
// throw if set to throw
|
||||
if (throwException != null) throw throwException;
|
||||
|
||||
return Response(getResponseBody, 200);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Response> delete(Uri url,
|
||||
{Map<String, String> headers, Object body, Encoding encoding}) async {
|
||||
// check that the request was made with expected values
|
||||
if (url != expectedUrl) {
|
||||
throw StateError(
|
||||
'DELETE was called with unexpected url: ${url} should be ${expectedUrl}');
|
||||
}
|
||||
if (!MapEquality().equals(headers, expectedHeaders)) {
|
||||
throw StateError(
|
||||
'DELETE was called with unexpected headers: ${headers} should be ${expectedHeaders}');
|
||||
}
|
||||
|
||||
// throw if set to throw
|
||||
if (throwException != null) throw throwException;
|
||||
|
||||
return Response(deleteResponseBody, 200);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Response> put(Uri url,
|
||||
{Map<String, String> headers, Object body, Encoding encoding}) async {
|
||||
// check that the request was made with expected values
|
||||
if (url != expectedUrl) {
|
||||
throw StateError(
|
||||
'PUT was called with unexpected url: ${url} should be ${expectedUrl}');
|
||||
}
|
||||
if (!MapEquality().equals(headers, expectedHeaders)) {
|
||||
throw StateError(
|
||||
'PUT was called with unexpected headers: ${headers} should be ${expectedHeaders}');
|
||||
}
|
||||
if (body != expectedPutRequestBody) {
|
||||
throw StateError(
|
||||
'PUT was called with unexpected body: ${body} should be ${expectedPutRequestBody}');
|
||||
}
|
||||
|
||||
// throw if set to throw
|
||||
if (throwException != null) throw throwException;
|
||||
|
||||
return Response(putResponseBody, 200);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<StreamedResponse> send(BaseRequest request) async {
|
||||
List<int> bytes = utf8.encode(sendResponseBody);
|
||||
return StreamedResponse(Stream.fromIterable([bytes]), 200);
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
{"code":200,"type":"unknown","message":"additionalMetadata: \nFile uploaded to ./null, 4 bytes"}
|
@ -1 +0,0 @@
|
||||
{"mine":1,"sold":18,"string":568,"Dead":2,"test":2,"Nonavailable":1,"custom":3,"pending":20,"available":2212,"notAvailable":26,"avaiflable":1,"AVAILABLE":1,"swimming":1,"availablee":2,"success":1,"105":1,"missing":11,"disabled":1,"Available":1,"]]>":1}
|
@ -1,9 +0,0 @@
|
||||
import 'package:openapi/api.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
test('Check if default value is generated', () async {
|
||||
var order = Order();
|
||||
expect(order.complete, equals(false));
|
||||
});
|
||||
}
|
@ -1,223 +0,0 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'fake_client.dart';
|
||||
import 'random_id.dart';
|
||||
|
||||
void main() {
|
||||
final petApi = PetApi();
|
||||
|
||||
Pet makePet({
|
||||
int id = 1234,
|
||||
String name = 'Fluffy',
|
||||
String status = '',
|
||||
}) {
|
||||
final category = Category()
|
||||
..id = 1234
|
||||
..name = 'eyeColor';
|
||||
final tags = [
|
||||
Tag()
|
||||
..id = 1234
|
||||
..name = 'New York',
|
||||
Tag()
|
||||
..id = 124321
|
||||
..name = 'Jose'
|
||||
];
|
||||
return Pet(name: name)
|
||||
..id = id
|
||||
..category = category
|
||||
..tags = tags
|
||||
..status = PetStatusEnum.fromJson(status)
|
||||
..photoUrls = ['https://petstore.com/sample/photo1.jpg'];
|
||||
}
|
||||
|
||||
/// Setup the fake client then call [petApi.addPet]
|
||||
Future<dynamic> addPet(Pet pet) async {
|
||||
petApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
||||
expectedPostRequestBody: await petApi.apiClient.serializeAsync(pet),
|
||||
postResponseBody: await petApi.apiClient.serializeAsync(pet),
|
||||
expectedHeaders: {'Content-Type': 'application/json'});
|
||||
return petApi.addPet(pet);
|
||||
}
|
||||
|
||||
group('Pet API with faked client', () {
|
||||
test('adds a new pet and gets it by id', () async {
|
||||
final id = newId();
|
||||
final newPet = makePet(id: id);
|
||||
|
||||
// use the pet api to add a pet
|
||||
petApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
||||
expectedPostRequestBody: await petApi.apiClient.serializeAsync(newPet),
|
||||
postResponseBody: await petApi.apiClient.serializeAsync(newPet),
|
||||
expectedHeaders: {'Content-Type': 'application/json'});
|
||||
await petApi.addPet(newPet);
|
||||
|
||||
// retrieve the same pet by id
|
||||
petApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/pet/$id',
|
||||
getResponseBody: await petApi.apiClient.serializeAsync(newPet),
|
||||
);
|
||||
final retrievedPet = await petApi.getPetById(id);
|
||||
|
||||
// check that the retrieved id is as expected
|
||||
expect(retrievedPet.id, equals(id));
|
||||
});
|
||||
|
||||
test('doesn\'t get non-existing pet by id', () {
|
||||
final id = newId();
|
||||
petApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/pet/$id',
|
||||
throwException: ApiException(400, 'not found'),
|
||||
);
|
||||
expect(petApi.getPetById(id), throwsA(equals(TypeMatcher<ApiException>())));
|
||||
});
|
||||
|
||||
test('deletes existing pet by id', () async {
|
||||
final id = newId();
|
||||
Pet newPet = makePet(id: id);
|
||||
|
||||
// add a new pet
|
||||
petApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
||||
expectedPostRequestBody: await petApi.apiClient.serializeAsync(newPet),
|
||||
postResponseBody: await petApi.apiClient.serializeAsync(newPet),
|
||||
expectedHeaders: {'Content-Type': 'application/json'});
|
||||
await petApi.addPet(newPet);
|
||||
|
||||
// delete the pet
|
||||
petApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/pet/$id',
|
||||
expectedHeaders: {'api_key': 'special-key'},
|
||||
deleteResponseBody: '',
|
||||
);
|
||||
await petApi.deletePet(id, apiKey: 'special-key');
|
||||
|
||||
// check for the deleted pet
|
||||
petApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/pet/$id',
|
||||
throwException: ApiException(400, 'Not found'),
|
||||
);
|
||||
expect(petApi.getPetById(id), throwsA(equals(TypeMatcher<ApiException>())));
|
||||
});
|
||||
|
||||
test('updates pet with form', () async {
|
||||
final id = newId();
|
||||
final newPet = makePet(id: id, name: 'Snowy');
|
||||
|
||||
// add a new pet
|
||||
petApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
||||
expectedPostRequestBody: await petApi.apiClient.serializeAsync(newPet),
|
||||
postResponseBody: await petApi.apiClient.serializeAsync(newPet),
|
||||
expectedHeaders: {'Content-Type': 'application/json'});
|
||||
await petApi.addPet(newPet);
|
||||
|
||||
// update with form
|
||||
petApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/pet/$id',
|
||||
expectedHeaders: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
expectedPostRequestBody: {'name': 'Doge', 'status': ''},
|
||||
postResponseBody: '',
|
||||
);
|
||||
await petApi.updatePetWithForm(id, name: 'Doge', status: '');
|
||||
|
||||
// check update worked
|
||||
newPet.name = 'Doge';
|
||||
petApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/pet/$id',
|
||||
getResponseBody: await petApi.apiClient.serializeAsync(newPet),
|
||||
);
|
||||
final pet = await petApi.getPetById(id);
|
||||
expect(pet.name, equals('Doge'));
|
||||
});
|
||||
|
||||
test('updates existing pet', () async {
|
||||
final id = newId();
|
||||
final name = 'Snowy';
|
||||
final newPet = makePet(id: id);
|
||||
final updatePet = makePet(id: id, name: name);
|
||||
|
||||
// add a new pet
|
||||
petApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
||||
expectedPostRequestBody: await petApi.apiClient.serializeAsync(newPet),
|
||||
postResponseBody: await petApi.apiClient.serializeAsync(newPet),
|
||||
expectedHeaders: {'Content-Type': 'application/json'});
|
||||
await petApi.addPet(newPet);
|
||||
|
||||
// update the same pet
|
||||
petApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
||||
expectedPutRequestBody: await petApi.apiClient.serializeAsync(updatePet),
|
||||
putResponseBody: await petApi.apiClient.serializeAsync(updatePet),
|
||||
expectedHeaders: {'Content-Type': 'application/json'});
|
||||
await petApi.updatePet(updatePet);
|
||||
|
||||
// check update worked
|
||||
petApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/pet/$id',
|
||||
getResponseBody: await petApi.apiClient.serializeAsync(updatePet),
|
||||
);
|
||||
final pet = await petApi.getPetById(id);
|
||||
expect(pet.name, equals(name));
|
||||
});
|
||||
|
||||
test('finds pets by status', () async {
|
||||
final id1 = newId();
|
||||
final id2 = newId();
|
||||
final id3 = newId();
|
||||
final status = '${PetStatusEnum.available}';
|
||||
final pet1 = makePet(id: id1, status: status);
|
||||
final pet2 = makePet(id: id2, status: status);
|
||||
final pet3 = makePet(id: id3, status: '${PetStatusEnum.sold}');
|
||||
|
||||
await addPet(pet1);
|
||||
await addPet(pet2);
|
||||
await addPet(pet3);
|
||||
|
||||
// retrieve pets by status
|
||||
petApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/pet/findByStatus?status=$status',
|
||||
getResponseBody: await petApi.apiClient.serializeAsync([pet1, pet2]),
|
||||
);
|
||||
final pets = await petApi.findPetsByStatus([status]);
|
||||
|
||||
// tests serialisation and deserialisation of enum
|
||||
final petsByStatus = pets.where((p) => p.status == PetStatusEnum.available);
|
||||
expect(petsByStatus.length, equals(2));
|
||||
final petIds = pets.map((pet) => pet.id).toList();
|
||||
expect(petIds, contains(id1));
|
||||
expect(petIds, contains(id2));
|
||||
expect(petIds, isNot(contains(id3)));
|
||||
});
|
||||
|
||||
test('uploads a pet image', () async {
|
||||
final id = newId();
|
||||
final newPet = makePet(id: id);
|
||||
// get some test data (recorded from live response)
|
||||
final uploadResponse = await File('test/file_upload_response.json').readAsString();
|
||||
|
||||
// add a new pet
|
||||
petApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
||||
expectedPostRequestBody: await petApi.apiClient.serializeAsync(newPet),
|
||||
postResponseBody: await petApi.apiClient.serializeAsync(newPet),
|
||||
expectedHeaders: {'Content-Type': 'application/json'});
|
||||
await petApi.addPet(newPet);
|
||||
|
||||
petApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
||||
sendResponseBody: uploadResponse,
|
||||
);
|
||||
final file = new MultipartFile.fromBytes('file', [104, 101, 108, 108, 111]);
|
||||
await petApi.uploadFile(id, file: file);
|
||||
});
|
||||
});
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
@Skip('Needs real petstore')
|
||||
import 'package:http/http.dart';
|
||||
import 'package:openapi/api.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'random_id.dart';
|
||||
|
||||
void main() {
|
||||
var petApi = PetApi();
|
||||
|
||||
Pet makePet({
|
||||
int id = 1234,
|
||||
String name = 'Fluffy',
|
||||
String status = '',
|
||||
}) {
|
||||
final category = Category()
|
||||
..id = 1234
|
||||
..name = 'eyeColor';
|
||||
final tags = [
|
||||
Tag()
|
||||
..id = 1234
|
||||
..name = 'New York',
|
||||
Tag()
|
||||
..id = 124321
|
||||
..name = 'Jose'
|
||||
];
|
||||
|
||||
return Pet(
|
||||
id: id,
|
||||
category: category,
|
||||
name: name, //required field
|
||||
tags: tags,
|
||||
photoUrls: ['https://petstore.com/sample/photo1.jpg'] //required field
|
||||
)
|
||||
..status = PetStatusEnum.fromJson(status)
|
||||
..photoUrls = ['https://petstore.com/sample/photo1.jpg'];
|
||||
}
|
||||
|
||||
group('Pet API with live client', () {
|
||||
test('adds a new pet and gets it by id', () async {
|
||||
var id = newId();
|
||||
await petApi.addPet(makePet(id: id));
|
||||
var pet = await petApi.getPetById(id);
|
||||
expect(pet.id, equals(id));
|
||||
});
|
||||
|
||||
test('doesn\'t get non-existing pet by id', () {
|
||||
expect(petApi.getPetById(newId()), throwsA(equals(TypeMatcher<ApiException>())));
|
||||
});
|
||||
|
||||
test('deletes existing pet by id', () async {
|
||||
var id = newId();
|
||||
await petApi.addPet(makePet(id: id));
|
||||
await petApi.deletePet(id, apiKey: 'special-key');
|
||||
expect(petApi.getPetById(id), throwsA(equals(TypeMatcher<ApiException>())));
|
||||
});
|
||||
|
||||
test('updates pet with form', () async {
|
||||
var id = newId();
|
||||
|
||||
await petApi.addPet(makePet(id: id, name: 'Snowy'));
|
||||
await petApi.updatePetWithForm(id, name: 'Doge', status: '');
|
||||
var pet = await petApi.getPetById(id);
|
||||
expect(pet.name, equals('Doge'));
|
||||
});
|
||||
|
||||
test('updates existing pet', () async {
|
||||
var id = newId();
|
||||
var name = 'Snowy';
|
||||
|
||||
await petApi.addPet(makePet(id: id));
|
||||
await petApi.updatePet(makePet(id: id, name: name));
|
||||
var pet = await petApi.getPetById(id);
|
||||
expect(pet.name, equals(name));
|
||||
});
|
||||
|
||||
test('finds pets by status', () async {
|
||||
var id1 = newId();
|
||||
var id2 = newId();
|
||||
var id3 = newId();
|
||||
var status = '${PetStatusEnum.available}';
|
||||
|
||||
await petApi.addPet(makePet(id: id1, status: status));
|
||||
await petApi.addPet(makePet(id: id2, status: status));
|
||||
await petApi.addPet(makePet(id: id3, status: '${PetStatusEnum.sold}'));
|
||||
|
||||
var pets = await petApi.findPetsByStatus([status]);
|
||||
var petIds = pets.map((pet) => pet.id).toList();
|
||||
expect(petIds, contains(id1));
|
||||
expect(petIds, contains(id2));
|
||||
expect(petIds, isNot(contains(id3)));
|
||||
});
|
||||
|
||||
test('uploads a pet image', () async {
|
||||
var id = newId();
|
||||
await petApi.addPet(makePet(id: id));
|
||||
var file = new MultipartFile.fromBytes('file', [104, 101, 108, 108, 111]);
|
||||
await petApi.uploadFile(id, additionalMetadata: '', file: file);
|
||||
});
|
||||
});
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
import 'dart:math';
|
||||
|
||||
final _random = new Random();
|
||||
|
||||
int newId() {
|
||||
return _random.nextInt(999999);
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:openapi/api.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'fake_client.dart';
|
||||
import 'random_id.dart';
|
||||
|
||||
void main() {
|
||||
var storeApi = new StoreApi();
|
||||
|
||||
Order makeOrder({int id}) {
|
||||
return Order()
|
||||
..id = id
|
||||
..petId = 1234
|
||||
..quantity = 1
|
||||
..shipDate = DateTime.now()
|
||||
..status
|
||||
..complete = false;
|
||||
}
|
||||
|
||||
group('Store API with faked client', () {
|
||||
test('places an order and gets it by id', () async {
|
||||
final id = newId();
|
||||
final newOrder = makeOrder(id: id);
|
||||
|
||||
// use the store api to add an order
|
||||
storeApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/store/order',
|
||||
expectedPostRequestBody: await storeApi.apiClient.serializeAsync(newOrder),
|
||||
postResponseBody: await storeApi.apiClient.serializeAsync(newOrder),
|
||||
expectedHeaders: {"Content-Type": "application/json"});
|
||||
await storeApi.placeOrder(newOrder);
|
||||
|
||||
// retrieve the same order by id
|
||||
storeApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/store/order/$id',
|
||||
getResponseBody: await storeApi.apiClient.serializeAsync(newOrder),
|
||||
);
|
||||
final placedOrder = await storeApi.getOrderById(id);
|
||||
expect(placedOrder.id, equals(id));
|
||||
});
|
||||
|
||||
test('deletes an order', () async {
|
||||
final id = newId();
|
||||
final newOrder = makeOrder(id: id);
|
||||
|
||||
// use the store api to add an order
|
||||
storeApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/store/order',
|
||||
expectedPostRequestBody: await storeApi.apiClient.serializeAsync(newOrder),
|
||||
postResponseBody: await storeApi.apiClient.serializeAsync(newOrder),
|
||||
expectedHeaders: {"Content-Type": "application/json"});
|
||||
await storeApi.placeOrder(newOrder);
|
||||
|
||||
// delete the same order
|
||||
storeApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/store/order/$id',
|
||||
deleteResponseBody: '',
|
||||
);
|
||||
await storeApi.deleteOrder(id.toString());
|
||||
|
||||
// try and retrieve the order
|
||||
storeApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/store/order/$id',
|
||||
throwException: ApiException(400, 'Not found'),
|
||||
);
|
||||
expect(storeApi.getOrderById(id), throwsA(equals(TypeMatcher<ApiException>())));
|
||||
});
|
||||
|
||||
test('gets the store inventory', () async {
|
||||
// get some test data (recorded from live response)
|
||||
final inventoryResponse = await File('test/inventory_response.json').readAsString();
|
||||
// use the store api to get the inventory
|
||||
storeApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/store/inventory',
|
||||
getResponseBody: inventoryResponse,
|
||||
);
|
||||
Map<String, int> inventory = await storeApi.getInventory();
|
||||
expect(inventory.length, isNot(equals(0)));
|
||||
});
|
||||
});
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
@Skip('Needs real petstore')
|
||||
import 'package:openapi/api.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'random_id.dart';
|
||||
|
||||
void main() {
|
||||
var storeApi = new StoreApi();
|
||||
|
||||
Order makeOrder({int id}) {
|
||||
return Order()
|
||||
..id = id
|
||||
..petId = 1234
|
||||
..quantity = 1
|
||||
..shipDate = DateTime.now()
|
||||
..status
|
||||
..complete = false;
|
||||
}
|
||||
|
||||
group('Store API with live client', () {
|
||||
test('places an order and gets it by id', () async {
|
||||
var id = newId();
|
||||
|
||||
await storeApi.placeOrder(makeOrder(id: id));
|
||||
var order = await storeApi.getOrderById(id);
|
||||
expect(order.id, equals(id));
|
||||
});
|
||||
|
||||
test('deletes an order', () async {
|
||||
var id = newId();
|
||||
|
||||
await storeApi.placeOrder(makeOrder(id: id));
|
||||
await storeApi.deleteOrder(id.toString());
|
||||
expect(storeApi.getOrderById(id), throwsA(equals(TypeMatcher<ApiException>())));
|
||||
});
|
||||
|
||||
test('gets the store inventory', () async {
|
||||
Map<String, int> inventory = await storeApi.getInventory();
|
||||
expect(inventory.length, isNot(equals(0)));
|
||||
});
|
||||
});
|
||||
}
|
@ -1,180 +0,0 @@
|
||||
import 'package:openapi/api.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'fake_client.dart';
|
||||
import 'random_id.dart';
|
||||
|
||||
void main() {
|
||||
var userApi = new UserApi();
|
||||
|
||||
User makeUser(
|
||||
{int id, String userName = 'username', String password = 'password'}) {
|
||||
return User()
|
||||
..id = id
|
||||
..username = userName
|
||||
..firstName = 'firstname'
|
||||
..lastName = 'lastname'
|
||||
..email = 'email'
|
||||
..password = password
|
||||
..phone = 'phone'
|
||||
..userStatus = 0;
|
||||
}
|
||||
|
||||
group('User API with faked client', () {
|
||||
test('creates a user', () async {
|
||||
final id = newId();
|
||||
final username = 'Mally45';
|
||||
final newUser = makeUser(id: id, userName: username);
|
||||
|
||||
// use the user api to create a user
|
||||
userApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/user',
|
||||
expectedPostRequestBody:
|
||||
await userApi.apiClient.serializeAsync(newUser),
|
||||
expectedHeaders: {'Content-Type': 'application/json'},
|
||||
postResponseBody: await userApi.apiClient.serializeAsync(newUser),
|
||||
);
|
||||
await userApi.createUser(newUser);
|
||||
|
||||
// retrieve the same user
|
||||
userApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/user/$username',
|
||||
getResponseBody: await userApi.apiClient.serializeAsync(newUser),
|
||||
);
|
||||
var user = await userApi.getUserByName(username);
|
||||
expect(user.id, equals(id));
|
||||
});
|
||||
|
||||
test('creates users with list input', () async {
|
||||
final firstId = newId();
|
||||
final joe = 'Joe';
|
||||
|
||||
final sally = 'Sally';
|
||||
final secondId = newId();
|
||||
|
||||
final users = [
|
||||
makeUser(id: firstId, userName: joe),
|
||||
makeUser(id: secondId, userName: sally),
|
||||
];
|
||||
|
||||
// use the user api to create a list of users
|
||||
userApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/user/createWithList',
|
||||
expectedPostRequestBody: await userApi.apiClient.serializeAsync(users),
|
||||
expectedHeaders: {'Content-Type': 'application/json'},
|
||||
postResponseBody: await userApi.apiClient.serializeAsync(users),
|
||||
);
|
||||
await userApi.createUsersWithListInput(users);
|
||||
|
||||
// retrieve the users
|
||||
userApi.apiClient.client = FakeClient(
|
||||
expectedUrl:
|
||||
'http://petstore.swagger.io/v2/user/${users.elementAt(0).username}',
|
||||
getResponseBody: await userApi.apiClient.serializeAsync(
|
||||
users.elementAt(0),
|
||||
),
|
||||
);
|
||||
final firstUser = await userApi.getUserByName(joe);
|
||||
userApi.apiClient.client = FakeClient(
|
||||
expectedUrl:
|
||||
'http://petstore.swagger.io/v2/user/${users.elementAt(1).username}',
|
||||
getResponseBody: await userApi.apiClient.serializeAsync(
|
||||
users.elementAt(1),
|
||||
),
|
||||
);
|
||||
final secondUser = await userApi.getUserByName(sally);
|
||||
expect(firstUser.id, equals(firstId));
|
||||
expect(secondUser.id, equals(secondId));
|
||||
});
|
||||
|
||||
test('updates a user', () async {
|
||||
final username = 'Arkjam89';
|
||||
final email = 'test@example.com';
|
||||
final newUser = makeUser(id: newId(), userName: username);
|
||||
|
||||
// use the user api to create a user
|
||||
userApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/user',
|
||||
expectedPostRequestBody:
|
||||
await userApi.apiClient.serializeAsync(newUser),
|
||||
expectedHeaders: {'Content-Type': 'application/json'},
|
||||
postResponseBody: await userApi.apiClient.serializeAsync(newUser),
|
||||
);
|
||||
await userApi.createUser(newUser);
|
||||
newUser.email = email;
|
||||
|
||||
// use the user api to update the user
|
||||
userApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/user/${newUser.username}',
|
||||
expectedPutRequestBody: await userApi.apiClient.serializeAsync(newUser),
|
||||
expectedHeaders: {'Content-Type': 'application/json'},
|
||||
putResponseBody: await userApi.apiClient.serializeAsync(newUser),
|
||||
);
|
||||
await userApi.updateUser(username, newUser);
|
||||
|
||||
// retrieve the same user
|
||||
userApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/user/${newUser.username}',
|
||||
getResponseBody: await userApi.apiClient.serializeAsync(newUser),
|
||||
);
|
||||
var foundUser = await userApi.getUserByName(username);
|
||||
expect(foundUser.email, equals(email));
|
||||
});
|
||||
|
||||
test('deletes a user', () async {
|
||||
final username = 'Riddlem325';
|
||||
final newUser = makeUser(id: newId(), userName: username);
|
||||
|
||||
// use the user api to create a user
|
||||
userApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/user',
|
||||
expectedPostRequestBody:
|
||||
await userApi.apiClient.serializeAsync(newUser),
|
||||
expectedHeaders: {'Content-Type': 'application/json'},
|
||||
postResponseBody: await userApi.apiClient.serializeAsync(newUser),
|
||||
);
|
||||
await userApi.createUser(newUser);
|
||||
|
||||
// delete the same user
|
||||
userApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/user/${newUser.username}',
|
||||
deleteResponseBody: '',
|
||||
);
|
||||
await userApi.deleteUser(username);
|
||||
|
||||
// try and retrieve the user
|
||||
userApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/user/${newUser.username}',
|
||||
throwException: ApiException(400, 'Not found'),
|
||||
);
|
||||
expect(userApi.getUserByName(username),
|
||||
throwsA(TypeMatcher<ApiException>()));
|
||||
});
|
||||
|
||||
test('logs a user in', () async {
|
||||
final username = 'sgarad625';
|
||||
final password = 'lokimoki1';
|
||||
final newUser =
|
||||
makeUser(id: newId(), userName: username, password: password);
|
||||
|
||||
// use the user api to create a user
|
||||
userApi.apiClient.client = FakeClient(
|
||||
expectedUrl: 'http://petstore.swagger.io/v2/user',
|
||||
expectedPostRequestBody:
|
||||
await userApi.apiClient.serializeAsync(newUser),
|
||||
expectedHeaders: {'Content-Type': 'application/json'},
|
||||
postResponseBody: await userApi.apiClient.serializeAsync(newUser),
|
||||
);
|
||||
await userApi.createUser(newUser);
|
||||
|
||||
// use the user api to login
|
||||
userApi.apiClient.client = FakeClient(
|
||||
expectedUrl:
|
||||
'http://petstore.swagger.io/v2/user/login?username=${newUser.username}&password=${newUser.password}',
|
||||
getResponseBody: 'logged in user session:',
|
||||
);
|
||||
final result = await userApi.loginUser(username, password);
|
||||
expect(result, contains('logged in user session:'));
|
||||
});
|
||||
});
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
@Skip('Needs real petstore')
|
||||
import 'package:openapi/api.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'random_id.dart';
|
||||
|
||||
void main() {
|
||||
var userApi = new UserApi();
|
||||
|
||||
User makeUser({int id, String userName = 'username', String password = 'password'}) {
|
||||
return User()
|
||||
..id = id
|
||||
..username = userName
|
||||
..firstName = 'firstname'
|
||||
..lastName = 'lastname'
|
||||
..email = 'email'
|
||||
..password = password
|
||||
..phone = 'phone'
|
||||
..userStatus = 0;
|
||||
}
|
||||
|
||||
group('User API with live client', () {
|
||||
test('creates a user', () async {
|
||||
var id = newId();
|
||||
var username = 'Mally45';
|
||||
await userApi.createUser(makeUser(id: id, userName: username));
|
||||
var user = await userApi.getUserByName(username);
|
||||
expect(user.id, equals(id));
|
||||
});
|
||||
|
||||
test('creates users with list input', () async {
|
||||
var firstId = newId();
|
||||
var joe = 'Joe';
|
||||
|
||||
var sally = 'Sally';
|
||||
var secondId = newId();
|
||||
|
||||
var users = [
|
||||
makeUser(id: firstId, userName: joe),
|
||||
makeUser(id: secondId, userName: sally),
|
||||
];
|
||||
|
||||
await userApi.createUsersWithListInput(users);
|
||||
var firstUser = await userApi.getUserByName(joe);
|
||||
var secondUser = await userApi.getUserByName(sally);
|
||||
expect(firstUser.id, equals(firstId));
|
||||
expect(secondUser.id, equals(secondId));
|
||||
});
|
||||
|
||||
test('updates a user', () async {
|
||||
var username = 'Arkjam89';
|
||||
var email = 'test@example.com';
|
||||
var user = makeUser(id: newId(), userName: username);
|
||||
|
||||
await userApi.createUser(user);
|
||||
user.email = email;
|
||||
await userApi.updateUser(username, user);
|
||||
var foundUser = await userApi.getUserByName(username);
|
||||
expect(foundUser.email, equals(email));
|
||||
});
|
||||
|
||||
test('deletes a user', () async {
|
||||
var username = 'Riddlem325';
|
||||
await userApi.createUser(makeUser(id: newId(), userName: username));
|
||||
await userApi.deleteUser(username);
|
||||
expect(userApi.getUserByName(username), throwsA(TypeMatcher<ApiException>()));
|
||||
});
|
||||
|
||||
test('logs a user in', () async {
|
||||
var username = 'sgarad625';
|
||||
var password = 'lokimoki1';
|
||||
var user = makeUser(id: newId(), userName: username, password: password);
|
||||
|
||||
await userApi.createUser(user);
|
||||
var result = await userApi.loginUser(username, password);
|
||||
expect(result, contains('logged in user session:'));
|
||||
});
|
||||
});
|
||||
}
|
@ -1,27 +1,17 @@
|
||||
# See https://www.dartlang.org/tools/private-files.html
|
||||
# See https://dart.dev/guides/libraries/private-files
|
||||
|
||||
# Files and directories created by pub
|
||||
.buildlog
|
||||
.dart_tool/
|
||||
.packages
|
||||
.project
|
||||
.pub/
|
||||
build/
|
||||
**/packages/
|
||||
pubspec.lock # Except for application 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
|
||||
# IntelliJ
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# Mac
|
||||
.DS_Store
|
||||
|
@ -6,7 +6,7 @@
|
||||
language: dart
|
||||
dart:
|
||||
# Install a specific stable release
|
||||
- "2.2.0"
|
||||
- "2.12"
|
||||
install:
|
||||
- pub get
|
||||
|
||||
|
@ -8,7 +8,7 @@ This Dart package is automatically generated by the [OpenAPI Generator](https://
|
||||
|
||||
## Requirements
|
||||
|
||||
Dart 2.0 or later
|
||||
Dart 2.12 or later
|
||||
|
||||
## Installation & Usage
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -12,7 +12,7 @@ part of openapi.api;
|
||||
|
||||
|
||||
class PetApi {
|
||||
PetApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
PetApi([ApiClient? apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
|
||||
final ApiClient apiClient;
|
||||
|
||||
@ -25,16 +25,11 @@ class PetApi {
|
||||
/// * [Pet] pet (required):
|
||||
/// Pet object that needs to be added to the store
|
||||
Future<Response> addPetWithHttpInfo(Pet pet,) async {
|
||||
// Verify required params are set.
|
||||
if (pet == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: pet');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/pet';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = pet;
|
||||
Object? postBody = pet;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -51,7 +46,7 @@ class PetApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -62,7 +57,7 @@ class PetApi {
|
||||
///
|
||||
/// * [Pet] pet (required):
|
||||
/// Pet object that needs to be added to the store
|
||||
Future<Pet> addPet(Pet pet,) async {
|
||||
Future<Pet?> addPet(Pet pet,) async {
|
||||
final response = await addPetWithHttpInfo(pet,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -70,11 +65,11 @@ class PetApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Pet',) as Pet;
|
||||
|
||||
}
|
||||
return Future<Pet>.value();
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Deletes a pet
|
||||
@ -87,18 +82,13 @@ class PetApi {
|
||||
/// Pet id to delete
|
||||
///
|
||||
/// * [String] apiKey:
|
||||
Future<Response> deletePetWithHttpInfo(int petId, { String apiKey, }) async {
|
||||
// Verify required params are set.
|
||||
if (petId == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
Future<Response> deletePetWithHttpInfo(int petId, { String? apiKey, }) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/pet/{petId}'
|
||||
.replaceAll('{petId}', petId.toString());
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -119,7 +109,7 @@ class PetApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -132,7 +122,7 @@ class PetApi {
|
||||
/// Pet id to delete
|
||||
///
|
||||
/// * [String] apiKey:
|
||||
Future<void> deletePet(int petId, { String apiKey, }) async {
|
||||
Future<void> deletePet(int petId, { String? apiKey, }) async {
|
||||
final response = await deletePetWithHttpInfo(petId, apiKey: apiKey, );
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -150,22 +140,17 @@ class PetApi {
|
||||
/// * [List<String>] status (required):
|
||||
/// Status values that need to be considered for filter
|
||||
Future<Response> findPetsByStatusWithHttpInfo(List<String> status,) async {
|
||||
// Verify required params are set.
|
||||
if (status == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: status');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/pet/findByStatus';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('csv', 'status', status));
|
||||
queryParams.addAll(_queryParams('csv', 'status', status));
|
||||
|
||||
const authNames = <String>['petstore_auth'];
|
||||
const contentTypes = <String>[];
|
||||
@ -178,7 +163,7 @@ class PetApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -191,7 +176,7 @@ class PetApi {
|
||||
///
|
||||
/// * [List<String>] status (required):
|
||||
/// Status values that need to be considered for filter
|
||||
Future<List<Pet>> findPetsByStatus(List<String> status,) async {
|
||||
Future<List<Pet>?> findPetsByStatus(List<String> status,) async {
|
||||
final response = await findPetsByStatusWithHttpInfo(status,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -199,14 +184,14 @@ class PetApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
final responseBody = await _decodeBodyBytes(response);
|
||||
return (await apiClient.deserializeAsync(responseBody, 'List<Pet>') as List)
|
||||
.cast<Pet>()
|
||||
.toList(growable: false);
|
||||
.toList();
|
||||
|
||||
}
|
||||
return Future<List<Pet>>.value();
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Finds Pets by tags
|
||||
@ -220,22 +205,17 @@ class PetApi {
|
||||
/// * [List<String>] tags (required):
|
||||
/// Tags to filter by
|
||||
Future<Response> findPetsByTagsWithHttpInfo(List<String> tags,) async {
|
||||
// Verify required params are set.
|
||||
if (tags == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: tags');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/pet/findByTags';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('csv', 'tags', tags));
|
||||
queryParams.addAll(_queryParams('csv', 'tags', tags));
|
||||
|
||||
const authNames = <String>['petstore_auth'];
|
||||
const contentTypes = <String>[];
|
||||
@ -248,7 +228,7 @@ class PetApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -261,7 +241,7 @@ class PetApi {
|
||||
///
|
||||
/// * [List<String>] tags (required):
|
||||
/// Tags to filter by
|
||||
Future<List<Pet>> findPetsByTags(List<String> tags,) async {
|
||||
Future<List<Pet>?> findPetsByTags(List<String> tags,) async {
|
||||
final response = await findPetsByTagsWithHttpInfo(tags,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -269,14 +249,14 @@ class PetApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
final responseBody = await _decodeBodyBytes(response);
|
||||
return (await apiClient.deserializeAsync(responseBody, 'List<Pet>') as List)
|
||||
.cast<Pet>()
|
||||
.toList(growable: false);
|
||||
.toList();
|
||||
|
||||
}
|
||||
return Future<List<Pet>>.value();
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Find pet by ID
|
||||
@ -290,17 +270,12 @@ class PetApi {
|
||||
/// * [int] petId (required):
|
||||
/// ID of pet to return
|
||||
Future<Response> getPetByIdWithHttpInfo(int petId,) async {
|
||||
// Verify required params are set.
|
||||
if (petId == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/pet/{petId}'
|
||||
.replaceAll('{petId}', petId.toString());
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -317,7 +292,7 @@ class PetApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -330,7 +305,7 @@ class PetApi {
|
||||
///
|
||||
/// * [int] petId (required):
|
||||
/// ID of pet to return
|
||||
Future<Pet> getPetById(int petId,) async {
|
||||
Future<Pet?> getPetById(int petId,) async {
|
||||
final response = await getPetByIdWithHttpInfo(petId,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -338,11 +313,11 @@ class PetApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Pet',) as Pet;
|
||||
|
||||
}
|
||||
return Future<Pet>.value();
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Update an existing pet
|
||||
@ -354,16 +329,11 @@ class PetApi {
|
||||
/// * [Pet] pet (required):
|
||||
/// Pet object that needs to be added to the store
|
||||
Future<Response> updatePetWithHttpInfo(Pet pet,) async {
|
||||
// Verify required params are set.
|
||||
if (pet == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: pet');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/pet';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = pet;
|
||||
Object? postBody = pet;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -380,7 +350,7 @@ class PetApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -391,7 +361,7 @@ class PetApi {
|
||||
///
|
||||
/// * [Pet] pet (required):
|
||||
/// Pet object that needs to be added to the store
|
||||
Future<Pet> updatePet(Pet pet,) async {
|
||||
Future<Pet?> updatePet(Pet pet,) async {
|
||||
final response = await updatePetWithHttpInfo(pet,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -399,11 +369,11 @@ class PetApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Pet',) as Pet;
|
||||
|
||||
}
|
||||
return Future<Pet>.value();
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Updates a pet in the store with form data
|
||||
@ -420,18 +390,13 @@ class PetApi {
|
||||
///
|
||||
/// * [String] status:
|
||||
/// Updated status of the pet
|
||||
Future<Response> updatePetWithFormWithHttpInfo(int petId, { String name, String status, }) async {
|
||||
// Verify required params are set.
|
||||
if (petId == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
Future<Response> updatePetWithFormWithHttpInfo(int petId, { String? name, String? status, }) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/pet/{petId}'
|
||||
.replaceAll('{petId}', petId.toString());
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -454,7 +419,7 @@ class PetApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -471,7 +436,7 @@ class PetApi {
|
||||
///
|
||||
/// * [String] status:
|
||||
/// Updated status of the pet
|
||||
Future<void> updatePetWithForm(int petId, { String name, String status, }) async {
|
||||
Future<void> updatePetWithForm(int petId, { String? name, String? status, }) async {
|
||||
final response = await updatePetWithFormWithHttpInfo(petId, name: name, status: status, );
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -492,18 +457,13 @@ class PetApi {
|
||||
///
|
||||
/// * [MultipartFile] file:
|
||||
/// file to upload
|
||||
Future<Response> uploadFileWithHttpInfo(int petId, { String additionalMetadata, MultipartFile file, }) async {
|
||||
// Verify required params are set.
|
||||
if (petId == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
Future<Response> uploadFileWithHttpInfo(int petId, { String? additionalMetadata, MultipartFile? file, }) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/pet/{petId}/uploadImage'
|
||||
.replaceAll('{petId}', petId.toString());
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -534,7 +494,7 @@ class PetApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -551,7 +511,7 @@ class PetApi {
|
||||
///
|
||||
/// * [MultipartFile] file:
|
||||
/// file to upload
|
||||
Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file, }) async {
|
||||
Future<ApiResponse?> uploadFile(int petId, { String? additionalMetadata, MultipartFile? file, }) async {
|
||||
final response = await uploadFileWithHttpInfo(petId, additionalMetadata: additionalMetadata, file: file, );
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -559,10 +519,10 @@ class PetApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ApiResponse',) as ApiResponse;
|
||||
|
||||
}
|
||||
return Future<ApiResponse>.value();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -12,7 +12,7 @@ part of openapi.api;
|
||||
|
||||
|
||||
class StoreApi {
|
||||
StoreApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
StoreApi([ApiClient? apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
|
||||
final ApiClient apiClient;
|
||||
|
||||
@ -27,17 +27,12 @@ class StoreApi {
|
||||
/// * [String] orderId (required):
|
||||
/// ID of the order that needs to be deleted
|
||||
Future<Response> deleteOrderWithHttpInfo(String orderId,) async {
|
||||
// Verify required params are set.
|
||||
if (orderId == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: orderId');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/store/order/{orderId}'
|
||||
.replaceAll('{orderId}', orderId);
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -54,7 +49,7 @@ class StoreApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -84,7 +79,7 @@ class StoreApi {
|
||||
final path = r'/store/inventory';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -101,7 +96,7 @@ class StoreApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -109,7 +104,7 @@ class StoreApi {
|
||||
/// Returns pet inventories by status
|
||||
///
|
||||
/// Returns a map of status codes to quantities
|
||||
Future<Map<String, int>> getInventory() async {
|
||||
Future<Map<String, int>?> getInventory() async {
|
||||
final response = await getInventoryWithHttpInfo();
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -117,11 +112,11 @@ class StoreApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return Map<String, int>.from(await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Map<String, int>'),);
|
||||
|
||||
}
|
||||
return Future<Map<String, int>>.value();
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Find purchase order by ID
|
||||
@ -135,17 +130,12 @@ class StoreApi {
|
||||
/// * [int] orderId (required):
|
||||
/// ID of pet that needs to be fetched
|
||||
Future<Response> getOrderByIdWithHttpInfo(int orderId,) async {
|
||||
// Verify required params are set.
|
||||
if (orderId == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: orderId');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/store/order/{orderId}'
|
||||
.replaceAll('{orderId}', orderId.toString());
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -162,7 +152,7 @@ class StoreApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -175,7 +165,7 @@ class StoreApi {
|
||||
///
|
||||
/// * [int] orderId (required):
|
||||
/// ID of pet that needs to be fetched
|
||||
Future<Order> getOrderById(int orderId,) async {
|
||||
Future<Order?> getOrderById(int orderId,) async {
|
||||
final response = await getOrderByIdWithHttpInfo(orderId,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -183,11 +173,11 @@ class StoreApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Order',) as Order;
|
||||
|
||||
}
|
||||
return Future<Order>.value();
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Place an order for a pet
|
||||
@ -199,16 +189,11 @@ class StoreApi {
|
||||
/// * [Order] order (required):
|
||||
/// order placed for purchasing the pet
|
||||
Future<Response> placeOrderWithHttpInfo(Order order,) async {
|
||||
// Verify required params are set.
|
||||
if (order == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: order');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/store/order';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = order;
|
||||
Object? postBody = order;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -225,7 +210,7 @@ class StoreApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -236,7 +221,7 @@ class StoreApi {
|
||||
///
|
||||
/// * [Order] order (required):
|
||||
/// order placed for purchasing the pet
|
||||
Future<Order> placeOrder(Order order,) async {
|
||||
Future<Order?> placeOrder(Order order,) async {
|
||||
final response = await placeOrderWithHttpInfo(order,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -244,10 +229,10 @@ class StoreApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Order',) as Order;
|
||||
|
||||
}
|
||||
return Future<Order>.value();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -12,7 +12,7 @@ part of openapi.api;
|
||||
|
||||
|
||||
class UserApi {
|
||||
UserApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
UserApi([ApiClient? apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
|
||||
final ApiClient apiClient;
|
||||
|
||||
@ -27,16 +27,11 @@ class UserApi {
|
||||
/// * [User] user (required):
|
||||
/// Created user object
|
||||
Future<Response> createUserWithHttpInfo(User user,) async {
|
||||
// Verify required params are set.
|
||||
if (user == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/user';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = user;
|
||||
Object? postBody = user;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -53,7 +48,7 @@ class UserApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -82,16 +77,11 @@ class UserApi {
|
||||
/// * [List<User>] user (required):
|
||||
/// List of user object
|
||||
Future<Response> createUsersWithArrayInputWithHttpInfo(List<User> user,) async {
|
||||
// Verify required params are set.
|
||||
if (user == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/user/createWithArray';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = user;
|
||||
Object? postBody = user;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -108,7 +98,7 @@ class UserApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -135,16 +125,11 @@ class UserApi {
|
||||
/// * [List<User>] user (required):
|
||||
/// List of user object
|
||||
Future<Response> createUsersWithListInputWithHttpInfo(List<User> user,) async {
|
||||
// Verify required params are set.
|
||||
if (user == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/user/createWithList';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = user;
|
||||
Object? postBody = user;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -161,7 +146,7 @@ class UserApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -190,17 +175,12 @@ class UserApi {
|
||||
/// * [String] username (required):
|
||||
/// The name that needs to be deleted
|
||||
Future<Response> deleteUserWithHttpInfo(String username,) async {
|
||||
// Verify required params are set.
|
||||
if (username == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: username');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/user/{username}'
|
||||
.replaceAll('{username}', username);
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -217,7 +197,7 @@ class UserApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -246,17 +226,12 @@ class UserApi {
|
||||
/// * [String] username (required):
|
||||
/// The name that needs to be fetched. Use user1 for testing.
|
||||
Future<Response> getUserByNameWithHttpInfo(String username,) async {
|
||||
// Verify required params are set.
|
||||
if (username == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: username');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/user/{username}'
|
||||
.replaceAll('{username}', username);
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -273,7 +248,7 @@ class UserApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -284,7 +259,7 @@ class UserApi {
|
||||
///
|
||||
/// * [String] username (required):
|
||||
/// The name that needs to be fetched. Use user1 for testing.
|
||||
Future<User> getUserByName(String username,) async {
|
||||
Future<User?> getUserByName(String username,) async {
|
||||
final response = await getUserByNameWithHttpInfo(username,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -292,11 +267,11 @@ class UserApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'User',) as User;
|
||||
|
||||
}
|
||||
return Future<User>.value();
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Logs user into the system
|
||||
@ -311,26 +286,18 @@ class UserApi {
|
||||
/// * [String] password (required):
|
||||
/// The password for login in clear text
|
||||
Future<Response> loginUserWithHttpInfo(String username, String password,) async {
|
||||
// Verify required params are set.
|
||||
if (username == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: username');
|
||||
}
|
||||
if (password == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: password');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/user/login';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('', 'username', username));
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('', 'password', password));
|
||||
queryParams.addAll(_queryParams('', 'username', username));
|
||||
queryParams.addAll(_queryParams('', 'password', password));
|
||||
|
||||
const authNames = <String>[];
|
||||
const contentTypes = <String>[];
|
||||
@ -343,7 +310,7 @@ class UserApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -357,7 +324,7 @@ class UserApi {
|
||||
///
|
||||
/// * [String] password (required):
|
||||
/// The password for login in clear text
|
||||
Future<String> loginUser(String username, String password,) async {
|
||||
Future<String?> loginUser(String username, String password,) async {
|
||||
final response = await loginUserWithHttpInfo(username, password,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -365,11 +332,11 @@ class UserApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'String',) as String;
|
||||
|
||||
}
|
||||
return Future<String>.value();
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Logs out current logged in user session
|
||||
@ -380,7 +347,7 @@ class UserApi {
|
||||
final path = r'/user/logout';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -397,7 +364,7 @@ class UserApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -424,20 +391,12 @@ class UserApi {
|
||||
/// * [User] user (required):
|
||||
/// Updated user object
|
||||
Future<Response> updateUserWithHttpInfo(String username, User user,) async {
|
||||
// Verify required params are set.
|
||||
if (username == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: username');
|
||||
}
|
||||
if (user == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/user/{username}'
|
||||
.replaceAll('{username}', username);
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = user;
|
||||
Object? postBody = user;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -454,7 +413,7 @@ class UserApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -27,12 +27,7 @@ class ApiClient {
|
||||
Client get client => _client;
|
||||
|
||||
/// Requests to use a new HTTP [Client] in this class.
|
||||
///
|
||||
/// If the [newClient] is null, an [ArgumentError] is thrown.
|
||||
set client(Client newClient) {
|
||||
if (newClient == null) {
|
||||
throw ArgumentError('New client instance cannot be null.');
|
||||
}
|
||||
_client = newClient;
|
||||
}
|
||||
|
||||
@ -49,7 +44,7 @@ class ApiClient {
|
||||
/// or deleted.
|
||||
Map<String, Authentication> get authentications => Map.unmodifiable(_authentications);
|
||||
|
||||
T getAuthentication<T extends Authentication>(String name) {
|
||||
T? getAuthentication<T extends Authentication>(String name) {
|
||||
final authentication = _authentications[name];
|
||||
return authentication is T ? authentication : null;
|
||||
}
|
||||
@ -60,35 +55,28 @@ class ApiClient {
|
||||
String path,
|
||||
String method,
|
||||
List<QueryParam> queryParams,
|
||||
Object body,
|
||||
Object? body,
|
||||
Map<String, String> headerParams,
|
||||
Map<String, String> formParams,
|
||||
String nullableContentType,
|
||||
String? contentType,
|
||||
List<String> authNames,
|
||||
) async {
|
||||
_updateParamsForAuth(authNames, queryParams, headerParams);
|
||||
|
||||
headerParams.addAll(_defaultHeaderMap);
|
||||
|
||||
final urlEncodedQueryParams = queryParams
|
||||
.where((param) => param.value != null)
|
||||
.map((param) => '$param');
|
||||
|
||||
final queryString = urlEncodedQueryParams.isNotEmpty
|
||||
? '?${urlEncodedQueryParams.join('&')}'
|
||||
: '';
|
||||
|
||||
final uri = Uri.parse('$basePath$path$queryString');
|
||||
|
||||
if (nullableContentType != null) {
|
||||
headerParams['Content-Type'] = nullableContentType;
|
||||
if (contentType != null) {
|
||||
headerParams['Content-Type'] = contentType;
|
||||
}
|
||||
|
||||
final urlEncodedQueryParams = queryParams.map((param) => '$param');
|
||||
final queryString = urlEncodedQueryParams.isNotEmpty ? '?${urlEncodedQueryParams.join('&')}' : '';
|
||||
final uri = Uri.parse('$basePath$path$queryString');
|
||||
|
||||
try {
|
||||
// Special case for uploading a single file which isn't a 'multipart/form-data'.
|
||||
if (
|
||||
body is MultipartFile && (nullableContentType == null ||
|
||||
!nullableContentType.toLowerCase().startsWith('multipart/form-data'))
|
||||
body is MultipartFile && (contentType == null ||
|
||||
!contentType.toLowerCase().startsWith('multipart/form-data'))
|
||||
) {
|
||||
final request = StreamedRequest(method, uri);
|
||||
request.headers.addAll(headerParams);
|
||||
@ -114,7 +102,7 @@ class ApiClient {
|
||||
return Response.fromStream(response);
|
||||
}
|
||||
|
||||
final msgBody = nullableContentType == 'application/x-www-form-urlencoded'
|
||||
final msgBody = contentType == 'application/x-www-form-urlencoded'
|
||||
? formParams
|
||||
: await serializeAsync(body);
|
||||
final nullableHeaderParams = headerParams.isEmpty ? null : headerParams;
|
||||
@ -127,41 +115,69 @@ class ApiClient {
|
||||
case 'HEAD': return await _client.head(uri, headers: nullableHeaderParams,);
|
||||
case 'GET': return await _client.get(uri, headers: nullableHeaderParams,);
|
||||
}
|
||||
} on SocketException catch (e, trace) {
|
||||
throw ApiException.withInner(HttpStatus.badRequest, 'Socket operation failed: $method $path', e, trace,);
|
||||
} on TlsException catch (e, trace) {
|
||||
throw ApiException.withInner(HttpStatus.badRequest, 'TLS/SSL communication failed: $method $path', e, trace,);
|
||||
} on IOException catch (e, trace) {
|
||||
throw ApiException.withInner(HttpStatus.badRequest, 'I/O operation failed: $method $path', e, trace,);
|
||||
} on ClientException catch (e, trace) {
|
||||
throw ApiException.withInner(HttpStatus.badRequest, 'HTTP connection failed: $method $path', e, trace,);
|
||||
} on Exception catch (e, trace) {
|
||||
throw ApiException.withInner(HttpStatus.badRequest, 'Exception occurred: $method $path', e, trace,);
|
||||
} on SocketException catch (error, trace) {
|
||||
throw ApiException.withInner(
|
||||
HttpStatus.badRequest,
|
||||
'Socket operation failed: $method $path',
|
||||
error,
|
||||
trace,
|
||||
);
|
||||
} on TlsException catch (error, trace) {
|
||||
throw ApiException.withInner(
|
||||
HttpStatus.badRequest,
|
||||
'TLS/SSL communication failed: $method $path',
|
||||
error,
|
||||
trace,
|
||||
);
|
||||
} on IOException catch (error, trace) {
|
||||
throw ApiException.withInner(
|
||||
HttpStatus.badRequest,
|
||||
'I/O operation failed: $method $path',
|
||||
error,
|
||||
trace,
|
||||
);
|
||||
} on ClientException catch (error, trace) {
|
||||
throw ApiException.withInner(
|
||||
HttpStatus.badRequest,
|
||||
'HTTP connection failed: $method $path',
|
||||
error,
|
||||
trace,
|
||||
);
|
||||
} on Exception catch (error, trace) {
|
||||
throw ApiException.withInner(
|
||||
HttpStatus.badRequest,
|
||||
'Exception occurred: $method $path',
|
||||
error,
|
||||
trace,
|
||||
);
|
||||
}
|
||||
|
||||
throw ApiException(HttpStatus.badRequest, 'Invalid HTTP operation: $method $path',);
|
||||
throw ApiException(
|
||||
HttpStatus.badRequest,
|
||||
'Invalid HTTP operation: $method $path',
|
||||
);
|
||||
}
|
||||
|
||||
Future<dynamic> deserializeAsync(String json, String targetType, {bool growable}) async =>
|
||||
Future<dynamic> deserializeAsync(String json, String targetType, {bool growable = false,}) async =>
|
||||
// ignore: deprecated_member_use_from_same_package
|
||||
deserialize(json, targetType, growable: growable);
|
||||
|
||||
@Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use deserializeAsync() instead.')
|
||||
dynamic deserialize(String json, String targetType, {bool growable}) {
|
||||
dynamic deserialize(String json, String targetType, {bool growable = false,}) {
|
||||
// Remove all spaces. Necessary for regular expressions as well.
|
||||
targetType = targetType.replaceAll(' ', ''); // ignore: parameter_assignments
|
||||
|
||||
// If the expected target type is String, nothing to do...
|
||||
return targetType == 'String'
|
||||
? json
|
||||
: _deserialize(jsonDecode(json), targetType, growable: growable == true);
|
||||
: _deserialize(jsonDecode(json), targetType, growable: growable);
|
||||
}
|
||||
|
||||
// ignore: deprecated_member_use_from_same_package
|
||||
Future<String> serializeAsync(Object value) async => serialize(value);
|
||||
Future<String> serializeAsync(Object? value) async => serialize(value);
|
||||
|
||||
@Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use serializeAsync() instead.')
|
||||
String serialize(Object value) => value == null ? '' : json.encode(value);
|
||||
String serialize(Object? value) => value == null ? '' : json.encode(value);
|
||||
|
||||
/// Update query and header parameters based on authentication settings.
|
||||
/// @param authNames The authentications to apply
|
||||
@ -179,7 +195,7 @@ class ApiClient {
|
||||
}
|
||||
}
|
||||
|
||||
static dynamic _deserialize(dynamic value, String targetType, {bool growable}) {
|
||||
static dynamic _deserialize(dynamic value, String targetType, {bool growable = false}) {
|
||||
try {
|
||||
switch (targetType) {
|
||||
case 'String':
|
||||
@ -207,24 +223,21 @@ class ApiClient {
|
||||
case 'User':
|
||||
return User.fromJson(value);
|
||||
default:
|
||||
Match match;
|
||||
if (value is List && (match = _regList.firstMatch(targetType)) != null) {
|
||||
targetType = match[1]; // ignore: parameter_assignments
|
||||
dynamic match;
|
||||
if (value is List && (match = _regList.firstMatch(targetType)?.group(1)) != null) {
|
||||
return value
|
||||
.map<dynamic>((dynamic v) => _deserialize(v, targetType, growable: growable))
|
||||
.map<dynamic>((dynamic v) => _deserialize(v, match, growable: growable,))
|
||||
.toList(growable: growable);
|
||||
}
|
||||
if (value is Set && (match = _regSet.firstMatch(targetType)) != null) {
|
||||
targetType = match[1]; // ignore: parameter_assignments
|
||||
if (value is Set && (match = _regSet.firstMatch(targetType)?.group(1)) != null) {
|
||||
return value
|
||||
.map<dynamic>((dynamic v) => _deserialize(v, targetType, growable: growable))
|
||||
.map<dynamic>((dynamic v) => _deserialize(v, match, growable: growable,))
|
||||
.toSet();
|
||||
}
|
||||
if (value is Map && (match = _regMap.firstMatch(targetType)) != null) {
|
||||
targetType = match[1]; // ignore: parameter_assignments
|
||||
if (value is Map && (match = _regMap.firstMatch(targetType)?.group(1)) != null) {
|
||||
return Map<String, dynamic>.fromIterables(
|
||||
value.keys.cast<String>(),
|
||||
value.values.map<dynamic>((dynamic v) => _deserialize(v, targetType, growable: growable)),
|
||||
value.values.map<dynamic>((dynamic v) => _deserialize(v, match, growable: growable,)),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -238,9 +251,9 @@ class ApiClient {
|
||||
/// Primarily intended for use in an isolate.
|
||||
class DeserializationMessage {
|
||||
const DeserializationMessage({
|
||||
@required this.json,
|
||||
@required this.targetType,
|
||||
this.growable,
|
||||
required this.json,
|
||||
required this.targetType,
|
||||
this.growable = false,
|
||||
});
|
||||
|
||||
/// The JSON value to deserialize.
|
||||
@ -264,9 +277,9 @@ Future<dynamic> deserializeAsync(DeserializationMessage message) async {
|
||||
: ApiClient._deserialize(
|
||||
jsonDecode(message.json),
|
||||
targetType,
|
||||
growable: message.growable == true,
|
||||
growable: message.growable,
|
||||
);
|
||||
}
|
||||
|
||||
/// Primarily intended for use in an isolate.
|
||||
Future<String> serializeAsync(Object value) async => value == null ? '' : json.encode(value);
|
||||
Future<String> serializeAsync(Object? value) async => value == null ? '' : json.encode(value);
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -16,9 +16,9 @@ class ApiException implements Exception {
|
||||
ApiException.withInner(this.code, this.message, this.innerException, this.stackTrace);
|
||||
|
||||
int code = 0;
|
||||
String message;
|
||||
Exception innerException;
|
||||
StackTrace stackTrace;
|
||||
String? message;
|
||||
Exception? innerException;
|
||||
StackTrace? stackTrace;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -21,32 +21,27 @@ class QueryParam {
|
||||
}
|
||||
|
||||
// Ported from the Java version.
|
||||
Iterable<QueryParam> _convertParametersForCollectionFormat(
|
||||
String collectionFormat,
|
||||
String name,
|
||||
dynamic value,
|
||||
) {
|
||||
Iterable<QueryParam> _queryParams(String collectionFormat, String name, dynamic value,) {
|
||||
// Assertions to run in debug mode only.
|
||||
assert(name.isNotEmpty, 'Parameter cannot be an empty string.');
|
||||
|
||||
final params = <QueryParam>[];
|
||||
|
||||
// preconditions
|
||||
if (name != null && name.isNotEmpty && value != null) {
|
||||
if (value is List) {
|
||||
if (collectionFormat == 'multi') {
|
||||
return value.map((dynamic v) => QueryParam(name, parameterToString(v)),);
|
||||
}
|
||||
|
||||
// Default collection format is 'csv'.
|
||||
if (collectionFormat == null || collectionFormat.isEmpty) {
|
||||
// ignore: parameter_assignments
|
||||
collectionFormat = 'csv';
|
||||
if (collectionFormat.isEmpty) {
|
||||
collectionFormat = 'csv'; // ignore: parameter_assignments
|
||||
}
|
||||
|
||||
final delimiter = _delimiters[collectionFormat] ?? ',';
|
||||
|
||||
params.add(QueryParam(name, value.map<dynamic>(parameterToString).join(delimiter)),);
|
||||
} else {
|
||||
params.add(QueryParam(name, parameterToString(value),));
|
||||
}
|
||||
params.add(QueryParam(name, value.map<dynamic>(parameterToString).join(delimiter),));
|
||||
} else if (value != null) {
|
||||
params.add(QueryParam(name, parameterToString(value)));
|
||||
}
|
||||
|
||||
return params;
|
||||
@ -68,27 +63,27 @@ String parameterToString(dynamic value) {
|
||||
Future<String> _decodeBodyBytes(Response response) async {
|
||||
final contentType = response.headers['content-type'];
|
||||
return contentType != null && contentType.toLowerCase().startsWith('application/json')
|
||||
? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes)
|
||||
? response.bodyBytes.isEmpty ? '' : utf8.decode(response.bodyBytes)
|
||||
: response.body;
|
||||
}
|
||||
|
||||
/// Returns a valid [T] value found at the specified Map [key], null otherwise.
|
||||
T mapValueOfType<T>(dynamic map, String key) {
|
||||
T? mapValueOfType<T>(dynamic map, String key) {
|
||||
final dynamic value = map is Map ? map[key] : null;
|
||||
return value is T ? value : null;
|
||||
}
|
||||
|
||||
/// Returns a valid Map<K, V> found at the specified Map [key], null otherwise.
|
||||
Map<K, V> mapCastOfType<K, V>(dynamic map, String key) {
|
||||
Map<K, V>? mapCastOfType<K, V>(dynamic map, String key) {
|
||||
final dynamic value = map is Map ? map[key] : null;
|
||||
return value is Map ? value.cast<K, V>() : null;
|
||||
}
|
||||
|
||||
/// Returns a valid [DateTime] found at the specified Map [key], null otherwise.
|
||||
DateTime mapDateTime(dynamic map, String key, [String pattern]) {
|
||||
DateTime? mapDateTime(dynamic map, String key, [String? pattern]) {
|
||||
final dynamic value = map is Map ? map[key] : null;
|
||||
if (value != null) {
|
||||
int millis;
|
||||
int? millis;
|
||||
if (value is int) {
|
||||
millis = value;
|
||||
} else if (value is String) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -16,23 +16,25 @@ class ApiKeyAuth implements Authentication {
|
||||
final String location;
|
||||
final String paramName;
|
||||
|
||||
String apiKeyPrefix;
|
||||
String apiKey;
|
||||
String apiKeyPrefix = '';
|
||||
String apiKey = '';
|
||||
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
final value = apiKeyPrefix == null ? apiKey : '$apiKeyPrefix $apiKey';
|
||||
final paramValue = apiKeyPrefix.isEmpty ? apiKey : '$apiKeyPrefix $apiKey';
|
||||
|
||||
if (location == 'query' && value != null) {
|
||||
queryParams.add(QueryParam(paramName, value));
|
||||
} else if (location == 'header' && value != null) {
|
||||
headerParams[paramName] = value;
|
||||
} else if (location == 'cookie' && value != null) {
|
||||
if (paramValue.isNotEmpty) {
|
||||
if (location == 'query') {
|
||||
queryParams.add(QueryParam(paramName, paramValue));
|
||||
} else if (location == 'header') {
|
||||
headerParams[paramName] = paramValue;
|
||||
} else if (location == 'cookie') {
|
||||
headerParams.update(
|
||||
'Cookie',
|
||||
(existingCookie) => '$existingCookie; $paramName=$value',
|
||||
ifAbsent: () => '$paramName=$value',
|
||||
(existingCookie) => '$existingCookie; $paramName=$paramValue',
|
||||
ifAbsent: () => '$paramName=$paramValue',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -11,12 +11,16 @@
|
||||
part of openapi.api;
|
||||
|
||||
class HttpBasicAuth implements Authentication {
|
||||
HttpBasicAuth({this.username = '', this.password = ''});
|
||||
|
||||
String username;
|
||||
String password;
|
||||
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
final credentials = '${username ?? ''}:${password ?? ''}';
|
||||
if (username.isNotEmpty && password.isNotEmpty) {
|
||||
final credentials = '$username:$password';
|
||||
headerParams['Authorization'] = 'Basic ${base64.encode(utf8.encode(credentials))}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -21,19 +21,29 @@ class HttpBearerAuth implements Authentication {
|
||||
|
||||
set accessToken(dynamic accessToken) {
|
||||
if (accessToken is! String && accessToken is! HttpBearerAuthProvider) {
|
||||
throw ArgumentError('Type of Bearer accessToken should be a String or a String Function().');
|
||||
throw ArgumentError('accessToken value must be either a String or a String Function().');
|
||||
}
|
||||
_accessToken = accessToken;
|
||||
}
|
||||
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
if (_accessToken == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String accessToken;
|
||||
|
||||
if (_accessToken is String) {
|
||||
headerParams['Authorization'] = 'Bearer $_accessToken';
|
||||
accessToken = _accessToken;
|
||||
} else if (_accessToken is HttpBearerAuthProvider) {
|
||||
headerParams['Authorization'] = 'Bearer ${_accessToken()}';
|
||||
accessToken = _accessToken!();
|
||||
} else {
|
||||
throw ArgumentError('Type of Bearer accessToken should be a String or a String Function().');
|
||||
return;
|
||||
}
|
||||
|
||||
if (accessToken.isNotEmpty) {
|
||||
headerParams['Authorization'] = 'Bearer $accessToken';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -11,13 +11,13 @@
|
||||
part of openapi.api;
|
||||
|
||||
class OAuth implements Authentication {
|
||||
OAuth({this.accessToken});
|
||||
OAuth({this.accessToken = ''});
|
||||
|
||||
String accessToken;
|
||||
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
if (accessToken != null) {
|
||||
if (accessToken.isNotEmpty) {
|
||||
headerParams['Authorization'] = 'Bearer $accessToken';
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -18,11 +18,29 @@ class ApiResponse {
|
||||
this.message,
|
||||
});
|
||||
|
||||
int code;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
int? code;
|
||||
|
||||
String type;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
String? type;
|
||||
|
||||
String message;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
String? message;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is ApiResponse &&
|
||||
@ -33,9 +51,9 @@ class ApiResponse {
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(code == null ? 0 : code.hashCode) +
|
||||
(type == null ? 0 : type.hashCode) +
|
||||
(message == null ? 0 : message.hashCode);
|
||||
(code == null ? 0 : code!.hashCode) +
|
||||
(type == null ? 0 : type!.hashCode) +
|
||||
(message == null ? 0 : message!.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'ApiResponse[code=$code, type=$type, message=$message]';
|
||||
@ -57,9 +75,21 @@ class ApiResponse {
|
||||
/// Returns a new [ApiResponse] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static ApiResponse fromJson(dynamic value) {
|
||||
static ApiResponse? fromJson(dynamic value) {
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
// Ensure that the map contains the required keys.
|
||||
// Note 1: the values aren't checked for validity beyond being non-null.
|
||||
// Note 2: this code is stripped in release mode!
|
||||
assert(() {
|
||||
requiredKeys.forEach((key) {
|
||||
assert(json.containsKey(key), 'Required key "ApiResponse[$key]" is missing from JSON.');
|
||||
assert(json[key] != null, 'Required key "ApiResponse[$key]" has a null value in JSON.');
|
||||
});
|
||||
return true;
|
||||
}());
|
||||
|
||||
return ApiResponse(
|
||||
code: mapValueOfType<int>(json, r'code'),
|
||||
type: mapValueOfType<String>(json, r'type'),
|
||||
@ -69,36 +99,50 @@ class ApiResponse {
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<ApiResponse> listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) =>
|
||||
json is List && json.isNotEmpty
|
||||
? json.map(ApiResponse.fromJson).toList(growable: true == growable)
|
||||
: true == emptyIsNull ? null : <ApiResponse>[];
|
||||
static List<ApiResponse>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <ApiResponse>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = ApiResponse.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, ApiResponse> mapFromJson(dynamic json) {
|
||||
final map = <String, ApiResponse>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) => map[key] = ApiResponse.fromJson(value));
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = ApiResponse.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of ApiResponse-objects as value to a dart map
|
||||
static Map<String, List<ApiResponse>> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) {
|
||||
static Map<String, List<ApiResponse>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<ApiResponse>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) {
|
||||
map[key] = ApiResponse.listFromJson(
|
||||
value,
|
||||
emptyIsNull: emptyIsNull,
|
||||
growable: growable,
|
||||
);
|
||||
});
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = ApiResponse.listFromJson(entry.value, growable: growable,);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -17,9 +17,21 @@ class Category {
|
||||
this.name,
|
||||
});
|
||||
|
||||
int id;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
int? id;
|
||||
|
||||
String name;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
String? name;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is Category &&
|
||||
@ -29,8 +41,8 @@ class Category {
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(id == null ? 0 : id.hashCode) +
|
||||
(name == null ? 0 : name.hashCode);
|
||||
(id == null ? 0 : id!.hashCode) +
|
||||
(name == null ? 0 : name!.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'Category[id=$id, name=$name]';
|
||||
@ -49,9 +61,21 @@ class Category {
|
||||
/// Returns a new [Category] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static Category fromJson(dynamic value) {
|
||||
static Category? fromJson(dynamic value) {
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
// Ensure that the map contains the required keys.
|
||||
// Note 1: the values aren't checked for validity beyond being non-null.
|
||||
// Note 2: this code is stripped in release mode!
|
||||
assert(() {
|
||||
requiredKeys.forEach((key) {
|
||||
assert(json.containsKey(key), 'Required key "Category[$key]" is missing from JSON.');
|
||||
assert(json[key] != null, 'Required key "Category[$key]" has a null value in JSON.');
|
||||
});
|
||||
return true;
|
||||
}());
|
||||
|
||||
return Category(
|
||||
id: mapValueOfType<int>(json, r'id'),
|
||||
name: mapValueOfType<String>(json, r'name'),
|
||||
@ -60,36 +84,50 @@ class Category {
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<Category> listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) =>
|
||||
json is List && json.isNotEmpty
|
||||
? json.map(Category.fromJson).toList(growable: true == growable)
|
||||
: true == emptyIsNull ? null : <Category>[];
|
||||
static List<Category>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <Category>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = Category.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, Category> mapFromJson(dynamic json) {
|
||||
final map = <String, Category>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) => map[key] = Category.fromJson(value));
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = Category.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of Category-objects as value to a dart map
|
||||
static Map<String, List<Category>> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) {
|
||||
static Map<String, List<Category>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<Category>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) {
|
||||
map[key] = Category.listFromJson(
|
||||
value,
|
||||
emptyIsNull: emptyIsNull,
|
||||
growable: growable,
|
||||
);
|
||||
});
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = Category.listFromJson(entry.value, growable: growable,);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -21,16 +21,40 @@ class Order {
|
||||
this.complete = false,
|
||||
});
|
||||
|
||||
int id;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
int? id;
|
||||
|
||||
int petId;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
int? petId;
|
||||
|
||||
int quantity;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
int? quantity;
|
||||
|
||||
DateTime shipDate;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
DateTime? shipDate;
|
||||
|
||||
/// Order Status
|
||||
OrderStatusEnum status;
|
||||
OrderStatusEnum? status;
|
||||
|
||||
bool complete;
|
||||
|
||||
@ -46,12 +70,12 @@ class Order {
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(id == null ? 0 : id.hashCode) +
|
||||
(petId == null ? 0 : petId.hashCode) +
|
||||
(quantity == null ? 0 : quantity.hashCode) +
|
||||
(shipDate == null ? 0 : shipDate.hashCode) +
|
||||
(status == null ? 0 : status.hashCode) +
|
||||
(complete == null ? 0 : complete.hashCode);
|
||||
(id == null ? 0 : id!.hashCode) +
|
||||
(petId == null ? 0 : petId!.hashCode) +
|
||||
(quantity == null ? 0 : quantity!.hashCode) +
|
||||
(shipDate == null ? 0 : shipDate!.hashCode) +
|
||||
(status == null ? 0 : status!.hashCode) +
|
||||
(complete.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'Order[id=$id, petId=$petId, quantity=$quantity, shipDate=$shipDate, status=$status, complete=$complete]';
|
||||
@ -68,66 +92,90 @@ class Order {
|
||||
json[r'quantity'] = quantity;
|
||||
}
|
||||
if (shipDate != null) {
|
||||
json[r'shipDate'] = shipDate.toUtc().toIso8601String();
|
||||
json[r'shipDate'] = shipDate!.toUtc().toIso8601String();
|
||||
}
|
||||
if (status != null) {
|
||||
json[r'status'] = status;
|
||||
}
|
||||
if (complete != null) {
|
||||
json[r'complete'] = complete;
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
/// Returns a new [Order] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static Order fromJson(dynamic value) {
|
||||
static Order? fromJson(dynamic value) {
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
// Ensure that the map contains the required keys.
|
||||
// Note 1: the values aren't checked for validity beyond being non-null.
|
||||
// Note 2: this code is stripped in release mode!
|
||||
assert(() {
|
||||
requiredKeys.forEach((key) {
|
||||
assert(json.containsKey(key), 'Required key "Order[$key]" is missing from JSON.');
|
||||
assert(json[key] != null, 'Required key "Order[$key]" has a null value in JSON.');
|
||||
});
|
||||
return true;
|
||||
}());
|
||||
|
||||
return Order(
|
||||
id: mapValueOfType<int>(json, r'id'),
|
||||
petId: mapValueOfType<int>(json, r'petId'),
|
||||
quantity: mapValueOfType<int>(json, r'quantity'),
|
||||
shipDate: mapDateTime(json, r'shipDate', ''),
|
||||
status: OrderStatusEnum.fromJson(json[r'status']),
|
||||
complete: mapValueOfType<bool>(json, r'complete'),
|
||||
complete: mapValueOfType<bool>(json, r'complete') ?? false,
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<Order> listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) =>
|
||||
json is List && json.isNotEmpty
|
||||
? json.map(Order.fromJson).toList(growable: true == growable)
|
||||
: true == emptyIsNull ? null : <Order>[];
|
||||
static List<Order>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <Order>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = Order.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, Order> mapFromJson(dynamic json) {
|
||||
final map = <String, Order>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) => map[key] = Order.fromJson(value));
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = Order.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of Order-objects as value to a dart map
|
||||
static Map<String, List<Order>> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) {
|
||||
static Map<String, List<Order>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<Order>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) {
|
||||
map[key] = Order.listFromJson(
|
||||
value,
|
||||
emptyIsNull: emptyIsNull,
|
||||
growable: growable,
|
||||
);
|
||||
});
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = Order.listFromJson(entry.value, growable: growable,);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
};
|
||||
}
|
||||
|
||||
/// Order Status
|
||||
@ -139,7 +187,7 @@ class OrderStatusEnum {
|
||||
final String value;
|
||||
|
||||
@override
|
||||
String toString() => value ?? '';
|
||||
String toString() => value;
|
||||
|
||||
String toJson() => value;
|
||||
|
||||
@ -154,13 +202,20 @@ class OrderStatusEnum {
|
||||
delivered,
|
||||
];
|
||||
|
||||
static OrderStatusEnum fromJson(dynamic value) =>
|
||||
OrderStatusEnumTypeTransformer().decode(value);
|
||||
static OrderStatusEnum? fromJson(dynamic value) => OrderStatusEnumTypeTransformer().decode(value);
|
||||
|
||||
static List<OrderStatusEnum> listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) =>
|
||||
json is List && json.isNotEmpty
|
||||
? json.map(OrderStatusEnum.fromJson).toList(growable: true == growable)
|
||||
: true == emptyIsNull ? null : <OrderStatusEnum>[];
|
||||
static List<OrderStatusEnum>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <OrderStatusEnum>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = OrderStatusEnum.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
}
|
||||
|
||||
/// Transformation class that can [encode] an instance of [OrderStatusEnum] to String,
|
||||
@ -180,14 +235,14 @@ class OrderStatusEnumTypeTransformer {
|
||||
///
|
||||
/// The [allowNull] is very handy when an API changes and a new enum value is added or removed,
|
||||
/// and users are still using an old app with the old code.
|
||||
OrderStatusEnum decode(dynamic data, {bool allowNull}) {
|
||||
OrderStatusEnum? decode(dynamic data, {bool allowNull = true}) {
|
||||
if (data != null) {
|
||||
switch (data.toString()) {
|
||||
case r'placed': return OrderStatusEnum.placed;
|
||||
case r'approved': return OrderStatusEnum.approved;
|
||||
case r'delivered': return OrderStatusEnum.delivered;
|
||||
default:
|
||||
if (allowNull == false) {
|
||||
if (!allowNull) {
|
||||
throw ArgumentError('Unknown enum value to decode: $data');
|
||||
}
|
||||
}
|
||||
@ -196,7 +251,7 @@ class OrderStatusEnumTypeTransformer {
|
||||
}
|
||||
|
||||
/// Singleton [OrderStatusEnumTypeTransformer] instance.
|
||||
static OrderStatusEnumTypeTransformer _instance;
|
||||
static OrderStatusEnumTypeTransformer? _instance;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -15,15 +15,27 @@ class Pet {
|
||||
Pet({
|
||||
this.id,
|
||||
this.category,
|
||||
@required this.name,
|
||||
required this.name,
|
||||
this.photoUrls = const [],
|
||||
this.tags = const [],
|
||||
this.status,
|
||||
});
|
||||
|
||||
int id;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
int? id;
|
||||
|
||||
Category category;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
Category? category;
|
||||
|
||||
String name;
|
||||
|
||||
@ -32,7 +44,7 @@ class Pet {
|
||||
List<Tag> tags;
|
||||
|
||||
/// pet status in the store
|
||||
PetStatusEnum status;
|
||||
PetStatusEnum? status;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is Pet &&
|
||||
@ -46,12 +58,12 @@ class Pet {
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(id == null ? 0 : id.hashCode) +
|
||||
(category == null ? 0 : category.hashCode) +
|
||||
(name == null ? 0 : name.hashCode) +
|
||||
(photoUrls == null ? 0 : photoUrls.hashCode) +
|
||||
(tags == null ? 0 : tags.hashCode) +
|
||||
(status == null ? 0 : status.hashCode);
|
||||
(id == null ? 0 : id!.hashCode) +
|
||||
(category == null ? 0 : category!.hashCode) +
|
||||
(name.hashCode) +
|
||||
(photoUrls.hashCode) +
|
||||
(tags.hashCode) +
|
||||
(status == null ? 0 : status!.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'Pet[id=$id, category=$category, name=$name, photoUrls=$photoUrls, tags=$tags, status=$status]';
|
||||
@ -66,9 +78,7 @@ class Pet {
|
||||
}
|
||||
json[r'name'] = name;
|
||||
json[r'photoUrls'] = photoUrls;
|
||||
if (tags != null) {
|
||||
json[r'tags'] = tags;
|
||||
}
|
||||
if (status != null) {
|
||||
json[r'status'] = status;
|
||||
}
|
||||
@ -78,54 +88,82 @@ class Pet {
|
||||
/// Returns a new [Pet] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static Pet fromJson(dynamic value) {
|
||||
static Pet? fromJson(dynamic value) {
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
// Ensure that the map contains the required keys.
|
||||
// Note 1: the values aren't checked for validity beyond being non-null.
|
||||
// Note 2: this code is stripped in release mode!
|
||||
assert(() {
|
||||
requiredKeys.forEach((key) {
|
||||
assert(json.containsKey(key), 'Required key "Pet[$key]" is missing from JSON.');
|
||||
assert(json[key] != null, 'Required key "Pet[$key]" has a null value in JSON.');
|
||||
});
|
||||
return true;
|
||||
}());
|
||||
|
||||
return Pet(
|
||||
id: mapValueOfType<int>(json, r'id'),
|
||||
category: Category.fromJson(json[r'category']),
|
||||
name: mapValueOfType<String>(json, r'name'),
|
||||
name: mapValueOfType<String>(json, r'name')!,
|
||||
photoUrls: json[r'photoUrls'] is List
|
||||
? (json[r'photoUrls'] as List).cast<String>()
|
||||
: null,
|
||||
tags: Tag.listFromJson(json[r'tags']),
|
||||
: const [],
|
||||
tags: Tag.listFromJson(json[r'tags']) ?? const [],
|
||||
status: PetStatusEnum.fromJson(json[r'status']),
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<Pet> listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) =>
|
||||
json is List && json.isNotEmpty
|
||||
? json.map(Pet.fromJson).toList(growable: true == growable)
|
||||
: true == emptyIsNull ? null : <Pet>[];
|
||||
static List<Pet>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <Pet>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = Pet.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, Pet> mapFromJson(dynamic json) {
|
||||
final map = <String, Pet>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) => map[key] = Pet.fromJson(value));
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = Pet.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of Pet-objects as value to a dart map
|
||||
static Map<String, List<Pet>> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) {
|
||||
static Map<String, List<Pet>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<Pet>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) {
|
||||
map[key] = Pet.listFromJson(
|
||||
value,
|
||||
emptyIsNull: emptyIsNull,
|
||||
growable: growable,
|
||||
);
|
||||
});
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = Pet.listFromJson(entry.value, growable: growable,);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
'name',
|
||||
'photoUrls',
|
||||
};
|
||||
}
|
||||
|
||||
/// pet status in the store
|
||||
@ -137,7 +175,7 @@ class PetStatusEnum {
|
||||
final String value;
|
||||
|
||||
@override
|
||||
String toString() => value ?? '';
|
||||
String toString() => value;
|
||||
|
||||
String toJson() => value;
|
||||
|
||||
@ -152,13 +190,20 @@ class PetStatusEnum {
|
||||
sold,
|
||||
];
|
||||
|
||||
static PetStatusEnum fromJson(dynamic value) =>
|
||||
PetStatusEnumTypeTransformer().decode(value);
|
||||
static PetStatusEnum? fromJson(dynamic value) => PetStatusEnumTypeTransformer().decode(value);
|
||||
|
||||
static List<PetStatusEnum> listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) =>
|
||||
json is List && json.isNotEmpty
|
||||
? json.map(PetStatusEnum.fromJson).toList(growable: true == growable)
|
||||
: true == emptyIsNull ? null : <PetStatusEnum>[];
|
||||
static List<PetStatusEnum>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <PetStatusEnum>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = PetStatusEnum.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
}
|
||||
|
||||
/// Transformation class that can [encode] an instance of [PetStatusEnum] to String,
|
||||
@ -178,14 +223,14 @@ class PetStatusEnumTypeTransformer {
|
||||
///
|
||||
/// The [allowNull] is very handy when an API changes and a new enum value is added or removed,
|
||||
/// and users are still using an old app with the old code.
|
||||
PetStatusEnum decode(dynamic data, {bool allowNull}) {
|
||||
PetStatusEnum? decode(dynamic data, {bool allowNull = true}) {
|
||||
if (data != null) {
|
||||
switch (data.toString()) {
|
||||
case r'available': return PetStatusEnum.available;
|
||||
case r'pending': return PetStatusEnum.pending;
|
||||
case r'sold': return PetStatusEnum.sold;
|
||||
default:
|
||||
if (allowNull == false) {
|
||||
if (!allowNull) {
|
||||
throw ArgumentError('Unknown enum value to decode: $data');
|
||||
}
|
||||
}
|
||||
@ -194,7 +239,7 @@ class PetStatusEnumTypeTransformer {
|
||||
}
|
||||
|
||||
/// Singleton [PetStatusEnumTypeTransformer] instance.
|
||||
static PetStatusEnumTypeTransformer _instance;
|
||||
static PetStatusEnumTypeTransformer? _instance;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -17,9 +17,21 @@ class Tag {
|
||||
this.name,
|
||||
});
|
||||
|
||||
int id;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
int? id;
|
||||
|
||||
String name;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
String? name;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is Tag &&
|
||||
@ -29,8 +41,8 @@ class Tag {
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(id == null ? 0 : id.hashCode) +
|
||||
(name == null ? 0 : name.hashCode);
|
||||
(id == null ? 0 : id!.hashCode) +
|
||||
(name == null ? 0 : name!.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'Tag[id=$id, name=$name]';
|
||||
@ -49,9 +61,21 @@ class Tag {
|
||||
/// Returns a new [Tag] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static Tag fromJson(dynamic value) {
|
||||
static Tag? fromJson(dynamic value) {
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
// Ensure that the map contains the required keys.
|
||||
// Note 1: the values aren't checked for validity beyond being non-null.
|
||||
// Note 2: this code is stripped in release mode!
|
||||
assert(() {
|
||||
requiredKeys.forEach((key) {
|
||||
assert(json.containsKey(key), 'Required key "Tag[$key]" is missing from JSON.');
|
||||
assert(json[key] != null, 'Required key "Tag[$key]" has a null value in JSON.');
|
||||
});
|
||||
return true;
|
||||
}());
|
||||
|
||||
return Tag(
|
||||
id: mapValueOfType<int>(json, r'id'),
|
||||
name: mapValueOfType<String>(json, r'name'),
|
||||
@ -60,36 +84,50 @@ class Tag {
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<Tag> listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) =>
|
||||
json is List && json.isNotEmpty
|
||||
? json.map(Tag.fromJson).toList(growable: true == growable)
|
||||
: true == emptyIsNull ? null : <Tag>[];
|
||||
static List<Tag>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <Tag>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = Tag.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, Tag> mapFromJson(dynamic json) {
|
||||
final map = <String, Tag>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) => map[key] = Tag.fromJson(value));
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = Tag.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of Tag-objects as value to a dart map
|
||||
static Map<String, List<Tag>> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) {
|
||||
static Map<String, List<Tag>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<Tag>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) {
|
||||
map[key] = Tag.listFromJson(
|
||||
value,
|
||||
emptyIsNull: emptyIsNull,
|
||||
growable: growable,
|
||||
);
|
||||
});
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = Tag.listFromJson(entry.value, growable: growable,);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -23,22 +23,70 @@ class User {
|
||||
this.userStatus,
|
||||
});
|
||||
|
||||
int id;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
int? id;
|
||||
|
||||
String username;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
String? username;
|
||||
|
||||
String firstName;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
String? firstName;
|
||||
|
||||
String lastName;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
String? lastName;
|
||||
|
||||
String email;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
String? email;
|
||||
|
||||
String password;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
String? password;
|
||||
|
||||
String phone;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
String? phone;
|
||||
|
||||
/// User Status
|
||||
int userStatus;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
int? userStatus;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is User &&
|
||||
@ -54,14 +102,14 @@ class User {
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(id == null ? 0 : id.hashCode) +
|
||||
(username == null ? 0 : username.hashCode) +
|
||||
(firstName == null ? 0 : firstName.hashCode) +
|
||||
(lastName == null ? 0 : lastName.hashCode) +
|
||||
(email == null ? 0 : email.hashCode) +
|
||||
(password == null ? 0 : password.hashCode) +
|
||||
(phone == null ? 0 : phone.hashCode) +
|
||||
(userStatus == null ? 0 : userStatus.hashCode);
|
||||
(id == null ? 0 : id!.hashCode) +
|
||||
(username == null ? 0 : username!.hashCode) +
|
||||
(firstName == null ? 0 : firstName!.hashCode) +
|
||||
(lastName == null ? 0 : lastName!.hashCode) +
|
||||
(email == null ? 0 : email!.hashCode) +
|
||||
(password == null ? 0 : password!.hashCode) +
|
||||
(phone == null ? 0 : phone!.hashCode) +
|
||||
(userStatus == null ? 0 : userStatus!.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'User[id=$id, username=$username, firstName=$firstName, lastName=$lastName, email=$email, password=$password, phone=$phone, userStatus=$userStatus]';
|
||||
@ -98,9 +146,21 @@ class User {
|
||||
/// Returns a new [User] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static User fromJson(dynamic value) {
|
||||
static User? fromJson(dynamic value) {
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
// Ensure that the map contains the required keys.
|
||||
// Note 1: the values aren't checked for validity beyond being non-null.
|
||||
// Note 2: this code is stripped in release mode!
|
||||
assert(() {
|
||||
requiredKeys.forEach((key) {
|
||||
assert(json.containsKey(key), 'Required key "User[$key]" is missing from JSON.');
|
||||
assert(json[key] != null, 'Required key "User[$key]" has a null value in JSON.');
|
||||
});
|
||||
return true;
|
||||
}());
|
||||
|
||||
return User(
|
||||
id: mapValueOfType<int>(json, r'id'),
|
||||
username: mapValueOfType<String>(json, r'username'),
|
||||
@ -115,36 +175,50 @@ class User {
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<User> listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) =>
|
||||
json is List && json.isNotEmpty
|
||||
? json.map(User.fromJson).toList(growable: true == growable)
|
||||
: true == emptyIsNull ? null : <User>[];
|
||||
static List<User>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <User>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = User.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, User> mapFromJson(dynamic json) {
|
||||
final map = <String, User>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) => map[key] = User.fromJson(value));
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = User.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of User-objects as value to a dart map
|
||||
static Map<String, List<User>> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) {
|
||||
static Map<String, List<User>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<User>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) {
|
||||
map[key] = User.listFromJson(
|
||||
value,
|
||||
emptyIsNull: emptyIsNull,
|
||||
growable: growable,
|
||||
);
|
||||
});
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = User.listFromJson(entry.value, growable: growable,);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,18 +1,20 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: constant_identifier_names
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
import 'package:openapi/api.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
// these tests are not regenerated by dart 2 generator as they break compatibility with Dart versions under 2.12
|
||||
// tests for ApiResponse
|
||||
void main() {
|
||||
final instance = ApiResponse();
|
||||
// final instance = ApiResponse();
|
||||
|
||||
group('test ApiResponse', () {
|
||||
// int code
|
||||
|
@ -1,18 +1,20 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: constant_identifier_names
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
import 'package:openapi/api.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
// these tests are not regenerated by dart 2 generator as they break compatibility with Dart versions under 2.12
|
||||
// tests for Category
|
||||
void main() {
|
||||
final instance = Category();
|
||||
// final instance = Category();
|
||||
|
||||
group('test Category', () {
|
||||
// int id
|
||||
|
@ -1,18 +1,20 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: constant_identifier_names
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
import 'package:openapi/api.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
// these tests are not regenerated by dart 2 generator as they break compatibility with Dart versions under 2.12
|
||||
// tests for Order
|
||||
void main() {
|
||||
final instance = Order();
|
||||
// final instance = Order();
|
||||
|
||||
group('test Order', () {
|
||||
// int id
|
||||
|
@ -1,19 +1,21 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: constant_identifier_names
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
import 'package:openapi/api.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
|
||||
// these tests are not regenerated by dart 2 generator as they break compatibility with Dart versions under 2.12
|
||||
/// tests for PetApi
|
||||
void main() {
|
||||
final instance = PetApi();
|
||||
// final instance = PetApi();
|
||||
|
||||
group('tests for PetApi', () {
|
||||
// Add a new pet to the store
|
||||
|
@ -1,18 +1,20 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: constant_identifier_names
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
import 'package:openapi/api.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
// these tests are not regenerated by dart 2 generator as they break compatibility with Dart versions under 2.12
|
||||
// tests for Pet
|
||||
void main() {
|
||||
final instance = Pet();
|
||||
// final instance = Pet();
|
||||
|
||||
group('test Pet', () {
|
||||
// int id
|
||||
|
@ -1,19 +1,21 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: constant_identifier_names
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
import 'package:openapi/api.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
|
||||
// these tests are not regenerated by dart 2 generator as they break compatibility with Dart versions under 2.12
|
||||
/// tests for StoreApi
|
||||
void main() {
|
||||
final instance = StoreApi();
|
||||
// final instance = StoreApi();
|
||||
|
||||
group('tests for StoreApi', () {
|
||||
// Delete purchase order by ID
|
||||
|
@ -1,18 +1,20 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: constant_identifier_names
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
import 'package:openapi/api.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
// these tests are not regenerated by dart 2 generator as they break compatibility with Dart versions under 2.12
|
||||
// tests for Tag
|
||||
void main() {
|
||||
final instance = Tag();
|
||||
// final instance = Tag();
|
||||
|
||||
group('test Tag', () {
|
||||
// int id
|
||||
|
@ -1,19 +1,21 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: constant_identifier_names
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
import 'package:openapi/api.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
|
||||
// these tests are not regenerated by dart 2 generator as they break compatibility with Dart versions under 2.12
|
||||
/// tests for UserApi
|
||||
void main() {
|
||||
final instance = UserApi();
|
||||
// final instance = UserApi();
|
||||
|
||||
group('tests for UserApi', () {
|
||||
// Create user
|
||||
|
@ -1,18 +1,20 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: constant_identifier_names
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
import 'package:openapi/api.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
// these tests are not regenerated by dart 2 generator as they break compatibility with Dart versions under 2.12
|
||||
// tests for User
|
||||
void main() {
|
||||
final instance = User();
|
||||
// final instance = User();
|
||||
|
||||
group('test User', () {
|
||||
// int id
|
||||
|
@ -1,27 +1,17 @@
|
||||
# See https://www.dartlang.org/tools/private-files.html
|
||||
# See https://dart.dev/guides/libraries/private-files
|
||||
|
||||
# Files and directories created by pub
|
||||
.buildlog
|
||||
.dart_tool/
|
||||
.packages
|
||||
.project
|
||||
.pub/
|
||||
build/
|
||||
**/packages/
|
||||
pubspec.lock # Except for application 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
|
||||
# IntelliJ
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# Mac
|
||||
.DS_Store
|
||||
|
@ -6,7 +6,7 @@
|
||||
language: dart
|
||||
dart:
|
||||
# Install a specific stable release
|
||||
- "2.2.0"
|
||||
- "2.12"
|
||||
install:
|
||||
- pub get
|
||||
|
||||
|
@ -8,7 +8,7 @@ This Dart package is automatically generated by the [OpenAPI Generator](https://
|
||||
|
||||
## Requirements
|
||||
|
||||
Dart 2.0 or later
|
||||
Dart 2.12 or later
|
||||
|
||||
## Installation & Usage
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -12,7 +12,7 @@ part of openapi.api;
|
||||
|
||||
|
||||
class AnotherFakeApi {
|
||||
AnotherFakeApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
AnotherFakeApi([ApiClient? apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
|
||||
final ApiClient apiClient;
|
||||
|
||||
@ -27,16 +27,11 @@ class AnotherFakeApi {
|
||||
/// * [ModelClient] modelClient (required):
|
||||
/// client model
|
||||
Future<Response> call123testSpecialTagsWithHttpInfo(ModelClient modelClient,) async {
|
||||
// Verify required params are set.
|
||||
if (modelClient == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: modelClient');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/another-fake/dummy';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = modelClient;
|
||||
Object? postBody = modelClient;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -53,7 +48,7 @@ class AnotherFakeApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -66,7 +61,7 @@ class AnotherFakeApi {
|
||||
///
|
||||
/// * [ModelClient] modelClient (required):
|
||||
/// client model
|
||||
Future<ModelClient> call123testSpecialTags(ModelClient modelClient,) async {
|
||||
Future<ModelClient?> call123testSpecialTags(ModelClient modelClient,) async {
|
||||
final response = await call123testSpecialTagsWithHttpInfo(modelClient,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -74,10 +69,10 @@ class AnotherFakeApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ModelClient',) as ModelClient;
|
||||
|
||||
}
|
||||
return Future<ModelClient>.value();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -12,7 +12,7 @@ part of openapi.api;
|
||||
|
||||
|
||||
class DefaultApi {
|
||||
DefaultApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
DefaultApi([ApiClient? apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
|
||||
final ApiClient apiClient;
|
||||
|
||||
@ -22,7 +22,7 @@ class DefaultApi {
|
||||
final path = r'/foo';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -39,12 +39,12 @@ class DefaultApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
Future<InlineResponseDefault> fooGet() async {
|
||||
Future<InlineResponseDefault?> fooGet() async {
|
||||
final response = await fooGetWithHttpInfo();
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -52,10 +52,10 @@ class DefaultApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'InlineResponseDefault',) as InlineResponseDefault;
|
||||
|
||||
}
|
||||
return Future<InlineResponseDefault>.value();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -12,7 +12,7 @@ part of openapi.api;
|
||||
|
||||
|
||||
class FakeApi {
|
||||
FakeApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
FakeApi([ApiClient? apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
|
||||
final ApiClient apiClient;
|
||||
|
||||
@ -24,7 +24,7 @@ class FakeApi {
|
||||
final path = r'/fake/health';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -41,13 +41,13 @@ class FakeApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
||||
/// Health check endpoint
|
||||
Future<HealthCheckResult> fakeHealthGet() async {
|
||||
Future<HealthCheckResult?> fakeHealthGet() async {
|
||||
final response = await fakeHealthGetWithHttpInfo();
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -55,11 +55,11 @@ class FakeApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'HealthCheckResult',) as HealthCheckResult;
|
||||
|
||||
}
|
||||
return Future<HealthCheckResult>.value();
|
||||
return null;
|
||||
}
|
||||
|
||||
/// test http signature authentication
|
||||
@ -76,24 +76,19 @@ class FakeApi {
|
||||
///
|
||||
/// * [String] header1:
|
||||
/// header parameter
|
||||
Future<Response> fakeHttpSignatureTestWithHttpInfo(Pet pet, { String query1, String header1, }) async {
|
||||
// Verify required params are set.
|
||||
if (pet == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: pet');
|
||||
}
|
||||
|
||||
Future<Response> fakeHttpSignatureTestWithHttpInfo(Pet pet, { String? query1, String? header1, }) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/fake/http-signature-test';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = pet;
|
||||
Object? postBody = pet;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
if (query1 != null) {
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('', 'query_1', query1));
|
||||
queryParams.addAll(_queryParams('', 'query_1', query1));
|
||||
}
|
||||
|
||||
if (header1 != null) {
|
||||
@ -111,7 +106,7 @@ class FakeApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -128,7 +123,7 @@ class FakeApi {
|
||||
///
|
||||
/// * [String] header1:
|
||||
/// header parameter
|
||||
Future<void> fakeHttpSignatureTest(Pet pet, { String query1, String header1, }) async {
|
||||
Future<void> fakeHttpSignatureTest(Pet pet, { String? query1, String? header1, }) async {
|
||||
final response = await fakeHttpSignatureTestWithHttpInfo(pet, query1: query1, header1: header1, );
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -143,14 +138,12 @@ class FakeApi {
|
||||
///
|
||||
/// * [bool] body:
|
||||
/// Input boolean as post body
|
||||
Future<Response> fakeOuterBooleanSerializeWithHttpInfo({ bool body, }) async {
|
||||
// Verify required params are set.
|
||||
|
||||
Future<Response> fakeOuterBooleanSerializeWithHttpInfo({ bool? body, }) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/fake/outer/boolean';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = body;
|
||||
Object? postBody = body;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -167,7 +160,7 @@ class FakeApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -178,7 +171,7 @@ class FakeApi {
|
||||
///
|
||||
/// * [bool] body:
|
||||
/// Input boolean as post body
|
||||
Future<bool> fakeOuterBooleanSerialize({ bool body, }) async {
|
||||
Future<bool?> fakeOuterBooleanSerialize({ bool? body, }) async {
|
||||
final response = await fakeOuterBooleanSerializeWithHttpInfo( body: body, );
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -186,11 +179,11 @@ class FakeApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'bool',) as bool;
|
||||
|
||||
}
|
||||
return Future<bool>.value();
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Test serialization of object with outer number type
|
||||
@ -201,14 +194,12 @@ class FakeApi {
|
||||
///
|
||||
/// * [OuterComposite] outerComposite:
|
||||
/// Input composite as post body
|
||||
Future<Response> fakeOuterCompositeSerializeWithHttpInfo({ OuterComposite outerComposite, }) async {
|
||||
// Verify required params are set.
|
||||
|
||||
Future<Response> fakeOuterCompositeSerializeWithHttpInfo({ OuterComposite? outerComposite, }) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/fake/outer/composite';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = outerComposite;
|
||||
Object? postBody = outerComposite;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -225,7 +216,7 @@ class FakeApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -236,7 +227,7 @@ class FakeApi {
|
||||
///
|
||||
/// * [OuterComposite] outerComposite:
|
||||
/// Input composite as post body
|
||||
Future<OuterComposite> fakeOuterCompositeSerialize({ OuterComposite outerComposite, }) async {
|
||||
Future<OuterComposite?> fakeOuterCompositeSerialize({ OuterComposite? outerComposite, }) async {
|
||||
final response = await fakeOuterCompositeSerializeWithHttpInfo( outerComposite: outerComposite, );
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -244,11 +235,11 @@ class FakeApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'OuterComposite',) as OuterComposite;
|
||||
|
||||
}
|
||||
return Future<OuterComposite>.value();
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Test serialization of outer number types
|
||||
@ -259,14 +250,12 @@ class FakeApi {
|
||||
///
|
||||
/// * [num] body:
|
||||
/// Input number as post body
|
||||
Future<Response> fakeOuterNumberSerializeWithHttpInfo({ num body, }) async {
|
||||
// Verify required params are set.
|
||||
|
||||
Future<Response> fakeOuterNumberSerializeWithHttpInfo({ num? body, }) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/fake/outer/number';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = body;
|
||||
Object? postBody = body;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -283,7 +272,7 @@ class FakeApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -294,7 +283,7 @@ class FakeApi {
|
||||
///
|
||||
/// * [num] body:
|
||||
/// Input number as post body
|
||||
Future<num> fakeOuterNumberSerialize({ num body, }) async {
|
||||
Future<num?> fakeOuterNumberSerialize({ num? body, }) async {
|
||||
final response = await fakeOuterNumberSerializeWithHttpInfo( body: body, );
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -302,11 +291,11 @@ class FakeApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'num',) as num;
|
||||
|
||||
}
|
||||
return Future<num>.value();
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Test serialization of outer string types
|
||||
@ -317,14 +306,12 @@ class FakeApi {
|
||||
///
|
||||
/// * [String] body:
|
||||
/// Input string as post body
|
||||
Future<Response> fakeOuterStringSerializeWithHttpInfo({ String body, }) async {
|
||||
// Verify required params are set.
|
||||
|
||||
Future<Response> fakeOuterStringSerializeWithHttpInfo({ String? body, }) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/fake/outer/string';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = body;
|
||||
Object? postBody = body;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -341,7 +328,7 @@ class FakeApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -352,7 +339,7 @@ class FakeApi {
|
||||
///
|
||||
/// * [String] body:
|
||||
/// Input string as post body
|
||||
Future<String> fakeOuterStringSerialize({ String body, }) async {
|
||||
Future<String?> fakeOuterStringSerialize({ String? body, }) async {
|
||||
final response = await fakeOuterStringSerializeWithHttpInfo( body: body, );
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -360,11 +347,11 @@ class FakeApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'String',) as String;
|
||||
|
||||
}
|
||||
return Future<String>.value();
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Test serialization of enum (int) properties with examples
|
||||
@ -376,16 +363,11 @@ class FakeApi {
|
||||
/// * [OuterObjectWithEnumProperty] outerObjectWithEnumProperty (required):
|
||||
/// Input enum (int) as post body
|
||||
Future<Response> fakePropertyEnumIntegerSerializeWithHttpInfo(OuterObjectWithEnumProperty outerObjectWithEnumProperty,) async {
|
||||
// Verify required params are set.
|
||||
if (outerObjectWithEnumProperty == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: outerObjectWithEnumProperty');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/fake/property/enum-int';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = outerObjectWithEnumProperty;
|
||||
Object? postBody = outerObjectWithEnumProperty;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -402,7 +384,7 @@ class FakeApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -413,7 +395,7 @@ class FakeApi {
|
||||
///
|
||||
/// * [OuterObjectWithEnumProperty] outerObjectWithEnumProperty (required):
|
||||
/// Input enum (int) as post body
|
||||
Future<OuterObjectWithEnumProperty> fakePropertyEnumIntegerSerialize(OuterObjectWithEnumProperty outerObjectWithEnumProperty,) async {
|
||||
Future<OuterObjectWithEnumProperty?> fakePropertyEnumIntegerSerialize(OuterObjectWithEnumProperty outerObjectWithEnumProperty,) async {
|
||||
final response = await fakePropertyEnumIntegerSerializeWithHttpInfo(outerObjectWithEnumProperty,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -421,11 +403,11 @@ class FakeApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'OuterObjectWithEnumProperty',) as OuterObjectWithEnumProperty;
|
||||
|
||||
}
|
||||
return Future<OuterObjectWithEnumProperty>.value();
|
||||
return null;
|
||||
}
|
||||
|
||||
/// For this test, the body has to be a binary file.
|
||||
@ -437,16 +419,11 @@ class FakeApi {
|
||||
/// * [MultipartFile] body (required):
|
||||
/// image to upload
|
||||
Future<Response> testBodyWithBinaryWithHttpInfo(MultipartFile body,) async {
|
||||
// Verify required params are set.
|
||||
if (body == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: body');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/fake/body-with-binary';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = body;
|
||||
Object? postBody = body;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -463,7 +440,7 @@ class FakeApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -489,16 +466,11 @@ class FakeApi {
|
||||
///
|
||||
/// * [FileSchemaTestClass] fileSchemaTestClass (required):
|
||||
Future<Response> testBodyWithFileSchemaWithHttpInfo(FileSchemaTestClass fileSchemaTestClass,) async {
|
||||
// Verify required params are set.
|
||||
if (fileSchemaTestClass == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: fileSchemaTestClass');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/fake/body-with-file-schema';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = fileSchemaTestClass;
|
||||
Object? postBody = fileSchemaTestClass;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -515,7 +487,7 @@ class FakeApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -539,25 +511,17 @@ class FakeApi {
|
||||
///
|
||||
/// * [User] user (required):
|
||||
Future<Response> testBodyWithQueryParamsWithHttpInfo(String query, User user,) async {
|
||||
// Verify required params are set.
|
||||
if (query == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: query');
|
||||
}
|
||||
if (user == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/fake/body-with-query-params';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = user;
|
||||
Object? postBody = user;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('', 'query', query));
|
||||
queryParams.addAll(_queryParams('', 'query', query));
|
||||
|
||||
const authNames = <String>[];
|
||||
const contentTypes = <String>['application/json'];
|
||||
@ -570,7 +534,7 @@ class FakeApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -598,16 +562,11 @@ class FakeApi {
|
||||
/// * [ModelClient] modelClient (required):
|
||||
/// client model
|
||||
Future<Response> testClientModelWithHttpInfo(ModelClient modelClient,) async {
|
||||
// Verify required params are set.
|
||||
if (modelClient == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: modelClient');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/fake';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = modelClient;
|
||||
Object? postBody = modelClient;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -624,7 +583,7 @@ class FakeApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -637,7 +596,7 @@ class FakeApi {
|
||||
///
|
||||
/// * [ModelClient] modelClient (required):
|
||||
/// client model
|
||||
Future<ModelClient> testClientModel(ModelClient modelClient,) async {
|
||||
Future<ModelClient?> testClientModel(ModelClient modelClient,) async {
|
||||
final response = await testClientModelWithHttpInfo(modelClient,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -645,11 +604,11 @@ class FakeApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ModelClient',) as ModelClient;
|
||||
|
||||
}
|
||||
return Future<ModelClient>.value();
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
@ -701,26 +660,12 @@ class FakeApi {
|
||||
///
|
||||
/// * [String] callback:
|
||||
/// None
|
||||
Future<Response> testEndpointParametersWithHttpInfo(num number, double double_, String patternWithoutDelimiter, String byte, { int integer, int int32, int int64, double float, String string, MultipartFile binary, DateTime date, DateTime dateTime, String password, String callback, }) async {
|
||||
// Verify required params are set.
|
||||
if (number == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: number');
|
||||
}
|
||||
if (double_ == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: double_');
|
||||
}
|
||||
if (patternWithoutDelimiter == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: patternWithoutDelimiter');
|
||||
}
|
||||
if (byte == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: byte');
|
||||
}
|
||||
|
||||
Future<Response> testEndpointParametersWithHttpInfo(num number, double double_, String patternWithoutDelimiter, String byte, { int? integer, int? int32, int? int64, double? float, String? string, MultipartFile? binary, DateTime? date, DateTime? dateTime, String? password, String? callback, }) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/fake';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -776,7 +721,7 @@ class FakeApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -828,7 +773,7 @@ class FakeApi {
|
||||
///
|
||||
/// * [String] callback:
|
||||
/// None
|
||||
Future<void> testEndpointParameters(num number, double double_, String patternWithoutDelimiter, String byte, { int integer, int int32, int int64, double float, String string, MultipartFile binary, DateTime date, DateTime dateTime, String password, String callback, }) async {
|
||||
Future<void> testEndpointParameters(num number, double double_, String patternWithoutDelimiter, String byte, { int? integer, int? int32, int? int64, double? float, String? string, MultipartFile? binary, DateTime? date, DateTime? dateTime, String? password, String? callback, }) async {
|
||||
final response = await testEndpointParametersWithHttpInfo(number, double_, patternWithoutDelimiter, byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback, );
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -866,30 +811,28 @@ class FakeApi {
|
||||
///
|
||||
/// * [String] enumFormString:
|
||||
/// Form parameter enum test (string)
|
||||
Future<Response> testEnumParametersWithHttpInfo({ List<String> enumHeaderStringArray, String enumHeaderString, List<String> enumQueryStringArray, String enumQueryString, int enumQueryInteger, double enumQueryDouble, List<String> enumFormStringArray, String enumFormString, }) async {
|
||||
// Verify required params are set.
|
||||
|
||||
Future<Response> testEnumParametersWithHttpInfo({ List<String>? enumHeaderStringArray, String? enumHeaderString, List<String>? enumQueryStringArray, String? enumQueryString, int? enumQueryInteger, double? enumQueryDouble, List<String>? enumFormStringArray, String? enumFormString, }) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/fake';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
if (enumQueryStringArray != null) {
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('multi', 'enum_query_string_array', enumQueryStringArray));
|
||||
queryParams.addAll(_queryParams('multi', 'enum_query_string_array', enumQueryStringArray));
|
||||
}
|
||||
if (enumQueryString != null) {
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('', 'enum_query_string', enumQueryString));
|
||||
queryParams.addAll(_queryParams('', 'enum_query_string', enumQueryString));
|
||||
}
|
||||
if (enumQueryInteger != null) {
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('', 'enum_query_integer', enumQueryInteger));
|
||||
queryParams.addAll(_queryParams('', 'enum_query_integer', enumQueryInteger));
|
||||
}
|
||||
if (enumQueryDouble != null) {
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('', 'enum_query_double', enumQueryDouble));
|
||||
queryParams.addAll(_queryParams('', 'enum_query_double', enumQueryDouble));
|
||||
}
|
||||
|
||||
if (enumHeaderStringArray != null) {
|
||||
@ -916,7 +859,7 @@ class FakeApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -950,7 +893,7 @@ class FakeApi {
|
||||
///
|
||||
/// * [String] enumFormString:
|
||||
/// Form parameter enum test (string)
|
||||
Future<void> testEnumParameters({ List<String> enumHeaderStringArray, String enumHeaderString, List<String> enumQueryStringArray, String enumQueryString, int enumQueryInteger, double enumQueryDouble, List<String> enumFormStringArray, String enumFormString, }) async {
|
||||
Future<void> testEnumParameters({ List<String>? enumHeaderStringArray, String? enumHeaderString, List<String>? enumQueryStringArray, String? enumQueryString, int? enumQueryInteger, double? enumQueryDouble, List<String>? enumFormStringArray, String? enumFormString, }) async {
|
||||
final response = await testEnumParametersWithHttpInfo( enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString, );
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -982,35 +925,24 @@ class FakeApi {
|
||||
///
|
||||
/// * [int] int64Group:
|
||||
/// Integer in group parameters
|
||||
Future<Response> testGroupParametersWithHttpInfo(int requiredStringGroup, bool requiredBooleanGroup, int requiredInt64Group, { int stringGroup, bool booleanGroup, int int64Group, }) async {
|
||||
// Verify required params are set.
|
||||
if (requiredStringGroup == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: requiredStringGroup');
|
||||
}
|
||||
if (requiredBooleanGroup == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: requiredBooleanGroup');
|
||||
}
|
||||
if (requiredInt64Group == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: requiredInt64Group');
|
||||
}
|
||||
|
||||
Future<Response> testGroupParametersWithHttpInfo(int requiredStringGroup, bool requiredBooleanGroup, int requiredInt64Group, { int? stringGroup, bool? booleanGroup, int? int64Group, }) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/fake';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('', 'required_string_group', requiredStringGroup));
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('', 'required_int64_group', requiredInt64Group));
|
||||
queryParams.addAll(_queryParams('', 'required_string_group', requiredStringGroup));
|
||||
queryParams.addAll(_queryParams('', 'required_int64_group', requiredInt64Group));
|
||||
if (stringGroup != null) {
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('', 'string_group', stringGroup));
|
||||
queryParams.addAll(_queryParams('', 'string_group', stringGroup));
|
||||
}
|
||||
if (int64Group != null) {
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('', 'int64_group', int64Group));
|
||||
queryParams.addAll(_queryParams('', 'int64_group', int64Group));
|
||||
}
|
||||
|
||||
headerParams[r'required_boolean_group'] = parameterToString(requiredBooleanGroup);
|
||||
@ -1029,7 +961,7 @@ class FakeApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -1057,7 +989,7 @@ class FakeApi {
|
||||
///
|
||||
/// * [int] int64Group:
|
||||
/// Integer in group parameters
|
||||
Future<void> testGroupParameters(int requiredStringGroup, bool requiredBooleanGroup, int requiredInt64Group, { int stringGroup, bool booleanGroup, int int64Group, }) async {
|
||||
Future<void> testGroupParameters(int requiredStringGroup, bool requiredBooleanGroup, int requiredInt64Group, { int? stringGroup, bool? booleanGroup, int? int64Group, }) async {
|
||||
final response = await testGroupParametersWithHttpInfo(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup: stringGroup, booleanGroup: booleanGroup, int64Group: int64Group, );
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -1073,16 +1005,11 @@ class FakeApi {
|
||||
/// * [Map<String, String>] requestBody (required):
|
||||
/// request body
|
||||
Future<Response> testInlineAdditionalPropertiesWithHttpInfo(Map<String, String> requestBody,) async {
|
||||
// Verify required params are set.
|
||||
if (requestBody == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: requestBody');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/fake/inline-additionalProperties';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = requestBody;
|
||||
Object? postBody = requestBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -1099,7 +1026,7 @@ class FakeApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -1129,19 +1056,11 @@ class FakeApi {
|
||||
/// * [String] param2 (required):
|
||||
/// field2
|
||||
Future<Response> testJsonFormDataWithHttpInfo(String param, String param2,) async {
|
||||
// Verify required params are set.
|
||||
if (param == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: param');
|
||||
}
|
||||
if (param2 == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: param2');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/fake/jsonFormData';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -1164,7 +1083,7 @@ class FakeApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -1204,46 +1123,26 @@ class FakeApi {
|
||||
/// * [String] allowEmpty (required):
|
||||
///
|
||||
/// * [Map<String, String>] language:
|
||||
Future<Response> testQueryParameterCollectionFormatWithHttpInfo(List<String> pipe, List<String> ioutil, List<String> http, List<String> url, List<String> context, String allowEmpty, { Map<String, String> language, }) async {
|
||||
// Verify required params are set.
|
||||
if (pipe == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: pipe');
|
||||
}
|
||||
if (ioutil == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: ioutil');
|
||||
}
|
||||
if (http == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: http');
|
||||
}
|
||||
if (url == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: url');
|
||||
}
|
||||
if (context == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: context');
|
||||
}
|
||||
if (allowEmpty == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: allowEmpty');
|
||||
}
|
||||
|
||||
Future<Response> testQueryParameterCollectionFormatWithHttpInfo(List<String> pipe, List<String> ioutil, List<String> http, List<String> url, List<String> context, String allowEmpty, { Map<String, String>? language, }) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/fake/test-query-parameters';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('pipes', 'pipe', pipe));
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('csv', 'ioutil', ioutil));
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('ssv', 'http', http));
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('csv', 'url', url));
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('multi', 'context', context));
|
||||
queryParams.addAll(_queryParams('pipes', 'pipe', pipe));
|
||||
queryParams.addAll(_queryParams('csv', 'ioutil', ioutil));
|
||||
queryParams.addAll(_queryParams('ssv', 'http', http));
|
||||
queryParams.addAll(_queryParams('csv', 'url', url));
|
||||
queryParams.addAll(_queryParams('multi', 'context', context));
|
||||
if (language != null) {
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('', 'language', language));
|
||||
queryParams.addAll(_queryParams('', 'language', language));
|
||||
}
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('', 'allowEmpty', allowEmpty));
|
||||
queryParams.addAll(_queryParams('', 'allowEmpty', allowEmpty));
|
||||
|
||||
const authNames = <String>[];
|
||||
const contentTypes = <String>[];
|
||||
@ -1256,7 +1155,7 @@ class FakeApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -1278,7 +1177,7 @@ class FakeApi {
|
||||
/// * [String] allowEmpty (required):
|
||||
///
|
||||
/// * [Map<String, String>] language:
|
||||
Future<void> testQueryParameterCollectionFormat(List<String> pipe, List<String> ioutil, List<String> http, List<String> url, List<String> context, String allowEmpty, { Map<String, String> language, }) async {
|
||||
Future<void> testQueryParameterCollectionFormat(List<String> pipe, List<String> ioutil, List<String> http, List<String> url, List<String> context, String allowEmpty, { Map<String, String>? language, }) async {
|
||||
final response = await testQueryParameterCollectionFormatWithHttpInfo(pipe, ioutil, http, url, context, allowEmpty, language: language, );
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -12,7 +12,7 @@ part of openapi.api;
|
||||
|
||||
|
||||
class FakeClassnameTags123Api {
|
||||
FakeClassnameTags123Api([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
FakeClassnameTags123Api([ApiClient? apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
|
||||
final ApiClient apiClient;
|
||||
|
||||
@ -27,16 +27,11 @@ class FakeClassnameTags123Api {
|
||||
/// * [ModelClient] modelClient (required):
|
||||
/// client model
|
||||
Future<Response> testClassnameWithHttpInfo(ModelClient modelClient,) async {
|
||||
// Verify required params are set.
|
||||
if (modelClient == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: modelClient');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/fake_classname_test';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = modelClient;
|
||||
Object? postBody = modelClient;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -53,7 +48,7 @@ class FakeClassnameTags123Api {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -66,7 +61,7 @@ class FakeClassnameTags123Api {
|
||||
///
|
||||
/// * [ModelClient] modelClient (required):
|
||||
/// client model
|
||||
Future<ModelClient> testClassname(ModelClient modelClient,) async {
|
||||
Future<ModelClient?> testClassname(ModelClient modelClient,) async {
|
||||
final response = await testClassnameWithHttpInfo(modelClient,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -74,10 +69,10 @@ class FakeClassnameTags123Api {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ModelClient',) as ModelClient;
|
||||
|
||||
}
|
||||
return Future<ModelClient>.value();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -12,7 +12,7 @@ part of openapi.api;
|
||||
|
||||
|
||||
class PetApi {
|
||||
PetApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
PetApi([ApiClient? apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
|
||||
final ApiClient apiClient;
|
||||
|
||||
@ -25,16 +25,11 @@ class PetApi {
|
||||
/// * [Pet] pet (required):
|
||||
/// Pet object that needs to be added to the store
|
||||
Future<Response> addPetWithHttpInfo(Pet pet,) async {
|
||||
// Verify required params are set.
|
||||
if (pet == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: pet');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/pet';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = pet;
|
||||
Object? postBody = pet;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -51,7 +46,7 @@ class PetApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -79,18 +74,13 @@ class PetApi {
|
||||
/// Pet id to delete
|
||||
///
|
||||
/// * [String] apiKey:
|
||||
Future<Response> deletePetWithHttpInfo(int petId, { String apiKey, }) async {
|
||||
// Verify required params are set.
|
||||
if (petId == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
Future<Response> deletePetWithHttpInfo(int petId, { String? apiKey, }) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/pet/{petId}'
|
||||
.replaceAll('{petId}', petId.toString());
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -111,7 +101,7 @@ class PetApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -124,7 +114,7 @@ class PetApi {
|
||||
/// Pet id to delete
|
||||
///
|
||||
/// * [String] apiKey:
|
||||
Future<void> deletePet(int petId, { String apiKey, }) async {
|
||||
Future<void> deletePet(int petId, { String? apiKey, }) async {
|
||||
final response = await deletePetWithHttpInfo(petId, apiKey: apiKey, );
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -142,22 +132,17 @@ class PetApi {
|
||||
/// * [List<String>] status (required):
|
||||
/// Status values that need to be considered for filter
|
||||
Future<Response> findPetsByStatusWithHttpInfo(List<String> status,) async {
|
||||
// Verify required params are set.
|
||||
if (status == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: status');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/pet/findByStatus';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('csv', 'status', status));
|
||||
queryParams.addAll(_queryParams('csv', 'status', status));
|
||||
|
||||
const authNames = <String>['petstore_auth'];
|
||||
const contentTypes = <String>[];
|
||||
@ -170,7 +155,7 @@ class PetApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -183,7 +168,7 @@ class PetApi {
|
||||
///
|
||||
/// * [List<String>] status (required):
|
||||
/// Status values that need to be considered for filter
|
||||
Future<List<Pet>> findPetsByStatus(List<String> status,) async {
|
||||
Future<List<Pet>?> findPetsByStatus(List<String> status,) async {
|
||||
final response = await findPetsByStatusWithHttpInfo(status,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -191,14 +176,14 @@ class PetApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
final responseBody = await _decodeBodyBytes(response);
|
||||
return (await apiClient.deserializeAsync(responseBody, 'List<Pet>') as List)
|
||||
.cast<Pet>()
|
||||
.toList(growable: false);
|
||||
.toList();
|
||||
|
||||
}
|
||||
return Future<List<Pet>>.value();
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Finds Pets by tags
|
||||
@ -212,22 +197,17 @@ class PetApi {
|
||||
/// * [Set<String>] tags (required):
|
||||
/// Tags to filter by
|
||||
Future<Response> findPetsByTagsWithHttpInfo(Set<String> tags,) async {
|
||||
// Verify required params are set.
|
||||
if (tags == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: tags');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/pet/findByTags';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('csv', 'tags', tags));
|
||||
queryParams.addAll(_queryParams('csv', 'tags', tags));
|
||||
|
||||
const authNames = <String>['petstore_auth'];
|
||||
const contentTypes = <String>[];
|
||||
@ -240,7 +220,7 @@ class PetApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -253,7 +233,7 @@ class PetApi {
|
||||
///
|
||||
/// * [Set<String>] tags (required):
|
||||
/// Tags to filter by
|
||||
Future<Set<Pet>> findPetsByTags(Set<String> tags,) async {
|
||||
Future<Set<Pet>?> findPetsByTags(Set<String> tags,) async {
|
||||
final response = await findPetsByTagsWithHttpInfo(tags,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -261,14 +241,14 @@ class PetApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
final responseBody = await _decodeBodyBytes(response);
|
||||
return (await apiClient.deserializeAsync(responseBody, 'Set<Pet>') as List)
|
||||
.cast<Pet>()
|
||||
.toSet();
|
||||
|
||||
}
|
||||
return Future<Set<Pet>>.value();
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Find pet by ID
|
||||
@ -282,17 +262,12 @@ class PetApi {
|
||||
/// * [int] petId (required):
|
||||
/// ID of pet to return
|
||||
Future<Response> getPetByIdWithHttpInfo(int petId,) async {
|
||||
// Verify required params are set.
|
||||
if (petId == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/pet/{petId}'
|
||||
.replaceAll('{petId}', petId.toString());
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -309,7 +284,7 @@ class PetApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -322,7 +297,7 @@ class PetApi {
|
||||
///
|
||||
/// * [int] petId (required):
|
||||
/// ID of pet to return
|
||||
Future<Pet> getPetById(int petId,) async {
|
||||
Future<Pet?> getPetById(int petId,) async {
|
||||
final response = await getPetByIdWithHttpInfo(petId,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -330,11 +305,11 @@ class PetApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Pet',) as Pet;
|
||||
|
||||
}
|
||||
return Future<Pet>.value();
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Update an existing pet
|
||||
@ -346,16 +321,11 @@ class PetApi {
|
||||
/// * [Pet] pet (required):
|
||||
/// Pet object that needs to be added to the store
|
||||
Future<Response> updatePetWithHttpInfo(Pet pet,) async {
|
||||
// Verify required params are set.
|
||||
if (pet == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: pet');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/pet';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = pet;
|
||||
Object? postBody = pet;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -372,7 +342,7 @@ class PetApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -404,18 +374,13 @@ class PetApi {
|
||||
///
|
||||
/// * [String] status:
|
||||
/// Updated status of the pet
|
||||
Future<Response> updatePetWithFormWithHttpInfo(int petId, { String name, String status, }) async {
|
||||
// Verify required params are set.
|
||||
if (petId == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
Future<Response> updatePetWithFormWithHttpInfo(int petId, { String? name, String? status, }) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/pet/{petId}'
|
||||
.replaceAll('{petId}', petId.toString());
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -438,7 +403,7 @@ class PetApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -455,7 +420,7 @@ class PetApi {
|
||||
///
|
||||
/// * [String] status:
|
||||
/// Updated status of the pet
|
||||
Future<void> updatePetWithForm(int petId, { String name, String status, }) async {
|
||||
Future<void> updatePetWithForm(int petId, { String? name, String? status, }) async {
|
||||
final response = await updatePetWithFormWithHttpInfo(petId, name: name, status: status, );
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -476,18 +441,13 @@ class PetApi {
|
||||
///
|
||||
/// * [MultipartFile] file:
|
||||
/// file to upload
|
||||
Future<Response> uploadFileWithHttpInfo(int petId, { String additionalMetadata, MultipartFile file, }) async {
|
||||
// Verify required params are set.
|
||||
if (petId == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
Future<Response> uploadFileWithHttpInfo(int petId, { String? additionalMetadata, MultipartFile? file, }) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/pet/{petId}/uploadImage'
|
||||
.replaceAll('{petId}', petId.toString());
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -518,7 +478,7 @@ class PetApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -535,7 +495,7 @@ class PetApi {
|
||||
///
|
||||
/// * [MultipartFile] file:
|
||||
/// file to upload
|
||||
Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file, }) async {
|
||||
Future<ApiResponse?> uploadFile(int petId, { String? additionalMetadata, MultipartFile? file, }) async {
|
||||
final response = await uploadFileWithHttpInfo(petId, additionalMetadata: additionalMetadata, file: file, );
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -543,11 +503,11 @@ class PetApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ApiResponse',) as ApiResponse;
|
||||
|
||||
}
|
||||
return Future<ApiResponse>.value();
|
||||
return null;
|
||||
}
|
||||
|
||||
/// uploads an image (required)
|
||||
@ -564,21 +524,13 @@ class PetApi {
|
||||
///
|
||||
/// * [String] additionalMetadata:
|
||||
/// Additional data to pass to server
|
||||
Future<Response> uploadFileWithRequiredFileWithHttpInfo(int petId, MultipartFile requiredFile, { String additionalMetadata, }) async {
|
||||
// Verify required params are set.
|
||||
if (petId == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
if (requiredFile == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: requiredFile');
|
||||
}
|
||||
|
||||
Future<Response> uploadFileWithRequiredFileWithHttpInfo(int petId, MultipartFile requiredFile, { String? additionalMetadata, }) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/fake/{petId}/uploadImageWithRequiredFile'
|
||||
.replaceAll('{petId}', petId.toString());
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -609,7 +561,7 @@ class PetApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -626,7 +578,7 @@ class PetApi {
|
||||
///
|
||||
/// * [String] additionalMetadata:
|
||||
/// Additional data to pass to server
|
||||
Future<ApiResponse> uploadFileWithRequiredFile(int petId, MultipartFile requiredFile, { String additionalMetadata, }) async {
|
||||
Future<ApiResponse?> uploadFileWithRequiredFile(int petId, MultipartFile requiredFile, { String? additionalMetadata, }) async {
|
||||
final response = await uploadFileWithRequiredFileWithHttpInfo(petId, requiredFile, additionalMetadata: additionalMetadata, );
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -634,10 +586,10 @@ class PetApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ApiResponse',) as ApiResponse;
|
||||
|
||||
}
|
||||
return Future<ApiResponse>.value();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -12,7 +12,7 @@ part of openapi.api;
|
||||
|
||||
|
||||
class StoreApi {
|
||||
StoreApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
StoreApi([ApiClient? apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
|
||||
final ApiClient apiClient;
|
||||
|
||||
@ -27,17 +27,12 @@ class StoreApi {
|
||||
/// * [String] orderId (required):
|
||||
/// ID of the order that needs to be deleted
|
||||
Future<Response> deleteOrderWithHttpInfo(String orderId,) async {
|
||||
// Verify required params are set.
|
||||
if (orderId == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: orderId');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/store/order/{order_id}'
|
||||
.replaceAll('{order_id}', orderId);
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -54,7 +49,7 @@ class StoreApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -84,7 +79,7 @@ class StoreApi {
|
||||
final path = r'/store/inventory';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -101,7 +96,7 @@ class StoreApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -109,7 +104,7 @@ class StoreApi {
|
||||
/// Returns pet inventories by status
|
||||
///
|
||||
/// Returns a map of status codes to quantities
|
||||
Future<Map<String, int>> getInventory() async {
|
||||
Future<Map<String, int>?> getInventory() async {
|
||||
final response = await getInventoryWithHttpInfo();
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -117,11 +112,11 @@ class StoreApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return Map<String, int>.from(await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Map<String, int>'),);
|
||||
|
||||
}
|
||||
return Future<Map<String, int>>.value();
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Find purchase order by ID
|
||||
@ -135,17 +130,12 @@ class StoreApi {
|
||||
/// * [int] orderId (required):
|
||||
/// ID of pet that needs to be fetched
|
||||
Future<Response> getOrderByIdWithHttpInfo(int orderId,) async {
|
||||
// Verify required params are set.
|
||||
if (orderId == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: orderId');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/store/order/{order_id}'
|
||||
.replaceAll('{order_id}', orderId.toString());
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -162,7 +152,7 @@ class StoreApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -175,7 +165,7 @@ class StoreApi {
|
||||
///
|
||||
/// * [int] orderId (required):
|
||||
/// ID of pet that needs to be fetched
|
||||
Future<Order> getOrderById(int orderId,) async {
|
||||
Future<Order?> getOrderById(int orderId,) async {
|
||||
final response = await getOrderByIdWithHttpInfo(orderId,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -183,11 +173,11 @@ class StoreApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Order',) as Order;
|
||||
|
||||
}
|
||||
return Future<Order>.value();
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Place an order for a pet
|
||||
@ -199,16 +189,11 @@ class StoreApi {
|
||||
/// * [Order] order (required):
|
||||
/// order placed for purchasing the pet
|
||||
Future<Response> placeOrderWithHttpInfo(Order order,) async {
|
||||
// Verify required params are set.
|
||||
if (order == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: order');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/store/order';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = order;
|
||||
Object? postBody = order;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -225,7 +210,7 @@ class StoreApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -236,7 +221,7 @@ class StoreApi {
|
||||
///
|
||||
/// * [Order] order (required):
|
||||
/// order placed for purchasing the pet
|
||||
Future<Order> placeOrder(Order order,) async {
|
||||
Future<Order?> placeOrder(Order order,) async {
|
||||
final response = await placeOrderWithHttpInfo(order,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -244,10 +229,10 @@ class StoreApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Order',) as Order;
|
||||
|
||||
}
|
||||
return Future<Order>.value();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -12,7 +12,7 @@ part of openapi.api;
|
||||
|
||||
|
||||
class UserApi {
|
||||
UserApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
UserApi([ApiClient? apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
|
||||
final ApiClient apiClient;
|
||||
|
||||
@ -27,16 +27,11 @@ class UserApi {
|
||||
/// * [User] user (required):
|
||||
/// Created user object
|
||||
Future<Response> createUserWithHttpInfo(User user,) async {
|
||||
// Verify required params are set.
|
||||
if (user == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/user';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = user;
|
||||
Object? postBody = user;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -53,7 +48,7 @@ class UserApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -82,16 +77,11 @@ class UserApi {
|
||||
/// * [List<User>] user (required):
|
||||
/// List of user object
|
||||
Future<Response> createUsersWithArrayInputWithHttpInfo(List<User> user,) async {
|
||||
// Verify required params are set.
|
||||
if (user == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/user/createWithArray';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = user;
|
||||
Object? postBody = user;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -108,7 +98,7 @@ class UserApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -135,16 +125,11 @@ class UserApi {
|
||||
/// * [List<User>] user (required):
|
||||
/// List of user object
|
||||
Future<Response> createUsersWithListInputWithHttpInfo(List<User> user,) async {
|
||||
// Verify required params are set.
|
||||
if (user == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/user/createWithList';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = user;
|
||||
Object? postBody = user;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -161,7 +146,7 @@ class UserApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -190,17 +175,12 @@ class UserApi {
|
||||
/// * [String] username (required):
|
||||
/// The name that needs to be deleted
|
||||
Future<Response> deleteUserWithHttpInfo(String username,) async {
|
||||
// Verify required params are set.
|
||||
if (username == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: username');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/user/{username}'
|
||||
.replaceAll('{username}', username);
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -217,7 +197,7 @@ class UserApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -246,17 +226,12 @@ class UserApi {
|
||||
/// * [String] username (required):
|
||||
/// The name that needs to be fetched. Use user1 for testing.
|
||||
Future<Response> getUserByNameWithHttpInfo(String username,) async {
|
||||
// Verify required params are set.
|
||||
if (username == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: username');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/user/{username}'
|
||||
.replaceAll('{username}', username);
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -273,7 +248,7 @@ class UserApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -284,7 +259,7 @@ class UserApi {
|
||||
///
|
||||
/// * [String] username (required):
|
||||
/// The name that needs to be fetched. Use user1 for testing.
|
||||
Future<User> getUserByName(String username,) async {
|
||||
Future<User?> getUserByName(String username,) async {
|
||||
final response = await getUserByNameWithHttpInfo(username,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -292,11 +267,11 @@ class UserApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'User',) as User;
|
||||
|
||||
}
|
||||
return Future<User>.value();
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Logs user into the system
|
||||
@ -311,26 +286,18 @@ class UserApi {
|
||||
/// * [String] password (required):
|
||||
/// The password for login in clear text
|
||||
Future<Response> loginUserWithHttpInfo(String username, String password,) async {
|
||||
// Verify required params are set.
|
||||
if (username == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: username');
|
||||
}
|
||||
if (password == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: password');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/user/login';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
final formParams = <String, String>{};
|
||||
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('', 'username', username));
|
||||
queryParams.addAll(_convertParametersForCollectionFormat('', 'password', password));
|
||||
queryParams.addAll(_queryParams('', 'username', username));
|
||||
queryParams.addAll(_queryParams('', 'password', password));
|
||||
|
||||
const authNames = <String>[];
|
||||
const contentTypes = <String>[];
|
||||
@ -343,7 +310,7 @@ class UserApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -357,7 +324,7 @@ class UserApi {
|
||||
///
|
||||
/// * [String] password (required):
|
||||
/// The password for login in clear text
|
||||
Future<String> loginUser(String username, String password,) async {
|
||||
Future<String?> loginUser(String username, String password,) async {
|
||||
final response = await loginUserWithHttpInfo(username, password,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
@ -365,11 +332,11 @@ class UserApi {
|
||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'String',) as String;
|
||||
|
||||
}
|
||||
return Future<String>.value();
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Logs out current logged in user session
|
||||
@ -380,7 +347,7 @@ class UserApi {
|
||||
final path = r'/user/logout';
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody;
|
||||
Object? postBody;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -397,7 +364,7 @@ class UserApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
@ -424,20 +391,12 @@ class UserApi {
|
||||
/// * [User] user (required):
|
||||
/// Updated user object
|
||||
Future<Response> updateUserWithHttpInfo(String username, User user,) async {
|
||||
// Verify required params are set.
|
||||
if (username == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: username');
|
||||
}
|
||||
if (user == null) {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/user/{username}'
|
||||
.replaceAll('{username}', username);
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object postBody = user;
|
||||
Object? postBody = user;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@ -454,7 +413,7 @@ class UserApi {
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentTypes.isEmpty ? null : contentTypes[0],
|
||||
contentTypes.isEmpty ? null : contentTypes.first,
|
||||
authNames,
|
||||
);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -30,12 +30,7 @@ class ApiClient {
|
||||
Client get client => _client;
|
||||
|
||||
/// Requests to use a new HTTP [Client] in this class.
|
||||
///
|
||||
/// If the [newClient] is null, an [ArgumentError] is thrown.
|
||||
set client(Client newClient) {
|
||||
if (newClient == null) {
|
||||
throw ArgumentError('New client instance cannot be null.');
|
||||
}
|
||||
_client = newClient;
|
||||
}
|
||||
|
||||
@ -52,7 +47,7 @@ class ApiClient {
|
||||
/// or deleted.
|
||||
Map<String, Authentication> get authentications => Map.unmodifiable(_authentications);
|
||||
|
||||
T getAuthentication<T extends Authentication>(String name) {
|
||||
T? getAuthentication<T extends Authentication>(String name) {
|
||||
final authentication = _authentications[name];
|
||||
return authentication is T ? authentication : null;
|
||||
}
|
||||
@ -63,35 +58,28 @@ class ApiClient {
|
||||
String path,
|
||||
String method,
|
||||
List<QueryParam> queryParams,
|
||||
Object body,
|
||||
Object? body,
|
||||
Map<String, String> headerParams,
|
||||
Map<String, String> formParams,
|
||||
String nullableContentType,
|
||||
String? contentType,
|
||||
List<String> authNames,
|
||||
) async {
|
||||
_updateParamsForAuth(authNames, queryParams, headerParams);
|
||||
|
||||
headerParams.addAll(_defaultHeaderMap);
|
||||
|
||||
final urlEncodedQueryParams = queryParams
|
||||
.where((param) => param.value != null)
|
||||
.map((param) => '$param');
|
||||
|
||||
final queryString = urlEncodedQueryParams.isNotEmpty
|
||||
? '?${urlEncodedQueryParams.join('&')}'
|
||||
: '';
|
||||
|
||||
final uri = Uri.parse('$basePath$path$queryString');
|
||||
|
||||
if (nullableContentType != null) {
|
||||
headerParams['Content-Type'] = nullableContentType;
|
||||
if (contentType != null) {
|
||||
headerParams['Content-Type'] = contentType;
|
||||
}
|
||||
|
||||
final urlEncodedQueryParams = queryParams.map((param) => '$param');
|
||||
final queryString = urlEncodedQueryParams.isNotEmpty ? '?${urlEncodedQueryParams.join('&')}' : '';
|
||||
final uri = Uri.parse('$basePath$path$queryString');
|
||||
|
||||
try {
|
||||
// Special case for uploading a single file which isn't a 'multipart/form-data'.
|
||||
if (
|
||||
body is MultipartFile && (nullableContentType == null ||
|
||||
!nullableContentType.toLowerCase().startsWith('multipart/form-data'))
|
||||
body is MultipartFile && (contentType == null ||
|
||||
!contentType.toLowerCase().startsWith('multipart/form-data'))
|
||||
) {
|
||||
final request = StreamedRequest(method, uri);
|
||||
request.headers.addAll(headerParams);
|
||||
@ -117,7 +105,7 @@ class ApiClient {
|
||||
return Response.fromStream(response);
|
||||
}
|
||||
|
||||
final msgBody = nullableContentType == 'application/x-www-form-urlencoded'
|
||||
final msgBody = contentType == 'application/x-www-form-urlencoded'
|
||||
? formParams
|
||||
: await serializeAsync(body);
|
||||
final nullableHeaderParams = headerParams.isEmpty ? null : headerParams;
|
||||
@ -130,41 +118,69 @@ class ApiClient {
|
||||
case 'HEAD': return await _client.head(uri, headers: nullableHeaderParams,);
|
||||
case 'GET': return await _client.get(uri, headers: nullableHeaderParams,);
|
||||
}
|
||||
} on SocketException catch (e, trace) {
|
||||
throw ApiException.withInner(HttpStatus.badRequest, 'Socket operation failed: $method $path', e, trace,);
|
||||
} on TlsException catch (e, trace) {
|
||||
throw ApiException.withInner(HttpStatus.badRequest, 'TLS/SSL communication failed: $method $path', e, trace,);
|
||||
} on IOException catch (e, trace) {
|
||||
throw ApiException.withInner(HttpStatus.badRequest, 'I/O operation failed: $method $path', e, trace,);
|
||||
} on ClientException catch (e, trace) {
|
||||
throw ApiException.withInner(HttpStatus.badRequest, 'HTTP connection failed: $method $path', e, trace,);
|
||||
} on Exception catch (e, trace) {
|
||||
throw ApiException.withInner(HttpStatus.badRequest, 'Exception occurred: $method $path', e, trace,);
|
||||
} on SocketException catch (error, trace) {
|
||||
throw ApiException.withInner(
|
||||
HttpStatus.badRequest,
|
||||
'Socket operation failed: $method $path',
|
||||
error,
|
||||
trace,
|
||||
);
|
||||
} on TlsException catch (error, trace) {
|
||||
throw ApiException.withInner(
|
||||
HttpStatus.badRequest,
|
||||
'TLS/SSL communication failed: $method $path',
|
||||
error,
|
||||
trace,
|
||||
);
|
||||
} on IOException catch (error, trace) {
|
||||
throw ApiException.withInner(
|
||||
HttpStatus.badRequest,
|
||||
'I/O operation failed: $method $path',
|
||||
error,
|
||||
trace,
|
||||
);
|
||||
} on ClientException catch (error, trace) {
|
||||
throw ApiException.withInner(
|
||||
HttpStatus.badRequest,
|
||||
'HTTP connection failed: $method $path',
|
||||
error,
|
||||
trace,
|
||||
);
|
||||
} on Exception catch (error, trace) {
|
||||
throw ApiException.withInner(
|
||||
HttpStatus.badRequest,
|
||||
'Exception occurred: $method $path',
|
||||
error,
|
||||
trace,
|
||||
);
|
||||
}
|
||||
|
||||
throw ApiException(HttpStatus.badRequest, 'Invalid HTTP operation: $method $path',);
|
||||
throw ApiException(
|
||||
HttpStatus.badRequest,
|
||||
'Invalid HTTP operation: $method $path',
|
||||
);
|
||||
}
|
||||
|
||||
Future<dynamic> deserializeAsync(String json, String targetType, {bool growable}) async =>
|
||||
Future<dynamic> deserializeAsync(String json, String targetType, {bool growable = false,}) async =>
|
||||
// ignore: deprecated_member_use_from_same_package
|
||||
deserialize(json, targetType, growable: growable);
|
||||
|
||||
@Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use deserializeAsync() instead.')
|
||||
dynamic deserialize(String json, String targetType, {bool growable}) {
|
||||
dynamic deserialize(String json, String targetType, {bool growable = false,}) {
|
||||
// Remove all spaces. Necessary for regular expressions as well.
|
||||
targetType = targetType.replaceAll(' ', ''); // ignore: parameter_assignments
|
||||
|
||||
// If the expected target type is String, nothing to do...
|
||||
return targetType == 'String'
|
||||
? json
|
||||
: _deserialize(jsonDecode(json), targetType, growable: growable == true);
|
||||
: _deserialize(jsonDecode(json), targetType, growable: growable);
|
||||
}
|
||||
|
||||
// ignore: deprecated_member_use_from_same_package
|
||||
Future<String> serializeAsync(Object value) async => serialize(value);
|
||||
Future<String> serializeAsync(Object? value) async => serialize(value);
|
||||
|
||||
@Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use serializeAsync() instead.')
|
||||
String serialize(Object value) => value == null ? '' : json.encode(value);
|
||||
String serialize(Object? value) => value == null ? '' : json.encode(value);
|
||||
|
||||
/// Update query and header parameters based on authentication settings.
|
||||
/// @param authNames The authentications to apply
|
||||
@ -182,7 +198,7 @@ class ApiClient {
|
||||
}
|
||||
}
|
||||
|
||||
static dynamic _deserialize(dynamic value, String targetType, {bool growable}) {
|
||||
static dynamic _deserialize(dynamic value, String targetType, {bool growable = false}) {
|
||||
try {
|
||||
switch (targetType) {
|
||||
case 'String':
|
||||
@ -290,24 +306,21 @@ class ApiClient {
|
||||
case 'User':
|
||||
return User.fromJson(value);
|
||||
default:
|
||||
Match match;
|
||||
if (value is List && (match = _regList.firstMatch(targetType)) != null) {
|
||||
targetType = match[1]; // ignore: parameter_assignments
|
||||
dynamic match;
|
||||
if (value is List && (match = _regList.firstMatch(targetType)?.group(1)) != null) {
|
||||
return value
|
||||
.map<dynamic>((dynamic v) => _deserialize(v, targetType, growable: growable))
|
||||
.map<dynamic>((dynamic v) => _deserialize(v, match, growable: growable,))
|
||||
.toList(growable: growable);
|
||||
}
|
||||
if (value is Set && (match = _regSet.firstMatch(targetType)) != null) {
|
||||
targetType = match[1]; // ignore: parameter_assignments
|
||||
if (value is Set && (match = _regSet.firstMatch(targetType)?.group(1)) != null) {
|
||||
return value
|
||||
.map<dynamic>((dynamic v) => _deserialize(v, targetType, growable: growable))
|
||||
.map<dynamic>((dynamic v) => _deserialize(v, match, growable: growable,))
|
||||
.toSet();
|
||||
}
|
||||
if (value is Map && (match = _regMap.firstMatch(targetType)) != null) {
|
||||
targetType = match[1]; // ignore: parameter_assignments
|
||||
if (value is Map && (match = _regMap.firstMatch(targetType)?.group(1)) != null) {
|
||||
return Map<String, dynamic>.fromIterables(
|
||||
value.keys.cast<String>(),
|
||||
value.values.map<dynamic>((dynamic v) => _deserialize(v, targetType, growable: growable)),
|
||||
value.values.map<dynamic>((dynamic v) => _deserialize(v, match, growable: growable,)),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -321,9 +334,9 @@ class ApiClient {
|
||||
/// Primarily intended for use in an isolate.
|
||||
class DeserializationMessage {
|
||||
const DeserializationMessage({
|
||||
@required this.json,
|
||||
@required this.targetType,
|
||||
this.growable,
|
||||
required this.json,
|
||||
required this.targetType,
|
||||
this.growable = false,
|
||||
});
|
||||
|
||||
/// The JSON value to deserialize.
|
||||
@ -347,9 +360,9 @@ Future<dynamic> deserializeAsync(DeserializationMessage message) async {
|
||||
: ApiClient._deserialize(
|
||||
jsonDecode(message.json),
|
||||
targetType,
|
||||
growable: message.growable == true,
|
||||
growable: message.growable,
|
||||
);
|
||||
}
|
||||
|
||||
/// Primarily intended for use in an isolate.
|
||||
Future<String> serializeAsync(Object value) async => value == null ? '' : json.encode(value);
|
||||
Future<String> serializeAsync(Object? value) async => value == null ? '' : json.encode(value);
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -16,9 +16,9 @@ class ApiException implements Exception {
|
||||
ApiException.withInner(this.code, this.message, this.innerException, this.stackTrace);
|
||||
|
||||
int code = 0;
|
||||
String message;
|
||||
Exception innerException;
|
||||
StackTrace stackTrace;
|
||||
String? message;
|
||||
Exception? innerException;
|
||||
StackTrace? stackTrace;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -21,32 +21,27 @@ class QueryParam {
|
||||
}
|
||||
|
||||
// Ported from the Java version.
|
||||
Iterable<QueryParam> _convertParametersForCollectionFormat(
|
||||
String collectionFormat,
|
||||
String name,
|
||||
dynamic value,
|
||||
) {
|
||||
Iterable<QueryParam> _queryParams(String collectionFormat, String name, dynamic value,) {
|
||||
// Assertions to run in debug mode only.
|
||||
assert(name.isNotEmpty, 'Parameter cannot be an empty string.');
|
||||
|
||||
final params = <QueryParam>[];
|
||||
|
||||
// preconditions
|
||||
if (name != null && name.isNotEmpty && value != null) {
|
||||
if (value is List) {
|
||||
if (collectionFormat == 'multi') {
|
||||
return value.map((dynamic v) => QueryParam(name, parameterToString(v)),);
|
||||
}
|
||||
|
||||
// Default collection format is 'csv'.
|
||||
if (collectionFormat == null || collectionFormat.isEmpty) {
|
||||
// ignore: parameter_assignments
|
||||
collectionFormat = 'csv';
|
||||
if (collectionFormat.isEmpty) {
|
||||
collectionFormat = 'csv'; // ignore: parameter_assignments
|
||||
}
|
||||
|
||||
final delimiter = _delimiters[collectionFormat] ?? ',';
|
||||
|
||||
params.add(QueryParam(name, value.map<dynamic>(parameterToString).join(delimiter)),);
|
||||
} else {
|
||||
params.add(QueryParam(name, parameterToString(value),));
|
||||
}
|
||||
params.add(QueryParam(name, value.map<dynamic>(parameterToString).join(delimiter),));
|
||||
} else if (value != null) {
|
||||
params.add(QueryParam(name, parameterToString(value)));
|
||||
}
|
||||
|
||||
return params;
|
||||
@ -83,27 +78,27 @@ String parameterToString(dynamic value) {
|
||||
Future<String> _decodeBodyBytes(Response response) async {
|
||||
final contentType = response.headers['content-type'];
|
||||
return contentType != null && contentType.toLowerCase().startsWith('application/json')
|
||||
? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes)
|
||||
? response.bodyBytes.isEmpty ? '' : utf8.decode(response.bodyBytes)
|
||||
: response.body;
|
||||
}
|
||||
|
||||
/// Returns a valid [T] value found at the specified Map [key], null otherwise.
|
||||
T mapValueOfType<T>(dynamic map, String key) {
|
||||
T? mapValueOfType<T>(dynamic map, String key) {
|
||||
final dynamic value = map is Map ? map[key] : null;
|
||||
return value is T ? value : null;
|
||||
}
|
||||
|
||||
/// Returns a valid Map<K, V> found at the specified Map [key], null otherwise.
|
||||
Map<K, V> mapCastOfType<K, V>(dynamic map, String key) {
|
||||
Map<K, V>? mapCastOfType<K, V>(dynamic map, String key) {
|
||||
final dynamic value = map is Map ? map[key] : null;
|
||||
return value is Map ? value.cast<K, V>() : null;
|
||||
}
|
||||
|
||||
/// Returns a valid [DateTime] found at the specified Map [key], null otherwise.
|
||||
DateTime mapDateTime(dynamic map, String key, [String pattern]) {
|
||||
DateTime? mapDateTime(dynamic map, String key, [String? pattern]) {
|
||||
final dynamic value = map is Map ? map[key] : null;
|
||||
if (value != null) {
|
||||
int millis;
|
||||
int? millis;
|
||||
if (value is int) {
|
||||
millis = value;
|
||||
} else if (value is String) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -16,23 +16,25 @@ class ApiKeyAuth implements Authentication {
|
||||
final String location;
|
||||
final String paramName;
|
||||
|
||||
String apiKeyPrefix;
|
||||
String apiKey;
|
||||
String apiKeyPrefix = '';
|
||||
String apiKey = '';
|
||||
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
final value = apiKeyPrefix == null ? apiKey : '$apiKeyPrefix $apiKey';
|
||||
final paramValue = apiKeyPrefix.isEmpty ? apiKey : '$apiKeyPrefix $apiKey';
|
||||
|
||||
if (location == 'query' && value != null) {
|
||||
queryParams.add(QueryParam(paramName, value));
|
||||
} else if (location == 'header' && value != null) {
|
||||
headerParams[paramName] = value;
|
||||
} else if (location == 'cookie' && value != null) {
|
||||
if (paramValue.isNotEmpty) {
|
||||
if (location == 'query') {
|
||||
queryParams.add(QueryParam(paramName, paramValue));
|
||||
} else if (location == 'header') {
|
||||
headerParams[paramName] = paramValue;
|
||||
} else if (location == 'cookie') {
|
||||
headerParams.update(
|
||||
'Cookie',
|
||||
(existingCookie) => '$existingCookie; $paramName=$value',
|
||||
ifAbsent: () => '$paramName=$value',
|
||||
(existingCookie) => '$existingCookie; $paramName=$paramValue',
|
||||
ifAbsent: () => '$paramName=$paramValue',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -11,12 +11,16 @@
|
||||
part of openapi.api;
|
||||
|
||||
class HttpBasicAuth implements Authentication {
|
||||
HttpBasicAuth({this.username = '', this.password = ''});
|
||||
|
||||
String username;
|
||||
String password;
|
||||
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
final credentials = '${username ?? ''}:${password ?? ''}';
|
||||
if (username.isNotEmpty && password.isNotEmpty) {
|
||||
final credentials = '$username:$password';
|
||||
headerParams['Authorization'] = 'Basic ${base64.encode(utf8.encode(credentials))}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -21,19 +21,29 @@ class HttpBearerAuth implements Authentication {
|
||||
|
||||
set accessToken(dynamic accessToken) {
|
||||
if (accessToken is! String && accessToken is! HttpBearerAuthProvider) {
|
||||
throw ArgumentError('Type of Bearer accessToken should be a String or a String Function().');
|
||||
throw ArgumentError('accessToken value must be either a String or a String Function().');
|
||||
}
|
||||
_accessToken = accessToken;
|
||||
}
|
||||
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
if (_accessToken == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String accessToken;
|
||||
|
||||
if (_accessToken is String) {
|
||||
headerParams['Authorization'] = 'Bearer $_accessToken';
|
||||
accessToken = _accessToken;
|
||||
} else if (_accessToken is HttpBearerAuthProvider) {
|
||||
headerParams['Authorization'] = 'Bearer ${_accessToken()}';
|
||||
accessToken = _accessToken!();
|
||||
} else {
|
||||
throw ArgumentError('Type of Bearer accessToken should be a String or a String Function().');
|
||||
return;
|
||||
}
|
||||
|
||||
if (accessToken.isNotEmpty) {
|
||||
headerParams['Authorization'] = 'Bearer $accessToken';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -11,13 +11,13 @@
|
||||
part of openapi.api;
|
||||
|
||||
class OAuth implements Authentication {
|
||||
OAuth({this.accessToken});
|
||||
OAuth({this.accessToken = ''});
|
||||
|
||||
String accessToken;
|
||||
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
if (accessToken != null) {
|
||||
if (accessToken.isNotEmpty) {
|
||||
headerParams['Authorization'] = 'Bearer $accessToken';
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -29,67 +29,89 @@ class AdditionalPropertiesClass {
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(mapProperty == null ? 0 : mapProperty.hashCode) +
|
||||
(mapOfMapProperty == null ? 0 : mapOfMapProperty.hashCode);
|
||||
(mapProperty.hashCode) +
|
||||
(mapOfMapProperty.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'AdditionalPropertiesClass[mapProperty=$mapProperty, mapOfMapProperty=$mapOfMapProperty]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final json = <String, dynamic>{};
|
||||
if (mapProperty != null) {
|
||||
json[r'map_property'] = mapProperty;
|
||||
}
|
||||
if (mapOfMapProperty != null) {
|
||||
json[r'map_of_map_property'] = mapOfMapProperty;
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
/// Returns a new [AdditionalPropertiesClass] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static AdditionalPropertiesClass fromJson(dynamic value) {
|
||||
static AdditionalPropertiesClass? fromJson(dynamic value) {
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
// Ensure that the map contains the required keys.
|
||||
// Note 1: the values aren't checked for validity beyond being non-null.
|
||||
// Note 2: this code is stripped in release mode!
|
||||
assert(() {
|
||||
requiredKeys.forEach((key) {
|
||||
assert(json.containsKey(key), 'Required key "AdditionalPropertiesClass[$key]" is missing from JSON.');
|
||||
assert(json[key] != null, 'Required key "AdditionalPropertiesClass[$key]" has a null value in JSON.');
|
||||
});
|
||||
return true;
|
||||
}());
|
||||
|
||||
return AdditionalPropertiesClass(
|
||||
mapProperty: mapCastOfType<String, String>(json, r'map_property'),
|
||||
mapOfMapProperty: mapCastOfType<String, dynamic>(json, r'map_of_map_property'),
|
||||
mapProperty: mapCastOfType<String, String>(json, r'map_property') ?? const {},
|
||||
mapOfMapProperty: mapCastOfType<String, dynamic>(json, r'map_of_map_property') ?? const {},
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<AdditionalPropertiesClass> listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) =>
|
||||
json is List && json.isNotEmpty
|
||||
? json.map(AdditionalPropertiesClass.fromJson).toList(growable: true == growable)
|
||||
: true == emptyIsNull ? null : <AdditionalPropertiesClass>[];
|
||||
static List<AdditionalPropertiesClass>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <AdditionalPropertiesClass>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = AdditionalPropertiesClass.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, AdditionalPropertiesClass> mapFromJson(dynamic json) {
|
||||
final map = <String, AdditionalPropertiesClass>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) => map[key] = AdditionalPropertiesClass.fromJson(value));
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = AdditionalPropertiesClass.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of AdditionalPropertiesClass-objects as value to a dart map
|
||||
static Map<String, List<AdditionalPropertiesClass>> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) {
|
||||
static Map<String, List<AdditionalPropertiesClass>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<AdditionalPropertiesClass>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) {
|
||||
map[key] = AdditionalPropertiesClass.listFromJson(
|
||||
value,
|
||||
emptyIsNull: emptyIsNull,
|
||||
growable: growable,
|
||||
);
|
||||
});
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = AdditionalPropertiesClass.listFromJson(entry.value, growable: growable,);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -13,7 +13,7 @@ part of openapi.api;
|
||||
class Animal {
|
||||
/// Returns a new [Animal] instance.
|
||||
Animal({
|
||||
@required this.className,
|
||||
required this.className,
|
||||
this.color = 'red',
|
||||
});
|
||||
|
||||
@ -29,8 +29,8 @@ class Animal {
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(className == null ? 0 : className.hashCode) +
|
||||
(color == null ? 0 : color.hashCode);
|
||||
(className.hashCode) +
|
||||
(color.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'Animal[className=$className, color=$color]';
|
||||
@ -38,56 +38,81 @@ class Animal {
|
||||
Map<String, dynamic> toJson() {
|
||||
final json = <String, dynamic>{};
|
||||
json[r'className'] = className;
|
||||
if (color != null) {
|
||||
json[r'color'] = color;
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
/// Returns a new [Animal] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static Animal fromJson(dynamic value) {
|
||||
static Animal? fromJson(dynamic value) {
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
// Ensure that the map contains the required keys.
|
||||
// Note 1: the values aren't checked for validity beyond being non-null.
|
||||
// Note 2: this code is stripped in release mode!
|
||||
assert(() {
|
||||
requiredKeys.forEach((key) {
|
||||
assert(json.containsKey(key), 'Required key "Animal[$key]" is missing from JSON.');
|
||||
assert(json[key] != null, 'Required key "Animal[$key]" has a null value in JSON.');
|
||||
});
|
||||
return true;
|
||||
}());
|
||||
|
||||
return Animal(
|
||||
className: mapValueOfType<String>(json, r'className'),
|
||||
color: mapValueOfType<String>(json, r'color'),
|
||||
className: mapValueOfType<String>(json, r'className')!,
|
||||
color: mapValueOfType<String>(json, r'color') ?? 'red',
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<Animal> listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) =>
|
||||
json is List && json.isNotEmpty
|
||||
? json.map(Animal.fromJson).toList(growable: true == growable)
|
||||
: true == emptyIsNull ? null : <Animal>[];
|
||||
static List<Animal>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <Animal>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = Animal.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, Animal> mapFromJson(dynamic json) {
|
||||
final map = <String, Animal>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) => map[key] = Animal.fromJson(value));
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = Animal.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of Animal-objects as value to a dart map
|
||||
static Map<String, List<Animal>> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) {
|
||||
static Map<String, List<Animal>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<Animal>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) {
|
||||
map[key] = Animal.listFromJson(
|
||||
value,
|
||||
emptyIsNull: emptyIsNull,
|
||||
growable: growable,
|
||||
);
|
||||
});
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = Animal.listFromJson(entry.value, growable: growable,);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
'className',
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -18,11 +18,29 @@ class ApiResponse {
|
||||
this.message,
|
||||
});
|
||||
|
||||
int code;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
int? code;
|
||||
|
||||
String type;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
String? type;
|
||||
|
||||
String message;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
String? message;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is ApiResponse &&
|
||||
@ -33,9 +51,9 @@ class ApiResponse {
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(code == null ? 0 : code.hashCode) +
|
||||
(type == null ? 0 : type.hashCode) +
|
||||
(message == null ? 0 : message.hashCode);
|
||||
(code == null ? 0 : code!.hashCode) +
|
||||
(type == null ? 0 : type!.hashCode) +
|
||||
(message == null ? 0 : message!.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'ApiResponse[code=$code, type=$type, message=$message]';
|
||||
@ -57,9 +75,21 @@ class ApiResponse {
|
||||
/// Returns a new [ApiResponse] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static ApiResponse fromJson(dynamic value) {
|
||||
static ApiResponse? fromJson(dynamic value) {
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
// Ensure that the map contains the required keys.
|
||||
// Note 1: the values aren't checked for validity beyond being non-null.
|
||||
// Note 2: this code is stripped in release mode!
|
||||
assert(() {
|
||||
requiredKeys.forEach((key) {
|
||||
assert(json.containsKey(key), 'Required key "ApiResponse[$key]" is missing from JSON.');
|
||||
assert(json[key] != null, 'Required key "ApiResponse[$key]" has a null value in JSON.');
|
||||
});
|
||||
return true;
|
||||
}());
|
||||
|
||||
return ApiResponse(
|
||||
code: mapValueOfType<int>(json, r'code'),
|
||||
type: mapValueOfType<String>(json, r'type'),
|
||||
@ -69,36 +99,50 @@ class ApiResponse {
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<ApiResponse> listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) =>
|
||||
json is List && json.isNotEmpty
|
||||
? json.map(ApiResponse.fromJson).toList(growable: true == growable)
|
||||
: true == emptyIsNull ? null : <ApiResponse>[];
|
||||
static List<ApiResponse>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <ApiResponse>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = ApiResponse.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, ApiResponse> mapFromJson(dynamic json) {
|
||||
final map = <String, ApiResponse>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) => map[key] = ApiResponse.fromJson(value));
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = ApiResponse.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of ApiResponse-objects as value to a dart map
|
||||
static Map<String, List<ApiResponse>> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) {
|
||||
static Map<String, List<ApiResponse>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<ApiResponse>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) {
|
||||
map[key] = ApiResponse.listFromJson(
|
||||
value,
|
||||
emptyIsNull: emptyIsNull,
|
||||
growable: growable,
|
||||
);
|
||||
});
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = ApiResponse.listFromJson(entry.value, growable: growable,);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -25,66 +25,90 @@ class ArrayOfArrayOfNumberOnly {
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(arrayArrayNumber == null ? 0 : arrayArrayNumber.hashCode);
|
||||
(arrayArrayNumber.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'ArrayOfArrayOfNumberOnly[arrayArrayNumber=$arrayArrayNumber]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final json = <String, dynamic>{};
|
||||
if (arrayArrayNumber != null) {
|
||||
json[r'ArrayArrayNumber'] = arrayArrayNumber;
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
/// Returns a new [ArrayOfArrayOfNumberOnly] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static ArrayOfArrayOfNumberOnly fromJson(dynamic value) {
|
||||
static ArrayOfArrayOfNumberOnly? fromJson(dynamic value) {
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
// Ensure that the map contains the required keys.
|
||||
// Note 1: the values aren't checked for validity beyond being non-null.
|
||||
// Note 2: this code is stripped in release mode!
|
||||
assert(() {
|
||||
requiredKeys.forEach((key) {
|
||||
assert(json.containsKey(key), 'Required key "ArrayOfArrayOfNumberOnly[$key]" is missing from JSON.');
|
||||
assert(json[key] != null, 'Required key "ArrayOfArrayOfNumberOnly[$key]" has a null value in JSON.');
|
||||
});
|
||||
return true;
|
||||
}());
|
||||
|
||||
return ArrayOfArrayOfNumberOnly(
|
||||
arrayArrayNumber: json[r'ArrayArrayNumber'] is List
|
||||
? (json[r'ArrayArrayNumber'] as List).map(
|
||||
(e) => e == null ? null : (e as List).cast<num>()
|
||||
).toList(growable: false)
|
||||
).toList()
|
||||
: null,
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<ArrayOfArrayOfNumberOnly> listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) =>
|
||||
json is List && json.isNotEmpty
|
||||
? json.map(ArrayOfArrayOfNumberOnly.fromJson).toList(growable: true == growable)
|
||||
: true == emptyIsNull ? null : <ArrayOfArrayOfNumberOnly>[];
|
||||
static List<ArrayOfArrayOfNumberOnly>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <ArrayOfArrayOfNumberOnly>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = ArrayOfArrayOfNumberOnly.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, ArrayOfArrayOfNumberOnly> mapFromJson(dynamic json) {
|
||||
final map = <String, ArrayOfArrayOfNumberOnly>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) => map[key] = ArrayOfArrayOfNumberOnly.fromJson(value));
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = ArrayOfArrayOfNumberOnly.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of ArrayOfArrayOfNumberOnly-objects as value to a dart map
|
||||
static Map<String, List<ArrayOfArrayOfNumberOnly>> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) {
|
||||
static Map<String, List<ArrayOfArrayOfNumberOnly>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<ArrayOfArrayOfNumberOnly>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) {
|
||||
map[key] = ArrayOfArrayOfNumberOnly.listFromJson(
|
||||
value,
|
||||
emptyIsNull: emptyIsNull,
|
||||
growable: growable,
|
||||
);
|
||||
});
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = ArrayOfArrayOfNumberOnly.listFromJson(entry.value, growable: growable,);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -25,64 +25,88 @@ class ArrayOfNumberOnly {
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(arrayNumber == null ? 0 : arrayNumber.hashCode);
|
||||
(arrayNumber.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'ArrayOfNumberOnly[arrayNumber=$arrayNumber]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final json = <String, dynamic>{};
|
||||
if (arrayNumber != null) {
|
||||
json[r'ArrayNumber'] = arrayNumber;
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
/// Returns a new [ArrayOfNumberOnly] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static ArrayOfNumberOnly fromJson(dynamic value) {
|
||||
static ArrayOfNumberOnly? fromJson(dynamic value) {
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
// Ensure that the map contains the required keys.
|
||||
// Note 1: the values aren't checked for validity beyond being non-null.
|
||||
// Note 2: this code is stripped in release mode!
|
||||
assert(() {
|
||||
requiredKeys.forEach((key) {
|
||||
assert(json.containsKey(key), 'Required key "ArrayOfNumberOnly[$key]" is missing from JSON.');
|
||||
assert(json[key] != null, 'Required key "ArrayOfNumberOnly[$key]" has a null value in JSON.');
|
||||
});
|
||||
return true;
|
||||
}());
|
||||
|
||||
return ArrayOfNumberOnly(
|
||||
arrayNumber: json[r'ArrayNumber'] is List
|
||||
? (json[r'ArrayNumber'] as List).cast<num>()
|
||||
: null,
|
||||
: const [],
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<ArrayOfNumberOnly> listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) =>
|
||||
json is List && json.isNotEmpty
|
||||
? json.map(ArrayOfNumberOnly.fromJson).toList(growable: true == growable)
|
||||
: true == emptyIsNull ? null : <ArrayOfNumberOnly>[];
|
||||
static List<ArrayOfNumberOnly>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <ArrayOfNumberOnly>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = ArrayOfNumberOnly.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, ArrayOfNumberOnly> mapFromJson(dynamic json) {
|
||||
final map = <String, ArrayOfNumberOnly>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) => map[key] = ArrayOfNumberOnly.fromJson(value));
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = ArrayOfNumberOnly.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of ArrayOfNumberOnly-objects as value to a dart map
|
||||
static Map<String, List<ArrayOfNumberOnly>> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) {
|
||||
static Map<String, List<ArrayOfNumberOnly>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<ArrayOfNumberOnly>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) {
|
||||
map[key] = ArrayOfNumberOnly.listFromJson(
|
||||
value,
|
||||
emptyIsNull: emptyIsNull,
|
||||
growable: growable,
|
||||
);
|
||||
});
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = ArrayOfNumberOnly.listFromJson(entry.value, growable: growable,);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -33,82 +33,102 @@ class ArrayTest {
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(arrayOfString == null ? 0 : arrayOfString.hashCode) +
|
||||
(arrayArrayOfInteger == null ? 0 : arrayArrayOfInteger.hashCode) +
|
||||
(arrayArrayOfModel == null ? 0 : arrayArrayOfModel.hashCode);
|
||||
(arrayOfString.hashCode) +
|
||||
(arrayArrayOfInteger.hashCode) +
|
||||
(arrayArrayOfModel.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'ArrayTest[arrayOfString=$arrayOfString, arrayArrayOfInteger=$arrayArrayOfInteger, arrayArrayOfModel=$arrayArrayOfModel]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final json = <String, dynamic>{};
|
||||
if (arrayOfString != null) {
|
||||
json[r'array_of_string'] = arrayOfString;
|
||||
}
|
||||
if (arrayArrayOfInteger != null) {
|
||||
json[r'array_array_of_integer'] = arrayArrayOfInteger;
|
||||
}
|
||||
if (arrayArrayOfModel != null) {
|
||||
json[r'array_array_of_model'] = arrayArrayOfModel;
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
/// Returns a new [ArrayTest] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static ArrayTest fromJson(dynamic value) {
|
||||
static ArrayTest? fromJson(dynamic value) {
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
// Ensure that the map contains the required keys.
|
||||
// Note 1: the values aren't checked for validity beyond being non-null.
|
||||
// Note 2: this code is stripped in release mode!
|
||||
assert(() {
|
||||
requiredKeys.forEach((key) {
|
||||
assert(json.containsKey(key), 'Required key "ArrayTest[$key]" is missing from JSON.');
|
||||
assert(json[key] != null, 'Required key "ArrayTest[$key]" has a null value in JSON.');
|
||||
});
|
||||
return true;
|
||||
}());
|
||||
|
||||
return ArrayTest(
|
||||
arrayOfString: json[r'array_of_string'] is List
|
||||
? (json[r'array_of_string'] as List).cast<String>()
|
||||
: null,
|
||||
: const [],
|
||||
arrayArrayOfInteger: json[r'array_array_of_integer'] is List
|
||||
? (json[r'array_array_of_integer'] as List).map(
|
||||
(e) => e == null ? null : (e as List).cast<int>()
|
||||
).toList(growable: false)
|
||||
).toList()
|
||||
: null,
|
||||
arrayArrayOfModel: json[r'array_array_of_model'] is List
|
||||
? (json[r'array_array_of_model'] as List).map(
|
||||
ReadOnlyFirst.listFromJson(json[r'array_array_of_model'])
|
||||
).toList(growable: false)
|
||||
).toList()
|
||||
: null,
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<ArrayTest> listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) =>
|
||||
json is List && json.isNotEmpty
|
||||
? json.map(ArrayTest.fromJson).toList(growable: true == growable)
|
||||
: true == emptyIsNull ? null : <ArrayTest>[];
|
||||
static List<ArrayTest>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <ArrayTest>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = ArrayTest.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, ArrayTest> mapFromJson(dynamic json) {
|
||||
final map = <String, ArrayTest>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) => map[key] = ArrayTest.fromJson(value));
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = ArrayTest.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of ArrayTest-objects as value to a dart map
|
||||
static Map<String, List<ArrayTest>> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) {
|
||||
static Map<String, List<ArrayTest>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<ArrayTest>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) {
|
||||
map[key] = ArrayTest.listFromJson(
|
||||
value,
|
||||
emptyIsNull: emptyIsNull,
|
||||
growable: growable,
|
||||
);
|
||||
});
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = ArrayTest.listFromJson(entry.value, growable: growable,);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -21,18 +21,54 @@ class Capitalization {
|
||||
this.ATT_NAME,
|
||||
});
|
||||
|
||||
String smallCamel;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
String? smallCamel;
|
||||
|
||||
String capitalCamel;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
String? capitalCamel;
|
||||
|
||||
String smallSnake;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
String? smallSnake;
|
||||
|
||||
String capitalSnake;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
String? capitalSnake;
|
||||
|
||||
String sCAETHFlowPoints;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
String? sCAETHFlowPoints;
|
||||
|
||||
/// Name of the pet
|
||||
String ATT_NAME;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
String? ATT_NAME;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is Capitalization &&
|
||||
@ -46,12 +82,12 @@ class Capitalization {
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(smallCamel == null ? 0 : smallCamel.hashCode) +
|
||||
(capitalCamel == null ? 0 : capitalCamel.hashCode) +
|
||||
(smallSnake == null ? 0 : smallSnake.hashCode) +
|
||||
(capitalSnake == null ? 0 : capitalSnake.hashCode) +
|
||||
(sCAETHFlowPoints == null ? 0 : sCAETHFlowPoints.hashCode) +
|
||||
(ATT_NAME == null ? 0 : ATT_NAME.hashCode);
|
||||
(smallCamel == null ? 0 : smallCamel!.hashCode) +
|
||||
(capitalCamel == null ? 0 : capitalCamel!.hashCode) +
|
||||
(smallSnake == null ? 0 : smallSnake!.hashCode) +
|
||||
(capitalSnake == null ? 0 : capitalSnake!.hashCode) +
|
||||
(sCAETHFlowPoints == null ? 0 : sCAETHFlowPoints!.hashCode) +
|
||||
(ATT_NAME == null ? 0 : ATT_NAME!.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'Capitalization[smallCamel=$smallCamel, capitalCamel=$capitalCamel, smallSnake=$smallSnake, capitalSnake=$capitalSnake, sCAETHFlowPoints=$sCAETHFlowPoints, ATT_NAME=$ATT_NAME]';
|
||||
@ -82,9 +118,21 @@ class Capitalization {
|
||||
/// Returns a new [Capitalization] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static Capitalization fromJson(dynamic value) {
|
||||
static Capitalization? fromJson(dynamic value) {
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
// Ensure that the map contains the required keys.
|
||||
// Note 1: the values aren't checked for validity beyond being non-null.
|
||||
// Note 2: this code is stripped in release mode!
|
||||
assert(() {
|
||||
requiredKeys.forEach((key) {
|
||||
assert(json.containsKey(key), 'Required key "Capitalization[$key]" is missing from JSON.');
|
||||
assert(json[key] != null, 'Required key "Capitalization[$key]" has a null value in JSON.');
|
||||
});
|
||||
return true;
|
||||
}());
|
||||
|
||||
return Capitalization(
|
||||
smallCamel: mapValueOfType<String>(json, r'smallCamel'),
|
||||
capitalCamel: mapValueOfType<String>(json, r'CapitalCamel'),
|
||||
@ -97,36 +145,50 @@ class Capitalization {
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<Capitalization> listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) =>
|
||||
json is List && json.isNotEmpty
|
||||
? json.map(Capitalization.fromJson).toList(growable: true == growable)
|
||||
: true == emptyIsNull ? null : <Capitalization>[];
|
||||
static List<Capitalization>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <Capitalization>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = Capitalization.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, Capitalization> mapFromJson(dynamic json) {
|
||||
final map = <String, Capitalization>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) => map[key] = Capitalization.fromJson(value));
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = Capitalization.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of Capitalization-objects as value to a dart map
|
||||
static Map<String, List<Capitalization>> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) {
|
||||
static Map<String, List<Capitalization>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<Capitalization>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) {
|
||||
map[key] = Capitalization.listFromJson(
|
||||
value,
|
||||
emptyIsNull: emptyIsNull,
|
||||
growable: growable,
|
||||
);
|
||||
});
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = Capitalization.listFromJson(entry.value, growable: growable,);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -13,7 +13,7 @@ part of openapi.api;
|
||||
class Cat {
|
||||
/// Returns a new [Cat] instance.
|
||||
Cat({
|
||||
@required this.className,
|
||||
required this.className,
|
||||
this.color = 'red',
|
||||
this.declawed,
|
||||
});
|
||||
@ -22,7 +22,13 @@ class Cat {
|
||||
|
||||
String color;
|
||||
|
||||
bool declawed;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
bool? declawed;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is Cat &&
|
||||
@ -33,9 +39,9 @@ class Cat {
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(className == null ? 0 : className.hashCode) +
|
||||
(color == null ? 0 : color.hashCode) +
|
||||
(declawed == null ? 0 : declawed.hashCode);
|
||||
(className.hashCode) +
|
||||
(color.hashCode) +
|
||||
(declawed == null ? 0 : declawed!.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'Cat[className=$className, color=$color, declawed=$declawed]';
|
||||
@ -43,9 +49,7 @@ class Cat {
|
||||
Map<String, dynamic> toJson() {
|
||||
final json = <String, dynamic>{};
|
||||
json[r'className'] = className;
|
||||
if (color != null) {
|
||||
json[r'color'] = color;
|
||||
}
|
||||
if (declawed != null) {
|
||||
json[r'declawed'] = declawed;
|
||||
}
|
||||
@ -55,48 +59,75 @@ class Cat {
|
||||
/// Returns a new [Cat] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static Cat fromJson(dynamic value) {
|
||||
static Cat? fromJson(dynamic value) {
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
// Ensure that the map contains the required keys.
|
||||
// Note 1: the values aren't checked for validity beyond being non-null.
|
||||
// Note 2: this code is stripped in release mode!
|
||||
assert(() {
|
||||
requiredKeys.forEach((key) {
|
||||
assert(json.containsKey(key), 'Required key "Cat[$key]" is missing from JSON.');
|
||||
assert(json[key] != null, 'Required key "Cat[$key]" has a null value in JSON.');
|
||||
});
|
||||
return true;
|
||||
}());
|
||||
|
||||
return Cat(
|
||||
className: mapValueOfType<String>(json, r'className'),
|
||||
color: mapValueOfType<String>(json, r'color'),
|
||||
className: mapValueOfType<String>(json, r'className')!,
|
||||
color: mapValueOfType<String>(json, r'color') ?? 'red',
|
||||
declawed: mapValueOfType<bool>(json, r'declawed'),
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<Cat> listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) =>
|
||||
json is List && json.isNotEmpty
|
||||
? json.map(Cat.fromJson).toList(growable: true == growable)
|
||||
: true == emptyIsNull ? null : <Cat>[];
|
||||
static List<Cat>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <Cat>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = Cat.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, Cat> mapFromJson(dynamic json) {
|
||||
final map = <String, Cat>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) => map[key] = Cat.fromJson(value));
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = Cat.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of Cat-objects as value to a dart map
|
||||
static Map<String, List<Cat>> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) {
|
||||
static Map<String, List<Cat>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<Cat>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) {
|
||||
map[key] = Cat.listFromJson(
|
||||
value,
|
||||
emptyIsNull: emptyIsNull,
|
||||
growable: growable,
|
||||
);
|
||||
});
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = Cat.listFromJson(entry.value, growable: growable,);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
'className',
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.0
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
@ -16,7 +16,13 @@ class CatAllOf {
|
||||
this.declawed,
|
||||
});
|
||||
|
||||
bool declawed;
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
bool? declawed;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is CatAllOf &&
|
||||
@ -25,7 +31,7 @@ class CatAllOf {
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(declawed == null ? 0 : declawed.hashCode);
|
||||
(declawed == null ? 0 : declawed!.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'CatAllOf[declawed=$declawed]';
|
||||
@ -41,9 +47,21 @@ class CatAllOf {
|
||||
/// Returns a new [CatAllOf] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static CatAllOf fromJson(dynamic value) {
|
||||
static CatAllOf? fromJson(dynamic value) {
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
// Ensure that the map contains the required keys.
|
||||
// Note 1: the values aren't checked for validity beyond being non-null.
|
||||
// Note 2: this code is stripped in release mode!
|
||||
assert(() {
|
||||
requiredKeys.forEach((key) {
|
||||
assert(json.containsKey(key), 'Required key "CatAllOf[$key]" is missing from JSON.');
|
||||
assert(json[key] != null, 'Required key "CatAllOf[$key]" has a null value in JSON.');
|
||||
});
|
||||
return true;
|
||||
}());
|
||||
|
||||
return CatAllOf(
|
||||
declawed: mapValueOfType<bool>(json, r'declawed'),
|
||||
);
|
||||
@ -51,36 +69,50 @@ class CatAllOf {
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<CatAllOf> listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) =>
|
||||
json is List && json.isNotEmpty
|
||||
? json.map(CatAllOf.fromJson).toList(growable: true == growable)
|
||||
: true == emptyIsNull ? null : <CatAllOf>[];
|
||||
static List<CatAllOf>? listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <CatAllOf>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = CatAllOf.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, CatAllOf> mapFromJson(dynamic json) {
|
||||
final map = <String, CatAllOf>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) => map[key] = CatAllOf.fromJson(value));
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = CatAllOf.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of CatAllOf-objects as value to a dart map
|
||||
static Map<String, List<CatAllOf>> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) {
|
||||
static Map<String, List<CatAllOf>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<CatAllOf>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json
|
||||
.cast<String, dynamic>()
|
||||
.forEach((key, dynamic value) {
|
||||
map[key] = CatAllOf.listFromJson(
|
||||
value,
|
||||
emptyIsNull: emptyIsNull,
|
||||
growable: growable,
|
||||
);
|
||||
});
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = CatAllOf.listFromJson(entry.value, growable: growable,);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
};
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user