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 like freezed but for our use case is by far better than it (I think in general but this is pretty subjective).
Edits
I transformed freezed boolean field with an enum called JsonSerializer that allow to understand inside the code which kind of serializer should be used. So the definition inside swagger_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:
indicate in swagger.parser.yaml json_serializer: "dart_mappable"
add the following string to build.yaml:
dart_mappable_builder:
runs_before:
- retrofit_generator
options:
renameMethods:
toJson: toJsonString
# This is because retrofit_generator expect a method Map<String,dynamic> toJson()
toMap: toJson
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.
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.