You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using "one of" fields where some variants are string enums and some are objects, the string enums are never deserialized.
Steps to reproduce
Use oneOf with differntly typed enums. Then the generated code only handles maps in the JSON and not strings.
/// Returns a new [QueueResult] instance and imports its values from /// [value] if it's a [Map], null otherwise.// ignore: prefer_constructors_over_static_methodsstaticQueueResult?fromJson(dynamic value) {
if (value isMap) {
final json = value.cast<String, dynamic>();
// Ensure that the map contains the required keys.// Note 1: the values aren't checked for validity beyond being non-null.// Note 2: this code is stripped in release mode!assert(() {
requiredKeys.forEach((key) {
assert(json.containsKey(key),
'Required key "QueueResult[$key]" is missing from JSON.');
assert(json[key] !=null,
'Required key "QueueResult[$key]" has a null value in JSON.');
});
returntrue;
}());
returnQueueResult(
error:mapValueOfType<String>(json, r'error')!,
);
}
returnnull;
}
Additionally, it has the object variants required fields as non-nullable members:
classQueueResult {
/// Returns a new [QueueResult] instance.QueueResult({
requiredthis.error,
});
/// Error occurredString error;
...
}
The spec is generated using utoipa from a Rust code similar to the following:
/// Status#[derive(Debug,Serialize,Deserialize,Clone,ToSchema)]pubstructUserStatus{/// Result of last queue attemptpublast_result:Option<QueueResult>,/// Service enabledpubenabled:bool,}/// Queue attempt result#[derive(Debug,Serialize,Deserialize,Clone,PartialEq,Eq,ToSchema)]#[serde(rename_all = "snake_case")]pubenumQueueResult{/// Service not enabled for userNotEnabled,/// Successfully queuedSuccess,Error(String),}
The text was updated successfully, but these errors were encountered:
Description of the bug
When using "one of" fields where some variants are string enums and some are objects, the string enums are never deserialized.
Steps to reproduce
Use oneOf with differntly typed enums. Then the generated code only handles maps in the JSON and not strings.
Additionally, it has the object variants required fields as non-nullable members:
Minimal openapi specification
Annotation used
Expected behavior
All variants are correctly deserialized.
Logs
Screenshots
No response
Platform
Linux
Library version
6.1.0
Flutter version
3.23.2
Flutter channel
stable
Additional context
The spec is generated using utoipa from a Rust code similar to the following:
The text was updated successfully, but these errors were encountered: