-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Params named "default" get replaced with "_default", resulting in incompatible clients #1943
Comments
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
related issue: #13 - even in java there is some problem with the "default" keyword. |
@seanlaff have you tried the
|
@wing328 The How I tried:
|
Hi, same with |
Are If not, we should have a look where the list is defined and move java-related stuff only in the java generator part. |
they are keywords, but can be used for property names, function names and variables 🤔 maybe it makes sense looking at all cases where they are used in templates and see if it's safe to remove some keywords from the list |
@eseliger Will this fix apply to all typescript clients or just typescript-angular? And will it apply to all prefixed properties, or just the ones listed here? I've encountered an issue with the |
this would be for all typescript clients, but it needs more investigation if that won't break with some dialects ... Since in object property names much more keywords are allowed than for function names for example. Unfortunately, I'm really busy these weeks and won't be able to continue the work on the generator. I hope I can find some spare time end of this month |
I'm hitting this exact scenario as well. The weird part is that changing it from I think it is allowed as properties for interfaces, so I don't know why we are trying to prevent that. Also, if it isn't allowed, can't we use square bracket notation? E.g.: interface Foo {
["long"]: number;
} |
One more data point. I found this when looking into why |
I use a dirty sed to get around this for now |
Generators shouldn't touch the property names. This behavior is simply BREAKING users' definitions and semantics. Please consider using the computed key syntax e.g. |
I switched to Autorest now. Works like a charm, and is so much more stable and reliable. It also supports way more features it seems. |
Hi @eseliger, I'm going to ask you again, because I don't understand and I need to understand the point of your modification 2512ea0 I agree with @ffMathy. I changed
please help us :) |
some generators support the name mapping features: https://github.com/openapitools/openapi-generator/blob/master/docs/customization.md#name-mapping so that one can customize the property naming according to the use cases |
thank you @wing328, but unfortunately not the |
i did a test and it works:
and here is the output export interface Pet {
id: number;
name: string;
default: boolean;
tag?: string;
} without the name mapping option, |
did you also try setting e.g. |
i'm not familiar with 2512ea0 (done in 2019) so not much I can tell you about that change in particular. |
should be fixed by #19508 |
Description
My api has a request object that contains a key called
default
, however when I generate client code from this spec, it gets converted to_default
. Since my api expectsdefault
, the generated client code does not work.I'm guessing this is escaping that happens in java since
default
is a java keyword. Is there any way around this?Expected generated:
Actual generated:
openapi-generator version
4.0.0
OpenAPI declaration file content or url
https://gist.github.com/seanlaff/d2aef0244adeeea95c1396952b28d987
Command line used for generation
The text was updated successfully, but these errors were encountered: