OpenAPITools / OpenAPITools/openapi-generator

[Dart-dio] Not correct to processing any response other than json.

Open
#14,904 1 comment 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

openapi-generator-cli 6.4.0
dio: ^5.0.0

If spec has "schema=string" API method will throw exception.

"responses": {
          "200": {
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }

The error is in this line
https://github.com/OpenAPITools/openapi-generator/blob/c81ff5801d0af944a3012a85e4e47d0813484b6f/modules/openapi-generator/src/main/resources/dart/libraries/dio/api.mustache#L108

I think it has to be
final _response = await _dio.request<{{{returnType}}}{{^returnType}}void{{/returnType}}>(

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 in modules/openapi-generator/src/main/resources/dart/libraries/dio/api.mustache at the referenced request construction. Reproduce generation from a spec with a text/plain string response and verify that the generated Dart Dio client uses the declared return type instead of assuming JSON; done means the generated method handles that response without throwing.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.