-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Open
Labels
Description
Is your feature request related to a problem? Please describe.
currently dart-dio
- generates api methods that handle both serialization and networking (see [BUG][dart-dio] Accept header not generated #15427 (comment) for further explaination)
- generates api classes are tightly coupled to the serializer, which means that different serialization options have to change networking mustache files directly, leading to complexities mentioned in [REQ] [dart-dio] [internal refactor] Unify test schemas #15449 (comment)
e.g.:json_serializable
: https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/json_serializable/apibuilt_value
: https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/api
Describe the solution you'd like
We can mitigate both of these issues with some non-breaking refactor of the generated API classes, essentially removing that api
mustache folder, that each serializer has to adapt.
- for the first issue, we introduce 2 method signatures (raw + json, as described in my comment)
- for the second issue, we introduce a new interface
IJsonSerializationRepository
which all serialization options have to implement.
It will include these 2 abstract methodswhere the general rule is thatObject serialize<T>(T src, {Object? context}); T deserialize<T>(Object value, {Object? context});
json == serialize<T>(deserialize<T>(json)) object == deserialize<T>(serialize<T>(object))
kuhnroyal