swagger-codegen-generators icon indicating copy to clipboard operation
swagger-codegen-generators copied to clipboard

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

Open mjaggard opened this issue 4 years ago • 1 comments

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 avatar Dec 08 '21 14:12 mjaggard

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)

mjaggard avatar Dec 08 '21 15:12 mjaggard