Add support for an another json serializer called dart_mappable
#141
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.
With this issue I add the support for dart_mappable as json_serializer.
dart_mappable
, is a library for json serialization and immutable data structures, it is likefreezed
but for our use case is by far better than it (I think in general but this is pretty subjective).Edits
freezed
boolean field with an enum calledJsonSerializer
that allow to understand inside the code which kind of serializer should be used. So the definition insideswagger_parser.yaml
change in this way:Obviously, the code that allows you to generate the models using
dart_mappable
has been added, to do this I have not touched the pre-existing generation in any way in order to avoid introducing breaking changes.Furthermore, a test case has also been added to test the generation of a class with
dart_mappable
.Usage
The usage remains unchanged obviously if you want to use dart_mappable you need to:
json_serializer: "dart_mappable"
build.yaml
:Final considerations
Every changes has been made incremental without compromising and touching the other serializer in this way backward compatibility is totally granted. The only "breaking change" is the definition inside
swagger_parser.yaml
as explained above.Please, I kindly request you to consider this PR and integrate it into the library. I am open to any suggestions or questions regarding my work.