You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
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 duplicateid` properties).
I assumed modelPropertyNaming=original would work, but it had no effect.
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:
openapi-generator-cli meta -o out/custom-generator -n custom-codegen
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.
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.
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
#5899
Suggest a fix
The text was updated successfully, but these errors were encountered: