Skip to content

Commit

Permalink
Merge pull request #1208 from swagger-api/encoder-override-tweak
Browse files Browse the repository at this point in the history
create option for override keyword
  • Loading branch information
HugoMario authored Nov 10, 2023
2 parents a0df9fa + eb047ba commit e341959
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
public static final String NG_PACKAGR = "useNgPackagr";
public static final String PROVIDED_IN_ROOT ="providedInRoot";
public static final String KEBAB_FILE_NAME ="kebab-file-name";
public static final String USE_OVERRIDE ="useOverride";

protected String npmName = null;
protected String npmVersion = "1.0.0";
Expand All @@ -63,6 +64,7 @@ public TypeScriptAngularClientCodegen() {
this.cliOptions.add(new CliOption(WITH_INTERFACES, "Setting this property to true will generate interfaces next to the default class implementations.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
this.cliOptions.add(new CliOption(NG_VERSION, "The version of Angular. Default is '4.3'"));
this.cliOptions.add(new CliOption(PROVIDED_IN_ROOT, "Use this property to provide Injectables in root (it is only valid in angular version greater or equal to 6.0.0).", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
this.cliOptions.add(new CliOption(USE_OVERRIDE, "Use this property to place `override` keyword in encoder methods.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
}

@Override
Expand Down Expand Up @@ -187,6 +189,11 @@ public void processOpts() {
}
}

if (additionalProperties.containsKey(USE_OVERRIDE)) {
final boolean useOverride = Boolean.parseBoolean(String.valueOf(additionalProperties.get(USE_OVERRIDE)));
additionalProperties.put(USE_OVERRIDE, useOverride);
}

kebabFileNaming = Boolean.parseBoolean(String.valueOf(additionalProperties.get(KEBAB_FILE_NAME)));

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
* See: https://github.com/angular/angular/issues/11058#issuecomment-247367318
*/
export class CustomHttpUrlEncodingCodec extends HttpUrlEncodingCodec {
override encodeKey(k: string): string {
{{#useOverride}}override {{/useOverride}}encodeKey(k: string): string {
k = super.encodeKey(k);
return k.replace(/\+/gi, '%2B');
}
override encodeValue(v: string): string {
{{#useOverride}}override {{/useOverride}}encodeValue(v: string): string {
v = super.encodeValue(v);
return v.replace(/\+/gi, '%2B');
}
Expand All @@ -29,11 +29,11 @@ export class CustomHttpUrlEncodingCodec extends HttpUrlEncodingCodec {
* See: https://github.com/angular/angular/issues/11058#issuecomment-247367318
*/
export class CustomQueryEncoderHelper extends QueryEncoder {
override encodeKey(k: string): string {
{{#useOverride}}override {{/useOverride}}encodeKey(k: string): string {
k = super.encodeKey(k);
return k.replace(/\+/gi, '%2B');
}
override encodeValue(v: string): string {
{{#useOverride}}override {{/useOverride}}encodeValue(v: string): string {
v = super.encodeValue(v);
return v.replace(/\+/gi, '%2B');
}
Expand Down

0 comments on commit e341959

Please sign in to comment.