OpenAPITools / OpenAPITools/openapi-generator

Is there a way to add a custom apiTemplateFile if queryParams are present? [dart-dio-next]

Open
#9,911 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

I am trying to add an additional apiTemplateFile when some queryParams are present for the api.

For example, in the case of petstore.yaml, this is what I want to do:

lib
    - src
        - api
            - pet_api.dart
            - pet_api_query.dart      // <----- New file
            - store_api.dart
            - user_api.dart        
            - user_api_query.dart     // <----- New file
        - model
            - api_response.dart
            - category.dart
            - date.dart
            - order.dart
            - pet.dart
            - tag.dart
            - user.dart
        - api.dart
        - serailizers.dart
    openapi.dart

I intend to place some Built classes like this in the *_query.dart (ideally in a different folder than api), but only for operations that contain at least one query parameter.

abstract class FindPetsByStatusQuery implements Built<FindPetsByStatusQuery, FindPetsByStatusQueryBuilder> {

    FindPetsByStatusQuery._();

    factory FindPetsByStatusQuery([void Function(FindPetsByStatusQueryBuilder) updates]) = _$FindPetsByStatusQuery;

    String? get status;

}
What I have tried so far
  • I have tried adding in a conditional statement inside the fromOperation method, but it still does not behave any differently. Am I looking/editing in the wrong place?
  • I also have a feeling that I should create a supporting file. But again I could not find any documentation on how to create a supporting file for every operation that contains a queryParam.

Any help would be appreciated.

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 tracing how the dart-dio-next generator handles apiTemplateFile and the fromOperation method, then reproduce the request with petstore.yaml. Determine whether the generator can emit an additional file for each operation containing query parameters, and document the required template and output behavior as done.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, openapi
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.