diff --git a/modules/openapi-generator/src/main/resources/dart2/analysis_options.mustache b/modules/openapi-generator/src/main/resources/dart2/analysis_options.mustache index 83d5a10bd7b..e69de29bb2d 100644 --- a/modules/openapi-generator/src/main/resources/dart2/analysis_options.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/analysis_options.mustache @@ -1,3 +0,0 @@ -analyzer: - strong-mode: - implicit-casts: true diff --git a/modules/openapi-generator/src/main/resources/dart2/api.mustache b/modules/openapi-generator/src/main/resources/dart2/api.mustache index b86bdb02228..c16db47c110 100644 --- a/modules/openapi-generator/src/main/resources/dart2/api.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/api.mustache @@ -49,7 +49,7 @@ class {{{classname}}} { /// {{/-last}} {{/allParams}} - Future {{{nickname}}}WithHttpInfo({{#allParams}}{{#required}}{{{dataType}}} {{{paramName}}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}} {{{paramName}}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async { + Future {{{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}} @@ -61,9 +61,11 @@ class {{{classname}}} { {{/allParams}} {{/hasParams}} + // ignore: prefer_const_declarations final path = r'{{{path}}}'{{#pathParams}} - .replaceAll('{' + '{{{baseName}}}' + '}', {{{paramName}}}.toString()){{/pathParams}}; + .replaceAll({{=<% %>=}}'{<% baseName %>}'<%={{ }}=%>, {{{paramName}}}{{^isString}}.toString(){{/isString}}){{/pathParams}}; + // ignore: prefer_final_locals Object postBody{{#bodyParam}} = {{{paramName}}}{{/bodyParam}}; final queryParams = []; @@ -95,9 +97,8 @@ class {{{classname}}} { {{/headerParams}} {{/hasHeaderParams}} - final contentTypes = [{{#prioritizedContentTypes}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/prioritizedContentTypes}}]; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = [{{#authMethods}}'{{{name}}}'{{^-last}}, {{/-last}}{{/authMethods}}]; + const authNames = [{{#authMethods}}'{{{name}}}'{{^-last}}, {{/-last}}{{/authMethods}}]; + const contentTypes = [{{#prioritizedContentTypes}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/prioritizedContentTypes}}]; {{#isMultipart}} bool hasFields = false; @@ -131,14 +132,14 @@ class {{{classname}}} { {{/formParams}} {{/isMultipart}} - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, '{{{httpMethod}}}', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -173,8 +174,8 @@ 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 { - final response = await {{{nickname}}}WithHttpInfo({{#allParams}}{{#required}}{{{paramName}}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}} {{#allParams}}{{^required}}{{{paramName}}}: {{{paramName}}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}} {{/hasOptionalParams}}); + 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 { + 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)); } @@ -185,7 +186,8 @@ class {{{classname}}} { if (response.body != null && response.statusCode != HttpStatus.noContent) { {{#native_serialization}} {{#isArray}} - return (await apiClient.deserializeAsync(await _decodeBodyBytes(response), '{{{returnType}}}') as List) + final responseBody = await _decodeBodyBytes(response); + return (await apiClient.deserializeAsync(responseBody, '{{{returnType}}}') as List) .cast<{{{returnBaseType}}}>() .{{#uniqueItems}}toSet(){{/uniqueItems}}{{^uniqueItems}}toList(growable: false){{/uniqueItems}}; {{/isArray}} @@ -223,7 +225,7 @@ class {{{classname}}} { {{/isArray}} {{/json_serializable}} } - return Future<{{{returnType}}}>.value(null); + return Future<{{{returnType}}}>.value(); {{/returnType}} } {{/operation}} diff --git a/modules/openapi-generator/src/main/resources/dart2/api_client.mustache b/modules/openapi-generator/src/main/resources/dart2/api_client.mustache index 822fe2912c8..85be6bc9376 100644 --- a/modules/openapi-generator/src/main/resources/dart2/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/api_client.mustache @@ -84,7 +84,7 @@ class ApiClient { ? '?${urlEncodedQueryParams.join('&')}' : ''; - final Uri uri = Uri.parse('$basePath$path$queryString'); + final uri = Uri.parse('$basePath$path$queryString'); if (nullableContentType != null) { headerParams['Content-Type'] = nullableContentType; @@ -102,7 +102,8 @@ class ApiClient { body.finalize().listen( request.sink.add, onDone: request.sink.close, - onError: (error, trace) => request.sink.close(), + // ignore: avoid_types_on_closure_parameters + onError: (Object error, StackTrace trace) => request.sink.close(), cancelOnError: true, ); final response = await _client.send(request); @@ -191,18 +192,17 @@ class ApiClient { try { switch (targetType) { case 'String': - return '$value'; + return value is String ? value : value.toString(); case 'int': return value is int ? value : int.parse('$value'); + case 'double': + return value is double ? value : double.parse('$value'); case 'bool': if (value is bool) { return value; } final valueString = '$value'.toLowerCase(); return valueString == 'true' || valueString == '1'; - break; - case 'double': - return value is double ? value : double.parse('$value'); {{#models}} {{#model}} case '{{{classname}}}': @@ -220,25 +220,24 @@ class ApiClient { if (value is List && (match = _regList.firstMatch(targetType)) != null) { targetType = match[1]; // ignore: parameter_assignments return value - .map((v) => _deserialize(v, targetType, growable: growable)) + .map((dynamic v) => _deserialize(v, targetType, growable: growable)) .toList(growable: growable); } if (value is Set && (match = _regSet.firstMatch(targetType)) != null) { targetType = match[1]; // ignore: parameter_assignments return value - .map((v) => _deserialize(v, targetType, growable: growable)) + .map((dynamic v) => _deserialize(v, targetType, growable: growable)) .toSet(); } if (value is Map && (match = _regMap.firstMatch(targetType)) != null) { targetType = match[1]; // ignore: parameter_assignments - return Map.fromIterables( - value.keys, - value.values.map((v) => _deserialize(v, targetType, growable: growable)), + return Map.fromIterables( + value.keys.cast(), + value.values.map((dynamic v) => _deserialize(v, targetType, growable: growable)), ); } - break; } - } catch (error, trace) { + } on Exception catch (error, trace) { throw ApiException.withInner(HttpStatus.internalServerError, 'Exception during deserialization.', error, trace,); } throw ApiException(HttpStatus.internalServerError, 'Could not find a suitable class for deserialization',); diff --git a/modules/openapi-generator/src/main/resources/dart2/api_helper.mustache b/modules/openapi-generator/src/main/resources/dart2/api_helper.mustache index e99fbb0505d..c64effcdda0 100644 --- a/modules/openapi-generator/src/main/resources/dart2/api_helper.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/api_helper.mustache @@ -21,20 +21,21 @@ Iterable _convertParametersForCollectionFormat( // preconditions if (name != null && name.isNotEmpty && value != null) { if (value is List) { - // get the collection format, default: csv - collectionFormat = (collectionFormat == null || collectionFormat.isEmpty) - ? 'csv' - : collectionFormat; - if (collectionFormat == 'multi') { - return value.map((v) => QueryParam(name, parameterToString(v))); + return value.map((dynamic v) => QueryParam(name, parameterToString(v)),); + } + + // Default collection format is 'csv'. + if (collectionFormat == null || collectionFormat.isEmpty) { + // ignore: parameter_assignments + collectionFormat = 'csv'; } final delimiter = _delimiters[collectionFormat] ?? ','; - params.add(QueryParam(name, value.map((v) => parameterToString(v)).join(delimiter))); + params.add(QueryParam(name, value.map(parameterToString).join(delimiter)),); } else { - params.add(QueryParam(name, parameterToString(value))); + params.add(QueryParam(name, parameterToString(value),)); } } @@ -69,3 +70,36 @@ Future _decodeBodyBytes(Response response) async { ? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes) : response.body; } + +/// Returns a valid [T] value found at the specified Map [key], null otherwise. +T mapValueOfType(dynamic map, String key) { + final dynamic value = map is Map ? map[key] : null; + return value is T ? value : null; +} + +/// Returns a valid Map found at the specified Map [key], null otherwise. +Map mapCastOfType(dynamic map, String key) { + final dynamic value = map is Map ? map[key] : null; + return value is Map ? value.cast() : null; +} + +/// Returns a valid [DateTime] found at the specified Map [key], null otherwise. +DateTime mapDateTime(dynamic map, String key, [String pattern]) { + final dynamic value = map is Map ? map[key] : null; + if (value != null) { + int millis; + if (value is int) { + millis = value; + } else if (value is String) { + if (pattern == _dateEpochMarker) { + millis = int.tryParse(value); + } else { + return DateTime.tryParse(value); + } + } + if (millis != null) { + return DateTime.fromMillisecondsSinceEpoch(millis, isUtc: true); + } + } + return null; +} diff --git a/modules/openapi-generator/src/main/resources/dart2/auth/api_key_auth.mustache b/modules/openapi-generator/src/main/resources/dart2/auth/api_key_auth.mustache index b3aa05f2f68..f5d602880de 100644 --- a/modules/openapi-generator/src/main/resources/dart2/auth/api_key_auth.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/auth/api_key_auth.mustache @@ -18,9 +18,11 @@ class ApiKeyAuth implements Authentication { } else if (location == 'header' && value != null) { headerParams[paramName] = value; } else if (location == 'cookie' && value != null) { - headerParams.update('Cookie', (String existingCookie) { - return '$existingCookie; $paramName=$value'; - }, ifAbsent: () => '$paramName=$value'); + headerParams.update( + 'Cookie', + (existingCookie) => '$existingCookie; $paramName=$value', + ifAbsent: () => '$paramName=$value', + ); } } } diff --git a/modules/openapi-generator/src/main/resources/dart2/auth/authentication.mustache b/modules/openapi-generator/src/main/resources/dart2/auth/authentication.mustache index ec754159c2d..e8aaaa4d541 100644 --- a/modules/openapi-generator/src/main/resources/dart2/auth/authentication.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/auth/authentication.mustache @@ -1,5 +1,6 @@ {{>header}} {{>part_of}} +// ignore: one_member_abstracts abstract class Authentication { /// Apply authentication settings to header and query params. void applyToParams(List queryParams, Map headerParams); diff --git a/modules/openapi-generator/src/main/resources/dart2/auth/header.mustache b/modules/openapi-generator/src/main/resources/dart2/auth/header.mustache index db48248792a..341e14bf9e6 100644 --- a/modules/openapi-generator/src/main/resources/dart2/auth/header.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/auth/header.mustache @@ -5,4 +5,5 @@ // 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 diff --git a/modules/openapi-generator/src/main/resources/dart2/auth/http_basic_auth.mustache b/modules/openapi-generator/src/main/resources/dart2/auth/http_basic_auth.mustache index 8be1da065a0..6098ba5661e 100644 --- a/modules/openapi-generator/src/main/resources/dart2/auth/http_basic_auth.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/auth/http_basic_auth.mustache @@ -6,7 +6,7 @@ class HttpBasicAuth implements Authentication { @override void applyToParams(List queryParams, Map headerParams) { - final credentials = (username ?? '') + ':' + (password ?? ''); + final credentials = '${username ?? ''}:${password ?? ''}'; headerParams['Authorization'] = 'Basic ${base64.encode(utf8.encode(credentials))}'; } } diff --git a/modules/openapi-generator/src/main/resources/dart2/auth/http_bearer_auth.mustache b/modules/openapi-generator/src/main/resources/dart2/auth/http_bearer_auth.mustache index 21469bdb088..1260ff9c99d 100644 --- a/modules/openapi-generator/src/main/resources/dart2/auth/http_bearer_auth.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/auth/http_bearer_auth.mustache @@ -13,7 +13,7 @@ class HttpBearerAuth implements Authentication { if (accessToken is! String && accessToken is! HttpBearerAuthProvider) { throw ArgumentError('Type of Bearer accessToken should be a String or a String Function().'); } - this._accessToken = accessToken; + _accessToken = accessToken; } @override diff --git a/modules/openapi-generator/src/main/resources/dart2/header.mustache b/modules/openapi-generator/src/main/resources/dart2/header.mustache index db48248792a..341e14bf9e6 100644 --- a/modules/openapi-generator/src/main/resources/dart2/header.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/header.mustache @@ -5,4 +5,5 @@ // 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 diff --git a/modules/openapi-generator/src/main/resources/dart2/serialization/json_serializable/json_serializable_class.mustache b/modules/openapi-generator/src/main/resources/dart2/serialization/json_serializable/json_serializable_class.mustache index f3c1ba77cb6..ec97f23eb72 100644 --- a/modules/openapi-generator/src/main/resources/dart2/serialization/json_serializable/json_serializable_class.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/serialization/json_serializable/json_serializable_class.mustache @@ -49,10 +49,7 @@ class {{{classname}}} { Map toJson() => _${{{classname}}}ToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } {{#vars}} {{#isEnum}} diff --git a/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_class.mustache b/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_class.mustache index 396236bd6f5..0efe1455c4b 100644 --- a/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_class.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_class.mustache @@ -24,6 +24,7 @@ class {{{classname}}} { @override int get hashCode => + // ignore: unnecessary_parenthesis {{#vars}} ({{{name}}} == null ? 0 : {{{name}}}.hashCode){{^-last}} +{{/-last}}{{#-last}};{{/-last}} {{/vars}} @@ -70,152 +71,143 @@ class {{{classname}}} { } /// Returns a new [{{{classname}}}] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static {{{classname}}} fromJson(Map json) => json == null - ? null - : {{{classname}}}( + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static {{{classname}}} fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return {{{classname}}}( {{#vars}} - {{#isDateTime}} - {{{name}}}: json[r'{{{baseName}}}'] == null - ? null - {{#pattern}} - : _dateEpochMarker == '{{{pattern}}}' - ? DateTime.fromMillisecondsSinceEpoch(json[r'{{{baseName}}}'] as int, isUtc: true) - : DateTime.parse(json[r'{{{baseName}}}']), - {{/pattern}} - {{^pattern}} - : DateTime.parse(json[r'{{{baseName}}}']), - {{/pattern}} - {{/isDateTime}} - {{#isDate}} - {{{name}}}: json[r'{{{baseName}}}'] == null - ? null - {{#pattern}} - : _dateEpochMarker == '{{{pattern}}}' - ? DateTime.fromMillisecondsSinceEpoch(json[r'{{{baseName}}}'] as int, isUtc: true) - : DateTime.parse(json[r'{{{baseName}}}']), - {{/pattern}} - {{^pattern}} - : DateTime.parse(json[r'{{{baseName}}}']), - {{/pattern}} - {{/isDate}} - {{^isDateTime}} - {{^isDate}} - {{#complexType}} - {{#isArray}} - {{#items.isArray}} - {{{name}}}: json[r'{{{baseName}}}'] == null - ? null - : (json[r'{{{baseName}}}'] as List).map( - {{#items.complexType}} - {{items.complexType}}.listFromJson(json[r'{{{baseName}}}']) - {{/items.complexType}} - {{^items.complexType}} - (e) => e == null ? null : (e as List).cast<{{items.items.dataType}}>() - {{/items.complexType}} - ).toList(growable: false), - {{/items.isArray}} - {{^items.isArray}} - {{{name}}}: {{{complexType}}}.listFromJson(json[r'{{{baseName}}}']), - {{/items.isArray}} - {{/isArray}} - {{^isArray}} - {{#isMap}} - {{#items.isArray}} - {{{name}}}: json[r'{{{baseName}}}'] == null - ? null + {{#isDateTime}} + {{{name}}}: mapDateTime(json, r'{{{baseName}}}', '{{{pattern}}}'), + {{/isDateTime}} + {{#isDate}} + {{{name}}}: mapDateTime(json, r'{{{baseName}}}', '{{{pattern}}}'), + {{/isDate}} + {{^isDateTime}} + {{^isDate}} + {{#complexType}} + {{#isArray}} + {{#items.isArray}} + {{{name}}}: json[r'{{{baseName}}}'] is List + ? (json[r'{{{baseName}}}'] as List).map( {{#items.complexType}} - : {{items.complexType}}.mapListFromJson(json[r'{{{baseName}}}']), + {{items.complexType}}.listFromJson(json[r'{{{baseName}}}']) {{/items.complexType}} {{^items.complexType}} - : (json[r'{{{baseName}}}'] as Map).cast(), + (e) => e == null ? null : (e as List).cast<{{items.items.dataType}}>() {{/items.complexType}} - {{/items.isArray}} - {{^items.isArray}} - {{#items.isMap}} + ).toList(growable: false) + : null, + {{/items.isArray}} + {{^items.isArray}} + {{{name}}}: {{{complexType}}}.listFromJson(json[r'{{{baseName}}}']), + {{/items.isArray}} + {{/isArray}} + {{^isArray}} + {{#isMap}} + {{#items.isArray}} {{{name}}}: json[r'{{{baseName}}}'] == null ? null - {{#items.complexType}} - : {{items.complexType}}.mapFromJson(json[r'{{{baseName}}}']), - {{/items.complexType}} - {{^items.complexType}} - : (json[r'{{{baseName}}}'] as Map).cast(), - {{/items.complexType}} - {{/items.isMap}} - {{^items.isMap}} - {{{name}}}: json[r'{{{baseName}}}'] - {{/items.isMap}} - {{/items.isArray}} - {{/isMap}} - {{^isMap}} - {{#isBinary}} + {{#items.complexType}} + : {{items.complexType}}.mapListFromJson(json[r'{{{baseName}}}']), + {{/items.complexType}} + {{^items.complexType}} + : mapCastOfType(json, r'{{{baseName}}}'), + {{/items.complexType}} + {{/items.isArray}} + {{^items.isArray}} + {{#items.isMap}} + {{#items.complexType}} + {{{name}}}: {{items.complexType}}.mapFromJson(json[r'{{{baseName}}}']), + {{/items.complexType}} + {{^items.complexType}} + {{{name}}}: mapCastOfType(json, r'{{{baseName}}}'), + {{/items.complexType}} + {{/items.isMap}} + {{^items.isMap}} + {{{name}}}: mapValueOfType<{{{datatypeWithEnum}}}>(json, r'{{{baseName}}}'), + {{/items.isMap}} + {{/items.isArray}} + {{/isMap}} + {{^isMap}} + {{#isBinary}} {{{name}}}: null, // No support for decoding binary content from JSON - {{/isBinary}} - {{^isBinary}} + {{/isBinary}} + {{^isBinary}} {{{name}}}: {{{complexType}}}.fromJson(json[r'{{{baseName}}}']), - {{/isBinary}} - {{/isMap}} - {{/isArray}} - {{/complexType}} - {{^complexType}} - {{#isArray}} - {{#isEnum}} + {{/isBinary}} + {{/isMap}} + {{/isArray}} + {{/complexType}} + {{^complexType}} + {{#isArray}} + {{#isEnum}} {{{name}}}: {{{items.datatypeWithEnum}}}.listFromJson(json[r'{{{baseName}}}']), - {{/isEnum}} - {{^isEnum}} + {{/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, + {{/isEnum}} + {{/isArray}} + {{^isArray}} + {{#isMap}} + {{{name}}}: mapCastOfType(json, r'{{{baseName}}}'), + {{/isMap}} + {{^isMap}} + {{#isNumber}} {{{name}}}: json[r'{{{baseName}}}'] == null ? null - : (json[r'{{{baseName}}}'] as {{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}).cast<{{{items.datatype}}}>(), - {{/isEnum}} - {{/isArray}} - {{^isArray}} - {{#isMap}} - {{{name}}}: json[r'{{{baseName}}}'] == null ? - null : - (json[r'{{{baseName}}}'] as Map).cast(), - {{/isMap}} - {{^isMap}} - {{#isNumber}} - {{{name}}}: json[r'{{{baseName}}}'] == null ? - null : - json[r'{{{baseName}}}'].toDouble(), - {{/isNumber}} - {{^isNumber}} - {{^isEnum}} - {{{name}}}: json[r'{{{baseName}}}'], - {{/isEnum}} - {{#isEnum}} + : {{{datatypeWithEnum}}}.parse(json[r'{{{baseName}}}'].toString()), + {{/isNumber}} + {{^isNumber}} + {{^isEnum}} + {{{name}}}: mapValueOfType<{{{datatypeWithEnum}}}>(json, r'{{{baseName}}}'), + {{/isEnum}} + {{#isEnum}} {{{name}}}: {{{enumName}}}.fromJson(json[r'{{{baseName}}}']), - {{/isEnum}} - {{/isNumber}} - {{/isMap}} - {{/isArray}} - {{/complexType}} - {{/isDate}} - {{/isDateTime}} + {{/isEnum}} + {{/isNumber}} + {{/isMap}} + {{/isArray}} + {{/complexType}} + {{/isDate}} + {{/isDateTime}} {{/vars}} - ); + ); + } + return null; + } - static List<{{{classname}}}> listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : <{{{classname}}}>[] - : json.map((dynamic value) => {{{classname}}}.fromJson(value)).toList(growable: true == growable); + 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 Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = {{{classname}}}.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = {{{classname}}}.fromJson(value)); } return map; } // maps a json object with a list of {{{classname}}}-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = {{{classname}}}.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = {{{classname}}}.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_enum.mustache b/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_enum.mustache index e9c7e5d2d72..f686a20a2f6 100644 --- a/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_enum.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_enum.mustache @@ -7,7 +7,7 @@ class {{{classname}}} { final {{{dataType}}} value; @override - String toString() => value{{^isString}}.toString(){{/isString}}; + String toString() => {{#isString}}value ?? ''{{/isString}}{{^isString}}value == null ? '' : value.toString(){{/isString}}; {{{dataType}}} toJson() => value; @@ -29,20 +29,18 @@ class {{{classname}}} { static {{{classname}}} fromJson(dynamic value) => {{{classname}}}TypeTransformer().decode(value); - static List<{{{classname}}}> listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : <{{{classname}}}>[] - : json - .map((value) => {{{classname}}}.fromJson(value)) - .toList(growable: true == growable); + 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}}}>[]; } /// Transformation class that can [encode] an instance of [{{{classname}}}] to {{{dataType}}}, /// and [decode] dynamic data back to [{{{classname}}}]. class {{{classname}}}TypeTransformer { - const {{{classname}}}TypeTransformer._(); + factory {{{classname}}}TypeTransformer() => _instance ??= const {{{classname}}}TypeTransformer._(); - factory {{{classname}}}TypeTransformer() => _instance ??= {{{classname}}}TypeTransformer._(); + const {{{classname}}}TypeTransformer._(); {{{dataType}}} encode({{{classname}}} data) => data.value; @@ -55,20 +53,22 @@ 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}) { - switch (data) { - {{#allowableValues}} - {{#enumVars}} - case {{#isString}}r{{/isString}}{{{value}}}: return {{{classname}}}.{{{name}}}; - {{/enumVars}} - {{/allowableValues}} - default: - if (allowNull == false) { - throw ArgumentError('Unknown enum value to decode: $data'); - } + if (data != null) { + switch (data.toString()) { + {{#allowableValues}} + {{#enumVars}} + case {{#isString}}r{{/isString}}{{{value}}}: return {{{classname}}}.{{{name}}}; + {{/enumVars}} + {{/allowableValues}} + default: + if (allowNull == false) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } } return null; } /// Singleton [{{{classname}}}TypeTransformer] instance. static {{{classname}}}TypeTransformer _instance; -} \ No newline at end of file +} diff --git a/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_enum_inline.mustache b/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_enum_inline.mustache index 139f4d02879..d01b1676aad 100644 --- a/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_enum_inline.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_enum_inline.mustache @@ -7,7 +7,7 @@ class {{{enumName}}} { final {{{dataType}}} value; @override - String toString() => value{{^isString}}.toString(){{/isString}}; + String toString() => {{#isString}}value ?? ''{{/isString}}{{^isString}}value == null ? '' : value.toString(){{/isString}}; {{{dataType}}} toJson() => value; @@ -29,20 +29,18 @@ class {{{enumName}}} { static {{{enumName}}} fromJson(dynamic value) => {{{enumName}}}TypeTransformer().decode(value); - static List<{{{enumName}}}> listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : <{{{enumName}}}>[] - : json - .map((value) => {{{enumName}}}.fromJson(value)) - .toList(growable: true == growable); + 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}}}>[]; } /// Transformation class that can [encode] an instance of [{{{enumName}}}] to {{{dataType}}}, /// and [decode] dynamic data back to [{{{enumName}}}]. class {{{enumName}}}TypeTransformer { - const {{{enumName}}}TypeTransformer._(); + factory {{{enumName}}}TypeTransformer() => _instance ??= const {{{enumName}}}TypeTransformer._(); - factory {{{enumName}}}TypeTransformer() => _instance ??= {{{enumName}}}TypeTransformer._(); + const {{{enumName}}}TypeTransformer._(); {{{dataType}}} encode({{{enumName}}} data) => data.value; @@ -55,20 +53,22 @@ 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}) { - switch (data) { - {{#allowableValues}} - {{#enumVars}} - case {{#isString}}r{{/isString}}{{{value}}}: return {{{enumName}}}.{{{name}}}; - {{/enumVars}} - {{/allowableValues}} - default: - if (allowNull == false) { - throw ArgumentError('Unknown enum value to decode: $data'); - } + if (data != null) { + switch (data.toString()) { + {{#allowableValues}} + {{#enumVars}} + case {{#isString}}r{{/isString}}{{{value}}}: return {{{enumName}}}.{{{name}}}; + {{/enumVars}} + {{/allowableValues}} + default: + if (allowNull == false) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } } return null; } /// Singleton [{{{enumName}}}TypeTransformer] instance. static {{{enumName}}}TypeTransformer _instance; -} \ No newline at end of file +} diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/analysis_options.yaml b/samples/openapi3/client/petstore/dart2/petstore_client_lib/analysis_options.yaml index 83d5a10bd7b..e69de29bb2d 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/analysis_options.yaml +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/analysis_options.yaml @@ -1,3 +0,0 @@ -analyzer: - strong-mode: - implicit-casts: true diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api.dart index f6bf3e75908..e67b60f2670 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api.dart @@ -5,6 +5,7 @@ // 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 library openapi.api; diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/pet_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/pet_api.dart index ee5c6f0d24c..2b7e10416d2 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/pet_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/pet_api.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -23,33 +24,34 @@ class PetApi { /// /// * [Pet] pet (required): /// Pet object that needs to be added to the store - Future addPetWithHttpInfo(Pet pet) async { + Future 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json', 'application/xml']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['petstore_auth']; + const authNames = ['petstore_auth']; + const contentTypes = ['application/json', 'application/xml']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -60,8 +62,8 @@ class PetApi { /// /// * [Pet] pet (required): /// Pet object that needs to be added to the store - Future addPet(Pet pet) async { - final response = await addPetWithHttpInfo(pet); + Future addPet(Pet pet,) async { + final response = await addPetWithHttpInfo(pet,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -71,7 +73,7 @@ class PetApi { if (response.body != null && response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Pet',) as Pet; } - return Future.value(null); + return Future.value(); } /// Deletes a pet @@ -84,15 +86,17 @@ class PetApi { /// Pet id to delete /// /// * [String] apiKey: - Future deletePetWithHttpInfo(int petId, { String apiKey }) async { + Future deletePetWithHttpInfo(int petId, { String apiKey, }) 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()); + .replaceAll('{petId}', petId.toString()); + // ignore: prefer_final_locals Object postBody; final queryParams = []; @@ -103,19 +107,18 @@ class PetApi { headerParams[r'api_key'] = parameterToString(apiKey); } - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['petstore_auth']; + const authNames = ['petstore_auth']; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'DELETE', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -128,8 +131,8 @@ class PetApi { /// Pet id to delete /// /// * [String] apiKey: - Future deletePet(int petId, { String apiKey }) async { - final response = await deletePetWithHttpInfo(petId, apiKey: apiKey ); + Future 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)); } @@ -145,14 +148,16 @@ class PetApi { /// /// * [List] status (required): /// Status values that need to be considered for filter - Future findPetsByStatusWithHttpInfo(List status) async { + Future findPetsByStatusWithHttpInfo(List 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; final queryParams = []; @@ -161,19 +166,18 @@ class PetApi { queryParams.addAll(_convertParametersForCollectionFormat('csv', 'status', status)); - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['petstore_auth']; + const authNames = ['petstore_auth']; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -186,8 +190,8 @@ class PetApi { /// /// * [List] status (required): /// Status values that need to be considered for filter - Future> findPetsByStatus(List status) async { - final response = await findPetsByStatusWithHttpInfo(status); + Future> findPetsByStatus(List status,) async { + final response = await findPetsByStatusWithHttpInfo(status,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -195,11 +199,12 @@ class PetApi { // 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) { - return (await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'List') as List) + final responseBody = await _decodeBodyBytes(response); + return (await apiClient.deserializeAsync(responseBody, 'List') as List) .cast() .toList(growable: false); } - return Future>.value(null); + return Future>.value(); } /// Finds Pets by tags @@ -212,14 +217,16 @@ class PetApi { /// /// * [List] tags (required): /// Tags to filter by - Future findPetsByTagsWithHttpInfo(List tags) async { + Future findPetsByTagsWithHttpInfo(List 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; final queryParams = []; @@ -228,19 +235,18 @@ class PetApi { queryParams.addAll(_convertParametersForCollectionFormat('csv', 'tags', tags)); - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['petstore_auth']; + const authNames = ['petstore_auth']; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -253,8 +259,8 @@ class PetApi { /// /// * [List] tags (required): /// Tags to filter by - Future> findPetsByTags(List tags) async { - final response = await findPetsByTagsWithHttpInfo(tags); + Future> findPetsByTags(List tags,) async { + final response = await findPetsByTagsWithHttpInfo(tags,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -262,11 +268,12 @@ class PetApi { // 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) { - return (await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'List') as List) + final responseBody = await _decodeBodyBytes(response); + return (await apiClient.deserializeAsync(responseBody, 'List') as List) .cast() .toList(growable: false); } - return Future>.value(null); + return Future>.value(); } /// Find pet by ID @@ -279,34 +286,35 @@ class PetApi { /// /// * [int] petId (required): /// ID of pet to return - Future getPetByIdWithHttpInfo(int petId) async { + Future 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()); + .replaceAll('{petId}', petId.toString()); + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['api_key']; + const authNames = ['api_key']; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -319,8 +327,8 @@ class PetApi { /// /// * [int] petId (required): /// ID of pet to return - Future getPetById(int petId) async { - final response = await getPetByIdWithHttpInfo(petId); + Future getPetById(int petId,) async { + final response = await getPetByIdWithHttpInfo(petId,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -330,7 +338,7 @@ class PetApi { if (response.body != null && response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Pet',) as Pet; } - return Future.value(null); + return Future.value(); } /// Update an existing pet @@ -341,33 +349,34 @@ class PetApi { /// /// * [Pet] pet (required): /// Pet object that needs to be added to the store - Future updatePetWithHttpInfo(Pet pet) async { + Future 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json', 'application/xml']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['petstore_auth']; + const authNames = ['petstore_auth']; + const contentTypes = ['application/json', 'application/xml']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'PUT', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -378,8 +387,8 @@ class PetApi { /// /// * [Pet] pet (required): /// Pet object that needs to be added to the store - Future updatePet(Pet pet) async { - final response = await updatePetWithHttpInfo(pet); + Future updatePet(Pet pet,) async { + final response = await updatePetWithHttpInfo(pet,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -389,7 +398,7 @@ class PetApi { if (response.body != null && response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Pet',) as Pet; } - return Future.value(null); + return Future.value(); } /// Updates a pet in the store with form data @@ -406,24 +415,25 @@ class PetApi { /// /// * [String] status: /// Updated status of the pet - Future updatePetWithFormWithHttpInfo(int petId, { String name, String status }) async { + Future updatePetWithFormWithHttpInfo(int petId, { String name, String status, }) 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()); + .replaceAll('{petId}', petId.toString()); + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/x-www-form-urlencoded']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['petstore_auth']; + const authNames = ['petstore_auth']; + const contentTypes = ['application/x-www-form-urlencoded']; if (name != null) { formParams[r'name'] = parameterToString(name); @@ -432,14 +442,14 @@ class PetApi { formParams[r'status'] = parameterToString(status); } - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -456,8 +466,8 @@ class PetApi { /// /// * [String] status: /// Updated status of the pet - Future updatePetWithForm(int petId, { String name, String status }) async { - final response = await updatePetWithFormWithHttpInfo(petId, name: name, status: status ); + Future 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)); } @@ -477,24 +487,25 @@ class PetApi { /// /// * [MultipartFile] file: /// file to upload - Future uploadFileWithHttpInfo(int petId, { String additionalMetadata, MultipartFile file }) async { + Future uploadFileWithHttpInfo(int petId, { String additionalMetadata, MultipartFile file, }) 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}/uploadImage' - .replaceAll('{' + 'petId' + '}', petId.toString()); + .replaceAll('{petId}', petId.toString()); + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['multipart/form-data']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['petstore_auth']; + const authNames = ['petstore_auth']; + const contentTypes = ['multipart/form-data']; bool hasFields = false; final mp = MultipartRequest('POST', Uri.parse(path)); @@ -511,14 +522,14 @@ class PetApi { postBody = mp; } - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -535,8 +546,8 @@ class PetApi { /// /// * [MultipartFile] file: /// file to upload - Future uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async { - final response = await uploadFileWithHttpInfo(petId, additionalMetadata: additionalMetadata, file: file ); + Future 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)); } @@ -546,6 +557,6 @@ class PetApi { if (response.body != null && response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ApiResponse',) as ApiResponse; } - return Future.value(null); + return Future.value(); } } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/store_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/store_api.dart index 4ff0cee3e1a..9a02b1f9510 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/store_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/store_api.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -25,34 +26,35 @@ class StoreApi { /// /// * [String] orderId (required): /// ID of the order that needs to be deleted - Future deleteOrderWithHttpInfo(String orderId) async { + Future 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.toString()); + .replaceAll('{orderId}', orderId); + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'DELETE', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -65,8 +67,8 @@ class StoreApi { /// /// * [String] orderId (required): /// ID of the order that needs to be deleted - Future deleteOrder(String orderId) async { - final response = await deleteOrderWithHttpInfo(orderId); + Future deleteOrder(String orderId,) async { + final response = await deleteOrderWithHttpInfo(orderId,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -78,27 +80,28 @@ class StoreApi { /// /// Note: This method returns the HTTP [Response]. Future getInventoryWithHttpInfo() async { + // ignore: prefer_const_declarations final path = r'/store/inventory'; + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['api_key']; + const authNames = ['api_key']; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -117,7 +120,7 @@ class StoreApi { if (response.body != null && response.statusCode != HttpStatus.noContent) { return Map.from(await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Map'),); } - return Future>.value(null); + return Future>.value(); } /// Find purchase order by ID @@ -130,34 +133,35 @@ class StoreApi { /// /// * [int] orderId (required): /// ID of pet that needs to be fetched - Future getOrderByIdWithHttpInfo(int orderId) async { + Future 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()); + .replaceAll('{orderId}', orderId.toString()); + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -170,8 +174,8 @@ class StoreApi { /// /// * [int] orderId (required): /// ID of pet that needs to be fetched - Future getOrderById(int orderId) async { - final response = await getOrderByIdWithHttpInfo(orderId); + Future getOrderById(int orderId,) async { + final response = await getOrderByIdWithHttpInfo(orderId,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -181,7 +185,7 @@ class StoreApi { if (response.body != null && response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Order',) as Order; } - return Future.value(null); + return Future.value(); } /// Place an order for a pet @@ -192,33 +196,34 @@ class StoreApi { /// /// * [Order] order (required): /// order placed for purchasing the pet - Future placeOrderWithHttpInfo(Order order) async { + Future 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -229,8 +234,8 @@ class StoreApi { /// /// * [Order] order (required): /// order placed for purchasing the pet - Future placeOrder(Order order) async { - final response = await placeOrderWithHttpInfo(order); + Future placeOrder(Order order,) async { + final response = await placeOrderWithHttpInfo(order,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -240,6 +245,6 @@ class StoreApi { if (response.body != null && response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Order',) as Order; } - return Future.value(null); + return Future.value(); } } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/user_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/user_api.dart index 274b176291b..22f0fb7b25f 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/user_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/user_api.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -25,33 +26,34 @@ class UserApi { /// /// * [User] user (required): /// Created user object - Future createUserWithHttpInfo(User user) async { + Future 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['api_key']; + const authNames = ['api_key']; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -64,8 +66,8 @@ class UserApi { /// /// * [User] user (required): /// Created user object - Future createUser(User user) async { - final response = await createUserWithHttpInfo(user); + Future createUser(User user,) async { + final response = await createUserWithHttpInfo(user,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -79,33 +81,34 @@ class UserApi { /// /// * [List] user (required): /// List of user object - Future createUsersWithArrayInputWithHttpInfo(List user) async { + Future createUsersWithArrayInputWithHttpInfo(List 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['api_key']; + const authNames = ['api_key']; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -116,8 +119,8 @@ class UserApi { /// /// * [List] user (required): /// List of user object - Future createUsersWithArrayInput(List user) async { - final response = await createUsersWithArrayInputWithHttpInfo(user); + Future createUsersWithArrayInput(List user,) async { + final response = await createUsersWithArrayInputWithHttpInfo(user,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -131,33 +134,34 @@ class UserApi { /// /// * [List] user (required): /// List of user object - Future createUsersWithListInputWithHttpInfo(List user) async { + Future createUsersWithListInputWithHttpInfo(List 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['api_key']; + const authNames = ['api_key']; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -168,8 +172,8 @@ class UserApi { /// /// * [List] user (required): /// List of user object - Future createUsersWithListInput(List user) async { - final response = await createUsersWithListInputWithHttpInfo(user); + Future createUsersWithListInput(List user,) async { + final response = await createUsersWithListInputWithHttpInfo(user,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -185,34 +189,35 @@ class UserApi { /// /// * [String] username (required): /// The name that needs to be deleted - Future deleteUserWithHttpInfo(String username) async { + Future 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.toString()); + .replaceAll('{username}', username); + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['api_key']; + const authNames = ['api_key']; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'DELETE', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -225,8 +230,8 @@ class UserApi { /// /// * [String] username (required): /// The name that needs to be deleted - Future deleteUser(String username) async { - final response = await deleteUserWithHttpInfo(username); + Future deleteUser(String username,) async { + final response = await deleteUserWithHttpInfo(username,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -240,34 +245,35 @@ class UserApi { /// /// * [String] username (required): /// The name that needs to be fetched. Use user1 for testing. - Future getUserByNameWithHttpInfo(String username) async { + Future 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.toString()); + .replaceAll('{username}', username); + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -278,8 +284,8 @@ class UserApi { /// /// * [String] username (required): /// The name that needs to be fetched. Use user1 for testing. - Future getUserByName(String username) async { - final response = await getUserByNameWithHttpInfo(username); + Future getUserByName(String username,) async { + final response = await getUserByNameWithHttpInfo(username,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -289,7 +295,7 @@ class UserApi { if (response.body != null && response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'User',) as User; } - return Future.value(null); + return Future.value(); } /// Logs user into the system @@ -303,7 +309,7 @@ class UserApi { /// /// * [String] password (required): /// The password for login in clear text - Future loginUserWithHttpInfo(String username, String password) async { + Future loginUserWithHttpInfo(String username, String password,) async { // Verify required params are set. if (username == null) { throw ApiException(HttpStatus.badRequest, 'Missing required param: username'); @@ -312,8 +318,10 @@ class UserApi { throw ApiException(HttpStatus.badRequest, 'Missing required param: password'); } + // ignore: prefer_const_declarations final path = r'/user/login'; + // ignore: prefer_final_locals Object postBody; final queryParams = []; @@ -323,19 +331,18 @@ class UserApi { queryParams.addAll(_convertParametersForCollectionFormat('', 'username', username)); queryParams.addAll(_convertParametersForCollectionFormat('', 'password', password)); - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -349,8 +356,8 @@ class UserApi { /// /// * [String] password (required): /// The password for login in clear text - Future loginUser(String username, String password) async { - final response = await loginUserWithHttpInfo(username, password); + Future loginUser(String username, String password,) async { + final response = await loginUserWithHttpInfo(username, password,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -360,34 +367,35 @@ class UserApi { if (response.body != null && response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'String',) as String; } - return Future.value(null); + return Future.value(); } /// Logs out current logged in user session /// /// Note: This method returns the HTTP [Response]. Future logoutUserWithHttpInfo() async { + // ignore: prefer_const_declarations final path = r'/user/logout'; + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['api_key']; + const authNames = ['api_key']; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -413,7 +421,7 @@ class UserApi { /// /// * [User] user (required): /// Updated user object - Future updateUserWithHttpInfo(String username, User user) async { + Future updateUserWithHttpInfo(String username, User user,) async { // Verify required params are set. if (username == null) { throw ApiException(HttpStatus.badRequest, 'Missing required param: username'); @@ -422,28 +430,29 @@ class UserApi { throw ApiException(HttpStatus.badRequest, 'Missing required param: user'); } + // ignore: prefer_const_declarations final path = r'/user/{username}' - .replaceAll('{' + 'username' + '}', username.toString()); + .replaceAll('{username}', username); + // ignore: prefer_final_locals Object postBody = user; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['api_key']; + const authNames = ['api_key']; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'PUT', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -459,8 +468,8 @@ class UserApi { /// /// * [User] user (required): /// Updated user object - Future updateUser(String username, User user) async { - final response = await updateUserWithHttpInfo(username, user); + Future updateUser(String username, User user,) async { + final response = await updateUserWithHttpInfo(username, user,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api_client.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api_client.dart index 8833c281a29..93057a79a7b 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api_client.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api_client.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -77,7 +78,7 @@ class ApiClient { ? '?${urlEncodedQueryParams.join('&')}' : ''; - final Uri uri = Uri.parse('$basePath$path$queryString'); + final uri = Uri.parse('$basePath$path$queryString'); if (nullableContentType != null) { headerParams['Content-Type'] = nullableContentType; @@ -95,7 +96,8 @@ class ApiClient { body.finalize().listen( request.sink.add, onDone: request.sink.close, - onError: (error, trace) => request.sink.close(), + // ignore: avoid_types_on_closure_parameters + onError: (Object error, StackTrace trace) => request.sink.close(), cancelOnError: true, ); final response = await _client.send(request); @@ -181,18 +183,17 @@ class ApiClient { try { switch (targetType) { case 'String': - return '$value'; + return value is String ? value : value.toString(); case 'int': return value is int ? value : int.parse('$value'); + case 'double': + return value is double ? value : double.parse('$value'); case 'bool': if (value is bool) { return value; } final valueString = '$value'.toLowerCase(); return valueString == 'true' || valueString == '1'; - break; - case 'double': - return value is double ? value : double.parse('$value'); case 'ApiResponse': return ApiResponse.fromJson(value); case 'Category': @@ -210,25 +211,24 @@ class ApiClient { if (value is List && (match = _regList.firstMatch(targetType)) != null) { targetType = match[1]; // ignore: parameter_assignments return value - .map((v) => _deserialize(v, targetType, growable: growable)) + .map((dynamic v) => _deserialize(v, targetType, growable: growable)) .toList(growable: growable); } if (value is Set && (match = _regSet.firstMatch(targetType)) != null) { targetType = match[1]; // ignore: parameter_assignments return value - .map((v) => _deserialize(v, targetType, growable: growable)) + .map((dynamic v) => _deserialize(v, targetType, growable: growable)) .toSet(); } if (value is Map && (match = _regMap.firstMatch(targetType)) != null) { targetType = match[1]; // ignore: parameter_assignments - return Map.fromIterables( - value.keys, - value.values.map((v) => _deserialize(v, targetType, growable: growable)), + return Map.fromIterables( + value.keys.cast(), + value.values.map((dynamic v) => _deserialize(v, targetType, growable: growable)), ); } - break; } - } catch (error, trace) { + } on Exception catch (error, trace) { throw ApiException.withInner(HttpStatus.internalServerError, 'Exception during deserialization.', error, trace,); } throw ApiException(HttpStatus.internalServerError, 'Could not find a suitable class for deserialization',); diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api_exception.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api_exception.dart index 86e2054bffe..8ffc340b4c9 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api_exception.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api_exception.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api_helper.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api_helper.dart index cb1db7f0a01..cf97058bec2 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api_helper.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api_helper.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -30,20 +31,21 @@ Iterable _convertParametersForCollectionFormat( // preconditions if (name != null && name.isNotEmpty && value != null) { if (value is List) { - // get the collection format, default: csv - collectionFormat = (collectionFormat == null || collectionFormat.isEmpty) - ? 'csv' - : collectionFormat; - if (collectionFormat == 'multi') { - return value.map((v) => QueryParam(name, parameterToString(v))); + return value.map((dynamic v) => QueryParam(name, parameterToString(v)),); + } + + // Default collection format is 'csv'. + if (collectionFormat == null || collectionFormat.isEmpty) { + // ignore: parameter_assignments + collectionFormat = 'csv'; } final delimiter = _delimiters[collectionFormat] ?? ','; - params.add(QueryParam(name, value.map((v) => parameterToString(v)).join(delimiter))); + params.add(QueryParam(name, value.map(parameterToString).join(delimiter)),); } else { - params.add(QueryParam(name, parameterToString(value))); + params.add(QueryParam(name, parameterToString(value),)); } } @@ -69,3 +71,36 @@ Future _decodeBodyBytes(Response response) async { ? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes) : response.body; } + +/// Returns a valid [T] value found at the specified Map [key], null otherwise. +T mapValueOfType(dynamic map, String key) { + final dynamic value = map is Map ? map[key] : null; + return value is T ? value : null; +} + +/// Returns a valid Map found at the specified Map [key], null otherwise. +Map mapCastOfType(dynamic map, String key) { + final dynamic value = map is Map ? map[key] : null; + return value is Map ? value.cast() : null; +} + +/// Returns a valid [DateTime] found at the specified Map [key], null otherwise. +DateTime mapDateTime(dynamic map, String key, [String pattern]) { + final dynamic value = map is Map ? map[key] : null; + if (value != null) { + int millis; + if (value is int) { + millis = value; + } else if (value is String) { + if (pattern == _dateEpochMarker) { + millis = int.tryParse(value); + } else { + return DateTime.tryParse(value); + } + } + if (millis != null) { + return DateTime.fromMillisecondsSinceEpoch(millis, isUtc: true); + } + } + return null; +} diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/auth/api_key_auth.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/auth/api_key_auth.dart index 41a4afd85d9..0c2303af09e 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/auth/api_key_auth.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/auth/api_key_auth.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -27,9 +28,11 @@ class ApiKeyAuth implements Authentication { } else if (location == 'header' && value != null) { headerParams[paramName] = value; } else if (location == 'cookie' && value != null) { - headerParams.update('Cookie', (String existingCookie) { - return '$existingCookie; $paramName=$value'; - }, ifAbsent: () => '$paramName=$value'); + headerParams.update( + 'Cookie', + (existingCookie) => '$existingCookie; $paramName=$value', + ifAbsent: () => '$paramName=$value', + ); } } } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/auth/authentication.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/auth/authentication.dart index 5ca198d41fd..4257e190006 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/auth/authentication.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/auth/authentication.dart @@ -5,10 +5,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 part of openapi.api; +// ignore: one_member_abstracts abstract class Authentication { /// Apply authentication settings to header and query params. void applyToParams(List queryParams, Map headerParams); diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/auth/http_basic_auth.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/auth/http_basic_auth.dart index 6dc36a13f49..0494f402d95 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/auth/http_basic_auth.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/auth/http_basic_auth.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -15,7 +16,7 @@ class HttpBasicAuth implements Authentication { @override void applyToParams(List queryParams, Map headerParams) { - final credentials = (username ?? '') + ':' + (password ?? ''); + final credentials = '${username ?? ''}:${password ?? ''}'; headerParams['Authorization'] = 'Basic ${base64.encode(utf8.encode(credentials))}'; } } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/auth/http_bearer_auth.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/auth/http_bearer_auth.dart index a23b65fac5e..23e243523dd 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/auth/http_bearer_auth.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/auth/http_bearer_auth.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -22,7 +23,7 @@ class HttpBearerAuth implements Authentication { if (accessToken is! String && accessToken is! HttpBearerAuthProvider) { throw ArgumentError('Type of Bearer accessToken should be a String or a String Function().'); } - this._accessToken = accessToken; + _accessToken = accessToken; } @override diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/auth/oauth.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/auth/oauth.dart index c0463ad3900..9299ac13f5b 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/auth/oauth.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/auth/oauth.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/api_response.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/api_response.dart index 6bb070b7eeb..bfd43366211 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/api_response.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/api_response.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -31,6 +32,7 @@ class ApiResponse { @override int get hashCode => + // ignore: unnecessary_parenthesis (code == null ? 0 : code.hashCode) + (type == null ? 0 : type.hashCode) + (message == null ? 0 : message.hashCode); @@ -53,35 +55,48 @@ class ApiResponse { } /// Returns a new [ApiResponse] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static ApiResponse fromJson(Map json) => json == null - ? null - : ApiResponse( - code: json[r'code'], - type: json[r'type'], - message: json[r'message'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static ApiResponse fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return ApiResponse( + code: mapValueOfType(json, r'code'), + type: mapValueOfType(json, r'type'), + message: mapValueOfType(json, r'message'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => ApiResponse.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(ApiResponse.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = ApiResponse.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = ApiResponse.fromJson(value)); } return map; } // maps a json object with a list of ApiResponse-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = ApiResponse.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = ApiResponse.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/category.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/category.dart index c1c25b5a078..50ad28ee006 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/category.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/category.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -27,6 +28,7 @@ class Category { @override int get hashCode => + // ignore: unnecessary_parenthesis (id == null ? 0 : id.hashCode) + (name == null ? 0 : name.hashCode); @@ -45,34 +47,47 @@ class Category { } /// Returns a new [Category] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static Category fromJson(Map json) => json == null - ? null - : Category( - id: json[r'id'], - name: json[r'name'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static Category fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return Category( + id: mapValueOfType(json, r'id'), + name: mapValueOfType(json, r'name'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => Category.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(Category.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = Category.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = Category.fromJson(value)); } return map; } // maps a json object with a list of Category-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = Category.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = Category.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/order.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/order.dart index 4cf8b636f47..61d01acfaaa 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/order.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/order.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -44,6 +45,7 @@ class Order { @override int get hashCode => + // ignore: unnecessary_parenthesis (id == null ? 0 : id.hashCode) + (petId == null ? 0 : petId.hashCode) + (quantity == null ? 0 : quantity.hashCode) + @@ -78,40 +80,51 @@ class Order { } /// Returns a new [Order] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static Order fromJson(Map json) => json == null - ? null - : Order( - id: json[r'id'], - petId: json[r'petId'], - quantity: json[r'quantity'], - shipDate: json[r'shipDate'] == null - ? null - : DateTime.parse(json[r'shipDate']), + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static Order fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return Order( + id: mapValueOfType(json, r'id'), + petId: mapValueOfType(json, r'petId'), + quantity: mapValueOfType(json, r'quantity'), + shipDate: mapDateTime(json, r'shipDate', ''), status: OrderStatusEnum.fromJson(json[r'status']), - complete: json[r'complete'], - ); + complete: mapValueOfType(json, r'complete'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => Order.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(Order.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = Order.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = Order.fromJson(value)); } return map; } // maps a json object with a list of Order-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = Order.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = Order.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } @@ -126,7 +139,7 @@ class OrderStatusEnum { final String value; @override - String toString() => value; + String toString() => value ?? ''; String toJson() => value; @@ -144,20 +157,18 @@ class OrderStatusEnum { static OrderStatusEnum fromJson(dynamic value) => OrderStatusEnumTypeTransformer().decode(value); - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json - .map((value) => OrderStatusEnum.fromJson(value)) - .toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(OrderStatusEnum.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; } /// Transformation class that can [encode] an instance of [OrderStatusEnum] to String, /// and [decode] dynamic data back to [OrderStatusEnum]. class OrderStatusEnumTypeTransformer { - const OrderStatusEnumTypeTransformer._(); + factory OrderStatusEnumTypeTransformer() => _instance ??= const OrderStatusEnumTypeTransformer._(); - factory OrderStatusEnumTypeTransformer() => _instance ??= OrderStatusEnumTypeTransformer._(); + const OrderStatusEnumTypeTransformer._(); String encode(OrderStatusEnum data) => data.value; @@ -170,14 +181,16 @@ 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}) { - switch (data) { - case r'placed': return OrderStatusEnum.placed; - case r'approved': return OrderStatusEnum.approved; - case r'delivered': return OrderStatusEnum.delivered; - default: - if (allowNull == false) { - throw ArgumentError('Unknown enum value to decode: $data'); - } + 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) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } } return null; } @@ -186,3 +199,4 @@ class OrderStatusEnumTypeTransformer { static OrderStatusEnumTypeTransformer _instance; } + diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/pet.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/pet.dart index 267e1485b8b..7b8d3c195e7 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/pet.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/pet.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -44,6 +45,7 @@ class Pet { @override int get hashCode => + // ignore: unnecessary_parenthesis (id == null ? 0 : id.hashCode) + (category == null ? 0 : category.hashCode) + (name == null ? 0 : name.hashCode) + @@ -74,40 +76,53 @@ class Pet { } /// Returns a new [Pet] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static Pet fromJson(Map json) => json == null - ? null - : Pet( - id: json[r'id'], + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static Pet fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return Pet( + id: mapValueOfType(json, r'id'), category: Category.fromJson(json[r'category']), - name: json[r'name'], - photoUrls: json[r'photoUrls'] == null - ? null - : (json[r'photoUrls'] as List).cast(), + name: mapValueOfType(json, r'name'), + photoUrls: json[r'photoUrls'] is List + ? (json[r'photoUrls'] as List).cast() + : null, tags: Tag.listFromJson(json[r'tags']), status: PetStatusEnum.fromJson(json[r'status']), - ); + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => Pet.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(Pet.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = Pet.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = Pet.fromJson(value)); } return map; } // maps a json object with a list of Pet-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = Pet.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = Pet.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } @@ -122,7 +137,7 @@ class PetStatusEnum { final String value; @override - String toString() => value; + String toString() => value ?? ''; String toJson() => value; @@ -140,20 +155,18 @@ class PetStatusEnum { static PetStatusEnum fromJson(dynamic value) => PetStatusEnumTypeTransformer().decode(value); - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json - .map((value) => PetStatusEnum.fromJson(value)) - .toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(PetStatusEnum.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; } /// Transformation class that can [encode] an instance of [PetStatusEnum] to String, /// and [decode] dynamic data back to [PetStatusEnum]. class PetStatusEnumTypeTransformer { - const PetStatusEnumTypeTransformer._(); + factory PetStatusEnumTypeTransformer() => _instance ??= const PetStatusEnumTypeTransformer._(); - factory PetStatusEnumTypeTransformer() => _instance ??= PetStatusEnumTypeTransformer._(); + const PetStatusEnumTypeTransformer._(); String encode(PetStatusEnum data) => data.value; @@ -166,14 +179,16 @@ 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}) { - switch (data) { - case r'available': return PetStatusEnum.available; - case r'pending': return PetStatusEnum.pending; - case r'sold': return PetStatusEnum.sold; - default: - if (allowNull == false) { - throw ArgumentError('Unknown enum value to decode: $data'); - } + 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) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } } return null; } @@ -182,3 +197,4 @@ class PetStatusEnumTypeTransformer { static PetStatusEnumTypeTransformer _instance; } + diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/tag.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/tag.dart index 0cd372910b9..193c7004028 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/tag.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/tag.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -27,6 +28,7 @@ class Tag { @override int get hashCode => + // ignore: unnecessary_parenthesis (id == null ? 0 : id.hashCode) + (name == null ? 0 : name.hashCode); @@ -45,34 +47,47 @@ class Tag { } /// Returns a new [Tag] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static Tag fromJson(Map json) => json == null - ? null - : Tag( - id: json[r'id'], - name: json[r'name'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static Tag fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return Tag( + id: mapValueOfType(json, r'id'), + name: mapValueOfType(json, r'name'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => Tag.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(Tag.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = Tag.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = Tag.fromJson(value)); } return map; } // maps a json object with a list of Tag-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = Tag.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = Tag.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/user.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/user.dart index 0eb3716fceb..d2b94ed6a7a 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/user.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/user.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -52,6 +53,7 @@ class User { @override int get hashCode => + // ignore: unnecessary_parenthesis (id == null ? 0 : id.hashCode) + (username == null ? 0 : username.hashCode) + (firstName == null ? 0 : firstName.hashCode) + @@ -94,40 +96,53 @@ class User { } /// Returns a new [User] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static User fromJson(Map json) => json == null - ? null - : User( - id: json[r'id'], - username: json[r'username'], - firstName: json[r'firstName'], - lastName: json[r'lastName'], - email: json[r'email'], - password: json[r'password'], - phone: json[r'phone'], - userStatus: json[r'userStatus'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static User fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return User( + id: mapValueOfType(json, r'id'), + username: mapValueOfType(json, r'username'), + firstName: mapValueOfType(json, r'firstName'), + lastName: mapValueOfType(json, r'lastName'), + email: mapValueOfType(json, r'email'), + password: mapValueOfType(json, r'password'), + phone: mapValueOfType(json, r'phone'), + userStatus: mapValueOfType(json, r'userStatus'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => User.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(User.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = User.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = User.fromJson(value)); } return map; } // maps a json object with a list of User-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = User.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = User.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/analysis_options.yaml b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/analysis_options.yaml index 83d5a10bd7b..e69de29bb2d 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/analysis_options.yaml +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/analysis_options.yaml @@ -1,3 +0,0 @@ -analyzer: - strong-mode: - implicit-casts: true diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api.dart index 0fac101f2ae..34d6adae2fa 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api.dart @@ -5,6 +5,7 @@ // 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 library openapi.api; diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/another_fake_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/another_fake_api.dart index 8f8b96abc53..e74ea06483b 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/another_fake_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/another_fake_api.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -25,33 +26,34 @@ class AnotherFakeApi { /// /// * [ModelClient] modelClient (required): /// client model - Future call123testSpecialTagsWithHttpInfo(ModelClient modelClient) async { + Future 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'PATCH', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -64,8 +66,8 @@ class AnotherFakeApi { /// /// * [ModelClient] modelClient (required): /// client model - Future call123testSpecialTags(ModelClient modelClient) async { - final response = await call123testSpecialTagsWithHttpInfo(modelClient); + Future call123testSpecialTags(ModelClient modelClient,) async { + final response = await call123testSpecialTagsWithHttpInfo(modelClient,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -75,6 +77,6 @@ class AnotherFakeApi { if (response.body != null && response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ModelClient',) as ModelClient; } - return Future.value(null); + return Future.value(); } } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/default_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/default_api.dart index e811495110f..1f3eca5bc84 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/default_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/default_api.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -17,27 +18,28 @@ class DefaultApi { /// Performs an HTTP 'GET /foo' operation and returns the [Response]. Future fooGetWithHttpInfo() async { + // ignore: prefer_const_declarations final path = r'/foo'; + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -53,6 +55,6 @@ class DefaultApi { if (response.body != null && response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'InlineResponseDefault',) as InlineResponseDefault; } - return Future.value(null); + return Future.value(); } } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart index d33a5697d31..33c43243404 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_api.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -19,27 +20,28 @@ class FakeApi { /// /// Note: This method returns the HTTP [Response]. Future fakeHealthGetWithHttpInfo() async { + // ignore: prefer_const_declarations final path = r'/fake/health'; + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -56,7 +58,7 @@ class FakeApi { if (response.body != null && response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'HealthCheckResult',) as HealthCheckResult; } - return Future.value(null); + return Future.value(); } /// test http signature authentication @@ -73,14 +75,16 @@ class FakeApi { /// /// * [String] header1: /// header parameter - Future fakeHttpSignatureTestWithHttpInfo(Pet pet, { String query1, String header1 }) async { + Future fakeHttpSignatureTestWithHttpInfo(Pet pet, { String query1, String header1, }) async { // Verify required params are set. if (pet == null) { throw ApiException(HttpStatus.badRequest, 'Missing required param: pet'); } + // ignore: prefer_const_declarations final path = r'/fake/http-signature-test'; + // ignore: prefer_final_locals Object postBody = pet; final queryParams = []; @@ -95,19 +99,18 @@ class FakeApi { headerParams[r'header_1'] = parameterToString(header1); } - final contentTypes = ['application/json', 'application/xml']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['http_signature_test']; + const authNames = ['http_signature_test']; + const contentTypes = ['application/json', 'application/xml']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -124,8 +127,8 @@ class FakeApi { /// /// * [String] header1: /// header parameter - Future fakeHttpSignatureTest(Pet pet, { String query1, String header1 }) async { - final response = await fakeHttpSignatureTestWithHttpInfo(pet, query1: query1, header1: header1 ); + Future 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)); } @@ -139,30 +142,31 @@ class FakeApi { /// /// * [bool] body: /// Input boolean as post body - Future fakeOuterBooleanSerializeWithHttpInfo({ bool body }) async { + Future fakeOuterBooleanSerializeWithHttpInfo({ bool body, }) async { // Verify required params are set. + // ignore: prefer_const_declarations final path = r'/fake/outer/boolean'; + // ignore: prefer_final_locals Object postBody = body; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -173,8 +177,8 @@ class FakeApi { /// /// * [bool] body: /// Input boolean as post body - Future fakeOuterBooleanSerialize({ bool body }) async { - final response = await fakeOuterBooleanSerializeWithHttpInfo( body: body ); + Future fakeOuterBooleanSerialize({ bool body, }) async { + final response = await fakeOuterBooleanSerializeWithHttpInfo( body: body, ); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -184,7 +188,7 @@ class FakeApi { if (response.body != null && response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'bool',) as bool; } - return Future.value(null); + return Future.value(); } /// Test serialization of object with outer number type @@ -195,30 +199,31 @@ class FakeApi { /// /// * [OuterComposite] outerComposite: /// Input composite as post body - Future fakeOuterCompositeSerializeWithHttpInfo({ OuterComposite outerComposite }) async { + Future fakeOuterCompositeSerializeWithHttpInfo({ OuterComposite outerComposite, }) async { // Verify required params are set. + // ignore: prefer_const_declarations final path = r'/fake/outer/composite'; + // ignore: prefer_final_locals Object postBody = outerComposite; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -229,8 +234,8 @@ class FakeApi { /// /// * [OuterComposite] outerComposite: /// Input composite as post body - Future fakeOuterCompositeSerialize({ OuterComposite outerComposite }) async { - final response = await fakeOuterCompositeSerializeWithHttpInfo( outerComposite: outerComposite ); + Future fakeOuterCompositeSerialize({ OuterComposite outerComposite, }) async { + final response = await fakeOuterCompositeSerializeWithHttpInfo( outerComposite: outerComposite, ); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -240,7 +245,7 @@ class FakeApi { if (response.body != null && response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'OuterComposite',) as OuterComposite; } - return Future.value(null); + return Future.value(); } /// Test serialization of outer number types @@ -251,30 +256,31 @@ class FakeApi { /// /// * [num] body: /// Input number as post body - Future fakeOuterNumberSerializeWithHttpInfo({ num body }) async { + Future fakeOuterNumberSerializeWithHttpInfo({ num body, }) async { // Verify required params are set. + // ignore: prefer_const_declarations final path = r'/fake/outer/number'; + // ignore: prefer_final_locals Object postBody = body; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -285,8 +291,8 @@ class FakeApi { /// /// * [num] body: /// Input number as post body - Future fakeOuterNumberSerialize({ num body }) async { - final response = await fakeOuterNumberSerializeWithHttpInfo( body: body ); + Future fakeOuterNumberSerialize({ num body, }) async { + final response = await fakeOuterNumberSerializeWithHttpInfo( body: body, ); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -296,7 +302,7 @@ class FakeApi { if (response.body != null && response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'num',) as num; } - return Future.value(null); + return Future.value(); } /// Test serialization of outer string types @@ -307,30 +313,31 @@ class FakeApi { /// /// * [String] body: /// Input string as post body - Future fakeOuterStringSerializeWithHttpInfo({ String body }) async { + Future fakeOuterStringSerializeWithHttpInfo({ String body, }) async { // Verify required params are set. + // ignore: prefer_const_declarations final path = r'/fake/outer/string'; + // ignore: prefer_final_locals Object postBody = body; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -341,8 +348,8 @@ class FakeApi { /// /// * [String] body: /// Input string as post body - Future fakeOuterStringSerialize({ String body }) async { - final response = await fakeOuterStringSerializeWithHttpInfo( body: body ); + Future fakeOuterStringSerialize({ String body, }) async { + final response = await fakeOuterStringSerializeWithHttpInfo( body: body, ); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -352,7 +359,7 @@ class FakeApi { if (response.body != null && response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'String',) as String; } - return Future.value(null); + return Future.value(); } /// Test serialization of enum (int) properties with examples @@ -363,33 +370,34 @@ class FakeApi { /// /// * [OuterObjectWithEnumProperty] outerObjectWithEnumProperty (required): /// Input enum (int) as post body - Future fakePropertyEnumIntegerSerializeWithHttpInfo(OuterObjectWithEnumProperty outerObjectWithEnumProperty) async { + Future 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -400,8 +408,8 @@ class FakeApi { /// /// * [OuterObjectWithEnumProperty] outerObjectWithEnumProperty (required): /// Input enum (int) as post body - Future fakePropertyEnumIntegerSerialize(OuterObjectWithEnumProperty outerObjectWithEnumProperty) async { - final response = await fakePropertyEnumIntegerSerializeWithHttpInfo(outerObjectWithEnumProperty); + Future fakePropertyEnumIntegerSerialize(OuterObjectWithEnumProperty outerObjectWithEnumProperty,) async { + final response = await fakePropertyEnumIntegerSerializeWithHttpInfo(outerObjectWithEnumProperty,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -411,7 +419,7 @@ class FakeApi { if (response.body != null && response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'OuterObjectWithEnumProperty',) as OuterObjectWithEnumProperty; } - return Future.value(null); + return Future.value(); } /// For this test, the body has to be a binary file. @@ -422,33 +430,34 @@ class FakeApi { /// /// * [MultipartFile] body (required): /// image to upload - Future testBodyWithBinaryWithHttpInfo(MultipartFile body) async { + Future 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['image/png']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['image/png']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'PUT', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -459,8 +468,8 @@ class FakeApi { /// /// * [MultipartFile] body (required): /// image to upload - Future testBodyWithBinary(MultipartFile body) async { - final response = await testBodyWithBinaryWithHttpInfo(body); + Future testBodyWithBinary(MultipartFile body,) async { + final response = await testBodyWithBinaryWithHttpInfo(body,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -473,33 +482,34 @@ class FakeApi { /// Parameters: /// /// * [FileSchemaTestClass] fileSchemaTestClass (required): - Future testBodyWithFileSchemaWithHttpInfo(FileSchemaTestClass fileSchemaTestClass) async { + Future 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'PUT', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -509,8 +519,8 @@ class FakeApi { /// Parameters: /// /// * [FileSchemaTestClass] fileSchemaTestClass (required): - Future testBodyWithFileSchema(FileSchemaTestClass fileSchemaTestClass) async { - final response = await testBodyWithFileSchemaWithHttpInfo(fileSchemaTestClass); + Future testBodyWithFileSchema(FileSchemaTestClass fileSchemaTestClass,) async { + final response = await testBodyWithFileSchemaWithHttpInfo(fileSchemaTestClass,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -522,7 +532,7 @@ class FakeApi { /// * [String] query (required): /// /// * [User] user (required): - Future testBodyWithQueryParamsWithHttpInfo(String query, User user) async { + Future testBodyWithQueryParamsWithHttpInfo(String query, User user,) async { // Verify required params are set. if (query == null) { throw ApiException(HttpStatus.badRequest, 'Missing required param: query'); @@ -531,8 +541,10 @@ class FakeApi { 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; final queryParams = []; @@ -541,19 +553,18 @@ class FakeApi { queryParams.addAll(_convertParametersForCollectionFormat('', 'query', query)); - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'PUT', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -563,8 +574,8 @@ class FakeApi { /// * [String] query (required): /// /// * [User] user (required): - Future testBodyWithQueryParams(String query, User user) async { - final response = await testBodyWithQueryParamsWithHttpInfo(query, user); + Future testBodyWithQueryParams(String query, User user,) async { + final response = await testBodyWithQueryParamsWithHttpInfo(query, user,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -580,33 +591,34 @@ class FakeApi { /// /// * [ModelClient] modelClient (required): /// client model - Future testClientModelWithHttpInfo(ModelClient modelClient) async { + Future 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'PATCH', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -619,8 +631,8 @@ class FakeApi { /// /// * [ModelClient] modelClient (required): /// client model - Future testClientModel(ModelClient modelClient) async { - final response = await testClientModelWithHttpInfo(modelClient); + Future testClientModel(ModelClient modelClient,) async { + final response = await testClientModelWithHttpInfo(modelClient,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -630,7 +642,7 @@ class FakeApi { if (response.body != null && response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ModelClient',) as ModelClient; } - return Future.value(null); + return Future.value(); } /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -682,7 +694,7 @@ class FakeApi { /// /// * [String] callback: /// None - Future 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 { + Future 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'); @@ -697,17 +709,18 @@ class FakeApi { throw ApiException(HttpStatus.badRequest, 'Missing required param: byte'); } + // ignore: prefer_const_declarations final path = r'/fake'; + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/x-www-form-urlencoded']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['http_basic_test']; + const authNames = ['http_basic_test']; + const contentTypes = ['application/x-www-form-urlencoded']; if (integer != null) { formParams[r'integer'] = parameterToString(integer); @@ -749,14 +762,14 @@ class FakeApi { formParams[r'callback'] = parameterToString(callback); } - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -808,8 +821,8 @@ class FakeApi { /// /// * [String] callback: /// None - Future 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 ); + Future 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)); } @@ -846,11 +859,13 @@ class FakeApi { /// /// * [String] enumFormString: /// Form parameter enum test (string) - Future testEnumParametersWithHttpInfo({ List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, int enumQueryInteger, double enumQueryDouble, List enumFormStringArray, String enumFormString }) async { + Future testEnumParametersWithHttpInfo({ List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, int enumQueryInteger, double enumQueryDouble, List enumFormStringArray, String enumFormString, }) async { // Verify required params are set. + // ignore: prefer_const_declarations final path = r'/fake'; + // ignore: prefer_final_locals Object postBody; final queryParams = []; @@ -877,9 +892,8 @@ class FakeApi { headerParams[r'enum_header_string'] = parameterToString(enumHeaderString); } - final contentTypes = ['application/x-www-form-urlencoded']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/x-www-form-urlencoded']; if (enumFormStringArray != null) { formParams[r'enum_form_string_array'] = parameterToString(enumFormStringArray); @@ -888,14 +902,14 @@ class FakeApi { formParams[r'enum_form_string'] = parameterToString(enumFormString); } - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -929,8 +943,8 @@ class FakeApi { /// /// * [String] enumFormString: /// Form parameter enum test (string) - Future testEnumParameters({ List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, int enumQueryInteger, double enumQueryDouble, List enumFormStringArray, String enumFormString }) async { - final response = await testEnumParametersWithHttpInfo( enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString ); + Future testEnumParameters({ List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, int enumQueryInteger, double enumQueryDouble, List 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)); } @@ -961,7 +975,7 @@ class FakeApi { /// /// * [int] int64Group: /// Integer in group parameters - Future testGroupParametersWithHttpInfo(int requiredStringGroup, bool requiredBooleanGroup, int requiredInt64Group, { int stringGroup, bool booleanGroup, int int64Group }) async { + Future 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'); @@ -973,8 +987,10 @@ class FakeApi { throw ApiException(HttpStatus.badRequest, 'Missing required param: requiredInt64Group'); } + // ignore: prefer_const_declarations final path = r'/fake'; + // ignore: prefer_final_locals Object postBody; final queryParams = []; @@ -995,19 +1011,18 @@ class FakeApi { headerParams[r'boolean_group'] = parameterToString(booleanGroup); } - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['bearer_test']; + const authNames = ['bearer_test']; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'DELETE', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -1035,8 +1050,8 @@ class FakeApi { /// /// * [int] int64Group: /// Integer in group parameters - Future 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 ); + Future 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)); } @@ -1050,33 +1065,34 @@ class FakeApi { /// /// * [Map] requestBody (required): /// request body - Future testInlineAdditionalPropertiesWithHttpInfo(Map requestBody) async { + Future testInlineAdditionalPropertiesWithHttpInfo(Map 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -1087,8 +1103,8 @@ class FakeApi { /// /// * [Map] requestBody (required): /// request body - Future testInlineAdditionalProperties(Map requestBody) async { - final response = await testInlineAdditionalPropertiesWithHttpInfo(requestBody); + Future testInlineAdditionalProperties(Map requestBody,) async { + final response = await testInlineAdditionalPropertiesWithHttpInfo(requestBody,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -1105,7 +1121,7 @@ class FakeApi { /// /// * [String] param2 (required): /// field2 - Future testJsonFormDataWithHttpInfo(String param, String param2) async { + Future testJsonFormDataWithHttpInfo(String param, String param2,) async { // Verify required params are set. if (param == null) { throw ApiException(HttpStatus.badRequest, 'Missing required param: param'); @@ -1114,17 +1130,18 @@ class FakeApi { throw ApiException(HttpStatus.badRequest, 'Missing required param: param2'); } + // ignore: prefer_const_declarations final path = r'/fake/jsonFormData'; + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/x-www-form-urlencoded']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/x-www-form-urlencoded']; if (param != null) { formParams[r'param'] = parameterToString(param); @@ -1133,14 +1150,14 @@ class FakeApi { formParams[r'param2'] = parameterToString(param2); } - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -1154,8 +1171,8 @@ class FakeApi { /// /// * [String] param2 (required): /// field2 - Future testJsonFormData(String param, String param2) async { - final response = await testJsonFormDataWithHttpInfo(param, param2); + Future testJsonFormData(String param, String param2,) async { + final response = await testJsonFormDataWithHttpInfo(param, param2,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -1180,7 +1197,7 @@ class FakeApi { /// * [String] allowEmpty (required): /// /// * [Map] language: - Future testQueryParameterCollectionFormatWithHttpInfo(List pipe, List ioutil, List http, List url, List context, String allowEmpty, { Map language }) async { + Future testQueryParameterCollectionFormatWithHttpInfo(List pipe, List ioutil, List http, List url, List context, String allowEmpty, { Map language, }) async { // Verify required params are set. if (pipe == null) { throw ApiException(HttpStatus.badRequest, 'Missing required param: pipe'); @@ -1201,8 +1218,10 @@ class FakeApi { throw ApiException(HttpStatus.badRequest, 'Missing required param: allowEmpty'); } + // ignore: prefer_const_declarations final path = r'/fake/test-query-parameters'; + // ignore: prefer_final_locals Object postBody; final queryParams = []; @@ -1219,19 +1238,18 @@ class FakeApi { } queryParams.addAll(_convertParametersForCollectionFormat('', 'allowEmpty', allowEmpty)); - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'PUT', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -1253,8 +1271,8 @@ class FakeApi { /// * [String] allowEmpty (required): /// /// * [Map] language: - Future testQueryParameterCollectionFormat(List pipe, List ioutil, List http, List url, List context, String allowEmpty, { Map language }) async { - final response = await testQueryParameterCollectionFormatWithHttpInfo(pipe, ioutil, http, url, context, allowEmpty, language: language ); + Future testQueryParameterCollectionFormat(List pipe, List ioutil, List http, List url, List context, String allowEmpty, { Map 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)); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_classname_tags123_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_classname_tags123_api.dart index 79ec2cbed45..9f92e00b7bd 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_classname_tags123_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/fake_classname_tags123_api.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -25,33 +26,34 @@ class FakeClassnameTags123Api { /// /// * [ModelClient] modelClient (required): /// client model - Future testClassnameWithHttpInfo(ModelClient modelClient) async { + Future 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['api_key_query']; + const authNames = ['api_key_query']; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'PATCH', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -64,8 +66,8 @@ class FakeClassnameTags123Api { /// /// * [ModelClient] modelClient (required): /// client model - Future testClassname(ModelClient modelClient) async { - final response = await testClassnameWithHttpInfo(modelClient); + Future testClassname(ModelClient modelClient,) async { + final response = await testClassnameWithHttpInfo(modelClient,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -75,6 +77,6 @@ class FakeClassnameTags123Api { if (response.body != null && response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ModelClient',) as ModelClient; } - return Future.value(null); + return Future.value(); } } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/pet_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/pet_api.dart index 50d001f61ce..b9217fef597 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/pet_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/pet_api.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -23,33 +24,34 @@ class PetApi { /// /// * [Pet] pet (required): /// Pet object that needs to be added to the store - Future addPetWithHttpInfo(Pet pet) async { + Future 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json', 'application/xml']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['petstore_auth']; + const authNames = ['petstore_auth']; + const contentTypes = ['application/json', 'application/xml']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -60,8 +62,8 @@ class PetApi { /// /// * [Pet] pet (required): /// Pet object that needs to be added to the store - Future addPet(Pet pet) async { - final response = await addPetWithHttpInfo(pet); + Future addPet(Pet pet,) async { + final response = await addPetWithHttpInfo(pet,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -77,15 +79,17 @@ class PetApi { /// Pet id to delete /// /// * [String] apiKey: - Future deletePetWithHttpInfo(int petId, { String apiKey }) async { + Future deletePetWithHttpInfo(int petId, { String apiKey, }) 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()); + .replaceAll('{petId}', petId.toString()); + // ignore: prefer_final_locals Object postBody; final queryParams = []; @@ -96,19 +100,18 @@ class PetApi { headerParams[r'api_key'] = parameterToString(apiKey); } - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['petstore_auth']; + const authNames = ['petstore_auth']; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'DELETE', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -121,8 +124,8 @@ class PetApi { /// Pet id to delete /// /// * [String] apiKey: - Future deletePet(int petId, { String apiKey }) async { - final response = await deletePetWithHttpInfo(petId, apiKey: apiKey ); + Future 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)); } @@ -138,14 +141,16 @@ class PetApi { /// /// * [List] status (required): /// Status values that need to be considered for filter - Future findPetsByStatusWithHttpInfo(List status) async { + Future findPetsByStatusWithHttpInfo(List 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; final queryParams = []; @@ -154,19 +159,18 @@ class PetApi { queryParams.addAll(_convertParametersForCollectionFormat('csv', 'status', status)); - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['petstore_auth']; + const authNames = ['petstore_auth']; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -179,8 +183,8 @@ class PetApi { /// /// * [List] status (required): /// Status values that need to be considered for filter - Future> findPetsByStatus(List status) async { - final response = await findPetsByStatusWithHttpInfo(status); + Future> findPetsByStatus(List status,) async { + final response = await findPetsByStatusWithHttpInfo(status,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -188,11 +192,12 @@ class PetApi { // 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) { - return (await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'List') as List) + final responseBody = await _decodeBodyBytes(response); + return (await apiClient.deserializeAsync(responseBody, 'List') as List) .cast() .toList(growable: false); } - return Future>.value(null); + return Future>.value(); } /// Finds Pets by tags @@ -205,14 +210,16 @@ class PetApi { /// /// * [Set] tags (required): /// Tags to filter by - Future findPetsByTagsWithHttpInfo(Set tags) async { + Future findPetsByTagsWithHttpInfo(Set 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; final queryParams = []; @@ -221,19 +228,18 @@ class PetApi { queryParams.addAll(_convertParametersForCollectionFormat('csv', 'tags', tags)); - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['petstore_auth']; + const authNames = ['petstore_auth']; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -246,8 +252,8 @@ class PetApi { /// /// * [Set] tags (required): /// Tags to filter by - Future> findPetsByTags(Set tags) async { - final response = await findPetsByTagsWithHttpInfo(tags); + Future> findPetsByTags(Set tags,) async { + final response = await findPetsByTagsWithHttpInfo(tags,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -255,11 +261,12 @@ class PetApi { // 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) { - return (await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Set') as List) + final responseBody = await _decodeBodyBytes(response); + return (await apiClient.deserializeAsync(responseBody, 'Set') as List) .cast() .toSet(); } - return Future>.value(null); + return Future>.value(); } /// Find pet by ID @@ -272,34 +279,35 @@ class PetApi { /// /// * [int] petId (required): /// ID of pet to return - Future getPetByIdWithHttpInfo(int petId) async { + Future 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()); + .replaceAll('{petId}', petId.toString()); + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['api_key']; + const authNames = ['api_key']; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -312,8 +320,8 @@ class PetApi { /// /// * [int] petId (required): /// ID of pet to return - Future getPetById(int petId) async { - final response = await getPetByIdWithHttpInfo(petId); + Future getPetById(int petId,) async { + final response = await getPetByIdWithHttpInfo(petId,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -323,7 +331,7 @@ class PetApi { if (response.body != null && response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Pet',) as Pet; } - return Future.value(null); + return Future.value(); } /// Update an existing pet @@ -334,33 +342,34 @@ class PetApi { /// /// * [Pet] pet (required): /// Pet object that needs to be added to the store - Future updatePetWithHttpInfo(Pet pet) async { + Future 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json', 'application/xml']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['petstore_auth']; + const authNames = ['petstore_auth']; + const contentTypes = ['application/json', 'application/xml']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'PUT', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -371,8 +380,8 @@ class PetApi { /// /// * [Pet] pet (required): /// Pet object that needs to be added to the store - Future updatePet(Pet pet) async { - final response = await updatePetWithHttpInfo(pet); + Future updatePet(Pet pet,) async { + final response = await updatePetWithHttpInfo(pet,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -392,24 +401,25 @@ class PetApi { /// /// * [String] status: /// Updated status of the pet - Future updatePetWithFormWithHttpInfo(int petId, { String name, String status }) async { + Future updatePetWithFormWithHttpInfo(int petId, { String name, String status, }) 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()); + .replaceAll('{petId}', petId.toString()); + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/x-www-form-urlencoded']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['petstore_auth']; + const authNames = ['petstore_auth']; + const contentTypes = ['application/x-www-form-urlencoded']; if (name != null) { formParams[r'name'] = parameterToString(name); @@ -418,14 +428,14 @@ class PetApi { formParams[r'status'] = parameterToString(status); } - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -442,8 +452,8 @@ class PetApi { /// /// * [String] status: /// Updated status of the pet - Future updatePetWithForm(int petId, { String name, String status }) async { - final response = await updatePetWithFormWithHttpInfo(petId, name: name, status: status ); + Future 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)); } @@ -463,24 +473,25 @@ class PetApi { /// /// * [MultipartFile] file: /// file to upload - Future uploadFileWithHttpInfo(int petId, { String additionalMetadata, MultipartFile file }) async { + Future uploadFileWithHttpInfo(int petId, { String additionalMetadata, MultipartFile file, }) 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}/uploadImage' - .replaceAll('{' + 'petId' + '}', petId.toString()); + .replaceAll('{petId}', petId.toString()); + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['multipart/form-data']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['petstore_auth']; + const authNames = ['petstore_auth']; + const contentTypes = ['multipart/form-data']; bool hasFields = false; final mp = MultipartRequest('POST', Uri.parse(path)); @@ -497,14 +508,14 @@ class PetApi { postBody = mp; } - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -521,8 +532,8 @@ class PetApi { /// /// * [MultipartFile] file: /// file to upload - Future uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async { - final response = await uploadFileWithHttpInfo(petId, additionalMetadata: additionalMetadata, file: file ); + Future 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)); } @@ -532,7 +543,7 @@ class PetApi { if (response.body != null && response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ApiResponse',) as ApiResponse; } - return Future.value(null); + return Future.value(); } /// uploads an image (required) @@ -549,7 +560,7 @@ class PetApi { /// /// * [String] additionalMetadata: /// Additional data to pass to server - Future uploadFileWithRequiredFileWithHttpInfo(int petId, MultipartFile requiredFile, { String additionalMetadata }) async { + Future uploadFileWithRequiredFileWithHttpInfo(int petId, MultipartFile requiredFile, { String additionalMetadata, }) async { // Verify required params are set. if (petId == null) { throw ApiException(HttpStatus.badRequest, 'Missing required param: petId'); @@ -558,18 +569,19 @@ class PetApi { throw ApiException(HttpStatus.badRequest, 'Missing required param: requiredFile'); } + // ignore: prefer_const_declarations final path = r'/fake/{petId}/uploadImageWithRequiredFile' - .replaceAll('{' + 'petId' + '}', petId.toString()); + .replaceAll('{petId}', petId.toString()); + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['multipart/form-data']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['petstore_auth']; + const authNames = ['petstore_auth']; + const contentTypes = ['multipart/form-data']; bool hasFields = false; final mp = MultipartRequest('POST', Uri.parse(path)); @@ -586,14 +598,14 @@ class PetApi { postBody = mp; } - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -610,8 +622,8 @@ class PetApi { /// /// * [String] additionalMetadata: /// Additional data to pass to server - Future uploadFileWithRequiredFile(int petId, MultipartFile requiredFile, { String additionalMetadata }) async { - final response = await uploadFileWithRequiredFileWithHttpInfo(petId, requiredFile, additionalMetadata: additionalMetadata ); + Future 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)); } @@ -621,6 +633,6 @@ class PetApi { if (response.body != null && response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ApiResponse',) as ApiResponse; } - return Future.value(null); + return Future.value(); } } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/store_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/store_api.dart index 08a73bb8fca..2137c99ba85 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/store_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/store_api.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -25,34 +26,35 @@ class StoreApi { /// /// * [String] orderId (required): /// ID of the order that needs to be deleted - Future deleteOrderWithHttpInfo(String orderId) async { + Future 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.toString()); + .replaceAll('{order_id}', orderId); + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'DELETE', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -65,8 +67,8 @@ class StoreApi { /// /// * [String] orderId (required): /// ID of the order that needs to be deleted - Future deleteOrder(String orderId) async { - final response = await deleteOrderWithHttpInfo(orderId); + Future deleteOrder(String orderId,) async { + final response = await deleteOrderWithHttpInfo(orderId,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -78,27 +80,28 @@ class StoreApi { /// /// Note: This method returns the HTTP [Response]. Future getInventoryWithHttpInfo() async { + // ignore: prefer_const_declarations final path = r'/store/inventory'; + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['api_key']; + const authNames = ['api_key']; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -117,7 +120,7 @@ class StoreApi { if (response.body != null && response.statusCode != HttpStatus.noContent) { return Map.from(await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Map'),); } - return Future>.value(null); + return Future>.value(); } /// Find purchase order by ID @@ -130,34 +133,35 @@ class StoreApi { /// /// * [int] orderId (required): /// ID of pet that needs to be fetched - Future getOrderByIdWithHttpInfo(int orderId) async { + Future 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()); + .replaceAll('{order_id}', orderId.toString()); + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -170,8 +174,8 @@ class StoreApi { /// /// * [int] orderId (required): /// ID of pet that needs to be fetched - Future getOrderById(int orderId) async { - final response = await getOrderByIdWithHttpInfo(orderId); + Future getOrderById(int orderId,) async { + final response = await getOrderByIdWithHttpInfo(orderId,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -181,7 +185,7 @@ class StoreApi { if (response.body != null && response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Order',) as Order; } - return Future.value(null); + return Future.value(); } /// Place an order for a pet @@ -192,33 +196,34 @@ class StoreApi { /// /// * [Order] order (required): /// order placed for purchasing the pet - Future placeOrderWithHttpInfo(Order order) async { + Future 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -229,8 +234,8 @@ class StoreApi { /// /// * [Order] order (required): /// order placed for purchasing the pet - Future placeOrder(Order order) async { - final response = await placeOrderWithHttpInfo(order); + Future placeOrder(Order order,) async { + final response = await placeOrderWithHttpInfo(order,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -240,6 +245,6 @@ class StoreApi { if (response.body != null && response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Order',) as Order; } - return Future.value(null); + return Future.value(); } } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/user_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/user_api.dart index d45509dcac5..ceecb982903 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/user_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api/user_api.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -25,33 +26,34 @@ class UserApi { /// /// * [User] user (required): /// Created user object - Future createUserWithHttpInfo(User user) async { + Future 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -64,8 +66,8 @@ class UserApi { /// /// * [User] user (required): /// Created user object - Future createUser(User user) async { - final response = await createUserWithHttpInfo(user); + Future createUser(User user,) async { + final response = await createUserWithHttpInfo(user,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -79,33 +81,34 @@ class UserApi { /// /// * [List] user (required): /// List of user object - Future createUsersWithArrayInputWithHttpInfo(List user) async { + Future createUsersWithArrayInputWithHttpInfo(List 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -116,8 +119,8 @@ class UserApi { /// /// * [List] user (required): /// List of user object - Future createUsersWithArrayInput(List user) async { - final response = await createUsersWithArrayInputWithHttpInfo(user); + Future createUsersWithArrayInput(List user,) async { + final response = await createUsersWithArrayInputWithHttpInfo(user,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -131,33 +134,34 @@ class UserApi { /// /// * [List] user (required): /// List of user object - Future createUsersWithListInputWithHttpInfo(List user) async { + Future createUsersWithListInputWithHttpInfo(List 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -168,8 +172,8 @@ class UserApi { /// /// * [List] user (required): /// List of user object - Future createUsersWithListInput(List user) async { - final response = await createUsersWithListInputWithHttpInfo(user); + Future createUsersWithListInput(List user,) async { + final response = await createUsersWithListInputWithHttpInfo(user,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -185,34 +189,35 @@ class UserApi { /// /// * [String] username (required): /// The name that needs to be deleted - Future deleteUserWithHttpInfo(String username) async { + Future 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.toString()); + .replaceAll('{username}', username); + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'DELETE', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -225,8 +230,8 @@ class UserApi { /// /// * [String] username (required): /// The name that needs to be deleted - Future deleteUser(String username) async { - final response = await deleteUserWithHttpInfo(username); + Future deleteUser(String username,) async { + final response = await deleteUserWithHttpInfo(username,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -240,34 +245,35 @@ class UserApi { /// /// * [String] username (required): /// The name that needs to be fetched. Use user1 for testing. - Future getUserByNameWithHttpInfo(String username) async { + Future 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.toString()); + .replaceAll('{username}', username); + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -278,8 +284,8 @@ class UserApi { /// /// * [String] username (required): /// The name that needs to be fetched. Use user1 for testing. - Future getUserByName(String username) async { - final response = await getUserByNameWithHttpInfo(username); + Future getUserByName(String username,) async { + final response = await getUserByNameWithHttpInfo(username,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -289,7 +295,7 @@ class UserApi { if (response.body != null && response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'User',) as User; } - return Future.value(null); + return Future.value(); } /// Logs user into the system @@ -303,7 +309,7 @@ class UserApi { /// /// * [String] password (required): /// The password for login in clear text - Future loginUserWithHttpInfo(String username, String password) async { + Future loginUserWithHttpInfo(String username, String password,) async { // Verify required params are set. if (username == null) { throw ApiException(HttpStatus.badRequest, 'Missing required param: username'); @@ -312,8 +318,10 @@ class UserApi { throw ApiException(HttpStatus.badRequest, 'Missing required param: password'); } + // ignore: prefer_const_declarations final path = r'/user/login'; + // ignore: prefer_final_locals Object postBody; final queryParams = []; @@ -323,19 +331,18 @@ class UserApi { queryParams.addAll(_convertParametersForCollectionFormat('', 'username', username)); queryParams.addAll(_convertParametersForCollectionFormat('', 'password', password)); - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -349,8 +356,8 @@ class UserApi { /// /// * [String] password (required): /// The password for login in clear text - Future loginUser(String username, String password) async { - final response = await loginUserWithHttpInfo(username, password); + Future loginUser(String username, String password,) async { + final response = await loginUserWithHttpInfo(username, password,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -360,34 +367,35 @@ class UserApi { if (response.body != null && response.statusCode != HttpStatus.noContent) { return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'String',) as String; } - return Future.value(null); + return Future.value(); } /// Logs out current logged in user session /// /// Note: This method returns the HTTP [Response]. Future logoutUserWithHttpInfo() async { + // ignore: prefer_const_declarations final path = r'/user/logout'; + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -413,7 +421,7 @@ class UserApi { /// /// * [User] user (required): /// Updated user object - Future updateUserWithHttpInfo(String username, User user) async { + Future updateUserWithHttpInfo(String username, User user,) async { // Verify required params are set. if (username == null) { throw ApiException(HttpStatus.badRequest, 'Missing required param: username'); @@ -422,28 +430,29 @@ class UserApi { throw ApiException(HttpStatus.badRequest, 'Missing required param: user'); } + // ignore: prefer_const_declarations final path = r'/user/{username}' - .replaceAll('{' + 'username' + '}', username.toString()); + .replaceAll('{username}', username); + // ignore: prefer_final_locals Object postBody = user; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'PUT', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -459,8 +468,8 @@ class UserApi { /// /// * [User] user (required): /// Updated user object - Future updateUser(String username, User user) async { - final response = await updateUserWithHttpInfo(username, user); + Future updateUser(String username, User user,) async { + final response = await updateUserWithHttpInfo(username, user,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_client.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_client.dart index 48ed9288e65..ed19ac29634 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_client.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_client.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -80,7 +81,7 @@ class ApiClient { ? '?${urlEncodedQueryParams.join('&')}' : ''; - final Uri uri = Uri.parse('$basePath$path$queryString'); + final uri = Uri.parse('$basePath$path$queryString'); if (nullableContentType != null) { headerParams['Content-Type'] = nullableContentType; @@ -98,7 +99,8 @@ class ApiClient { body.finalize().listen( request.sink.add, onDone: request.sink.close, - onError: (error, trace) => request.sink.close(), + // ignore: avoid_types_on_closure_parameters + onError: (Object error, StackTrace trace) => request.sink.close(), cancelOnError: true, ); final response = await _client.send(request); @@ -184,18 +186,17 @@ class ApiClient { try { switch (targetType) { case 'String': - return '$value'; + return value is String ? value : value.toString(); case 'int': return value is int ? value : int.parse('$value'); + case 'double': + return value is double ? value : double.parse('$value'); case 'bool': if (value is bool) { return value; } final valueString = '$value'.toLowerCase(); return valueString == 'true' || valueString == '1'; - break; - case 'double': - return value is double ? value : double.parse('$value'); case 'AdditionalPropertiesClass': return AdditionalPropertiesClass.fromJson(value); case 'Animal': @@ -298,25 +299,24 @@ class ApiClient { if (value is List && (match = _regList.firstMatch(targetType)) != null) { targetType = match[1]; // ignore: parameter_assignments return value - .map((v) => _deserialize(v, targetType, growable: growable)) + .map((dynamic v) => _deserialize(v, targetType, growable: growable)) .toList(growable: growable); } if (value is Set && (match = _regSet.firstMatch(targetType)) != null) { targetType = match[1]; // ignore: parameter_assignments return value - .map((v) => _deserialize(v, targetType, growable: growable)) + .map((dynamic v) => _deserialize(v, targetType, growable: growable)) .toSet(); } if (value is Map && (match = _regMap.firstMatch(targetType)) != null) { targetType = match[1]; // ignore: parameter_assignments - return Map.fromIterables( - value.keys, - value.values.map((v) => _deserialize(v, targetType, growable: growable)), + return Map.fromIterables( + value.keys.cast(), + value.values.map((dynamic v) => _deserialize(v, targetType, growable: growable)), ); } - break; } - } catch (error, trace) { + } on Exception catch (error, trace) { throw ApiException.withInner(HttpStatus.internalServerError, 'Exception during deserialization.', error, trace,); } throw ApiException(HttpStatus.internalServerError, 'Could not find a suitable class for deserialization',); diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_exception.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_exception.dart index 86e2054bffe..8ffc340b4c9 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_exception.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_exception.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_helper.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_helper.dart index 474cfb4294f..bdb7b1fc166 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_helper.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/api_helper.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -30,20 +31,21 @@ Iterable _convertParametersForCollectionFormat( // preconditions if (name != null && name.isNotEmpty && value != null) { if (value is List) { - // get the collection format, default: csv - collectionFormat = (collectionFormat == null || collectionFormat.isEmpty) - ? 'csv' - : collectionFormat; - if (collectionFormat == 'multi') { - return value.map((v) => QueryParam(name, parameterToString(v))); + return value.map((dynamic v) => QueryParam(name, parameterToString(v)),); + } + + // Default collection format is 'csv'. + if (collectionFormat == null || collectionFormat.isEmpty) { + // ignore: parameter_assignments + collectionFormat = 'csv'; } final delimiter = _delimiters[collectionFormat] ?? ','; - params.add(QueryParam(name, value.map((v) => parameterToString(v)).join(delimiter))); + params.add(QueryParam(name, value.map(parameterToString).join(delimiter)),); } else { - params.add(QueryParam(name, parameterToString(value))); + params.add(QueryParam(name, parameterToString(value),)); } } @@ -84,3 +86,36 @@ Future _decodeBodyBytes(Response response) async { ? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes) : response.body; } + +/// Returns a valid [T] value found at the specified Map [key], null otherwise. +T mapValueOfType(dynamic map, String key) { + final dynamic value = map is Map ? map[key] : null; + return value is T ? value : null; +} + +/// Returns a valid Map found at the specified Map [key], null otherwise. +Map mapCastOfType(dynamic map, String key) { + final dynamic value = map is Map ? map[key] : null; + return value is Map ? value.cast() : null; +} + +/// Returns a valid [DateTime] found at the specified Map [key], null otherwise. +DateTime mapDateTime(dynamic map, String key, [String pattern]) { + final dynamic value = map is Map ? map[key] : null; + if (value != null) { + int millis; + if (value is int) { + millis = value; + } else if (value is String) { + if (pattern == _dateEpochMarker) { + millis = int.tryParse(value); + } else { + return DateTime.tryParse(value); + } + } + if (millis != null) { + return DateTime.fromMillisecondsSinceEpoch(millis, isUtc: true); + } + } + return null; +} diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/auth/api_key_auth.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/auth/api_key_auth.dart index 41a4afd85d9..0c2303af09e 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/auth/api_key_auth.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/auth/api_key_auth.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -27,9 +28,11 @@ class ApiKeyAuth implements Authentication { } else if (location == 'header' && value != null) { headerParams[paramName] = value; } else if (location == 'cookie' && value != null) { - headerParams.update('Cookie', (String existingCookie) { - return '$existingCookie; $paramName=$value'; - }, ifAbsent: () => '$paramName=$value'); + headerParams.update( + 'Cookie', + (existingCookie) => '$existingCookie; $paramName=$value', + ifAbsent: () => '$paramName=$value', + ); } } } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/auth/authentication.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/auth/authentication.dart index 5ca198d41fd..4257e190006 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/auth/authentication.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/auth/authentication.dart @@ -5,10 +5,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 part of openapi.api; +// ignore: one_member_abstracts abstract class Authentication { /// Apply authentication settings to header and query params. void applyToParams(List queryParams, Map headerParams); diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/auth/http_basic_auth.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/auth/http_basic_auth.dart index 6dc36a13f49..0494f402d95 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/auth/http_basic_auth.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/auth/http_basic_auth.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -15,7 +16,7 @@ class HttpBasicAuth implements Authentication { @override void applyToParams(List queryParams, Map headerParams) { - final credentials = (username ?? '') + ':' + (password ?? ''); + final credentials = '${username ?? ''}:${password ?? ''}'; headerParams['Authorization'] = 'Basic ${base64.encode(utf8.encode(credentials))}'; } } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/auth/http_bearer_auth.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/auth/http_bearer_auth.dart index a23b65fac5e..23e243523dd 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/auth/http_bearer_auth.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/auth/http_bearer_auth.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -22,7 +23,7 @@ class HttpBearerAuth implements Authentication { if (accessToken is! String && accessToken is! HttpBearerAuthProvider) { throw ArgumentError('Type of Bearer accessToken should be a String or a String Function().'); } - this._accessToken = accessToken; + _accessToken = accessToken; } @override diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/auth/oauth.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/auth/oauth.dart index c0463ad3900..9299ac13f5b 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/auth/oauth.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/auth/oauth.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/additional_properties_class.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/additional_properties_class.dart index b62ac79d3e2..dc1f488f0b2 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/additional_properties_class.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/additional_properties_class.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -27,6 +28,7 @@ class AdditionalPropertiesClass { @override int get hashCode => + // ignore: unnecessary_parenthesis (mapProperty == null ? 0 : mapProperty.hashCode) + (mapOfMapProperty == null ? 0 : mapOfMapProperty.hashCode); @@ -45,38 +47,47 @@ class AdditionalPropertiesClass { } /// Returns a new [AdditionalPropertiesClass] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static AdditionalPropertiesClass fromJson(Map json) => json == null - ? null - : AdditionalPropertiesClass( - mapProperty: json[r'map_property'] == null ? - null : - (json[r'map_property'] as Map).cast(), - mapOfMapProperty: json[r'map_of_map_property'] == null - ? null - : (json[r'map_of_map_property'] as Map).cast(), - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static AdditionalPropertiesClass fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return AdditionalPropertiesClass( + mapProperty: mapCastOfType(json, r'map_property'), + mapOfMapProperty: mapCastOfType(json, r'map_of_map_property'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => AdditionalPropertiesClass.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(AdditionalPropertiesClass.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = AdditionalPropertiesClass.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = AdditionalPropertiesClass.fromJson(value)); } return map; } // maps a json object with a list of AdditionalPropertiesClass-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = AdditionalPropertiesClass.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = AdditionalPropertiesClass.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/animal.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/animal.dart index ba9066e4ef7..d138a87c008 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/animal.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/animal.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -27,6 +28,7 @@ class Animal { @override int get hashCode => + // ignore: unnecessary_parenthesis (className == null ? 0 : className.hashCode) + (color == null ? 0 : color.hashCode); @@ -43,34 +45,47 @@ class Animal { } /// Returns a new [Animal] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static Animal fromJson(Map json) => json == null - ? null - : Animal( - className: json[r'className'], - color: json[r'color'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static Animal fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return Animal( + className: mapValueOfType(json, r'className'), + color: mapValueOfType(json, r'color'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => Animal.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(Animal.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = Animal.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = Animal.fromJson(value)); } return map; } // maps a json object with a list of Animal-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = Animal.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = Animal.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/api_response.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/api_response.dart index 6bb070b7eeb..bfd43366211 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/api_response.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/api_response.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -31,6 +32,7 @@ class ApiResponse { @override int get hashCode => + // ignore: unnecessary_parenthesis (code == null ? 0 : code.hashCode) + (type == null ? 0 : type.hashCode) + (message == null ? 0 : message.hashCode); @@ -53,35 +55,48 @@ class ApiResponse { } /// Returns a new [ApiResponse] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static ApiResponse fromJson(Map json) => json == null - ? null - : ApiResponse( - code: json[r'code'], - type: json[r'type'], - message: json[r'message'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static ApiResponse fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return ApiResponse( + code: mapValueOfType(json, r'code'), + type: mapValueOfType(json, r'type'), + message: mapValueOfType(json, r'message'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => ApiResponse.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(ApiResponse.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = ApiResponse.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = ApiResponse.fromJson(value)); } return map; } // maps a json object with a list of ApiResponse-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = ApiResponse.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = ApiResponse.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/array_of_array_of_number_only.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/array_of_array_of_number_only.dart index 90ec9124de9..5525cd19379 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/array_of_array_of_number_only.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/array_of_array_of_number_only.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -23,6 +24,7 @@ class ArrayOfArrayOfNumberOnly { @override int get hashCode => + // ignore: unnecessary_parenthesis (arrayArrayNumber == null ? 0 : arrayArrayNumber.hashCode); @override @@ -37,37 +39,50 @@ class ArrayOfArrayOfNumberOnly { } /// Returns a new [ArrayOfArrayOfNumberOnly] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static ArrayOfArrayOfNumberOnly fromJson(Map json) => json == null - ? null - : ArrayOfArrayOfNumberOnly( - arrayArrayNumber: json[r'ArrayArrayNumber'] == null - ? null - : (json[r'ArrayArrayNumber'] as List).map( + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static ArrayOfArrayOfNumberOnly fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return ArrayOfArrayOfNumberOnly( + arrayArrayNumber: json[r'ArrayArrayNumber'] is List + ? (json[r'ArrayArrayNumber'] as List).map( (e) => e == null ? null : (e as List).cast() - ).toList(growable: false), - ); + ).toList(growable: false) + : null, + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => ArrayOfArrayOfNumberOnly.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(ArrayOfArrayOfNumberOnly.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = ArrayOfArrayOfNumberOnly.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = ArrayOfArrayOfNumberOnly.fromJson(value)); } return map; } // maps a json object with a list of ArrayOfArrayOfNumberOnly-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = ArrayOfArrayOfNumberOnly.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = ArrayOfArrayOfNumberOnly.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/array_of_number_only.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/array_of_number_only.dart index 19b93cc3d73..1e23c3ad2d3 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/array_of_number_only.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/array_of_number_only.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -23,6 +24,7 @@ class ArrayOfNumberOnly { @override int get hashCode => + // ignore: unnecessary_parenthesis (arrayNumber == null ? 0 : arrayNumber.hashCode); @override @@ -37,35 +39,48 @@ class ArrayOfNumberOnly { } /// Returns a new [ArrayOfNumberOnly] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static ArrayOfNumberOnly fromJson(Map json) => json == null - ? null - : ArrayOfNumberOnly( - arrayNumber: json[r'ArrayNumber'] == null - ? null - : (json[r'ArrayNumber'] as List).cast(), - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static ArrayOfNumberOnly fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return ArrayOfNumberOnly( + arrayNumber: json[r'ArrayNumber'] is List + ? (json[r'ArrayNumber'] as List).cast() + : null, + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => ArrayOfNumberOnly.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(ArrayOfNumberOnly.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = ArrayOfNumberOnly.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = ArrayOfNumberOnly.fromJson(value)); } return map; } // maps a json object with a list of ArrayOfNumberOnly-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = ArrayOfNumberOnly.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = ArrayOfNumberOnly.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/array_test.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/array_test.dart index c911626fa13..6ae2096a565 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/array_test.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/array_test.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -31,6 +32,7 @@ class ArrayTest { @override int get hashCode => + // ignore: unnecessary_parenthesis (arrayOfString == null ? 0 : arrayOfString.hashCode) + (arrayArrayOfInteger == null ? 0 : arrayArrayOfInteger.hashCode) + (arrayArrayOfModel == null ? 0 : arrayArrayOfModel.hashCode); @@ -53,45 +55,58 @@ class ArrayTest { } /// Returns a new [ArrayTest] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static ArrayTest fromJson(Map json) => json == null - ? null - : ArrayTest( - arrayOfString: json[r'array_of_string'] == null - ? null - : (json[r'array_of_string'] as List).cast(), - arrayArrayOfInteger: json[r'array_array_of_integer'] == null - ? null - : (json[r'array_array_of_integer'] as List).map( + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static ArrayTest fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return ArrayTest( + arrayOfString: json[r'array_of_string'] is List + ? (json[r'array_of_string'] as List).cast() + : null, + 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() - ).toList(growable: false), - arrayArrayOfModel: json[r'array_array_of_model'] == null - ? null - : (json[r'array_array_of_model'] as List).map( + ).toList(growable: false) + : 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(growable: false) + : null, + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => ArrayTest.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(ArrayTest.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = ArrayTest.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = ArrayTest.fromJson(value)); } return map; } // maps a json object with a list of ArrayTest-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = ArrayTest.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = ArrayTest.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/capitalization.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/capitalization.dart index 7b60d37fd39..678bc6f2ea8 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/capitalization.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/capitalization.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -44,6 +45,7 @@ class Capitalization { @override int get hashCode => + // ignore: unnecessary_parenthesis (smallCamel == null ? 0 : smallCamel.hashCode) + (capitalCamel == null ? 0 : capitalCamel.hashCode) + (smallSnake == null ? 0 : smallSnake.hashCode) + @@ -78,38 +80,51 @@ class Capitalization { } /// Returns a new [Capitalization] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static Capitalization fromJson(Map json) => json == null - ? null - : Capitalization( - smallCamel: json[r'smallCamel'], - capitalCamel: json[r'CapitalCamel'], - smallSnake: json[r'small_Snake'], - capitalSnake: json[r'Capital_Snake'], - sCAETHFlowPoints: json[r'SCA_ETH_Flow_Points'], - ATT_NAME: json[r'ATT_NAME'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static Capitalization fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return Capitalization( + smallCamel: mapValueOfType(json, r'smallCamel'), + capitalCamel: mapValueOfType(json, r'CapitalCamel'), + smallSnake: mapValueOfType(json, r'small_Snake'), + capitalSnake: mapValueOfType(json, r'Capital_Snake'), + sCAETHFlowPoints: mapValueOfType(json, r'SCA_ETH_Flow_Points'), + ATT_NAME: mapValueOfType(json, r'ATT_NAME'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => Capitalization.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(Capitalization.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = Capitalization.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = Capitalization.fromJson(value)); } return map; } // maps a json object with a list of Capitalization-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = Capitalization.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = Capitalization.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/cat.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/cat.dart index 94d0b96a9c7..b34fdc7d9a2 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/cat.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/cat.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -31,6 +32,7 @@ class Cat { @override int get hashCode => + // ignore: unnecessary_parenthesis (className == null ? 0 : className.hashCode) + (color == null ? 0 : color.hashCode) + (declawed == null ? 0 : declawed.hashCode); @@ -51,35 +53,48 @@ class Cat { } /// Returns a new [Cat] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static Cat fromJson(Map json) => json == null - ? null - : Cat( - className: json[r'className'], - color: json[r'color'], - declawed: json[r'declawed'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static Cat fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return Cat( + className: mapValueOfType(json, r'className'), + color: mapValueOfType(json, r'color'), + declawed: mapValueOfType(json, r'declawed'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => Cat.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(Cat.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = Cat.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = Cat.fromJson(value)); } return map; } // maps a json object with a list of Cat-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = Cat.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = Cat.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/cat_all_of.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/cat_all_of.dart index e3fe4944874..97bbde44213 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/cat_all_of.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/cat_all_of.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -23,6 +24,7 @@ class CatAllOf { @override int get hashCode => + // ignore: unnecessary_parenthesis (declawed == null ? 0 : declawed.hashCode); @override @@ -37,33 +39,46 @@ class CatAllOf { } /// Returns a new [CatAllOf] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static CatAllOf fromJson(Map json) => json == null - ? null - : CatAllOf( - declawed: json[r'declawed'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static CatAllOf fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return CatAllOf( + declawed: mapValueOfType(json, r'declawed'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => CatAllOf.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(CatAllOf.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = CatAllOf.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = CatAllOf.fromJson(value)); } return map; } // maps a json object with a list of CatAllOf-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = CatAllOf.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = CatAllOf.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/category.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/category.dart index eddc54e7315..294c4f57e9c 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/category.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/category.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -27,6 +28,7 @@ class Category { @override int get hashCode => + // ignore: unnecessary_parenthesis (id == null ? 0 : id.hashCode) + (name == null ? 0 : name.hashCode); @@ -43,34 +45,47 @@ class Category { } /// Returns a new [Category] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static Category fromJson(Map json) => json == null - ? null - : Category( - id: json[r'id'], - name: json[r'name'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static Category fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return Category( + id: mapValueOfType(json, r'id'), + name: mapValueOfType(json, r'name'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => Category.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(Category.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = Category.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = Category.fromJson(value)); } return map; } // maps a json object with a list of Category-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = Category.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = Category.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/class_model.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/class_model.dart index 927f01e06b6..4736fb60ca8 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/class_model.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/class_model.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -23,6 +24,7 @@ class ClassModel { @override int get hashCode => + // ignore: unnecessary_parenthesis (class_ == null ? 0 : class_.hashCode); @override @@ -37,33 +39,46 @@ class ClassModel { } /// Returns a new [ClassModel] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static ClassModel fromJson(Map json) => json == null - ? null - : ClassModel( - class_: json[r'_class'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static ClassModel fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return ClassModel( + class_: mapValueOfType(json, r'_class'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => ClassModel.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(ClassModel.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = ClassModel.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = ClassModel.fromJson(value)); } return map; } // maps a json object with a list of ClassModel-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = ClassModel.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = ClassModel.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/deprecated_object.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/deprecated_object.dart index 0b7b4b1445e..a84c7155c8a 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/deprecated_object.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/deprecated_object.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -23,6 +24,7 @@ class DeprecatedObject { @override int get hashCode => + // ignore: unnecessary_parenthesis (name == null ? 0 : name.hashCode); @override @@ -37,33 +39,46 @@ class DeprecatedObject { } /// Returns a new [DeprecatedObject] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static DeprecatedObject fromJson(Map json) => json == null - ? null - : DeprecatedObject( - name: json[r'name'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static DeprecatedObject fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return DeprecatedObject( + name: mapValueOfType(json, r'name'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => DeprecatedObject.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(DeprecatedObject.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = DeprecatedObject.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = DeprecatedObject.fromJson(value)); } return map; } // maps a json object with a list of DeprecatedObject-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = DeprecatedObject.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = DeprecatedObject.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/dog.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/dog.dart index 3a1efcb1c4f..68d592bef45 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/dog.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/dog.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -31,6 +32,7 @@ class Dog { @override int get hashCode => + // ignore: unnecessary_parenthesis (className == null ? 0 : className.hashCode) + (color == null ? 0 : color.hashCode) + (breed == null ? 0 : breed.hashCode); @@ -51,35 +53,48 @@ class Dog { } /// Returns a new [Dog] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static Dog fromJson(Map json) => json == null - ? null - : Dog( - className: json[r'className'], - color: json[r'color'], - breed: json[r'breed'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static Dog fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return Dog( + className: mapValueOfType(json, r'className'), + color: mapValueOfType(json, r'color'), + breed: mapValueOfType(json, r'breed'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => Dog.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(Dog.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = Dog.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = Dog.fromJson(value)); } return map; } // maps a json object with a list of Dog-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = Dog.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = Dog.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/dog_all_of.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/dog_all_of.dart index a77ba88b0bf..a4e2559cd66 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/dog_all_of.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/dog_all_of.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -23,6 +24,7 @@ class DogAllOf { @override int get hashCode => + // ignore: unnecessary_parenthesis (breed == null ? 0 : breed.hashCode); @override @@ -37,33 +39,46 @@ class DogAllOf { } /// Returns a new [DogAllOf] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static DogAllOf fromJson(Map json) => json == null - ? null - : DogAllOf( - breed: json[r'breed'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static DogAllOf fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return DogAllOf( + breed: mapValueOfType(json, r'breed'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => DogAllOf.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(DogAllOf.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = DogAllOf.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = DogAllOf.fromJson(value)); } return map; } // maps a json object with a list of DogAllOf-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = DogAllOf.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = DogAllOf.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/enum_arrays.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/enum_arrays.dart index dc994bc308a..96ff43d0038 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/enum_arrays.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/enum_arrays.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -27,6 +28,7 @@ class EnumArrays { @override int get hashCode => + // ignore: unnecessary_parenthesis (justSymbol == null ? 0 : justSymbol.hashCode) + (arrayEnum == null ? 0 : arrayEnum.hashCode); @@ -45,34 +47,47 @@ class EnumArrays { } /// Returns a new [EnumArrays] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static EnumArrays fromJson(Map json) => json == null - ? null - : EnumArrays( + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static EnumArrays fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return EnumArrays( justSymbol: EnumArraysJustSymbolEnum.fromJson(json[r'just_symbol']), arrayEnum: EnumArraysArrayEnumEnum.listFromJson(json[r'array_enum']), - ); + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => EnumArrays.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(EnumArrays.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = EnumArrays.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = EnumArrays.fromJson(value)); } return map; } // maps a json object with a list of EnumArrays-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = EnumArrays.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = EnumArrays.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } @@ -87,7 +102,7 @@ class EnumArraysJustSymbolEnum { final String value; @override - String toString() => value; + String toString() => value ?? ''; String toJson() => value; @@ -103,20 +118,18 @@ class EnumArraysJustSymbolEnum { static EnumArraysJustSymbolEnum fromJson(dynamic value) => EnumArraysJustSymbolEnumTypeTransformer().decode(value); - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json - .map((value) => EnumArraysJustSymbolEnum.fromJson(value)) - .toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(EnumArraysJustSymbolEnum.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; } /// Transformation class that can [encode] an instance of [EnumArraysJustSymbolEnum] to String, /// and [decode] dynamic data back to [EnumArraysJustSymbolEnum]. class EnumArraysJustSymbolEnumTypeTransformer { - const EnumArraysJustSymbolEnumTypeTransformer._(); + factory EnumArraysJustSymbolEnumTypeTransformer() => _instance ??= const EnumArraysJustSymbolEnumTypeTransformer._(); - factory EnumArraysJustSymbolEnumTypeTransformer() => _instance ??= EnumArraysJustSymbolEnumTypeTransformer._(); + const EnumArraysJustSymbolEnumTypeTransformer._(); String encode(EnumArraysJustSymbolEnum data) => data.value; @@ -129,13 +142,15 @@ class EnumArraysJustSymbolEnumTypeTransformer { /// 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. EnumArraysJustSymbolEnum decode(dynamic data, {bool allowNull}) { - switch (data) { - case r'>=': return EnumArraysJustSymbolEnum.greaterThanEqual; - case r'$': return EnumArraysJustSymbolEnum.dollar; - default: - if (allowNull == false) { - throw ArgumentError('Unknown enum value to decode: $data'); - } + if (data != null) { + switch (data.toString()) { + case r'>=': return EnumArraysJustSymbolEnum.greaterThanEqual; + case r'$': return EnumArraysJustSymbolEnum.dollar; + default: + if (allowNull == false) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } } return null; } @@ -145,6 +160,7 @@ class EnumArraysJustSymbolEnumTypeTransformer { } + class EnumArraysArrayEnumEnum { /// Instantiate a new enum with the provided [value]. const EnumArraysArrayEnumEnum._(this.value); @@ -153,7 +169,7 @@ class EnumArraysArrayEnumEnum { final String value; @override - String toString() => value; + String toString() => value ?? ''; String toJson() => value; @@ -169,20 +185,18 @@ class EnumArraysArrayEnumEnum { static EnumArraysArrayEnumEnum fromJson(dynamic value) => EnumArraysArrayEnumEnumTypeTransformer().decode(value); - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json - .map((value) => EnumArraysArrayEnumEnum.fromJson(value)) - .toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(EnumArraysArrayEnumEnum.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; } /// Transformation class that can [encode] an instance of [EnumArraysArrayEnumEnum] to String, /// and [decode] dynamic data back to [EnumArraysArrayEnumEnum]. class EnumArraysArrayEnumEnumTypeTransformer { - const EnumArraysArrayEnumEnumTypeTransformer._(); + factory EnumArraysArrayEnumEnumTypeTransformer() => _instance ??= const EnumArraysArrayEnumEnumTypeTransformer._(); - factory EnumArraysArrayEnumEnumTypeTransformer() => _instance ??= EnumArraysArrayEnumEnumTypeTransformer._(); + const EnumArraysArrayEnumEnumTypeTransformer._(); String encode(EnumArraysArrayEnumEnum data) => data.value; @@ -195,13 +209,15 @@ class EnumArraysArrayEnumEnumTypeTransformer { /// 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. EnumArraysArrayEnumEnum decode(dynamic data, {bool allowNull}) { - switch (data) { - case r'fish': return EnumArraysArrayEnumEnum.fish; - case r'crab': return EnumArraysArrayEnumEnum.crab; - default: - if (allowNull == false) { - throw ArgumentError('Unknown enum value to decode: $data'); - } + if (data != null) { + switch (data.toString()) { + case r'fish': return EnumArraysArrayEnumEnum.fish; + case r'crab': return EnumArraysArrayEnumEnum.crab; + default: + if (allowNull == false) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } } return null; } @@ -210,3 +226,4 @@ class EnumArraysArrayEnumEnumTypeTransformer { static EnumArraysArrayEnumEnumTypeTransformer _instance; } + diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/enum_class.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/enum_class.dart index 96647a37971..e50e9471eac 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/enum_class.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/enum_class.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -18,7 +19,7 @@ class EnumClass { final String value; @override - String toString() => value; + String toString() => value ?? ''; String toJson() => value; @@ -36,20 +37,18 @@ class EnumClass { static EnumClass fromJson(dynamic value) => EnumClassTypeTransformer().decode(value); - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json - .map((value) => EnumClass.fromJson(value)) - .toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(EnumClass.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; } /// Transformation class that can [encode] an instance of [EnumClass] to String, /// and [decode] dynamic data back to [EnumClass]. class EnumClassTypeTransformer { - const EnumClassTypeTransformer._(); + factory EnumClassTypeTransformer() => _instance ??= const EnumClassTypeTransformer._(); - factory EnumClassTypeTransformer() => _instance ??= EnumClassTypeTransformer._(); + const EnumClassTypeTransformer._(); String encode(EnumClass data) => data.value; @@ -62,14 +61,16 @@ class EnumClassTypeTransformer { /// 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. EnumClass decode(dynamic data, {bool allowNull}) { - switch (data) { - case r'_abc': return EnumClass.abc; - case r'-efg': return EnumClass.efg; - case r'(xyz)': return EnumClass.leftParenthesisXyzRightParenthesis; - default: - if (allowNull == false) { - throw ArgumentError('Unknown enum value to decode: $data'); - } + if (data != null) { + switch (data.toString()) { + case r'_abc': return EnumClass.abc; + case r'-efg': return EnumClass.efg; + case r'(xyz)': return EnumClass.leftParenthesisXyzRightParenthesis; + default: + if (allowNull == false) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } } return null; } @@ -77,3 +78,4 @@ class EnumClassTypeTransformer { /// Singleton [EnumClassTypeTransformer] instance. static EnumClassTypeTransformer _instance; } + diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/enum_test.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/enum_test.dart index 51a444f1cea..ee1a8aff9f3 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/enum_test.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/enum_test.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -51,6 +52,7 @@ class EnumTest { @override int get hashCode => + // ignore: unnecessary_parenthesis (enumString == null ? 0 : enumString.hashCode) + (enumStringRequired == null ? 0 : enumStringRequired.hashCode) + (enumInteger == null ? 0 : enumInteger.hashCode) + @@ -91,10 +93,12 @@ class EnumTest { } /// Returns a new [EnumTest] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static EnumTest fromJson(Map json) => json == null - ? null - : EnumTest( + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static EnumTest fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return EnumTest( enumString: EnumTestEnumStringEnum.fromJson(json[r'enum_string']), enumStringRequired: EnumTestEnumStringRequiredEnum.fromJson(json[r'enum_string_required']), enumInteger: EnumTestEnumIntegerEnum.fromJson(json[r'enum_integer']), @@ -103,28 +107,39 @@ class EnumTest { outerEnumInteger: OuterEnumInteger.fromJson(json[r'outerEnumInteger']), outerEnumDefaultValue: OuterEnumDefaultValue.fromJson(json[r'outerEnumDefaultValue']), outerEnumIntegerDefaultValue: OuterEnumIntegerDefaultValue.fromJson(json[r'outerEnumIntegerDefaultValue']), - ); + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => EnumTest.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(EnumTest.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = EnumTest.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = EnumTest.fromJson(value)); } return map; } // maps a json object with a list of EnumTest-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = EnumTest.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = EnumTest.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } @@ -139,7 +154,7 @@ class EnumTestEnumStringEnum { final String value; @override - String toString() => value; + String toString() => value ?? ''; String toJson() => value; @@ -157,20 +172,18 @@ class EnumTestEnumStringEnum { static EnumTestEnumStringEnum fromJson(dynamic value) => EnumTestEnumStringEnumTypeTransformer().decode(value); - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json - .map((value) => EnumTestEnumStringEnum.fromJson(value)) - .toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(EnumTestEnumStringEnum.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; } /// Transformation class that can [encode] an instance of [EnumTestEnumStringEnum] to String, /// and [decode] dynamic data back to [EnumTestEnumStringEnum]. class EnumTestEnumStringEnumTypeTransformer { - const EnumTestEnumStringEnumTypeTransformer._(); + factory EnumTestEnumStringEnumTypeTransformer() => _instance ??= const EnumTestEnumStringEnumTypeTransformer._(); - factory EnumTestEnumStringEnumTypeTransformer() => _instance ??= EnumTestEnumStringEnumTypeTransformer._(); + const EnumTestEnumStringEnumTypeTransformer._(); String encode(EnumTestEnumStringEnum data) => data.value; @@ -183,14 +196,16 @@ class EnumTestEnumStringEnumTypeTransformer { /// 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. EnumTestEnumStringEnum decode(dynamic data, {bool allowNull}) { - switch (data) { - case r'UPPER': return EnumTestEnumStringEnum.UPPER; - case r'lower': return EnumTestEnumStringEnum.lower; - case r'': return EnumTestEnumStringEnum.empty; - default: - if (allowNull == false) { - throw ArgumentError('Unknown enum value to decode: $data'); - } + if (data != null) { + switch (data.toString()) { + case r'UPPER': return EnumTestEnumStringEnum.UPPER; + case r'lower': return EnumTestEnumStringEnum.lower; + case r'': return EnumTestEnumStringEnum.empty; + default: + if (allowNull == false) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } } return null; } @@ -200,6 +215,7 @@ class EnumTestEnumStringEnumTypeTransformer { } + class EnumTestEnumStringRequiredEnum { /// Instantiate a new enum with the provided [value]. const EnumTestEnumStringRequiredEnum._(this.value); @@ -208,7 +224,7 @@ class EnumTestEnumStringRequiredEnum { final String value; @override - String toString() => value; + String toString() => value ?? ''; String toJson() => value; @@ -226,20 +242,18 @@ class EnumTestEnumStringRequiredEnum { static EnumTestEnumStringRequiredEnum fromJson(dynamic value) => EnumTestEnumStringRequiredEnumTypeTransformer().decode(value); - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json - .map((value) => EnumTestEnumStringRequiredEnum.fromJson(value)) - .toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(EnumTestEnumStringRequiredEnum.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; } /// Transformation class that can [encode] an instance of [EnumTestEnumStringRequiredEnum] to String, /// and [decode] dynamic data back to [EnumTestEnumStringRequiredEnum]. class EnumTestEnumStringRequiredEnumTypeTransformer { - const EnumTestEnumStringRequiredEnumTypeTransformer._(); + factory EnumTestEnumStringRequiredEnumTypeTransformer() => _instance ??= const EnumTestEnumStringRequiredEnumTypeTransformer._(); - factory EnumTestEnumStringRequiredEnumTypeTransformer() => _instance ??= EnumTestEnumStringRequiredEnumTypeTransformer._(); + const EnumTestEnumStringRequiredEnumTypeTransformer._(); String encode(EnumTestEnumStringRequiredEnum data) => data.value; @@ -252,14 +266,16 @@ class EnumTestEnumStringRequiredEnumTypeTransformer { /// 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. EnumTestEnumStringRequiredEnum decode(dynamic data, {bool allowNull}) { - switch (data) { - case r'UPPER': return EnumTestEnumStringRequiredEnum.UPPER; - case r'lower': return EnumTestEnumStringRequiredEnum.lower; - case r'': return EnumTestEnumStringRequiredEnum.empty; - default: - if (allowNull == false) { - throw ArgumentError('Unknown enum value to decode: $data'); - } + if (data != null) { + switch (data.toString()) { + case r'UPPER': return EnumTestEnumStringRequiredEnum.UPPER; + case r'lower': return EnumTestEnumStringRequiredEnum.lower; + case r'': return EnumTestEnumStringRequiredEnum.empty; + default: + if (allowNull == false) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } } return null; } @@ -269,6 +285,7 @@ class EnumTestEnumStringRequiredEnumTypeTransformer { } + class EnumTestEnumIntegerEnum { /// Instantiate a new enum with the provided [value]. const EnumTestEnumIntegerEnum._(this.value); @@ -277,7 +294,7 @@ class EnumTestEnumIntegerEnum { final int value; @override - String toString() => value.toString(); + String toString() => value == null ? '' : value.toString(); int toJson() => value; @@ -293,20 +310,18 @@ class EnumTestEnumIntegerEnum { static EnumTestEnumIntegerEnum fromJson(dynamic value) => EnumTestEnumIntegerEnumTypeTransformer().decode(value); - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json - .map((value) => EnumTestEnumIntegerEnum.fromJson(value)) - .toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(EnumTestEnumIntegerEnum.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; } /// Transformation class that can [encode] an instance of [EnumTestEnumIntegerEnum] to int, /// and [decode] dynamic data back to [EnumTestEnumIntegerEnum]. class EnumTestEnumIntegerEnumTypeTransformer { - const EnumTestEnumIntegerEnumTypeTransformer._(); + factory EnumTestEnumIntegerEnumTypeTransformer() => _instance ??= const EnumTestEnumIntegerEnumTypeTransformer._(); - factory EnumTestEnumIntegerEnumTypeTransformer() => _instance ??= EnumTestEnumIntegerEnumTypeTransformer._(); + const EnumTestEnumIntegerEnumTypeTransformer._(); int encode(EnumTestEnumIntegerEnum data) => data.value; @@ -319,13 +334,15 @@ class EnumTestEnumIntegerEnumTypeTransformer { /// 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. EnumTestEnumIntegerEnum decode(dynamic data, {bool allowNull}) { - switch (data) { - case 1: return EnumTestEnumIntegerEnum.number1; - case -1: return EnumTestEnumIntegerEnum.numberNegative1; - default: - if (allowNull == false) { - throw ArgumentError('Unknown enum value to decode: $data'); - } + if (data != null) { + switch (data.toString()) { + case 1: return EnumTestEnumIntegerEnum.number1; + case -1: return EnumTestEnumIntegerEnum.numberNegative1; + default: + if (allowNull == false) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } } return null; } @@ -335,6 +352,7 @@ class EnumTestEnumIntegerEnumTypeTransformer { } + class EnumTestEnumNumberEnum { /// Instantiate a new enum with the provided [value]. const EnumTestEnumNumberEnum._(this.value); @@ -343,7 +361,7 @@ class EnumTestEnumNumberEnum { final double value; @override - String toString() => value.toString(); + String toString() => value == null ? '' : value.toString(); double toJson() => value; @@ -359,20 +377,18 @@ class EnumTestEnumNumberEnum { static EnumTestEnumNumberEnum fromJson(dynamic value) => EnumTestEnumNumberEnumTypeTransformer().decode(value); - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json - .map((value) => EnumTestEnumNumberEnum.fromJson(value)) - .toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(EnumTestEnumNumberEnum.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; } /// Transformation class that can [encode] an instance of [EnumTestEnumNumberEnum] to double, /// and [decode] dynamic data back to [EnumTestEnumNumberEnum]. class EnumTestEnumNumberEnumTypeTransformer { - const EnumTestEnumNumberEnumTypeTransformer._(); + factory EnumTestEnumNumberEnumTypeTransformer() => _instance ??= const EnumTestEnumNumberEnumTypeTransformer._(); - factory EnumTestEnumNumberEnumTypeTransformer() => _instance ??= EnumTestEnumNumberEnumTypeTransformer._(); + const EnumTestEnumNumberEnumTypeTransformer._(); double encode(EnumTestEnumNumberEnum data) => data.value; @@ -385,13 +401,15 @@ class EnumTestEnumNumberEnumTypeTransformer { /// 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. EnumTestEnumNumberEnum decode(dynamic data, {bool allowNull}) { - switch (data) { - case '1.1': return EnumTestEnumNumberEnum.number1Period1; - case '-1.2': return EnumTestEnumNumberEnum.numberNegative1Period2; - default: - if (allowNull == false) { - throw ArgumentError('Unknown enum value to decode: $data'); - } + if (data != null) { + switch (data.toString()) { + case '1.1': return EnumTestEnumNumberEnum.number1Period1; + case '-1.2': return EnumTestEnumNumberEnum.numberNegative1Period2; + default: + if (allowNull == false) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } } return null; } @@ -400,3 +418,4 @@ class EnumTestEnumNumberEnumTypeTransformer { static EnumTestEnumNumberEnumTypeTransformer _instance; } + diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/file_schema_test_class.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/file_schema_test_class.dart index 4f659cddafa..82decacafc7 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/file_schema_test_class.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/file_schema_test_class.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -27,6 +28,7 @@ class FileSchemaTestClass { @override int get hashCode => + // ignore: unnecessary_parenthesis (file == null ? 0 : file.hashCode) + (files == null ? 0 : files.hashCode); @@ -45,34 +47,47 @@ class FileSchemaTestClass { } /// Returns a new [FileSchemaTestClass] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static FileSchemaTestClass fromJson(Map json) => json == null - ? null - : FileSchemaTestClass( + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static FileSchemaTestClass fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return FileSchemaTestClass( file: ModelFile.fromJson(json[r'file']), files: ModelFile.listFromJson(json[r'files']), - ); + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => FileSchemaTestClass.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(FileSchemaTestClass.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = FileSchemaTestClass.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = FileSchemaTestClass.fromJson(value)); } return map; } // maps a json object with a list of FileSchemaTestClass-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = FileSchemaTestClass.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = FileSchemaTestClass.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/foo.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/foo.dart index 4100fa1fa04..fe73d270550 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/foo.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/foo.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -23,6 +24,7 @@ class Foo { @override int get hashCode => + // ignore: unnecessary_parenthesis (bar == null ? 0 : bar.hashCode); @override @@ -37,33 +39,46 @@ class Foo { } /// Returns a new [Foo] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static Foo fromJson(Map json) => json == null - ? null - : Foo( - bar: json[r'bar'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static Foo fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return Foo( + bar: mapValueOfType(json, r'bar'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => Foo.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(Foo.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = Foo.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = Foo.fromJson(value)); } return map; } // maps a json object with a list of Foo-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = Foo.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = Foo.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/format_test.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/format_test.dart index 5f735c24f86..978a6713226 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/format_test.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/format_test.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -95,6 +96,7 @@ class FormatTest { @override int get hashCode => + // ignore: unnecessary_parenthesis (integer == null ? 0 : integer.hashCode) + (int32 == null ? 0 : int32.hashCode) + (int64 == null ? 0 : int64.hashCode) + @@ -161,54 +163,63 @@ class FormatTest { } /// Returns a new [FormatTest] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static FormatTest fromJson(Map json) => json == null - ? null - : FormatTest( - integer: json[r'integer'], - int32: json[r'int32'], - int64: json[r'int64'], - number: json[r'number'] == null ? - null : - json[r'number'].toDouble(), - float: json[r'float'], - double_: json[r'double'], - decimal: json[r'decimal'], - string: json[r'string'], - byte: json[r'byte'], + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static FormatTest fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return FormatTest( + integer: mapValueOfType(json, r'integer'), + int32: mapValueOfType(json, r'int32'), + int64: mapValueOfType(json, r'int64'), + number: json[r'number'] == null + ? null + : num.parse(json[r'number'].toString()), + float: mapValueOfType(json, r'float'), + double_: mapValueOfType(json, r'double'), + decimal: mapValueOfType(json, r'decimal'), + string: mapValueOfType(json, r'string'), + byte: mapValueOfType(json, r'byte'), binary: null, // No support for decoding binary content from JSON - date: json[r'date'] == null - ? null - : DateTime.parse(json[r'date']), - dateTime: json[r'dateTime'] == null - ? null - : DateTime.parse(json[r'dateTime']), - uuid: json[r'uuid'], - password: json[r'password'], - patternWithDigits: json[r'pattern_with_digits'], - patternWithDigitsAndDelimiter: json[r'pattern_with_digits_and_delimiter'], - ); + date: mapDateTime(json, r'date', ''), + dateTime: mapDateTime(json, r'dateTime', ''), + uuid: mapValueOfType(json, r'uuid'), + password: mapValueOfType(json, r'password'), + patternWithDigits: mapValueOfType(json, r'pattern_with_digits'), + patternWithDigitsAndDelimiter: mapValueOfType(json, r'pattern_with_digits_and_delimiter'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => FormatTest.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(FormatTest.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = FormatTest.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = FormatTest.fromJson(value)); } return map; } // maps a json object with a list of FormatTest-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = FormatTest.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = FormatTest.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/has_only_read_only.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/has_only_read_only.dart index dee44032840..c827adf295e 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/has_only_read_only.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/has_only_read_only.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -27,6 +28,7 @@ class HasOnlyReadOnly { @override int get hashCode => + // ignore: unnecessary_parenthesis (bar == null ? 0 : bar.hashCode) + (foo == null ? 0 : foo.hashCode); @@ -45,34 +47,47 @@ class HasOnlyReadOnly { } /// Returns a new [HasOnlyReadOnly] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static HasOnlyReadOnly fromJson(Map json) => json == null - ? null - : HasOnlyReadOnly( - bar: json[r'bar'], - foo: json[r'foo'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static HasOnlyReadOnly fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return HasOnlyReadOnly( + bar: mapValueOfType(json, r'bar'), + foo: mapValueOfType(json, r'foo'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => HasOnlyReadOnly.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(HasOnlyReadOnly.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = HasOnlyReadOnly.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = HasOnlyReadOnly.fromJson(value)); } return map; } // maps a json object with a list of HasOnlyReadOnly-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = HasOnlyReadOnly.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = HasOnlyReadOnly.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/health_check_result.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/health_check_result.dart index 06a044bb153..52359ee4003 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/health_check_result.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/health_check_result.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -23,6 +24,7 @@ class HealthCheckResult { @override int get hashCode => + // ignore: unnecessary_parenthesis (nullableMessage == null ? 0 : nullableMessage.hashCode); @override @@ -37,33 +39,46 @@ class HealthCheckResult { } /// Returns a new [HealthCheckResult] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static HealthCheckResult fromJson(Map json) => json == null - ? null - : HealthCheckResult( - nullableMessage: json[r'NullableMessage'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static HealthCheckResult fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return HealthCheckResult( + nullableMessage: mapValueOfType(json, r'NullableMessage'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => HealthCheckResult.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(HealthCheckResult.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = HealthCheckResult.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = HealthCheckResult.fromJson(value)); } return map; } // maps a json object with a list of HealthCheckResult-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = HealthCheckResult.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = HealthCheckResult.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/inline_response_default.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/inline_response_default.dart index 1cdee99a2de..12ac601d7e3 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/inline_response_default.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/inline_response_default.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -23,6 +24,7 @@ class InlineResponseDefault { @override int get hashCode => + // ignore: unnecessary_parenthesis (string == null ? 0 : string.hashCode); @override @@ -37,33 +39,46 @@ class InlineResponseDefault { } /// Returns a new [InlineResponseDefault] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static InlineResponseDefault fromJson(Map json) => json == null - ? null - : InlineResponseDefault( + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static InlineResponseDefault fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return InlineResponseDefault( string: Foo.fromJson(json[r'string']), - ); + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => InlineResponseDefault.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(InlineResponseDefault.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = InlineResponseDefault.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = InlineResponseDefault.fromJson(value)); } return map; } // maps a json object with a list of InlineResponseDefault-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = InlineResponseDefault.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = InlineResponseDefault.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/map_test.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/map_test.dart index 23a54bd34ae..cbb3f198252 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/map_test.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/map_test.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -35,6 +36,7 @@ class MapTest { @override int get hashCode => + // ignore: unnecessary_parenthesis (mapMapOfString == null ? 0 : mapMapOfString.hashCode) + (mapOfEnumString == null ? 0 : mapOfEnumString.hashCode) + (directMap == null ? 0 : directMap.hashCode) + @@ -61,44 +63,49 @@ class MapTest { } /// Returns a new [MapTest] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static MapTest fromJson(Map json) => json == null - ? null - : MapTest( - mapMapOfString: json[r'map_map_of_string'] == null - ? null - : (json[r'map_map_of_string'] as Map).cast(), - mapOfEnumString: json[r'map_of_enum_string'] == null ? - null : - (json[r'map_of_enum_string'] as Map).cast(), - directMap: json[r'direct_map'] == null ? - null : - (json[r'direct_map'] as Map).cast(), - indirectMap: json[r'indirect_map'] == null ? - null : - (json[r'indirect_map'] as Map).cast(), - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static MapTest fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return MapTest( + mapMapOfString: mapCastOfType(json, r'map_map_of_string'), + mapOfEnumString: mapCastOfType(json, r'map_of_enum_string'), + directMap: mapCastOfType(json, r'direct_map'), + indirectMap: mapCastOfType(json, r'indirect_map'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => MapTest.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(MapTest.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = MapTest.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = MapTest.fromJson(value)); } return map; } // maps a json object with a list of MapTest-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = MapTest.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = MapTest.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } @@ -113,7 +120,7 @@ class MapTestMapOfEnumStringEnum { final String value; @override - String toString() => value; + String toString() => value ?? ''; String toJson() => value; @@ -129,20 +136,18 @@ class MapTestMapOfEnumStringEnum { static MapTestMapOfEnumStringEnum fromJson(dynamic value) => MapTestMapOfEnumStringEnumTypeTransformer().decode(value); - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json - .map((value) => MapTestMapOfEnumStringEnum.fromJson(value)) - .toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(MapTestMapOfEnumStringEnum.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; } /// Transformation class that can [encode] an instance of [MapTestMapOfEnumStringEnum] to String, /// and [decode] dynamic data back to [MapTestMapOfEnumStringEnum]. class MapTestMapOfEnumStringEnumTypeTransformer { - const MapTestMapOfEnumStringEnumTypeTransformer._(); + factory MapTestMapOfEnumStringEnumTypeTransformer() => _instance ??= const MapTestMapOfEnumStringEnumTypeTransformer._(); - factory MapTestMapOfEnumStringEnumTypeTransformer() => _instance ??= MapTestMapOfEnumStringEnumTypeTransformer._(); + const MapTestMapOfEnumStringEnumTypeTransformer._(); String encode(MapTestMapOfEnumStringEnum data) => data.value; @@ -155,13 +160,15 @@ class MapTestMapOfEnumStringEnumTypeTransformer { /// 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. MapTestMapOfEnumStringEnum decode(dynamic data, {bool allowNull}) { - switch (data) { - case r'UPPER': return MapTestMapOfEnumStringEnum.UPPER; - case r'lower': return MapTestMapOfEnumStringEnum.lower; - default: - if (allowNull == false) { - throw ArgumentError('Unknown enum value to decode: $data'); - } + if (data != null) { + switch (data.toString()) { + case r'UPPER': return MapTestMapOfEnumStringEnum.UPPER; + case r'lower': return MapTestMapOfEnumStringEnum.lower; + default: + if (allowNull == false) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } } return null; } @@ -170,3 +177,4 @@ class MapTestMapOfEnumStringEnumTypeTransformer { static MapTestMapOfEnumStringEnumTypeTransformer _instance; } + diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/mixed_properties_and_additional_properties_class.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/mixed_properties_and_additional_properties_class.dart index 053427aafd1..994be26f9e3 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/mixed_properties_and_additional_properties_class.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/mixed_properties_and_additional_properties_class.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -31,6 +32,7 @@ class MixedPropertiesAndAdditionalPropertiesClass { @override int get hashCode => + // ignore: unnecessary_parenthesis (uuid == null ? 0 : uuid.hashCode) + (dateTime == null ? 0 : dateTime.hashCode) + (map == null ? 0 : map.hashCode); @@ -53,37 +55,48 @@ class MixedPropertiesAndAdditionalPropertiesClass { } /// Returns a new [MixedPropertiesAndAdditionalPropertiesClass] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static MixedPropertiesAndAdditionalPropertiesClass fromJson(Map json) => json == null - ? null - : MixedPropertiesAndAdditionalPropertiesClass( - uuid: json[r'uuid'], - dateTime: json[r'dateTime'] == null - ? null - : DateTime.parse(json[r'dateTime']), - map: json[r'map'] - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static MixedPropertiesAndAdditionalPropertiesClass fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return MixedPropertiesAndAdditionalPropertiesClass( + uuid: mapValueOfType(json, r'uuid'), + dateTime: mapDateTime(json, r'dateTime', ''), + map: mapValueOfType>(json, r'map'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => MixedPropertiesAndAdditionalPropertiesClass.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(MixedPropertiesAndAdditionalPropertiesClass.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = MixedPropertiesAndAdditionalPropertiesClass.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = MixedPropertiesAndAdditionalPropertiesClass.fromJson(value)); } return map; } // maps a json object with a list of MixedPropertiesAndAdditionalPropertiesClass-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = MixedPropertiesAndAdditionalPropertiesClass.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = MixedPropertiesAndAdditionalPropertiesClass.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model200_response.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model200_response.dart index 169581175eb..01fbb8e4e9a 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model200_response.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model200_response.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -27,6 +28,7 @@ class Model200Response { @override int get hashCode => + // ignore: unnecessary_parenthesis (name == null ? 0 : name.hashCode) + (class_ == null ? 0 : class_.hashCode); @@ -45,34 +47,47 @@ class Model200Response { } /// Returns a new [Model200Response] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static Model200Response fromJson(Map json) => json == null - ? null - : Model200Response( - name: json[r'name'], - class_: json[r'class'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static Model200Response fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return Model200Response( + name: mapValueOfType(json, r'name'), + class_: mapValueOfType(json, r'class'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => Model200Response.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(Model200Response.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = Model200Response.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = Model200Response.fromJson(value)); } return map; } // maps a json object with a list of Model200Response-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = Model200Response.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = Model200Response.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_client.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_client.dart index 039517160be..9b3ef92da87 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_client.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_client.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -23,6 +24,7 @@ class ModelClient { @override int get hashCode => + // ignore: unnecessary_parenthesis (client == null ? 0 : client.hashCode); @override @@ -37,33 +39,46 @@ class ModelClient { } /// Returns a new [ModelClient] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static ModelClient fromJson(Map json) => json == null - ? null - : ModelClient( - client: json[r'client'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static ModelClient fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return ModelClient( + client: mapValueOfType(json, r'client'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => ModelClient.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(ModelClient.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = ModelClient.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = ModelClient.fromJson(value)); } return map; } // maps a json object with a list of ModelClient-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = ModelClient.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = ModelClient.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_file.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_file.dart index 251cb11748b..66907de557c 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_file.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_file.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -24,6 +25,7 @@ class ModelFile { @override int get hashCode => + // ignore: unnecessary_parenthesis (sourceURI == null ? 0 : sourceURI.hashCode); @override @@ -38,33 +40,46 @@ class ModelFile { } /// Returns a new [ModelFile] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static ModelFile fromJson(Map json) => json == null - ? null - : ModelFile( - sourceURI: json[r'sourceURI'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static ModelFile fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return ModelFile( + sourceURI: mapValueOfType(json, r'sourceURI'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => ModelFile.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(ModelFile.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = ModelFile.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = ModelFile.fromJson(value)); } return map; } // maps a json object with a list of ModelFile-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = ModelFile.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = ModelFile.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_list.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_list.dart index c269cec60cf..e83b8055bc6 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_list.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_list.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -23,6 +24,7 @@ class ModelList { @override int get hashCode => + // ignore: unnecessary_parenthesis (n123list == null ? 0 : n123list.hashCode); @override @@ -37,33 +39,46 @@ class ModelList { } /// Returns a new [ModelList] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static ModelList fromJson(Map json) => json == null - ? null - : ModelList( - n123list: json[r'123-list'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static ModelList fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return ModelList( + n123list: mapValueOfType(json, r'123-list'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => ModelList.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(ModelList.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = ModelList.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = ModelList.fromJson(value)); } return map; } // maps a json object with a list of ModelList-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = ModelList.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = ModelList.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_return.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_return.dart index b4a37d9f633..3c740b8be85 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_return.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/model_return.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -23,6 +24,7 @@ class ModelReturn { @override int get hashCode => + // ignore: unnecessary_parenthesis (return_ == null ? 0 : return_.hashCode); @override @@ -37,33 +39,46 @@ class ModelReturn { } /// Returns a new [ModelReturn] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static ModelReturn fromJson(Map json) => json == null - ? null - : ModelReturn( - return_: json[r'return'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static ModelReturn fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return ModelReturn( + return_: mapValueOfType(json, r'return'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => ModelReturn.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(ModelReturn.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = ModelReturn.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = ModelReturn.fromJson(value)); } return map; } // maps a json object with a list of ModelReturn-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = ModelReturn.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = ModelReturn.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/name.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/name.dart index 9068f61d639..d0c3106e326 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/name.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/name.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -35,6 +36,7 @@ class Name { @override int get hashCode => + // ignore: unnecessary_parenthesis (name == null ? 0 : name.hashCode) + (snakeCase == null ? 0 : snakeCase.hashCode) + (property == null ? 0 : property.hashCode) + @@ -59,36 +61,49 @@ class Name { } /// Returns a new [Name] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static Name fromJson(Map json) => json == null - ? null - : Name( - name: json[r'name'], - snakeCase: json[r'snake_case'], - property: json[r'property'], - n123number: json[r'123Number'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static Name fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return Name( + name: mapValueOfType(json, r'name'), + snakeCase: mapValueOfType(json, r'snake_case'), + property: mapValueOfType(json, r'property'), + n123number: mapValueOfType(json, r'123Number'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => Name.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(Name.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = Name.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = Name.fromJson(value)); } return map; } // maps a json object with a list of Name-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = Name.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = Name.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/nullable_class.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/nullable_class.dart index f1df88a935a..469db464a5f 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/nullable_class.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/nullable_class.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -67,6 +68,7 @@ class NullableClass { @override int get hashCode => + // ignore: unnecessary_parenthesis (integerProp == null ? 0 : integerProp.hashCode) + (numberProp == null ? 0 : numberProp.hashCode) + (booleanProp == null ? 0 : booleanProp.hashCode) + @@ -125,50 +127,59 @@ class NullableClass { } /// Returns a new [NullableClass] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static NullableClass fromJson(Map json) => json == null - ? null - : NullableClass( - integerProp: json[r'integer_prop'], - numberProp: json[r'number_prop'] == null ? - null : - json[r'number_prop'].toDouble(), - booleanProp: json[r'boolean_prop'], - stringProp: json[r'string_prop'], - dateProp: json[r'date_prop'] == null + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static NullableClass fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return NullableClass( + integerProp: mapValueOfType(json, r'integer_prop'), + numberProp: json[r'number_prop'] == null ? null - : DateTime.parse(json[r'date_prop']), - datetimeProp: json[r'datetime_prop'] == null - ? null - : DateTime.parse(json[r'datetime_prop']), + : num.parse(json[r'number_prop'].toString()), + booleanProp: mapValueOfType(json, r'boolean_prop'), + stringProp: mapValueOfType(json, r'string_prop'), + dateProp: mapDateTime(json, r'date_prop', ''), + datetimeProp: mapDateTime(json, r'datetime_prop', ''), arrayNullableProp: Object.listFromJson(json[r'array_nullable_prop']), arrayAndItemsNullableProp: Object.listFromJson(json[r'array_and_items_nullable_prop']), arrayItemsNullable: Object.listFromJson(json[r'array_items_nullable']), - objectNullableProp: json[r'object_nullable_prop'] - objectAndItemsNullableProp: json[r'object_and_items_nullable_prop'] - objectItemsNullable: json[r'object_items_nullable'] - ); + objectNullableProp: mapValueOfType>(json, r'object_nullable_prop'), + objectAndItemsNullableProp: mapValueOfType>(json, r'object_and_items_nullable_prop'), + objectItemsNullable: mapValueOfType>(json, r'object_items_nullable'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => NullableClass.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(NullableClass.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = NullableClass.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = NullableClass.fromJson(value)); } return map; } // maps a json object with a list of NullableClass-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = NullableClass.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = NullableClass.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/number_only.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/number_only.dart index 16cc2514577..686cfff791f 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/number_only.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/number_only.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -23,6 +24,7 @@ class NumberOnly { @override int get hashCode => + // ignore: unnecessary_parenthesis (justNumber == null ? 0 : justNumber.hashCode); @override @@ -37,35 +39,48 @@ class NumberOnly { } /// Returns a new [NumberOnly] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static NumberOnly fromJson(Map json) => json == null - ? null - : NumberOnly( - justNumber: json[r'JustNumber'] == null ? - null : - json[r'JustNumber'].toDouble(), - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static NumberOnly fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return NumberOnly( + justNumber: json[r'JustNumber'] == null + ? null + : num.parse(json[r'JustNumber'].toString()), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => NumberOnly.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(NumberOnly.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = NumberOnly.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = NumberOnly.fromJson(value)); } return map; } // maps a json object with a list of NumberOnly-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = NumberOnly.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = NumberOnly.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_with_deprecated_fields.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_with_deprecated_fields.dart index b6fc0ba2ae8..b5e83009cf9 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_with_deprecated_fields.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/object_with_deprecated_fields.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -35,6 +36,7 @@ class ObjectWithDeprecatedFields { @override int get hashCode => + // ignore: unnecessary_parenthesis (uuid == null ? 0 : uuid.hashCode) + (id == null ? 0 : id.hashCode) + (deprecatedRef == null ? 0 : deprecatedRef.hashCode) + @@ -61,40 +63,53 @@ class ObjectWithDeprecatedFields { } /// Returns a new [ObjectWithDeprecatedFields] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static ObjectWithDeprecatedFields fromJson(Map json) => json == null - ? null - : ObjectWithDeprecatedFields( - uuid: json[r'uuid'], - id: json[r'id'] == null ? - null : - json[r'id'].toDouble(), - deprecatedRef: DeprecatedObject.fromJson(json[r'deprecatedRef']), - bars: json[r'bars'] == null + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static ObjectWithDeprecatedFields fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return ObjectWithDeprecatedFields( + uuid: mapValueOfType(json, r'uuid'), + id: json[r'id'] == null ? null - : (json[r'bars'] as List).cast(), - ); + : num.parse(json[r'id'].toString()), + deprecatedRef: DeprecatedObject.fromJson(json[r'deprecatedRef']), + bars: json[r'bars'] is List + ? (json[r'bars'] as List).cast() + : null, + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => ObjectWithDeprecatedFields.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(ObjectWithDeprecatedFields.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = ObjectWithDeprecatedFields.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = ObjectWithDeprecatedFields.fromJson(value)); } return map; } // maps a json object with a list of ObjectWithDeprecatedFields-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = ObjectWithDeprecatedFields.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = ObjectWithDeprecatedFields.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/order.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/order.dart index 4cf8b636f47..61d01acfaaa 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/order.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/order.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -44,6 +45,7 @@ class Order { @override int get hashCode => + // ignore: unnecessary_parenthesis (id == null ? 0 : id.hashCode) + (petId == null ? 0 : petId.hashCode) + (quantity == null ? 0 : quantity.hashCode) + @@ -78,40 +80,51 @@ class Order { } /// Returns a new [Order] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static Order fromJson(Map json) => json == null - ? null - : Order( - id: json[r'id'], - petId: json[r'petId'], - quantity: json[r'quantity'], - shipDate: json[r'shipDate'] == null - ? null - : DateTime.parse(json[r'shipDate']), + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static Order fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return Order( + id: mapValueOfType(json, r'id'), + petId: mapValueOfType(json, r'petId'), + quantity: mapValueOfType(json, r'quantity'), + shipDate: mapDateTime(json, r'shipDate', ''), status: OrderStatusEnum.fromJson(json[r'status']), - complete: json[r'complete'], - ); + complete: mapValueOfType(json, r'complete'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => Order.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(Order.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = Order.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = Order.fromJson(value)); } return map; } // maps a json object with a list of Order-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = Order.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = Order.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } @@ -126,7 +139,7 @@ class OrderStatusEnum { final String value; @override - String toString() => value; + String toString() => value ?? ''; String toJson() => value; @@ -144,20 +157,18 @@ class OrderStatusEnum { static OrderStatusEnum fromJson(dynamic value) => OrderStatusEnumTypeTransformer().decode(value); - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json - .map((value) => OrderStatusEnum.fromJson(value)) - .toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(OrderStatusEnum.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; } /// Transformation class that can [encode] an instance of [OrderStatusEnum] to String, /// and [decode] dynamic data back to [OrderStatusEnum]. class OrderStatusEnumTypeTransformer { - const OrderStatusEnumTypeTransformer._(); + factory OrderStatusEnumTypeTransformer() => _instance ??= const OrderStatusEnumTypeTransformer._(); - factory OrderStatusEnumTypeTransformer() => _instance ??= OrderStatusEnumTypeTransformer._(); + const OrderStatusEnumTypeTransformer._(); String encode(OrderStatusEnum data) => data.value; @@ -170,14 +181,16 @@ 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}) { - switch (data) { - case r'placed': return OrderStatusEnum.placed; - case r'approved': return OrderStatusEnum.approved; - case r'delivered': return OrderStatusEnum.delivered; - default: - if (allowNull == false) { - throw ArgumentError('Unknown enum value to decode: $data'); - } + 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) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } } return null; } @@ -186,3 +199,4 @@ class OrderStatusEnumTypeTransformer { static OrderStatusEnumTypeTransformer _instance; } + diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_composite.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_composite.dart index c7aeb68f1ae..6ea8ef2ad98 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_composite.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_composite.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -31,6 +32,7 @@ class OuterComposite { @override int get hashCode => + // ignore: unnecessary_parenthesis (myNumber == null ? 0 : myNumber.hashCode) + (myString == null ? 0 : myString.hashCode) + (myBoolean == null ? 0 : myBoolean.hashCode); @@ -53,37 +55,50 @@ class OuterComposite { } /// Returns a new [OuterComposite] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static OuterComposite fromJson(Map json) => json == null - ? null - : OuterComposite( - myNumber: json[r'my_number'] == null ? - null : - json[r'my_number'].toDouble(), - myString: json[r'my_string'], - myBoolean: json[r'my_boolean'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static OuterComposite fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return OuterComposite( + myNumber: json[r'my_number'] == null + ? null + : num.parse(json[r'my_number'].toString()), + myString: mapValueOfType(json, r'my_string'), + myBoolean: mapValueOfType(json, r'my_boolean'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => OuterComposite.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(OuterComposite.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = OuterComposite.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = OuterComposite.fromJson(value)); } return map; } // maps a json object with a list of OuterComposite-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = OuterComposite.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = OuterComposite.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_enum.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_enum.dart index ce3f4c30a53..13e54eb7e59 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_enum.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_enum.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -18,7 +19,7 @@ class OuterEnum { final String value; @override - String toString() => value; + String toString() => value ?? ''; String toJson() => value; @@ -36,20 +37,18 @@ class OuterEnum { static OuterEnum fromJson(dynamic value) => OuterEnumTypeTransformer().decode(value); - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json - .map((value) => OuterEnum.fromJson(value)) - .toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(OuterEnum.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; } /// Transformation class that can [encode] an instance of [OuterEnum] to String, /// and [decode] dynamic data back to [OuterEnum]. class OuterEnumTypeTransformer { - const OuterEnumTypeTransformer._(); + factory OuterEnumTypeTransformer() => _instance ??= const OuterEnumTypeTransformer._(); - factory OuterEnumTypeTransformer() => _instance ??= OuterEnumTypeTransformer._(); + const OuterEnumTypeTransformer._(); String encode(OuterEnum data) => data.value; @@ -62,14 +61,16 @@ class OuterEnumTypeTransformer { /// 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. OuterEnum decode(dynamic data, {bool allowNull}) { - switch (data) { - case r'placed': return OuterEnum.placed; - case r'approved': return OuterEnum.approved; - case r'delivered': return OuterEnum.delivered; - default: - if (allowNull == false) { - throw ArgumentError('Unknown enum value to decode: $data'); - } + if (data != null) { + switch (data.toString()) { + case r'placed': return OuterEnum.placed; + case r'approved': return OuterEnum.approved; + case r'delivered': return OuterEnum.delivered; + default: + if (allowNull == false) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } } return null; } @@ -77,3 +78,4 @@ class OuterEnumTypeTransformer { /// Singleton [OuterEnumTypeTransformer] instance. static OuterEnumTypeTransformer _instance; } + diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_enum_default_value.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_enum_default_value.dart index 8f6d40b7d1e..5b2b1d500e5 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_enum_default_value.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_enum_default_value.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -18,7 +19,7 @@ class OuterEnumDefaultValue { final String value; @override - String toString() => value; + String toString() => value ?? ''; String toJson() => value; @@ -36,20 +37,18 @@ class OuterEnumDefaultValue { static OuterEnumDefaultValue fromJson(dynamic value) => OuterEnumDefaultValueTypeTransformer().decode(value); - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json - .map((value) => OuterEnumDefaultValue.fromJson(value)) - .toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(OuterEnumDefaultValue.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; } /// Transformation class that can [encode] an instance of [OuterEnumDefaultValue] to String, /// and [decode] dynamic data back to [OuterEnumDefaultValue]. class OuterEnumDefaultValueTypeTransformer { - const OuterEnumDefaultValueTypeTransformer._(); + factory OuterEnumDefaultValueTypeTransformer() => _instance ??= const OuterEnumDefaultValueTypeTransformer._(); - factory OuterEnumDefaultValueTypeTransformer() => _instance ??= OuterEnumDefaultValueTypeTransformer._(); + const OuterEnumDefaultValueTypeTransformer._(); String encode(OuterEnumDefaultValue data) => data.value; @@ -62,14 +61,16 @@ class OuterEnumDefaultValueTypeTransformer { /// 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. OuterEnumDefaultValue decode(dynamic data, {bool allowNull}) { - switch (data) { - case r'placed': return OuterEnumDefaultValue.placed; - case r'approved': return OuterEnumDefaultValue.approved; - case r'delivered': return OuterEnumDefaultValue.delivered; - default: - if (allowNull == false) { - throw ArgumentError('Unknown enum value to decode: $data'); - } + if (data != null) { + switch (data.toString()) { + case r'placed': return OuterEnumDefaultValue.placed; + case r'approved': return OuterEnumDefaultValue.approved; + case r'delivered': return OuterEnumDefaultValue.delivered; + default: + if (allowNull == false) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } } return null; } @@ -77,3 +78,4 @@ class OuterEnumDefaultValueTypeTransformer { /// Singleton [OuterEnumDefaultValueTypeTransformer] instance. static OuterEnumDefaultValueTypeTransformer _instance; } + diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_enum_integer.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_enum_integer.dart index 751506326be..6becb11fd9a 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_enum_integer.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_enum_integer.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -18,7 +19,7 @@ class OuterEnumInteger { final int value; @override - String toString() => value.toString(); + String toString() => value == null ? '' : value.toString(); int toJson() => value; @@ -36,20 +37,18 @@ class OuterEnumInteger { static OuterEnumInteger fromJson(dynamic value) => OuterEnumIntegerTypeTransformer().decode(value); - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json - .map((value) => OuterEnumInteger.fromJson(value)) - .toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(OuterEnumInteger.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; } /// Transformation class that can [encode] an instance of [OuterEnumInteger] to int, /// and [decode] dynamic data back to [OuterEnumInteger]. class OuterEnumIntegerTypeTransformer { - const OuterEnumIntegerTypeTransformer._(); + factory OuterEnumIntegerTypeTransformer() => _instance ??= const OuterEnumIntegerTypeTransformer._(); - factory OuterEnumIntegerTypeTransformer() => _instance ??= OuterEnumIntegerTypeTransformer._(); + const OuterEnumIntegerTypeTransformer._(); int encode(OuterEnumInteger data) => data.value; @@ -62,14 +61,16 @@ class OuterEnumIntegerTypeTransformer { /// 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. OuterEnumInteger decode(dynamic data, {bool allowNull}) { - switch (data) { - case 0: return OuterEnumInteger.number0; - case 1: return OuterEnumInteger.number1; - case 2: return OuterEnumInteger.number2; - default: - if (allowNull == false) { - throw ArgumentError('Unknown enum value to decode: $data'); - } + if (data != null) { + switch (data.toString()) { + case 0: return OuterEnumInteger.number0; + case 1: return OuterEnumInteger.number1; + case 2: return OuterEnumInteger.number2; + default: + if (allowNull == false) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } } return null; } @@ -77,3 +78,4 @@ class OuterEnumIntegerTypeTransformer { /// Singleton [OuterEnumIntegerTypeTransformer] instance. static OuterEnumIntegerTypeTransformer _instance; } + diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_enum_integer_default_value.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_enum_integer_default_value.dart index c5f52fc8047..5e534ea0f5c 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_enum_integer_default_value.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_enum_integer_default_value.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -18,7 +19,7 @@ class OuterEnumIntegerDefaultValue { final int value; @override - String toString() => value.toString(); + String toString() => value == null ? '' : value.toString(); int toJson() => value; @@ -36,20 +37,18 @@ class OuterEnumIntegerDefaultValue { static OuterEnumIntegerDefaultValue fromJson(dynamic value) => OuterEnumIntegerDefaultValueTypeTransformer().decode(value); - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json - .map((value) => OuterEnumIntegerDefaultValue.fromJson(value)) - .toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(OuterEnumIntegerDefaultValue.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; } /// Transformation class that can [encode] an instance of [OuterEnumIntegerDefaultValue] to int, /// and [decode] dynamic data back to [OuterEnumIntegerDefaultValue]. class OuterEnumIntegerDefaultValueTypeTransformer { - const OuterEnumIntegerDefaultValueTypeTransformer._(); + factory OuterEnumIntegerDefaultValueTypeTransformer() => _instance ??= const OuterEnumIntegerDefaultValueTypeTransformer._(); - factory OuterEnumIntegerDefaultValueTypeTransformer() => _instance ??= OuterEnumIntegerDefaultValueTypeTransformer._(); + const OuterEnumIntegerDefaultValueTypeTransformer._(); int encode(OuterEnumIntegerDefaultValue data) => data.value; @@ -62,14 +61,16 @@ class OuterEnumIntegerDefaultValueTypeTransformer { /// 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. OuterEnumIntegerDefaultValue decode(dynamic data, {bool allowNull}) { - switch (data) { - case 0: return OuterEnumIntegerDefaultValue.number0; - case 1: return OuterEnumIntegerDefaultValue.number1; - case 2: return OuterEnumIntegerDefaultValue.number2; - default: - if (allowNull == false) { - throw ArgumentError('Unknown enum value to decode: $data'); - } + if (data != null) { + switch (data.toString()) { + case 0: return OuterEnumIntegerDefaultValue.number0; + case 1: return OuterEnumIntegerDefaultValue.number1; + case 2: return OuterEnumIntegerDefaultValue.number2; + default: + if (allowNull == false) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } } return null; } @@ -77,3 +78,4 @@ class OuterEnumIntegerDefaultValueTypeTransformer { /// Singleton [OuterEnumIntegerDefaultValueTypeTransformer] instance. static OuterEnumIntegerDefaultValueTypeTransformer _instance; } + diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_object_with_enum_property.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_object_with_enum_property.dart index accf401ed9a..3ca207b7b74 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_object_with_enum_property.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_object_with_enum_property.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -23,6 +24,7 @@ class OuterObjectWithEnumProperty { @override int get hashCode => + // ignore: unnecessary_parenthesis (value == null ? 0 : value.hashCode); @override @@ -35,33 +37,46 @@ class OuterObjectWithEnumProperty { } /// Returns a new [OuterObjectWithEnumProperty] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static OuterObjectWithEnumProperty fromJson(Map json) => json == null - ? null - : OuterObjectWithEnumProperty( + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static OuterObjectWithEnumProperty fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return OuterObjectWithEnumProperty( value: OuterEnumInteger.fromJson(json[r'value']), - ); + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => OuterObjectWithEnumProperty.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(OuterObjectWithEnumProperty.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = OuterObjectWithEnumProperty.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = OuterObjectWithEnumProperty.fromJson(value)); } return map; } // maps a json object with a list of OuterObjectWithEnumProperty-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = OuterObjectWithEnumProperty.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = OuterObjectWithEnumProperty.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/pet.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/pet.dart index 3043edb921f..988948fe7c7 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/pet.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/pet.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -44,6 +45,7 @@ class Pet { @override int get hashCode => + // ignore: unnecessary_parenthesis (id == null ? 0 : id.hashCode) + (category == null ? 0 : category.hashCode) + (name == null ? 0 : name.hashCode) + @@ -74,40 +76,53 @@ class Pet { } /// Returns a new [Pet] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static Pet fromJson(Map json) => json == null - ? null - : Pet( - id: json[r'id'], + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static Pet fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return Pet( + id: mapValueOfType(json, r'id'), category: Category.fromJson(json[r'category']), - name: json[r'name'], - photoUrls: json[r'photoUrls'] == null - ? null - : (json[r'photoUrls'] as Set).cast(), + name: mapValueOfType(json, r'name'), + photoUrls: json[r'photoUrls'] is Set + ? (json[r'photoUrls'] as Set).cast() + : null, tags: Tag.listFromJson(json[r'tags']), status: PetStatusEnum.fromJson(json[r'status']), - ); + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => Pet.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(Pet.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = Pet.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = Pet.fromJson(value)); } return map; } // maps a json object with a list of Pet-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = Pet.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = Pet.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } @@ -122,7 +137,7 @@ class PetStatusEnum { final String value; @override - String toString() => value; + String toString() => value ?? ''; String toJson() => value; @@ -140,20 +155,18 @@ class PetStatusEnum { static PetStatusEnum fromJson(dynamic value) => PetStatusEnumTypeTransformer().decode(value); - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json - .map((value) => PetStatusEnum.fromJson(value)) - .toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(PetStatusEnum.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; } /// Transformation class that can [encode] an instance of [PetStatusEnum] to String, /// and [decode] dynamic data back to [PetStatusEnum]. class PetStatusEnumTypeTransformer { - const PetStatusEnumTypeTransformer._(); + factory PetStatusEnumTypeTransformer() => _instance ??= const PetStatusEnumTypeTransformer._(); - factory PetStatusEnumTypeTransformer() => _instance ??= PetStatusEnumTypeTransformer._(); + const PetStatusEnumTypeTransformer._(); String encode(PetStatusEnum data) => data.value; @@ -166,14 +179,16 @@ 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}) { - switch (data) { - case r'available': return PetStatusEnum.available; - case r'pending': return PetStatusEnum.pending; - case r'sold': return PetStatusEnum.sold; - default: - if (allowNull == false) { - throw ArgumentError('Unknown enum value to decode: $data'); - } + 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) { + throw ArgumentError('Unknown enum value to decode: $data'); + } + } } return null; } @@ -182,3 +197,4 @@ class PetStatusEnumTypeTransformer { static PetStatusEnumTypeTransformer _instance; } + diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/read_only_first.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/read_only_first.dart index b0eb02b6942..b1a1fe0c1d0 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/read_only_first.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/read_only_first.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -27,6 +28,7 @@ class ReadOnlyFirst { @override int get hashCode => + // ignore: unnecessary_parenthesis (bar == null ? 0 : bar.hashCode) + (baz == null ? 0 : baz.hashCode); @@ -45,34 +47,47 @@ class ReadOnlyFirst { } /// Returns a new [ReadOnlyFirst] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static ReadOnlyFirst fromJson(Map json) => json == null - ? null - : ReadOnlyFirst( - bar: json[r'bar'], - baz: json[r'baz'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static ReadOnlyFirst fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return ReadOnlyFirst( + bar: mapValueOfType(json, r'bar'), + baz: mapValueOfType(json, r'baz'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => ReadOnlyFirst.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(ReadOnlyFirst.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = ReadOnlyFirst.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = ReadOnlyFirst.fromJson(value)); } return map; } // maps a json object with a list of ReadOnlyFirst-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = ReadOnlyFirst.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = ReadOnlyFirst.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/special_model_name.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/special_model_name.dart index e43a6b267d2..5ed9408d26a 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/special_model_name.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/special_model_name.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -23,6 +24,7 @@ class SpecialModelName { @override int get hashCode => + // ignore: unnecessary_parenthesis (dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket == null ? 0 : dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket.hashCode); @override @@ -37,33 +39,46 @@ class SpecialModelName { } /// Returns a new [SpecialModelName] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static SpecialModelName fromJson(Map json) => json == null - ? null - : SpecialModelName( - dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket: json[r'$special[property.name]'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static SpecialModelName fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return SpecialModelName( + dollarSpecialLeftSquareBracketPropertyPeriodNameRightSquareBracket: mapValueOfType(json, r'$special[property.name]'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => SpecialModelName.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(SpecialModelName.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = SpecialModelName.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = SpecialModelName.fromJson(value)); } return map; } // maps a json object with a list of SpecialModelName-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = SpecialModelName.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = SpecialModelName.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/tag.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/tag.dart index 0cd372910b9..193c7004028 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/tag.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/tag.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -27,6 +28,7 @@ class Tag { @override int get hashCode => + // ignore: unnecessary_parenthesis (id == null ? 0 : id.hashCode) + (name == null ? 0 : name.hashCode); @@ -45,34 +47,47 @@ class Tag { } /// Returns a new [Tag] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static Tag fromJson(Map json) => json == null - ? null - : Tag( - id: json[r'id'], - name: json[r'name'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static Tag fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return Tag( + id: mapValueOfType(json, r'id'), + name: mapValueOfType(json, r'name'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => Tag.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(Tag.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = Tag.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = Tag.fromJson(value)); } return map; } // maps a json object with a list of Tag-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = Tag.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = Tag.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/user.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/user.dart index 0eb3716fceb..d2b94ed6a7a 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/user.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/user.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -52,6 +53,7 @@ class User { @override int get hashCode => + // ignore: unnecessary_parenthesis (id == null ? 0 : id.hashCode) + (username == null ? 0 : username.hashCode) + (firstName == null ? 0 : firstName.hashCode) + @@ -94,40 +96,53 @@ class User { } /// Returns a new [User] instance and imports its values from - /// [json] if it's non-null, null if [json] is null. - static User fromJson(Map json) => json == null - ? null - : User( - id: json[r'id'], - username: json[r'username'], - firstName: json[r'firstName'], - lastName: json[r'lastName'], - email: json[r'email'], - password: json[r'password'], - phone: json[r'phone'], - userStatus: json[r'userStatus'], - ); + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static User fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + return User( + id: mapValueOfType(json, r'id'), + username: mapValueOfType(json, r'username'), + firstName: mapValueOfType(json, r'firstName'), + lastName: mapValueOfType(json, r'lastName'), + email: mapValueOfType(json, r'email'), + password: mapValueOfType(json, r'password'), + phone: mapValueOfType(json, r'phone'), + userStatus: mapValueOfType(json, r'userStatus'), + ); + } + return null; + } - static List listFromJson(List json, {bool emptyIsNull, bool growable,}) => - json == null || json.isEmpty - ? true == emptyIsNull ? null : [] - : json.map((dynamic value) => User.fromJson(value)).toList(growable: true == growable); + static List listFromJson(dynamic json, {bool emptyIsNull, bool growable,}) => + json is List && json.isNotEmpty + ? json.map(User.fromJson).toList(growable: true == growable) + : true == emptyIsNull ? null : []; - static Map mapFromJson(Map json) { + static Map mapFromJson(dynamic json) { final map = {}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) => map[key] = User.fromJson(value)); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) => map[key] = User.fromJson(value)); } return map; } // maps a json object with a list of User-objects as value to a dart map - static Map> mapListFromJson(Map json, {bool emptyIsNull, bool growable,}) { + static Map> mapListFromJson(dynamic json, {bool emptyIsNull, bool growable,}) { final map = >{}; - if (json?.isNotEmpty == true) { - json.forEach((key, value) { - map[key] = User.listFromJson(value, emptyIsNull: emptyIsNull, growable: growable,); - }); + if (json is Map && json.isNotEmpty) { + json + .cast() + .forEach((key, dynamic value) { + map[key] = User.listFromJson( + value, + emptyIsNull: emptyIsNull, + growable: growable, + ); + }); } return map; } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/analysis_options.yaml b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/analysis_options.yaml index 83d5a10bd7b..e69de29bb2d 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/analysis_options.yaml +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/analysis_options.yaml @@ -1,3 +0,0 @@ -analyzer: - strong-mode: - implicit-casts: true diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api.dart index 2e56998b25b..920f26ddc57 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api.dart @@ -5,6 +5,7 @@ // 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 library openapi.api; diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/another_fake_api.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/another_fake_api.dart index f0115e6907b..2295e5df8ad 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/another_fake_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/another_fake_api.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -25,33 +26,34 @@ class AnotherFakeApi { /// /// * [ModelClient] modelClient (required): /// client model - Future call123testSpecialTagsWithHttpInfo(ModelClient modelClient) async { + Future 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'PATCH', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -64,8 +66,8 @@ class AnotherFakeApi { /// /// * [ModelClient] modelClient (required): /// client model - Future call123testSpecialTags(ModelClient modelClient) async { - final response = await call123testSpecialTagsWithHttpInfo(modelClient); + Future call123testSpecialTags(ModelClient modelClient,) async { + final response = await call123testSpecialTagsWithHttpInfo(modelClient,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -76,6 +78,6 @@ class AnotherFakeApi { return ModelClient.fromJson(json.decode(response.body)); } - return Future.value(null); + return Future.value(); } } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/default_api.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/default_api.dart index 182442cbd42..8f485dacf17 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/default_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/default_api.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -17,27 +18,28 @@ class DefaultApi { /// Performs an HTTP 'GET /foo' operation and returns the [Response]. Future fooGetWithHttpInfo() async { + // ignore: prefer_const_declarations final path = r'/foo'; + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -54,6 +56,6 @@ class DefaultApi { return InlineResponseDefault.fromJson(json.decode(response.body)); } - return Future.value(null); + return Future.value(); } } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/fake_api.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/fake_api.dart index 3a1d5162364..05fedc622a2 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/fake_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/fake_api.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -19,27 +20,28 @@ class FakeApi { /// /// Note: This method returns the HTTP [Response]. Future fakeHealthGetWithHttpInfo() async { + // ignore: prefer_const_declarations final path = r'/fake/health'; + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -57,7 +59,7 @@ class FakeApi { return HealthCheckResult.fromJson(json.decode(response.body)); } - return Future.value(null); + return Future.value(); } /// test http signature authentication @@ -74,14 +76,16 @@ class FakeApi { /// /// * [String] header1: /// header parameter - Future fakeHttpSignatureTestWithHttpInfo(Pet pet, { String query1, String header1 }) async { + Future fakeHttpSignatureTestWithHttpInfo(Pet pet, { String query1, String header1, }) async { // Verify required params are set. if (pet == null) { throw ApiException(HttpStatus.badRequest, 'Missing required param: pet'); } + // ignore: prefer_const_declarations final path = r'/fake/http-signature-test'; + // ignore: prefer_final_locals Object postBody = pet; final queryParams = []; @@ -96,19 +100,18 @@ class FakeApi { headerParams[r'header_1'] = parameterToString(header1); } - final contentTypes = ['application/json', 'application/xml']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['http_signature_test']; + const authNames = ['http_signature_test']; + const contentTypes = ['application/json', 'application/xml']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -125,8 +128,8 @@ class FakeApi { /// /// * [String] header1: /// header parameter - Future fakeHttpSignatureTest(Pet pet, { String query1, String header1 }) async { - final response = await fakeHttpSignatureTestWithHttpInfo(pet, query1: query1, header1: header1 ); + Future 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)); } @@ -140,30 +143,31 @@ class FakeApi { /// /// * [bool] body: /// Input boolean as post body - Future fakeOuterBooleanSerializeWithHttpInfo({ bool body }) async { + Future fakeOuterBooleanSerializeWithHttpInfo({ bool body, }) async { // Verify required params are set. + // ignore: prefer_const_declarations final path = r'/fake/outer/boolean'; + // ignore: prefer_final_locals Object postBody = body; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -174,8 +178,8 @@ class FakeApi { /// /// * [bool] body: /// Input boolean as post body - Future fakeOuterBooleanSerialize({ bool body }) async { - final response = await fakeOuterBooleanSerializeWithHttpInfo( body: body ); + Future fakeOuterBooleanSerialize({ bool body, }) async { + final response = await fakeOuterBooleanSerializeWithHttpInfo( body: body, ); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -186,7 +190,7 @@ class FakeApi { return response.body as bool; } - return Future.value(null); + return Future.value(); } /// Test serialization of object with outer number type @@ -197,30 +201,31 @@ class FakeApi { /// /// * [OuterComposite] outerComposite: /// Input composite as post body - Future fakeOuterCompositeSerializeWithHttpInfo({ OuterComposite outerComposite }) async { + Future fakeOuterCompositeSerializeWithHttpInfo({ OuterComposite outerComposite, }) async { // Verify required params are set. + // ignore: prefer_const_declarations final path = r'/fake/outer/composite'; + // ignore: prefer_final_locals Object postBody = outerComposite; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -231,8 +236,8 @@ class FakeApi { /// /// * [OuterComposite] outerComposite: /// Input composite as post body - Future fakeOuterCompositeSerialize({ OuterComposite outerComposite }) async { - final response = await fakeOuterCompositeSerializeWithHttpInfo( outerComposite: outerComposite ); + Future fakeOuterCompositeSerialize({ OuterComposite outerComposite, }) async { + final response = await fakeOuterCompositeSerializeWithHttpInfo( outerComposite: outerComposite, ); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -243,7 +248,7 @@ class FakeApi { return OuterComposite.fromJson(json.decode(response.body)); } - return Future.value(null); + return Future.value(); } /// Test serialization of outer number types @@ -254,30 +259,31 @@ class FakeApi { /// /// * [num] body: /// Input number as post body - Future fakeOuterNumberSerializeWithHttpInfo({ num body }) async { + Future fakeOuterNumberSerializeWithHttpInfo({ num body, }) async { // Verify required params are set. + // ignore: prefer_const_declarations final path = r'/fake/outer/number'; + // ignore: prefer_final_locals Object postBody = body; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -288,8 +294,8 @@ class FakeApi { /// /// * [num] body: /// Input number as post body - Future fakeOuterNumberSerialize({ num body }) async { - final response = await fakeOuterNumberSerializeWithHttpInfo( body: body ); + Future fakeOuterNumberSerialize({ num body, }) async { + final response = await fakeOuterNumberSerializeWithHttpInfo( body: body, ); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -300,7 +306,7 @@ class FakeApi { return response.body as num; } - return Future.value(null); + return Future.value(); } /// Test serialization of outer string types @@ -311,30 +317,31 @@ class FakeApi { /// /// * [String] body: /// Input string as post body - Future fakeOuterStringSerializeWithHttpInfo({ String body }) async { + Future fakeOuterStringSerializeWithHttpInfo({ String body, }) async { // Verify required params are set. + // ignore: prefer_const_declarations final path = r'/fake/outer/string'; + // ignore: prefer_final_locals Object postBody = body; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -345,8 +352,8 @@ class FakeApi { /// /// * [String] body: /// Input string as post body - Future fakeOuterStringSerialize({ String body }) async { - final response = await fakeOuterStringSerializeWithHttpInfo( body: body ); + Future fakeOuterStringSerialize({ String body, }) async { + final response = await fakeOuterStringSerializeWithHttpInfo( body: body, ); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -357,7 +364,7 @@ class FakeApi { return response.body as String; } - return Future.value(null); + return Future.value(); } /// Test serialization of enum (int) properties with examples @@ -368,33 +375,34 @@ class FakeApi { /// /// * [OuterObjectWithEnumProperty] outerObjectWithEnumProperty (required): /// Input enum (int) as post body - Future fakePropertyEnumIntegerSerializeWithHttpInfo(OuterObjectWithEnumProperty outerObjectWithEnumProperty) async { + Future 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -405,8 +413,8 @@ class FakeApi { /// /// * [OuterObjectWithEnumProperty] outerObjectWithEnumProperty (required): /// Input enum (int) as post body - Future fakePropertyEnumIntegerSerialize(OuterObjectWithEnumProperty outerObjectWithEnumProperty) async { - final response = await fakePropertyEnumIntegerSerializeWithHttpInfo(outerObjectWithEnumProperty); + Future fakePropertyEnumIntegerSerialize(OuterObjectWithEnumProperty outerObjectWithEnumProperty,) async { + final response = await fakePropertyEnumIntegerSerializeWithHttpInfo(outerObjectWithEnumProperty,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -417,7 +425,7 @@ class FakeApi { return OuterObjectWithEnumProperty.fromJson(json.decode(response.body)); } - return Future.value(null); + return Future.value(); } /// For this test, the body has to be a binary file. @@ -428,33 +436,34 @@ class FakeApi { /// /// * [MultipartFile] body (required): /// image to upload - Future testBodyWithBinaryWithHttpInfo(MultipartFile body) async { + Future 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['image/png']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['image/png']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'PUT', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -465,8 +474,8 @@ class FakeApi { /// /// * [MultipartFile] body (required): /// image to upload - Future testBodyWithBinary(MultipartFile body) async { - final response = await testBodyWithBinaryWithHttpInfo(body); + Future testBodyWithBinary(MultipartFile body,) async { + final response = await testBodyWithBinaryWithHttpInfo(body,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -479,33 +488,34 @@ class FakeApi { /// Parameters: /// /// * [FileSchemaTestClass] fileSchemaTestClass (required): - Future testBodyWithFileSchemaWithHttpInfo(FileSchemaTestClass fileSchemaTestClass) async { + Future 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'PUT', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -515,8 +525,8 @@ class FakeApi { /// Parameters: /// /// * [FileSchemaTestClass] fileSchemaTestClass (required): - Future testBodyWithFileSchema(FileSchemaTestClass fileSchemaTestClass) async { - final response = await testBodyWithFileSchemaWithHttpInfo(fileSchemaTestClass); + Future testBodyWithFileSchema(FileSchemaTestClass fileSchemaTestClass,) async { + final response = await testBodyWithFileSchemaWithHttpInfo(fileSchemaTestClass,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -528,7 +538,7 @@ class FakeApi { /// * [String] query (required): /// /// * [User] user (required): - Future testBodyWithQueryParamsWithHttpInfo(String query, User user) async { + Future testBodyWithQueryParamsWithHttpInfo(String query, User user,) async { // Verify required params are set. if (query == null) { throw ApiException(HttpStatus.badRequest, 'Missing required param: query'); @@ -537,8 +547,10 @@ class FakeApi { 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; final queryParams = []; @@ -547,19 +559,18 @@ class FakeApi { queryParams.addAll(_convertParametersForCollectionFormat('', 'query', query)); - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'PUT', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -569,8 +580,8 @@ class FakeApi { /// * [String] query (required): /// /// * [User] user (required): - Future testBodyWithQueryParams(String query, User user) async { - final response = await testBodyWithQueryParamsWithHttpInfo(query, user); + Future testBodyWithQueryParams(String query, User user,) async { + final response = await testBodyWithQueryParamsWithHttpInfo(query, user,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -586,33 +597,34 @@ class FakeApi { /// /// * [ModelClient] modelClient (required): /// client model - Future testClientModelWithHttpInfo(ModelClient modelClient) async { + Future 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'PATCH', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -625,8 +637,8 @@ class FakeApi { /// /// * [ModelClient] modelClient (required): /// client model - Future testClientModel(ModelClient modelClient) async { - final response = await testClientModelWithHttpInfo(modelClient); + Future testClientModel(ModelClient modelClient,) async { + final response = await testClientModelWithHttpInfo(modelClient,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -637,7 +649,7 @@ class FakeApi { return ModelClient.fromJson(json.decode(response.body)); } - return Future.value(null); + return Future.value(); } /// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -689,7 +701,7 @@ class FakeApi { /// /// * [String] callback: /// None - Future 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 { + Future 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'); @@ -704,17 +716,18 @@ class FakeApi { throw ApiException(HttpStatus.badRequest, 'Missing required param: byte'); } + // ignore: prefer_const_declarations final path = r'/fake'; + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/x-www-form-urlencoded']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['http_basic_test']; + const authNames = ['http_basic_test']; + const contentTypes = ['application/x-www-form-urlencoded']; if (integer != null) { formParams[r'integer'] = parameterToString(integer); @@ -756,14 +769,14 @@ class FakeApi { formParams[r'callback'] = parameterToString(callback); } - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -815,8 +828,8 @@ class FakeApi { /// /// * [String] callback: /// None - Future 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 ); + Future 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)); } @@ -853,11 +866,13 @@ class FakeApi { /// /// * [String] enumFormString: /// Form parameter enum test (string) - Future testEnumParametersWithHttpInfo({ List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, int enumQueryInteger, double enumQueryDouble, List enumFormStringArray, String enumFormString }) async { + Future testEnumParametersWithHttpInfo({ List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, int enumQueryInteger, double enumQueryDouble, List enumFormStringArray, String enumFormString, }) async { // Verify required params are set. + // ignore: prefer_const_declarations final path = r'/fake'; + // ignore: prefer_final_locals Object postBody; final queryParams = []; @@ -884,9 +899,8 @@ class FakeApi { headerParams[r'enum_header_string'] = parameterToString(enumHeaderString); } - final contentTypes = ['application/x-www-form-urlencoded']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/x-www-form-urlencoded']; if (enumFormStringArray != null) { formParams[r'enum_form_string_array'] = parameterToString(enumFormStringArray); @@ -895,14 +909,14 @@ class FakeApi { formParams[r'enum_form_string'] = parameterToString(enumFormString); } - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -936,8 +950,8 @@ class FakeApi { /// /// * [String] enumFormString: /// Form parameter enum test (string) - Future testEnumParameters({ List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, int enumQueryInteger, double enumQueryDouble, List enumFormStringArray, String enumFormString }) async { - final response = await testEnumParametersWithHttpInfo( enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString ); + Future testEnumParameters({ List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, int enumQueryInteger, double enumQueryDouble, List 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)); } @@ -968,7 +982,7 @@ class FakeApi { /// /// * [int] int64Group: /// Integer in group parameters - Future testGroupParametersWithHttpInfo(int requiredStringGroup, bool requiredBooleanGroup, int requiredInt64Group, { int stringGroup, bool booleanGroup, int int64Group }) async { + Future 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'); @@ -980,8 +994,10 @@ class FakeApi { throw ApiException(HttpStatus.badRequest, 'Missing required param: requiredInt64Group'); } + // ignore: prefer_const_declarations final path = r'/fake'; + // ignore: prefer_final_locals Object postBody; final queryParams = []; @@ -1002,19 +1018,18 @@ class FakeApi { headerParams[r'boolean_group'] = parameterToString(booleanGroup); } - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['bearer_test']; + const authNames = ['bearer_test']; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'DELETE', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -1042,8 +1057,8 @@ class FakeApi { /// /// * [int] int64Group: /// Integer in group parameters - Future 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 ); + Future 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)); } @@ -1057,33 +1072,34 @@ class FakeApi { /// /// * [Map] requestBody (required): /// request body - Future testInlineAdditionalPropertiesWithHttpInfo(Map requestBody) async { + Future testInlineAdditionalPropertiesWithHttpInfo(Map 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -1094,8 +1110,8 @@ class FakeApi { /// /// * [Map] requestBody (required): /// request body - Future testInlineAdditionalProperties(Map requestBody) async { - final response = await testInlineAdditionalPropertiesWithHttpInfo(requestBody); + Future testInlineAdditionalProperties(Map requestBody,) async { + final response = await testInlineAdditionalPropertiesWithHttpInfo(requestBody,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -1112,7 +1128,7 @@ class FakeApi { /// /// * [String] param2 (required): /// field2 - Future testJsonFormDataWithHttpInfo(String param, String param2) async { + Future testJsonFormDataWithHttpInfo(String param, String param2,) async { // Verify required params are set. if (param == null) { throw ApiException(HttpStatus.badRequest, 'Missing required param: param'); @@ -1121,17 +1137,18 @@ class FakeApi { throw ApiException(HttpStatus.badRequest, 'Missing required param: param2'); } + // ignore: prefer_const_declarations final path = r'/fake/jsonFormData'; + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/x-www-form-urlencoded']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/x-www-form-urlencoded']; if (param != null) { formParams[r'param'] = parameterToString(param); @@ -1140,14 +1157,14 @@ class FakeApi { formParams[r'param2'] = parameterToString(param2); } - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -1161,8 +1178,8 @@ class FakeApi { /// /// * [String] param2 (required): /// field2 - Future testJsonFormData(String param, String param2) async { - final response = await testJsonFormDataWithHttpInfo(param, param2); + Future testJsonFormData(String param, String param2,) async { + final response = await testJsonFormDataWithHttpInfo(param, param2,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -1187,7 +1204,7 @@ class FakeApi { /// * [String] allowEmpty (required): /// /// * [Map] language: - Future testQueryParameterCollectionFormatWithHttpInfo(List pipe, List ioutil, List http, List url, List context, String allowEmpty, { Map language }) async { + Future testQueryParameterCollectionFormatWithHttpInfo(List pipe, List ioutil, List http, List url, List context, String allowEmpty, { Map language, }) async { // Verify required params are set. if (pipe == null) { throw ApiException(HttpStatus.badRequest, 'Missing required param: pipe'); @@ -1208,8 +1225,10 @@ class FakeApi { throw ApiException(HttpStatus.badRequest, 'Missing required param: allowEmpty'); } + // ignore: prefer_const_declarations final path = r'/fake/test-query-parameters'; + // ignore: prefer_final_locals Object postBody; final queryParams = []; @@ -1226,19 +1245,18 @@ class FakeApi { } queryParams.addAll(_convertParametersForCollectionFormat('', 'allowEmpty', allowEmpty)); - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'PUT', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -1260,8 +1278,8 @@ class FakeApi { /// * [String] allowEmpty (required): /// /// * [Map] language: - Future testQueryParameterCollectionFormat(List pipe, List ioutil, List http, List url, List context, String allowEmpty, { Map language }) async { - final response = await testQueryParameterCollectionFormatWithHttpInfo(pipe, ioutil, http, url, context, allowEmpty, language: language ); + Future testQueryParameterCollectionFormat(List pipe, List ioutil, List http, List url, List context, String allowEmpty, { Map 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)); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/fake_classname_tags123_api.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/fake_classname_tags123_api.dart index c9fc34d194c..42639bc346e 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/fake_classname_tags123_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/fake_classname_tags123_api.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -25,33 +26,34 @@ class FakeClassnameTags123Api { /// /// * [ModelClient] modelClient (required): /// client model - Future testClassnameWithHttpInfo(ModelClient modelClient) async { + Future 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['api_key_query']; + const authNames = ['api_key_query']; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'PATCH', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -64,8 +66,8 @@ class FakeClassnameTags123Api { /// /// * [ModelClient] modelClient (required): /// client model - Future testClassname(ModelClient modelClient) async { - final response = await testClassnameWithHttpInfo(modelClient); + Future testClassname(ModelClient modelClient,) async { + final response = await testClassnameWithHttpInfo(modelClient,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -76,6 +78,6 @@ class FakeClassnameTags123Api { return ModelClient.fromJson(json.decode(response.body)); } - return Future.value(null); + return Future.value(); } } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/pet_api.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/pet_api.dart index dec9efa15f7..398fd576224 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/pet_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/pet_api.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -23,33 +24,34 @@ class PetApi { /// /// * [Pet] pet (required): /// Pet object that needs to be added to the store - Future addPetWithHttpInfo(Pet pet) async { + Future 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json', 'application/xml']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['petstore_auth']; + const authNames = ['petstore_auth']; + const contentTypes = ['application/json', 'application/xml']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -60,8 +62,8 @@ class PetApi { /// /// * [Pet] pet (required): /// Pet object that needs to be added to the store - Future addPet(Pet pet) async { - final response = await addPetWithHttpInfo(pet); + Future addPet(Pet pet,) async { + final response = await addPetWithHttpInfo(pet,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -77,15 +79,17 @@ class PetApi { /// Pet id to delete /// /// * [String] apiKey: - Future deletePetWithHttpInfo(int petId, { String apiKey }) async { + Future deletePetWithHttpInfo(int petId, { String apiKey, }) 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()); + .replaceAll('{petId}', petId.toString()); + // ignore: prefer_final_locals Object postBody; final queryParams = []; @@ -96,19 +100,18 @@ class PetApi { headerParams[r'api_key'] = parameterToString(apiKey); } - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['petstore_auth']; + const authNames = ['petstore_auth']; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'DELETE', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -121,8 +124,8 @@ class PetApi { /// Pet id to delete /// /// * [String] apiKey: - Future deletePet(int petId, { String apiKey }) async { - final response = await deletePetWithHttpInfo(petId, apiKey: apiKey ); + Future 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)); } @@ -138,14 +141,16 @@ class PetApi { /// /// * [List] status (required): /// Status values that need to be considered for filter - Future findPetsByStatusWithHttpInfo(List status) async { + Future findPetsByStatusWithHttpInfo(List 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; final queryParams = []; @@ -154,19 +159,18 @@ class PetApi { queryParams.addAll(_convertParametersForCollectionFormat('csv', 'status', status)); - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['petstore_auth']; + const authNames = ['petstore_auth']; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -179,8 +183,8 @@ class PetApi { /// /// * [List] status (required): /// Status values that need to be considered for filter - Future> findPetsByStatus(List status) async { - final response = await findPetsByStatusWithHttpInfo(status); + Future> findPetsByStatus(List status,) async { + final response = await findPetsByStatusWithHttpInfo(status,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -193,7 +197,7 @@ class PetApi { .map((i) => Pet.fromJson(i)) .toList(); } - return Future>.value(null); + return Future>.value(); } /// Finds Pets by tags @@ -206,14 +210,16 @@ class PetApi { /// /// * [Set] tags (required): /// Tags to filter by - Future findPetsByTagsWithHttpInfo(Set tags) async { + Future findPetsByTagsWithHttpInfo(Set 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; final queryParams = []; @@ -222,19 +228,18 @@ class PetApi { queryParams.addAll(_convertParametersForCollectionFormat('csv', 'tags', tags)); - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['petstore_auth']; + const authNames = ['petstore_auth']; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -247,8 +252,8 @@ class PetApi { /// /// * [Set] tags (required): /// Tags to filter by - Future> findPetsByTags(Set tags) async { - final response = await findPetsByTagsWithHttpInfo(tags); + Future> findPetsByTags(Set tags,) async { + final response = await findPetsByTagsWithHttpInfo(tags,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -261,7 +266,7 @@ class PetApi { .map((i) => Pet.fromJson(i)) .toSet(); } - return Future>.value(null); + return Future>.value(); } /// Find pet by ID @@ -274,34 +279,35 @@ class PetApi { /// /// * [int] petId (required): /// ID of pet to return - Future getPetByIdWithHttpInfo(int petId) async { + Future 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()); + .replaceAll('{petId}', petId.toString()); + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['api_key']; + const authNames = ['api_key']; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -314,8 +320,8 @@ class PetApi { /// /// * [int] petId (required): /// ID of pet to return - Future getPetById(int petId) async { - final response = await getPetByIdWithHttpInfo(petId); + Future getPetById(int petId,) async { + final response = await getPetByIdWithHttpInfo(petId,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -326,7 +332,7 @@ class PetApi { return Pet.fromJson(json.decode(response.body)); } - return Future.value(null); + return Future.value(); } /// Update an existing pet @@ -337,33 +343,34 @@ class PetApi { /// /// * [Pet] pet (required): /// Pet object that needs to be added to the store - Future updatePetWithHttpInfo(Pet pet) async { + Future 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json', 'application/xml']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['petstore_auth']; + const authNames = ['petstore_auth']; + const contentTypes = ['application/json', 'application/xml']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'PUT', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -374,8 +381,8 @@ class PetApi { /// /// * [Pet] pet (required): /// Pet object that needs to be added to the store - Future updatePet(Pet pet) async { - final response = await updatePetWithHttpInfo(pet); + Future updatePet(Pet pet,) async { + final response = await updatePetWithHttpInfo(pet,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -395,24 +402,25 @@ class PetApi { /// /// * [String] status: /// Updated status of the pet - Future updatePetWithFormWithHttpInfo(int petId, { String name, String status }) async { + Future updatePetWithFormWithHttpInfo(int petId, { String name, String status, }) 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()); + .replaceAll('{petId}', petId.toString()); + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/x-www-form-urlencoded']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['petstore_auth']; + const authNames = ['petstore_auth']; + const contentTypes = ['application/x-www-form-urlencoded']; if (name != null) { formParams[r'name'] = parameterToString(name); @@ -421,14 +429,14 @@ class PetApi { formParams[r'status'] = parameterToString(status); } - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -445,8 +453,8 @@ class PetApi { /// /// * [String] status: /// Updated status of the pet - Future updatePetWithForm(int petId, { String name, String status }) async { - final response = await updatePetWithFormWithHttpInfo(petId, name: name, status: status ); + Future 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)); } @@ -466,24 +474,25 @@ class PetApi { /// /// * [MultipartFile] file: /// file to upload - Future uploadFileWithHttpInfo(int petId, { String additionalMetadata, MultipartFile file }) async { + Future uploadFileWithHttpInfo(int petId, { String additionalMetadata, MultipartFile file, }) 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}/uploadImage' - .replaceAll('{' + 'petId' + '}', petId.toString()); + .replaceAll('{petId}', petId.toString()); + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['multipart/form-data']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['petstore_auth']; + const authNames = ['petstore_auth']; + const contentTypes = ['multipart/form-data']; bool hasFields = false; final mp = MultipartRequest('POST', Uri.parse(path)); @@ -500,14 +509,14 @@ class PetApi { postBody = mp; } - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -524,8 +533,8 @@ class PetApi { /// /// * [MultipartFile] file: /// file to upload - Future uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async { - final response = await uploadFileWithHttpInfo(petId, additionalMetadata: additionalMetadata, file: file ); + Future 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)); } @@ -536,7 +545,7 @@ class PetApi { return ApiResponse.fromJson(json.decode(response.body)); } - return Future.value(null); + return Future.value(); } /// uploads an image (required) @@ -553,7 +562,7 @@ class PetApi { /// /// * [String] additionalMetadata: /// Additional data to pass to server - Future uploadFileWithRequiredFileWithHttpInfo(int petId, MultipartFile requiredFile, { String additionalMetadata }) async { + Future uploadFileWithRequiredFileWithHttpInfo(int petId, MultipartFile requiredFile, { String additionalMetadata, }) async { // Verify required params are set. if (petId == null) { throw ApiException(HttpStatus.badRequest, 'Missing required param: petId'); @@ -562,18 +571,19 @@ class PetApi { throw ApiException(HttpStatus.badRequest, 'Missing required param: requiredFile'); } + // ignore: prefer_const_declarations final path = r'/fake/{petId}/uploadImageWithRequiredFile' - .replaceAll('{' + 'petId' + '}', petId.toString()); + .replaceAll('{petId}', petId.toString()); + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['multipart/form-data']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['petstore_auth']; + const authNames = ['petstore_auth']; + const contentTypes = ['multipart/form-data']; bool hasFields = false; final mp = MultipartRequest('POST', Uri.parse(path)); @@ -590,14 +600,14 @@ class PetApi { postBody = mp; } - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -614,8 +624,8 @@ class PetApi { /// /// * [String] additionalMetadata: /// Additional data to pass to server - Future uploadFileWithRequiredFile(int petId, MultipartFile requiredFile, { String additionalMetadata }) async { - final response = await uploadFileWithRequiredFileWithHttpInfo(petId, requiredFile, additionalMetadata: additionalMetadata ); + Future 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)); } @@ -626,6 +636,6 @@ class PetApi { return ApiResponse.fromJson(json.decode(response.body)); } - return Future.value(null); + return Future.value(); } } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/store_api.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/store_api.dart index f7a67632d33..9b60b28a7e5 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/store_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/store_api.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -25,34 +26,35 @@ class StoreApi { /// /// * [String] orderId (required): /// ID of the order that needs to be deleted - Future deleteOrderWithHttpInfo(String orderId) async { + Future 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.toString()); + .replaceAll('{order_id}', orderId); + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'DELETE', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -65,8 +67,8 @@ class StoreApi { /// /// * [String] orderId (required): /// ID of the order that needs to be deleted - Future deleteOrder(String orderId) async { - final response = await deleteOrderWithHttpInfo(orderId); + Future deleteOrder(String orderId,) async { + final response = await deleteOrderWithHttpInfo(orderId,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -78,27 +80,28 @@ class StoreApi { /// /// Note: This method returns the HTTP [Response]. Future getInventoryWithHttpInfo() async { + // ignore: prefer_const_declarations final path = r'/store/inventory'; + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = ['api_key']; + const authNames = ['api_key']; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -118,7 +121,7 @@ class StoreApi { return Map.from(json.decode(response.body)); } - return Future>.value(null); + return Future>.value(); } /// Find purchase order by ID @@ -131,34 +134,35 @@ class StoreApi { /// /// * [int] orderId (required): /// ID of pet that needs to be fetched - Future getOrderByIdWithHttpInfo(int orderId) async { + Future 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()); + .replaceAll('{order_id}', orderId.toString()); + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -171,8 +175,8 @@ class StoreApi { /// /// * [int] orderId (required): /// ID of pet that needs to be fetched - Future getOrderById(int orderId) async { - final response = await getOrderByIdWithHttpInfo(orderId); + Future getOrderById(int orderId,) async { + final response = await getOrderByIdWithHttpInfo(orderId,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -183,7 +187,7 @@ class StoreApi { return Order.fromJson(json.decode(response.body)); } - return Future.value(null); + return Future.value(); } /// Place an order for a pet @@ -194,33 +198,34 @@ class StoreApi { /// /// * [Order] order (required): /// order placed for purchasing the pet - Future placeOrderWithHttpInfo(Order order) async { + Future 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -231,8 +236,8 @@ class StoreApi { /// /// * [Order] order (required): /// order placed for purchasing the pet - Future placeOrder(Order order) async { - final response = await placeOrderWithHttpInfo(order); + Future placeOrder(Order order,) async { + final response = await placeOrderWithHttpInfo(order,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -243,6 +248,6 @@ class StoreApi { return Order.fromJson(json.decode(response.body)); } - return Future.value(null); + return Future.value(); } } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/user_api.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/user_api.dart index 13e62586ac9..2e3e0757958 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/user_api.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api/user_api.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -25,33 +26,34 @@ class UserApi { /// /// * [User] user (required): /// Created user object - Future createUserWithHttpInfo(User user) async { + Future 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -64,8 +66,8 @@ class UserApi { /// /// * [User] user (required): /// Created user object - Future createUser(User user) async { - final response = await createUserWithHttpInfo(user); + Future createUser(User user,) async { + final response = await createUserWithHttpInfo(user,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -79,33 +81,34 @@ class UserApi { /// /// * [List] user (required): /// List of user object - Future createUsersWithArrayInputWithHttpInfo(List user) async { + Future createUsersWithArrayInputWithHttpInfo(List 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -116,8 +119,8 @@ class UserApi { /// /// * [List] user (required): /// List of user object - Future createUsersWithArrayInput(List user) async { - final response = await createUsersWithArrayInputWithHttpInfo(user); + Future createUsersWithArrayInput(List user,) async { + final response = await createUsersWithArrayInputWithHttpInfo(user,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -131,33 +134,34 @@ class UserApi { /// /// * [List] user (required): /// List of user object - Future createUsersWithListInputWithHttpInfo(List user) async { + Future createUsersWithListInputWithHttpInfo(List 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; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'POST', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -168,8 +172,8 @@ class UserApi { /// /// * [List] user (required): /// List of user object - Future createUsersWithListInput(List user) async { - final response = await createUsersWithListInputWithHttpInfo(user); + Future createUsersWithListInput(List user,) async { + final response = await createUsersWithListInputWithHttpInfo(user,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -185,34 +189,35 @@ class UserApi { /// /// * [String] username (required): /// The name that needs to be deleted - Future deleteUserWithHttpInfo(String username) async { + Future 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.toString()); + .replaceAll('{username}', username); + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'DELETE', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -225,8 +230,8 @@ class UserApi { /// /// * [String] username (required): /// The name that needs to be deleted - Future deleteUser(String username) async { - final response = await deleteUserWithHttpInfo(username); + Future deleteUser(String username,) async { + final response = await deleteUserWithHttpInfo(username,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -240,34 +245,35 @@ class UserApi { /// /// * [String] username (required): /// The name that needs to be fetched. Use user1 for testing. - Future getUserByNameWithHttpInfo(String username) async { + Future 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.toString()); + .replaceAll('{username}', username); + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -278,8 +284,8 @@ class UserApi { /// /// * [String] username (required): /// The name that needs to be fetched. Use user1 for testing. - Future getUserByName(String username) async { - final response = await getUserByNameWithHttpInfo(username); + Future getUserByName(String username,) async { + final response = await getUserByNameWithHttpInfo(username,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -290,7 +296,7 @@ class UserApi { return User.fromJson(json.decode(response.body)); } - return Future.value(null); + return Future.value(); } /// Logs user into the system @@ -304,7 +310,7 @@ class UserApi { /// /// * [String] password (required): /// The password for login in clear text - Future loginUserWithHttpInfo(String username, String password) async { + Future loginUserWithHttpInfo(String username, String password,) async { // Verify required params are set. if (username == null) { throw ApiException(HttpStatus.badRequest, 'Missing required param: username'); @@ -313,8 +319,10 @@ class UserApi { throw ApiException(HttpStatus.badRequest, 'Missing required param: password'); } + // ignore: prefer_const_declarations final path = r'/user/login'; + // ignore: prefer_final_locals Object postBody; final queryParams = []; @@ -324,19 +332,18 @@ class UserApi { queryParams.addAll(_convertParametersForCollectionFormat('', 'username', username)); queryParams.addAll(_convertParametersForCollectionFormat('', 'password', password)); - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -350,8 +357,8 @@ class UserApi { /// /// * [String] password (required): /// The password for login in clear text - Future loginUser(String username, String password) async { - final response = await loginUserWithHttpInfo(username, password); + Future loginUser(String username, String password,) async { + final response = await loginUserWithHttpInfo(username, password,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } @@ -362,34 +369,35 @@ class UserApi { return response.body as String; } - return Future.value(null); + return Future.value(); } /// Logs out current logged in user session /// /// Note: This method returns the HTTP [Response]. Future logoutUserWithHttpInfo() async { + // ignore: prefer_const_declarations final path = r'/user/logout'; + // ignore: prefer_final_locals Object postBody; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = []; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = []; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'GET', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -415,7 +423,7 @@ class UserApi { /// /// * [User] user (required): /// Updated user object - Future updateUserWithHttpInfo(String username, User user) async { + Future updateUserWithHttpInfo(String username, User user,) async { // Verify required params are set. if (username == null) { throw ApiException(HttpStatus.badRequest, 'Missing required param: username'); @@ -424,28 +432,29 @@ class UserApi { throw ApiException(HttpStatus.badRequest, 'Missing required param: user'); } + // ignore: prefer_const_declarations final path = r'/user/{username}' - .replaceAll('{' + 'username' + '}', username.toString()); + .replaceAll('{username}', username); + // ignore: prefer_final_locals Object postBody = user; final queryParams = []; final headerParams = {}; final formParams = {}; - final contentTypes = ['application/json']; - final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - final authNames = []; + const authNames = []; + const contentTypes = ['application/json']; - return await apiClient.invokeAPI( + return apiClient.invokeAPI( path, 'PUT', queryParams, postBody, headerParams, formParams, - nullableContentType, + contentTypes.isEmpty ? null : contentTypes[0], authNames, ); } @@ -461,8 +470,8 @@ class UserApi { /// /// * [User] user (required): /// Updated user object - Future updateUser(String username, User user) async { - final response = await updateUserWithHttpInfo(username, user); + Future updateUser(String username, User user,) async { + final response = await updateUserWithHttpInfo(username, user,); if (response.statusCode >= HttpStatus.badRequest) { throw ApiException(response.statusCode, await _decodeBodyBytes(response)); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api_client.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api_client.dart index 8a3db870eca..18e47e88715 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api_client.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api_client.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -80,7 +81,7 @@ class ApiClient { ? '?${urlEncodedQueryParams.join('&')}' : ''; - final Uri uri = Uri.parse('$basePath$path$queryString'); + final uri = Uri.parse('$basePath$path$queryString'); if (nullableContentType != null) { headerParams['Content-Type'] = nullableContentType; @@ -98,7 +99,8 @@ class ApiClient { body.finalize().listen( request.sink.add, onDone: request.sink.close, - onError: (error, trace) => request.sink.close(), + // ignore: avoid_types_on_closure_parameters + onError: (Object error, StackTrace trace) => request.sink.close(), cancelOnError: true, ); final response = await _client.send(request); diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api_exception.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api_exception.dart index 86e2054bffe..8ffc340b4c9 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api_exception.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api_exception.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api_helper.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api_helper.dart index e88f8cc2987..e2ffc78abb7 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api_helper.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/api_helper.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -30,20 +31,21 @@ Iterable _convertParametersForCollectionFormat( // preconditions if (name != null && name.isNotEmpty && value != null) { if (value is List) { - // get the collection format, default: csv - collectionFormat = (collectionFormat == null || collectionFormat.isEmpty) - ? 'csv' - : collectionFormat; - if (collectionFormat == 'multi') { - return value.map((v) => QueryParam(name, parameterToString(v))); + return value.map((dynamic v) => QueryParam(name, parameterToString(v)),); + } + + // Default collection format is 'csv'. + if (collectionFormat == null || collectionFormat.isEmpty) { + // ignore: parameter_assignments + collectionFormat = 'csv'; } final delimiter = _delimiters[collectionFormat] ?? ','; - params.add(QueryParam(name, value.map((v) => parameterToString(v)).join(delimiter))); + params.add(QueryParam(name, value.map(parameterToString).join(delimiter)),); } else { - params.add(QueryParam(name, parameterToString(value))); + params.add(QueryParam(name, parameterToString(value),)); } } @@ -84,3 +86,36 @@ Future _decodeBodyBytes(Response response) async { ? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes) : response.body; } + +/// Returns a valid [T] value found at the specified Map [key], null otherwise. +T mapValueOfType(dynamic map, String key) { + final dynamic value = map is Map ? map[key] : null; + return value is T ? value : null; +} + +/// Returns a valid Map found at the specified Map [key], null otherwise. +Map mapCastOfType(dynamic map, String key) { + final dynamic value = map is Map ? map[key] : null; + return value is Map ? value.cast() : null; +} + +/// Returns a valid [DateTime] found at the specified Map [key], null otherwise. +DateTime mapDateTime(dynamic map, String key, [String pattern]) { + final dynamic value = map is Map ? map[key] : null; + if (value != null) { + int millis; + if (value is int) { + millis = value; + } else if (value is String) { + if (pattern == _dateEpochMarker) { + millis = int.tryParse(value); + } else { + return DateTime.tryParse(value); + } + } + if (millis != null) { + return DateTime.fromMillisecondsSinceEpoch(millis, isUtc: true); + } + } + return null; +} diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/auth/api_key_auth.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/auth/api_key_auth.dart index 41a4afd85d9..0c2303af09e 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/auth/api_key_auth.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/auth/api_key_auth.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -27,9 +28,11 @@ class ApiKeyAuth implements Authentication { } else if (location == 'header' && value != null) { headerParams[paramName] = value; } else if (location == 'cookie' && value != null) { - headerParams.update('Cookie', (String existingCookie) { - return '$existingCookie; $paramName=$value'; - }, ifAbsent: () => '$paramName=$value'); + headerParams.update( + 'Cookie', + (existingCookie) => '$existingCookie; $paramName=$value', + ifAbsent: () => '$paramName=$value', + ); } } } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/auth/authentication.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/auth/authentication.dart index 5ca198d41fd..4257e190006 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/auth/authentication.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/auth/authentication.dart @@ -5,10 +5,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 part of openapi.api; +// ignore: one_member_abstracts abstract class Authentication { /// Apply authentication settings to header and query params. void applyToParams(List queryParams, Map headerParams); diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/auth/http_basic_auth.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/auth/http_basic_auth.dart index 6dc36a13f49..0494f402d95 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/auth/http_basic_auth.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/auth/http_basic_auth.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -15,7 +16,7 @@ class HttpBasicAuth implements Authentication { @override void applyToParams(List queryParams, Map headerParams) { - final credentials = (username ?? '') + ':' + (password ?? ''); + final credentials = '${username ?? ''}:${password ?? ''}'; headerParams['Authorization'] = 'Basic ${base64.encode(utf8.encode(credentials))}'; } } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/auth/http_bearer_auth.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/auth/http_bearer_auth.dart index a23b65fac5e..23e243523dd 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/auth/http_bearer_auth.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/auth/http_bearer_auth.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -22,7 +23,7 @@ class HttpBearerAuth implements Authentication { if (accessToken is! String && accessToken is! HttpBearerAuthProvider) { throw ArgumentError('Type of Bearer accessToken should be a String or a String Function().'); } - this._accessToken = accessToken; + _accessToken = accessToken; } @override diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/auth/oauth.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/auth/oauth.dart index c0463ad3900..9299ac13f5b 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/auth/oauth.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/auth/oauth.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/additional_properties_class.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/additional_properties_class.dart index 3d89437b45f..de1ac810d59 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/additional_properties_class.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/additional_properties_class.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -51,9 +52,6 @@ class AdditionalPropertiesClass { Map toJson() => _$AdditionalPropertiesClassToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/animal.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/animal.dart index 007faa9351d..8d4772ba251 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/animal.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/animal.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -51,9 +52,6 @@ class Animal { Map toJson() => _$AnimalToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/api_response.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/api_response.dart index 15d9ef8dd4b..24516bbcb1c 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/api_response.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/api_response.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -61,9 +62,6 @@ class ApiResponse { Map toJson() => _$ApiResponseToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/array_of_array_of_number_only.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/array_of_array_of_number_only.dart index f9ab4b487ee..7d7d2d004ef 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/array_of_array_of_number_only.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/array_of_array_of_number_only.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -41,9 +42,6 @@ class ArrayOfArrayOfNumberOnly { Map toJson() => _$ArrayOfArrayOfNumberOnlyToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/array_of_number_only.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/array_of_number_only.dart index 4d27ea30055..27bea05339d 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/array_of_number_only.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/array_of_number_only.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -41,9 +42,6 @@ class ArrayOfNumberOnly { Map toJson() => _$ArrayOfNumberOnlyToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/array_test.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/array_test.dart index d3363409d02..03656ce5fbc 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/array_test.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/array_test.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -61,9 +62,6 @@ class ArrayTest { Map toJson() => _$ArrayTestToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/capitalization.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/capitalization.dart index f559b327cbd..bb906c2c45e 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/capitalization.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/capitalization.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -92,9 +93,6 @@ class Capitalization { Map toJson() => _$CapitalizationToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/cat.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/cat.dart index c0c70cfe67f..479cf62f2cd 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/cat.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/cat.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -61,9 +62,6 @@ class Cat { Map toJson() => _$CatToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/cat_all_of.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/cat_all_of.dart index c9758d9df38..e3ca59d3b37 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/cat_all_of.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/cat_all_of.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -41,9 +42,6 @@ class CatAllOf { Map toJson() => _$CatAllOfToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/category.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/category.dart index a55587bb2c1..1275e305b82 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/category.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/category.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -51,9 +52,6 @@ class Category { Map toJson() => _$CategoryToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/class_model.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/class_model.dart index 0b4e4fa4718..fc2d7534ce7 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/class_model.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/class_model.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -41,9 +42,6 @@ class ClassModel { Map toJson() => _$ClassModelToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/deprecated_object.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/deprecated_object.dart index 168b8234cfa..945fbc85e1f 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/deprecated_object.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/deprecated_object.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -41,9 +42,6 @@ class DeprecatedObject { Map toJson() => _$DeprecatedObjectToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/dog.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/dog.dart index 1ec4ba53d02..8b8d1d36a04 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/dog.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/dog.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -61,9 +62,6 @@ class Dog { Map toJson() => _$DogToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/dog_all_of.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/dog_all_of.dart index 7dc79a08a50..0a2672d908a 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/dog_all_of.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/dog_all_of.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -41,9 +42,6 @@ class DogAllOf { Map toJson() => _$DogAllOfToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/enum_arrays.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/enum_arrays.dart index a12d0045f4d..f1eb8b7d367 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/enum_arrays.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/enum_arrays.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -51,10 +52,7 @@ class EnumArrays { Map toJson() => _$EnumArraysToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/enum_class.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/enum_class.dart index 391c2c83ba7..37273211efc 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/enum_class.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/enum_class.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/enum_test.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/enum_test.dart index 421da9523c2..27d07a985e2 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/enum_test.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/enum_test.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -111,10 +112,7 @@ class EnumTest { Map toJson() => _$EnumTestToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/file_schema_test_class.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/file_schema_test_class.dart index c994f6088e1..15a0b8d7daa 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/file_schema_test_class.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/file_schema_test_class.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -51,9 +52,6 @@ class FileSchemaTestClass { Map toJson() => _$FileSchemaTestClassToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/foo.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/foo.dart index af23e19a358..a2917b7c2e8 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/foo.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/foo.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -41,9 +42,6 @@ class Foo { Map toJson() => _$FooToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/format_test.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/format_test.dart index d126d55673f..6c66d928175 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/format_test.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/format_test.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -199,9 +200,6 @@ class FormatTest { Map toJson() => _$FormatTestToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/has_only_read_only.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/has_only_read_only.dart index d4138d9e314..5d016561de7 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/has_only_read_only.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/has_only_read_only.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -51,9 +52,6 @@ class HasOnlyReadOnly { Map toJson() => _$HasOnlyReadOnlyToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/health_check_result.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/health_check_result.dart index acdbcc10877..eaa93075b46 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/health_check_result.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/health_check_result.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -41,9 +42,6 @@ class HealthCheckResult { Map toJson() => _$HealthCheckResultToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/inline_response_default.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/inline_response_default.dart index a205e74866c..55baf510408 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/inline_response_default.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/inline_response_default.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -41,9 +42,6 @@ class InlineResponseDefault { Map toJson() => _$InlineResponseDefaultToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/map_test.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/map_test.dart index 0749f10b998..3c06f1815f7 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/map_test.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/map_test.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -71,10 +72,7 @@ class MapTest { Map toJson() => _$MapTestToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/mixed_properties_and_additional_properties_class.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/mixed_properties_and_additional_properties_class.dart index 91fca43d388..1fd6acc5160 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/mixed_properties_and_additional_properties_class.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/mixed_properties_and_additional_properties_class.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -61,9 +62,6 @@ class MixedPropertiesAndAdditionalPropertiesClass { Map toJson() => _$MixedPropertiesAndAdditionalPropertiesClassToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/model200_response.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/model200_response.dart index 77b72970d98..a1c8996439b 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/model200_response.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/model200_response.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -51,9 +52,6 @@ class Model200Response { Map toJson() => _$Model200ResponseToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/model_client.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/model_client.dart index 5193315a39b..70e3a6ebeb8 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/model_client.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/model_client.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -41,9 +42,6 @@ class ModelClient { Map toJson() => _$ModelClientToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/model_file.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/model_file.dart index 7c8742d92da..6fb382ebf1c 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/model_file.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/model_file.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -42,9 +43,6 @@ class ModelFile { Map toJson() => _$ModelFileToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/model_list.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/model_list.dart index 7ea607d3eb4..b69abf130f5 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/model_list.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/model_list.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -41,9 +42,6 @@ class ModelList { Map toJson() => _$ModelListToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/model_return.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/model_return.dart index 6058870d576..0a18d3ed489 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/model_return.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/model_return.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -41,9 +42,6 @@ class ModelReturn { Map toJson() => _$ModelReturnToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/name.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/name.dart index 714d47df963..c554627bfcd 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/name.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/name.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -71,9 +72,6 @@ class Name { Map toJson() => _$NameToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/nullable_class.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/nullable_class.dart index 87b5a308b5b..68c0deefc5a 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/nullable_class.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/nullable_class.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -151,9 +152,6 @@ class NullableClass { Map toJson() => _$NullableClassToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/number_only.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/number_only.dart index aacbd85e3de..deccb0c854d 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/number_only.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/number_only.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -41,9 +42,6 @@ class NumberOnly { Map toJson() => _$NumberOnlyToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/object_with_deprecated_fields.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/object_with_deprecated_fields.dart index 6e0dee099d0..936ecc671f8 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/object_with_deprecated_fields.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/object_with_deprecated_fields.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -71,9 +72,6 @@ class ObjectWithDeprecatedFields { Map toJson() => _$ObjectWithDeprecatedFieldsToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/order.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/order.dart index 73c52c14860..096ccfe4b4e 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/order.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/order.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -92,10 +93,7 @@ class Order { Map toJson() => _$OrderToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } /// Order Status diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/outer_composite.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/outer_composite.dart index e5edc3bc21a..2f2bd6f221e 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/outer_composite.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/outer_composite.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -61,9 +62,6 @@ class OuterComposite { Map toJson() => _$OuterCompositeToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/outer_enum.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/outer_enum.dart index 1ba9c098494..a91f63c0ed2 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/outer_enum.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/outer_enum.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/outer_enum_default_value.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/outer_enum_default_value.dart index 7255a5c75ef..a1e26235455 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/outer_enum_default_value.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/outer_enum_default_value.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/outer_enum_integer.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/outer_enum_integer.dart index 45865586c47..5fa167be541 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/outer_enum_integer.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/outer_enum_integer.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/outer_enum_integer_default_value.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/outer_enum_integer_default_value.dart index 66c8e1a8869..5d6ed62ea7c 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/outer_enum_integer_default_value.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/outer_enum_integer_default_value.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/outer_object_with_enum_property.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/outer_object_with_enum_property.dart index fd9ea7cf80b..9971d8b005d 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/outer_object_with_enum_property.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/outer_object_with_enum_property.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -41,9 +42,6 @@ class OuterObjectWithEnumProperty { Map toJson() => _$OuterObjectWithEnumPropertyToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/pet.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/pet.dart index 422971a25b7..572f3e67f7c 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/pet.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/pet.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -92,10 +93,7 @@ class Pet { Map toJson() => _$PetToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } /// pet status in the store diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/read_only_first.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/read_only_first.dart index 84d626357ab..46af402a0e5 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/read_only_first.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/read_only_first.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -51,9 +52,6 @@ class ReadOnlyFirst { Map toJson() => _$ReadOnlyFirstToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/special_model_name.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/special_model_name.dart index de09411bd1d..34e81dbe4d9 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/special_model_name.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/special_model_name.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -41,9 +42,6 @@ class SpecialModelName { Map toJson() => _$SpecialModelNameToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/tag.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/tag.dart index f9e4a1dd9ee..797f3fdcded 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/tag.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/tag.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -51,9 +52,6 @@ class Tag { Map toJson() => _$TagToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); } diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/user.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/user.dart index 0c89dd53249..8ca6ebef695 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/user.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/user.dart @@ -5,6 +5,7 @@ // 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 part of openapi.api; @@ -112,9 +113,6 @@ class User { Map toJson() => _$UserToJson(this); @override - String toString() { - return toJson().toString(); - } - + String toString() => toJson().toString(); }