OpenAPITools / OpenAPITools/openapi-generator
[BUG] [dart-dio] Does not generate imports if the model is inherited more than once
Open
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)?
- 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
If a model has nesting greater than 1, then imports are not generated
Undefined name 'FirstMyEnumEnum'. (Documentation)
To fix this, need to add import yourself to the file my_test/lib/src/model/third.dart
import 'package:openapi/src/model/first.dart';
openapi-generator version
openapi-generator-cli 7.7.0
commit : 4eaac3d
built : -999999999-01-01T00:00:00+18:00
source : https://github.com/openapitools/openapi-generator
docs : https://openapi-generator.tech/
OpenAPI declaration file content or url
{
"openapi": "3.0.3",
"info": {
"title": "Title",
"description": "Title",
"version": "1.0.0"
},
"servers": [
{
"url": "https"
}
],
"paths": {},
"components": {
"schemas": {
"First": {
"properties": {
"my-enum": {
"enum": [
"first"
]
}
}
},
"Second": {
"allOf": [
{
"$ref": "#/components/schemas/First"
}
]
},
"Third": {
"allOf": [
{
"$ref": "#/components/schemas/Second"
}
]
}
}
}
}
Generation Details
Steps to reproduce
java -jar openapi-generator-cli-7.8.0-20240711.071610-23.jar generate -g dart-dio -i my.json -o my_test
cd my_test
dart run build_runner build -d
Related issues/PRs
Suggest a fix
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the provided OpenAPI schema using the dart-dio generator command, then inspect the generated my_test/lib/src/model/third.dart and the generator path responsible for model imports. Run dart run build_runner build -d and confirm that the generated model includes the needed import and no longer reports the undefined FirstMyEnumEnum error.
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
- 50/100