[Dart] Fix incorrect generation of additionalProperties:true (#12165) #12426
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes #12165
This PR includes a patch to the
modules/openapi-generator/src/main/resources/dart2/serialization/native/native_class.mustache
file which previously wasn't handling the deserialiation ofMap<String, Object>
types correctly.Previously, the deserialization of such fields was being generated as
mapValueOfType<Map<String, Object>>(json, key)
, but due to Dart using different internal map representations, this would always fail at runtime, meaning that such objects were not able to be generated by this project.This change adjusts the mustache file to detect when a field is a complex map and uses
mapCastOfType<String, Object>(json[key])
instead, which does not crash at runtime.The correctness of the change can be confirmed using the following test files:
spec.yaml:
Dart test file
@jaumard @josh-burton @amondnet @sbu-WBT @kuhnroyal @agilob @ahmednfwela