3

In my model definition I have a property called "public" as part of an object. When running the swagger code-gen, it generates the code for my object, but it adds an underscore to the "public" property. So my object looks as follows:

export interface ObjectInfo { 

    _public?: boolean;

}

I'd like the property to just be called "public", as follows:

export interface ObjectInfo { 
    
        public?: boolean;
    
}

Angular does not have an issue with you doing:

public public: boolean;

So not sure why OpenAPI feels the need to add the underscore. Is there anyway to avoid this?

p192
  • 518
  • 1
  • 6
  • 19

1 Answers1

1

Late to the party but maybe this helps other people like myself:

You can define a mapping for reserved words when generating. Config is called reservedWordsMappings: Official readme

Also from the official readme:

specifies how a reserved name should be escaped to. Otherwise, the default _<name> is used. For example id=identifier. You can also have multiple occurrences of this option

In my case of using the maven plugin my config looks like this (had to map in to in since my backend doesnt know how to handle jpa criterias with _in):

.....
<configuration>
    <inputSpec>${project.basedir}/src/main/resources/openapi/api-docs.yaml</inputSpec>
    <generatorName>typescript-axios</generatorName
    <reservedWordsMappings>in=in</reservedWordsMappings>
    ...
</configuration>
.....
David Fariña
  • 1,536
  • 1
  • 18
  • 28