OpenAPITools / OpenAPITools/openapi-generator

[REQ] [dart-dio] Refactor api methods and classes

Open
#15,477 10 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
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

  1. generates api methods that handle both serialization and networking (see https://github.com/OpenAPITools/openapi-generator/issues/15427#issuecomment-1540251921 for further explaination)
  2. 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.:

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 methods
    Object serialize<T>(T src, {Object? context});
    T deserialize<T>(Object value, {Object? context});
    
    where the general rule is that
    json == serialize<T>(deserialize<T>(json))
    object == deserialize<T>(serialize<T>(object))
    

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.