swagger-api / swagger-codegen-generators

Apache License 2.0
284 stars 423 forks source link

@type and type are not allowed in the same JSON object #995

Open mjaggard opened 2 years ago

mjaggard commented 2 years ago

https://github.com/swagger-api/swagger-codegen-generators/blob/137b149e1e7078aeef23e8938a3caf1933f040ba/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java#L3663

I have a model that has @type and type as two separate model properties (for legacy reasons) but the code generator will not allow it because of the line referenced above.

My data contains something like this: {"type":"","@type":""}

mjaggard commented 2 years ago

It seems that change the line I listed doesn't help because _type and type are also treated identically elsewhere. It works correctly if I add

name = name.replaceAll("@", "at_");

to the method DefaultCodegenConfig.sanitizeName(String)