I have _ key in my json and Dart uses a leading underscore in an identifier to mark members and top-level declarations as private
3.0.19
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i swagger.json \
-l dart\
-o /var/tmp/dart_api_client
1- rename a field of http://petstore.swagger.io/v2/swagger.json and put _ first
2- generate dart files
Maybe a fix to this problem is to replace all identifiers that start with "_" by "$", since dart/flutter seems to accept in its standard.
swagger-codegen must automatically handle it , like reserved keywords
since dart/flutter seems to accept in its standard.
@fabricio-godoi Can you refer me to official document?
@ sm2017 Check page 141 of the official Dart page:
https://dart.dev/guides/language/specifications/DartLangSpec-v2.2.pdf
It states that 〈IDENTIFIER_START〉 :: = 〈〈LETTER〉 | '_'〉 | ‘$’
Which means that variables and methods could start with the dollar sign. For now I couldn't find any reason behind this, but doesn't seem to have any special characteristics starting with "$" which I assume is a simple wildcard to be used as will.
I agree with you that swagger codegen should handle it. Can you test this method in your swagger to know if works? Maybe you or I could make a PR correcting it.
Best regards
@fabricio-godoi I tested dollar sign and it works well
I think it's good to prepend $ to keys that start with $ or _
_ => $_
$ => $$
_foo => $_foo
__foo => $__foo
$foo => $$foo
$$foo => $$$foo
@fabricio-godoi I don't know Java can you please make a PR?
@sm2017 I'm a little busy these days, so if I have some time at the weekends I should try something.
But I agree with your mapping strategy, I think that it could help prevent misunderstandings of variables that starts with $
@fabricio-godoi Do you have plan to make a PR?
@frantuma @HugoMario take a look please
@sm2017 I'm sorry, but I'm unable to mess with it right now. So if anyone else could create the improvement it will be nice.
ðŸ˜
@HugoMario Do you working on it?
@HugoMario Can you please reply
Hi @sm2017, sorry for delay reply. This issue is certaintly in my to-do list. But got others pending too. If someone else can provide a PR I can help with merging