[BUG] [dart][dart-dio] Generator does not work with property named "source" or definition named "URL"
Created by: cputoaster
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)