OpenAPITools / OpenAPITools/openapi-generator
[REQ] [dart-dio] Refactor api methods and classes
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
currently dart-dio
- generates api methods that handle both serialization and networking (see https://github.com/OpenAPITools/openapi-generator/issues/15427#issuecomment-1540251921 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 https://github.com/OpenAPITools/openapi-generator/issues/15449#issuecomment-1539943367
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
IJsonSerializationRepositorywhich all serialization options have to implement.
It will include these 2 abstract methods
where 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))
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the referenced issue comments, then inspect the dart-dio templates under modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/, especially the json_serializable/api and built_value/api directories. Trace how generated API methods currently combine serialization and networking. Done means the proposed raw and JSON method signatures and shared IJsonSerializationRepository design are reflected consistently across the serialization options.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- api, tooling
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100