OpenAPITools / OpenAPITools/openapi-generator
[BUG] [dart][dart-dio] Generator does not work with property named "source" or definition named "URL"
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- [ x] Have you provided a full/minimal spec to reproduce the issue?
- [ x] Have you validated the input using an OpenAPI validator (example)?
- [ x] What's the version of OpenAPI Generator used?
- [x ] Have you search for related issues/PRs?
- [x ] What's the actual output vs expected output?
- [Optional] Bounty to sponsor the fix ([example]
Description
When trying to generate dart-dio source from a json openapi definition that includes a property called "source" or a definition called "URL", it does not compile
openapi-generator version
MacOS Catalina, openapi-generator 4.2.2
OpenAPI declaration file content or url
...
"definitions": {
"URL": {
"type": "object",
"properties": {
"myproperty": {
"type": "string"
}
}
},
"Document":{
"type": "object",
"properties": {
"source": {
"type": "string"
}
}
}
}
...
Command line used for generation
openapi-generator generate -g dart-dio -i openapi.json -o openapi/
Steps to reproduce
- create openapi.json with a definition called "URL" and / or a field called "source"
- generate dart-dio source
- try building the source with mentioned command-line below
Error in BuiltValueGenerator for /openapi/lib/model/url.dart.
Please make the following changes to use built_value serialization:
1. Declare URL.serializer as: static Serializer<URL> get serializer => _$uRLSerializer; got static Serializer<URL> get serializer => _$URLSerializer;
Error in BuiltValueGenerator for abstract class Document implements Built<Document, dynamic>.
Please make the following changes to use BuiltValue:
1. Make field _source public; remove the underscore.
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/4865
Suggest a fix
renaming the variables in the dart source like mentioned in the error messages works:
_source -> source
_$URLSerializer -> _$uRLSerializer (for the instance variable, not the class)
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
Start at the dart-dio generator entry point and reproduce the issue with the provided openapi.json containing a source property and URL definition. Run flutter pub run build_runner build --delete-conflicting-outputs; done means the generated Dart source builds without the reported serializer or field errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100