Skip to content

[BUG][Dart] Generator creates a model class name that conflicts with a core lib class name (Type) #9029

Closed
@robrbecker

Description

@robrbecker

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue? Yes:
  • Have you validated the input using an OpenAPI validator (example)?
  • 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

When generating Dart code, an OAS is using a reserved(ish) word (Type) which the generator defines a class for which then conflicts and causes errors. (It's not technically a reserved word of the language, it's a class in the core library. Something that's always available and you can't import it with a namespace)

image

openapi-generator version

5.1.0 release
on both dart-dio and dart-dio-next

OpenAPI declaration file content or url

https://cdn-prod.wdesk.com/endpoints-admin/1.342.0/openapi/platform-v1.yaml

Problem arises from line 813

Generation Details

I used the jar release for 5.1.0 with this command:
java -jar openapi-generator-cli.jar generate -i https://cdn-prod.wdesk.com/endpoints-admin/1.342.0/openapi/platform-v1.yaml -g dart-dio -o ./ --additional-properties="pubDescription=Workiva Platform API (Dart),pubName=wk,pubVersion=1.0.0"

Steps to reproduce

Generate Dart code with the above command.
Have Dart installed (2.12.2)
Then run
pub get
pub run build_runner build --delete-conflicting-outputs -o build
(then remove the build directory .. you only need to run a build to do built_value code generation
Then either open in an IDE with the Dart plugin (VS Code, intelliJ) or just run dartanalyzer . which will show the errors.

Related issues/PRs
Suggest a fix

I'm not actually sure what a good fix would be. I might actually prefer if generation failed when creating the code and suggested a way to work around it, possibly by using the [--reserved-words-mappings <reserved word mappings>...] option ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions