Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !8839

[dart][dart-dio] Add DioError wrapping

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Peter Leibiger requested to merge github/fork/kuhnroyal/dart-dio/serialization-errors into master 4 years ago
  • Overview 0
  • Commits 1
  • Pipelines 0
  • Changes 21
  • wrap (de)serialization in try/catch and throw a DioError (this uses the new RequestOptions instance) - generic StateError and FormatException are now wrapped in a DioError which makes it clear that they originated from an API call
  • this is a new option in the generator wich defaults to true
  • no longer generate code for null body data

This is a breaking change with fallback.

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    Commit all changed files. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master, 5.1.x, 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

CC @swipesight (2018/09) @jaumard (2018/09) @josh-burton (2019/12) @amondnet (2019/12) @sbu-WBT (2020/12) @kuhnroyal (2020/12) @agilob (2020/12)

Compare
  • master (base)

and
  • latest version
    07970a72
    1 commit, 2 years ago

21 files
+ 1187
- 500

    Preferences

    File browser
    Compare changes
docs/ge‎nerators‎
dart-‎dio.md‎ +2 -1
modules/openap‎i-generator/src‎
ma‎in‎
java/org/opena‎pitools/codegen‎
lang‎uages‎
DartClientC‎odegen.java‎ +1 -1
DartDioClien‎tCodegen.java‎ +75 -35
CodegenOpe‎ration.java‎ +9 -0
resources‎/dart-dio‎
api.mu‎stache‎ +78 -49
test/java/org/ope‎napitools/codegen‎
dar‎tdio‎
DartDioClientO‎ptionsTest.java‎ +7 -5
DartDioMod‎elTest.java‎ +2 -10
opt‎ions‎
DartDioClientOpt‎ionsProvider.java‎ +3 -4
sam‎ples‎
client/petstore/d‎art-dio/…/lib/api‎
pet_ap‎i.dart‎ +104 -44
store_a‎pi.dart‎ +55 -26
user_a‎pi.dart‎ +66 -26
openapi3/client/‎petstore/dart-dio‎
petstore_clie‎nt_lib/lib/api‎
pet_ap‎i.dart‎ +134 -54
store_a‎pi.dart‎ +55 -26
user_a‎pi.dart‎ +66 -26
petstore_client_‎lib_fake/lib/api‎
another_fa‎ke_api.dart‎ +25 -7
default_‎api.dart‎ +15 -8
fake_a‎pi.dart‎ +213 -66
fake_classname_‎tags123_api.dart‎ +25 -7
pet_ap‎i.dart‎ +131 -53
store_a‎pi.dart‎ +55 -26
user_a‎pi.dart‎ +66 -26
docs/generators/dart-dio.md
+ 2
- 1
  • View file @ 07970a72


@@ -9,10 +9,11 @@ These options may be applied as additional-properties (cli) or configOptions (pl
@@ -9,10 +9,11 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| ------ | ----------- | ------ | ------- |
| ------ | ----------- | ------ | ------- |
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|dateLibrary|Option. Date library to use|<dl><dt>**core**</dt><dd>Dart core library (DateTime)</dd><dt>**timemachine**</dt><dd>Time Machine is date and time library for Flutter, Web, and Server with support for timezones, calendars, cultures, formatting and parsing.</dd></dl>|core|
|dateLibrary|Option. Date library to use|<dl><dt>**core**</dt><dd>Dart core library (DateTime)</dd><dt>**timemachine**</dt><dd>Time Machine is date and time library for Flutter, Web, and Server with support for timezones, calendars, cultures, formatting and parsing.</dd></dl>|core|
 
|dioErrorWrapping|Wrap serialization errors in DioErrors| |true|
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|legacyDiscriminatorBehavior|Set to true for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|legacyDiscriminatorBehavior|Set to true for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|nullableFields|Make all fields nullable in the JSON payload| |null|
|nullableFields|Make all fields nullable in the JSON payload| |false|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|pubAuthor|Author name in generated pubspec| |null|
|pubAuthor|Author name in generated pubspec| |null|
|pubAuthorEmail|Email address of the author in generated pubspec| |null|
|pubAuthorEmail|Email address of the author in generated pubspec| |null|
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartClientCodegen.java
+ 1
- 1
  • View file @ 07970a72


@@ -54,7 +54,7 @@ public class DartClientCodegen extends AbstractDartCodegen {
@@ -54,7 +54,7 @@ public class DartClientCodegen extends AbstractDartCodegen {
super.processOpts();
super.processOpts();
// handle library not being set
// handle library not being set
if(additionalProperties.get(CodegenConstants.SERIALIZATION_LIBRARY) == null) {
if (additionalProperties.get(CodegenConstants.SERIALIZATION_LIBRARY) == null) {
this.library = SERIALIZATION_LIBRARY_NATIVE;
this.library = SERIALIZATION_LIBRARY_NATIVE;
LOGGER.debug("Serialization library not set, using default {}", SERIALIZATION_LIBRARY_NATIVE);
LOGGER.debug("Serialization library not set, using default {}", SERIALIZATION_LIBRARY_NATIVE);
} else {
} else {
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioClientCodegen.java
+ 75
- 35
  • View file @ 07970a72


@@ -37,12 +37,22 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
@@ -37,12 +37,22 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
private final Logger LOGGER = LoggerFactory.getLogger(DartDioClientCodegen.class);
private final Logger LOGGER = LoggerFactory.getLogger(DartDioClientCodegen.class);
public static final String NULLABLE_FIELDS = "nullableFields";
public static final String NULLABLE_FIELDS = "nullableFields";
 
public static final Boolean NULLABLE_FIELDS_DEFAULT = false;
 
 
public static final String DIO_ERROR_WRAPPING = "dioErrorWrapping";
 
public static final Boolean DIO_ERROR_WRAPPING_DEFAULT = true;
 
public static final String DATE_LIBRARY = "dateLibrary";
public static final String DATE_LIBRARY = "dateLibrary";
 
public static final String DATE_LIBRARY_CORE = "core";
 
public static final String DATE_LIBRARY_TIME_MACHINE = "timemachine";
 
public static final String DATE_LIBRARY_DEFAULT = DATE_LIBRARY_CORE;
private static final String CLIENT_NAME = "clientName";
private static final String CLIENT_NAME = "clientName";
private boolean nullableFields = false;
private boolean nullableFields;
private String dateLibrary = "core";
private boolean dioErrorWrapping;
 
private String dateLibrary;
 
private String clientName;
public DartDioClientCodegen() {
public DartDioClientCodegen() {
super();
super();
@@ -50,13 +60,17 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
@@ -50,13 +60,17 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
embeddedTemplateDir = "dart-dio";
embeddedTemplateDir = "dart-dio";
this.setTemplateDir(embeddedTemplateDir);
this.setTemplateDir(embeddedTemplateDir);
cliOptions.add(new CliOption(NULLABLE_FIELDS, "Make all fields nullable in the JSON payload"));
cliOptions.add(CliOption.newBoolean(NULLABLE_FIELDS, "Make all fields nullable in the JSON payload", NULLABLE_FIELDS_DEFAULT));
CliOption dateLibrary = new CliOption(DATE_LIBRARY, "Option. Date library to use").defaultValue(this.getDateLibrary());
cliOptions.add(CliOption.newBoolean(DIO_ERROR_WRAPPING, "Wrap serialization errors in DioErrors", DIO_ERROR_WRAPPING_DEFAULT));
Map<String, String> dateOptions = new HashMap<>();
final CliOption dateOption = new CliOption(DATE_LIBRARY, "Option. Date library to use");
dateOptions.put("core", "Dart core library (DateTime)");
dateOption.setDefault(DATE_LIBRARY_DEFAULT);
dateOptions.put("timemachine", "Time Machine is date and time library for Flutter, Web, and Server with support for timezones, calendars, cultures, formatting and parsing.");
dateOption.setType("String");
dateLibrary.setEnum(dateOptions);
cliOptions.add(dateLibrary);
final Map<String, String> dateOptions = new HashMap<>();
 
dateOptions.put(DATE_LIBRARY_CORE, "Dart core library (DateTime)");
 
dateOptions.put(DATE_LIBRARY_TIME_MACHINE, "Time Machine is date and time library for Flutter, Web, and Server with support for timezones, calendars, cultures, formatting and parsing.");
 
dateOption.setEnum(dateOptions);
 
cliOptions.add(dateOption);
typeMapping.put("Array", "BuiltList");
typeMapping.put("Array", "BuiltList");
typeMapping.put("array", "BuiltList");
typeMapping.put("array", "BuiltList");
@@ -94,7 +108,7 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
@@ -94,7 +108,7 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
this.dateLibrary = library;
this.dateLibrary = library;
}
}
public boolean getNullableFields() {
public boolean isNullableFields() {
return nullableFields;
return nullableFields;
}
}
@@ -102,6 +116,22 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
@@ -102,6 +116,22 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
this.nullableFields = nullableFields;
this.nullableFields = nullableFields;
}
}
 
public boolean isDioErrorWrapping() {
 
return dioErrorWrapping;
 
}
 
 
public void setDioErrorWrapping(boolean dioErrorWrapping) {
 
this.dioErrorWrapping = dioErrorWrapping;
 
}
 
 
public String getClientName() {
 
return clientName;
 
}
 
 
public void setClientName(String clientName) {
 
this.clientName = clientName;
 
}
 
@Override
@Override
public String getName() {
public String getName() {
return "dart-dio";
return "dart-dio";
@@ -157,23 +187,25 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
@@ -157,23 +187,25 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");
}
}
if (additionalProperties.containsKey(NULLABLE_FIELDS)) {
if (!additionalProperties.containsKey(NULLABLE_FIELDS)) {
this.setNullableFields(convertPropertyToBooleanAndWriteBack(NULLABLE_FIELDS));
additionalProperties.put(NULLABLE_FIELDS, NULLABLE_FIELDS_DEFAULT);
} else {
//not set, use to be passed to template
additionalProperties.put(NULLABLE_FIELDS, nullableFields);
}
}
 
setNullableFields(convertPropertyToBooleanAndWriteBack(NULLABLE_FIELDS));
if (!additionalProperties.containsKey(CLIENT_NAME)) {
if (!additionalProperties.containsKey(DIO_ERROR_WRAPPING)) {
additionalProperties.put(CLIENT_NAME, org.openapitools.codegen.utils.StringUtils.camelize(pubName));
additionalProperties.put(DIO_ERROR_WRAPPING, DIO_ERROR_WRAPPING_DEFAULT);
 
}
 
setDioErrorWrapping(convertPropertyToBooleanAndWriteBack(DIO_ERROR_WRAPPING));
 
 
if (!additionalProperties.containsKey(DATE_LIBRARY)) {
 
additionalProperties.put(DATE_LIBRARY, DATE_LIBRARY_DEFAULT);
}
}
 
setDateLibrary(additionalProperties.get(DATE_LIBRARY).toString());
if (additionalProperties.containsKey(DATE_LIBRARY)) {
if (!additionalProperties.containsKey(CLIENT_NAME)) {
this.setDateLibrary(additionalProperties.get(DATE_LIBRARY).toString());
additionalProperties.put(CLIENT_NAME, org.openapitools.codegen.utils.StringUtils.camelize(pubName));
}
}
// make api and model doc path available in mustache template
setClientName(additionalProperties.get(CLIENT_NAME).toString());
additionalProperties.put("apiDocPath", apiDocPath);
additionalProperties.put("modelDocPath", modelDocPath);
final String libFolder = sourceFolder + File.separator + "lib";
final String libFolder = sourceFolder + File.separator + "lib";
supportingFiles.add(new SupportingFile("pubspec.mustache", "", "pubspec.yaml"));
supportingFiles.add(new SupportingFile("pubspec.mustache", "", "pubspec.yaml"));
@@ -192,19 +224,27 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
@@ -192,19 +224,27 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
supportingFiles.add(new SupportingFile("auth/oauth.mustache", authFolder, "oauth.dart"));
supportingFiles.add(new SupportingFile("auth/oauth.mustache", authFolder, "oauth.dart"));
supportingFiles.add(new SupportingFile("auth/auth.mustache", authFolder, "auth.dart"));
supportingFiles.add(new SupportingFile("auth/auth.mustache", authFolder, "auth.dart"));
if ("core".equals(dateLibrary)) {
configureDateLibrary(libFolder);
// this option uses the same classes as normal dart generator
}
additionalProperties.put("core", "true");
} else if ("timemachine".equals(dateLibrary)) {
private void configureDateLibrary(String libFolder) {
additionalProperties.put("timeMachine", "true");
switch (dateLibrary) {
typeMapping.put("date", "OffsetDate");
case DATE_LIBRARY_TIME_MACHINE:
typeMapping.put("Date", "OffsetDate");
additionalProperties.put("timeMachine", "true");
typeMapping.put("DateTime", "OffsetDateTime");
typeMapping.put("date", "OffsetDate");
typeMapping.put("datetime", "OffsetDateTime");
typeMapping.put("Date", "OffsetDate");
additionalReservedWords.addAll(Sets.newHashSet("OffsetDate", "OffsetDateTime"));
typeMapping.put("DateTime", "OffsetDateTime");
importMapping.put("OffsetDate", "package:time_machine/time_machine.dart");
typeMapping.put("datetime", "OffsetDateTime");
importMapping.put("OffsetDateTime", "package:time_machine/time_machine.dart");
additionalReservedWords.addAll(Sets.newHashSet("OffsetDate", "OffsetDateTime"));
supportingFiles.add(new SupportingFile("local_date_serializer.mustache", libFolder, "local_date_serializer.dart"));
importMapping.put("OffsetDate", "package:time_machine/time_machine.dart");
 
importMapping.put("OffsetDateTime", "package:time_machine/time_machine.dart");
 
supportingFiles.add(new SupportingFile("local_date_serializer.mustache", libFolder, "local_date_serializer.dart"));
 
break;
 
default:
 
case DATE_LIBRARY_CORE:
 
// this option uses the same classes as normal dart generator
 
additionalProperties.put("core", "true");
 
break;
}
}
}
}
modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenOperation.java
+ 9
- 0
  • View file @ 07970a72


@@ -78,6 +78,15 @@ public class CodegenOperation {
@@ -78,6 +78,15 @@ public class CodegenOperation {
return nonempty(bodyParams);
return nonempty(bodyParams);
}
}
 
/**
 
* Check if there's at least one body parameter or at least one form parameter
 
*
 
* @return true if body or form parameter exists, false otherwise
 
*/
 
public boolean getHasBodyOrFormParams() {
 
return getHasBodyParam() || getHasFormParams();
 
}
 
/**
/**
* Check if there's at least one query parameter
* Check if there's at least one query parameter
*
*
modules/openapi-generator/src/main/resources/dart-dio/api.mustache
+ 78
- 49
  • View file @ 07970a72


@@ -71,64 +71,93 @@ class {{classname}} {
@@ -71,64 +71,93 @@ class {{classname}} {
onSendProgress: onSendProgress,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
onReceiveProgress: onReceiveProgress,
);
);
 
{{#hasBodyOrFormParams}}
dynamic _bodyData;
dynamic _bodyData;
{{#hasFormParams}}
_bodyData = {{#isMultipart}}FormData.fromMap({{/isMultipart}}<String, dynamic>{
try {
{{#formParams}}
{{#hasFormParams}}
{{^required}}{{^nullable}}if ({{{paramName}}} != null) {{/nullable}}{{/required}}r'{{{baseName}}}': {{#isFile}}MultipartFile.fromBytes({{{paramName}}}, filename: r'{{{baseName}}}'){{/isFile}}{{^isFile}}parameterToString(_serializers, {{{paramName}}}){{/isFile}},
_bodyData = {{#isMultipart}}FormData.fromMap({{/isMultipart}}<String, dynamic>{
{{/formParams}}
{{#formParams}}
}{{#isMultipart}}){{/isMultipart}};
{{^required}}{{^nullable}}if ({{{paramName}}} != null) {{/nullable}}{{/required}}r'{{{baseName}}}': {{#isFile}}MultipartFile.fromBytes({{{paramName}}}, filename: r'{{{baseName}}}'){{/isFile}}{{^isFile}}parameterToString(_serializers, {{{paramName}}}){{/isFile}},
{{/hasFormParams}}
{{/formParams}}
{{#bodyParam}}
}{{#isMultipart}}){{/isMultipart}};
{{/hasFormParams}}
{{#isPrimitiveType}}
{{#bodyParam}}
_bodyData = {{paramName}};
{{#isPrimitiveType}}
{{/isPrimitiveType}}
_bodyData = {{paramName}};
{{^isPrimitiveType}}
{{/isPrimitiveType}}
{{#isContainer}}
{{^isPrimitiveType}}
const _type = FullType(Built{{#isMap}}Map{{/isMap}}{{#isArray}}{{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}{{/isArray}}, [{{#isMap}}FullType(String), {{/isMap}}FullType({{{baseType}}})]);
{{#isContainer}}
_bodyData = _serializers.serialize({{paramName}}, specifiedType: _type);
const _type = FullType(Built{{#isMap}}Map{{/isMap}}{{#isArray}}{{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}{{/isArray}}, [{{#isMap}}FullType(String), {{/isMap}}FullType({{{baseType}}})]);
{{/isContainer}}
_bodyData = _serializers.serialize({{paramName}}, specifiedType: _type);
{{^isContainer}}
{{/isContainer}}
const _type = FullType({{{baseType}}});
{{^isContainer}}
_bodyData = _serializers.serialize({{paramName}}, specifiedType: _type);
const _type = FullType({{{baseType}}});
{{/isContainer}}
_bodyData = _serializers.serialize({{paramName}}, specifiedType: _type);
{{/isPrimitiveType}}
{{/isContainer}}
{{/bodyParam}}
{{/isPrimitiveType}}
 
{{/bodyParam}}
 
} catch(error) {
 
{{#dioErrorWrapping}}
 
throw DioError(
 
request: _request,
 
type: DioErrorType.DEFAULT,
 
error: error,
 
);
 
{{/dioErrorWrapping}}
 
{{^dioErrorWrapping}}
 
rethrow;
 
{{/dioErrorWrapping}}
 
}
 
{{/hasBodyOrFormParams}}
final _response = await _dio.request<dynamic>(
final _response = await _dio.request<dynamic>(
_request.path,
_request.path,{{#hasBodyOrFormParams}}
data: _bodyData,
data: _bodyData,{{/hasBodyOrFormParams}}
options: _request,
options: _request,
);
);
{{#returnType}}
{{#returnType}}
{{#isResponseFile}}
{{{returnType}}} _responseData;
final {{{returnType}}} _responseData = _response.data;
try {
{{/isResponseFile}}
{{#isResponseFile}}
{{^isResponseFile}}
_responseData = _response.data;
{{#returnSimpleType}}
{{/isResponseFile}}
{{#returnTypeIsPrimitive}}
{{^isResponseFile}}
final {{{returnType}}} _responseData = _response.data as {{{returnType}}};
{{#returnSimpleType}}
{{/returnTypeIsPrimitive}}
{{#returnTypeIsPrimitive}}
{{^returnTypeIsPrimitive}}
_responseData = _response.data as {{{returnType}}};
const _responseType = FullType({{{returnType}}});
{{/returnTypeIsPrimitive}}
final _responseData = _serializers.deserialize(
{{^returnTypeIsPrimitive}}
_response.data,
const _responseType = FullType({{{returnType}}});
specifiedType: _responseType,
_responseData = _serializers.deserialize(
) as {{{returnType}}};
_response.data,
{{/returnTypeIsPrimitive}}
specifiedType: _responseType,
{{/returnSimpleType}}
) as {{{returnType}}};
{{^returnSimpleType}}
{{/returnTypeIsPrimitive}}
const _responseType = FullType(Built{{#isArray}}{{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}{{/isArray}}{{#isMap}}Map{{/isMap}}, [{{#isMap}}FullType(String), {{/isMap}}FullType({{{returnBaseType}}})]);
{{/returnSimpleType}}
final {{{returnType}}} _responseData = _serializers.deserialize(
{{^returnSimpleType}}
_response.data,
const _responseType = FullType(Built{{#isArray}}{{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}{{/isArray}}{{#isMap}}Map{{/isMap}}, [{{#isMap}}FullType(String), {{/isMap}}FullType({{{returnBaseType}}})]);
specifiedType: _responseType,
_responseData = _serializers.deserialize(
) as {{{returnType}}};
_response.data,
{{/returnSimpleType}}
specifiedType: _responseType,
{{/isResponseFile}}
) as {{{returnType}}};
 
{{/returnSimpleType}}
 
{{/isResponseFile}}
 
} catch (error) {
 
{{#dioErrorWrapping}}
 
throw DioError(
 
request: _request,
 
response: _response,
 
type: DioErrorType.DEFAULT,
 
error: error,
 
);
 
{{/dioErrorWrapping}}
 
{{^dioErrorWrapping}}
 
rethrow;
 
{{/dioErrorWrapping}}
 
}
return Response<{{{returnType}}}>(
return Response<{{{returnType}}}>(
data: _responseData,
data: _responseData,
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
1
dependencies
1
dependencies
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
0
0 participants
Reference: OpenAPITools/openapi-generator!12021
Source branch: github/fork/kuhnroyal/dart-dio/serialization-errors

Menu

Explore Projects Groups Snippets