OpenAPITools / OpenAPITools/openapi-generator

[BUG][DART] Polymorphism for dart-dio broken

Open
#6,160 7 comments 13 reactions 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)?
  • What's the version of OpenAPI Generator used? 2.0
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
Description

This is a general problem with generated code for dart. Annotated classes with allOf are not identified correctly and generated twice.

For e.g. we have an Dog and Cat inherited from class Pet. The code generator would create

pet.dart
dog.dart
dog_all_off.dart
cat.dart
cat_all_off.dart

To support polymorphism in general, it would be needed to match this built_value example

openapi-generator version

Using latest snapshot 4.3.1.

OpenAPI declaration file content or url

https://pastebin.com/f4ied29Q

Command line used for generation

java -jar openapi-generator-cli-4.3.1-20200423.060155-118.jar generate -i swagger.json -c config.json -l dart-dio -o .

Steps to reproduce

Generate the code

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 reproducing the issue with the listed openapi-generator-cli command, swagger.json, and config.json, using the declaration at the linked Pastebin URL. Compare the generated pet.dart, dog.dart, dog_all_off.dart, cat.dart, and cat_all_off.dart files with the intended Pet, Dog, and Cat hierarchy. Done means allOf-derived classes are identified correctly without duplicate generated classes and polymorphism works as described.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.