OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
20.74k stars 6.32k forks source link

[BUG] [dart][dart-dio] Generator does not work with property named "source" or definition named "URL" #5149

Open cputoaster opened 4 years ago

cputoaster commented 4 years ago

Bug Report Checklist

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
  1. create openapi.json with a definition called "URL" and / or a field called "source"
  2. generate dart-dio source
  3. 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)

auto-labeler[bot] commented 4 years ago

👍 Thanks for opening this issue! 🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.