Open Richard87 opened 2 years ago
Any news?
I guess one solution would be to set a different "serializedName" for those properties that intersect with hydra, granted that requires touching a lot of stuff
Edit:
Found a dirty but simple workaround that involves a custom generator.
First create the scaffolding for the custom generator:
Now open the file located in custom-generator/src/main/java/company/codegen/CustomCodegenGenerator.java. Replace everything but the first line with:
import org.openapitools.codegen.*;
import org.openapitools.codegen.languages.TypeScriptAngularClientCodegen;
public class CustomCodegenGenerator extends TypeScriptAngularClientCodegen implements CodegenConfig {
public String getName() {
return "custom-codegen";
}
@Override
public String toVarName(String name) {
switch(name) {
case "@context":
case "@id":
case "@type":
return ("\"" + name + "\"");
}
return super.sanitizeName(name);
}
}
You basically just intercept any call to "toVarName" and make sure that certain properties are quoted and not passed to the sanitize-function.
Compile the generator by executing
wherever the pom.xml is located in.
And then generate your Code with:
One could go ahead and add all other hydra-context properties to the switch, or just check if an @ is at the beginning of "name", though that may catch unwanted properties as well.
i have the same issues thank's for the work arroud
Bug Report Checklist
Description
Json-LD includes a few fields that starts with a
@
sign, like@id
,@type
and ´@context, when using
typescript-fetchthe
@sign is stripped wich leads to invalid code (often duplicate
id` properties).I assumed
modelPropertyNaming=original
would work, but it had no effect.openapi-generator version
npm:
@openapitools/openapi-generator-cli
2.5.2
OpenAPI declaration file content or url
Generation Details
I run this command as a php
composer.json
script:Steps to reproduce
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/5899
Suggest a fix