OpenAPITools / OpenAPITools/openapi-generator

[BUG][dart-dio] Generates call to non-existant .replace method

Open
#20,964 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • [] Have you validated the input using an OpenAPI validator (example)?
    • That seems like an potentially dangerous, outdated link ^
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

dart_dio Generates code that doesn't compile. Assuming you did the steps below to generate the dart library:

  1. Some imports are missing, I assume this is tracked in #19144
  2. in src/model/resource.dart non-compiling code without clear semantics is generated. Here is a simplified version of whats generated:
ResourceBuilder result = ...;
JsonObject valueDes = ...;
result.path.replace(valueDes);
  • .path is an optional attribute, calling a method unconditionally is no valid dart
  • .path is of type JsonObject and not ResourceBuilder so there is no .replace method defined
openapi-generator version

OpenAPI Generator 7

OpenAPI declaration file content or url

https://app.swaggerhub.com/apis/Plattform_i40/AssetAdministrationShellRepositoryServiceSpecification/V3.0_SSP-001

Generation Details

java -jar openapi-generator-cli-7.7.0.jar generate -g dart-dio -i /home/derdilla/co24it/dart_aas/Plattform_i40-AssetAdministrationShellRepositoryServiceSpecification-V3.0_SSP-001-resolved.yaml -o /home/derdilla/co24it/dart_aas_gen --additional-properties=pubLibrary=dart_aas,pubVersion=1.0.0,serializationLibrary=built_value,finalProperties=false

Steps to reproduce
  1. run the generator
  2. open src/model/resource.dart
Related issues/PRs
Suggest a fix

Without deeper knowledge of how OpenApi generator works, this seems like an incorrect or outdated template.

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

Run the listed OpenAPI Generator 7.7.0 command with the referenced declaration, then inspect the generated src/model/resource.dart. Trace the generated result.path.replace(valueDes) expression and determine the generator source responsible for it. Done means the dart-dio output compiles without the invalid optional access or nonexistent replace call.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.