forked from loafle/openapi-generator-original
This commit is contained in:
@@ -84,6 +84,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
supportingFiles.add(new SupportingFile("rxjs-operators.mustache", getIndexDirectory(), "rxjs-operators.ts"));
|
||||
supportingFiles.add(new SupportingFile("configuration.mustache", getIndexDirectory(), "configuration.ts"));
|
||||
supportingFiles.add(new SupportingFile("variables.mustache", getIndexDirectory(), "variables.ts"));
|
||||
supportingFiles.add(new SupportingFile("encoder.mustache", getIndexDirectory(), "encoder.ts"));
|
||||
supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore"));
|
||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import { {{classname}} } from '../{{filename}}';
|
||||
|
||||
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
|
||||
import { Configuration } from '../configuration';
|
||||
import { CustomQueryEncoderHelper } from '../encoder';
|
||||
{{#withInterfaces}}
|
||||
import { {{classname}}Interface } from './{{classname}}Interface';
|
||||
{{/withInterfaces}}
|
||||
@@ -118,7 +119,7 @@ export class {{classname}} {
|
||||
const path = this.basePath + '{{{path}}}'{{#pathParams}}
|
||||
.replace('${' + '{{baseName}}' + '}', String({{paramName}})){{/pathParams}};
|
||||
|
||||
let queryParameters = new URLSearchParams();
|
||||
let queryParameters = new URLSearchParams('', new CustomQueryEncoderHelper());
|
||||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
|
||||
|
||||
{{#allParams}}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { QueryEncoder } from "@angular/http";
|
||||
|
||||
/**
|
||||
* CustomQueryEncoderHelper
|
||||
* Fix plus sign (+) not encoding, so sent as blank space
|
||||
* See: https://github.com/angular/angular/issues/11058#issuecomment-247367318
|
||||
*/
|
||||
export class CustomQueryEncoderHelper extends QueryEncoder {
|
||||
encodeKey(k: string): string {
|
||||
k = super.encodeKey(k);
|
||||
return k.replace(/\+/gi, '%2B');
|
||||
}
|
||||
encodeValue(v: string): string {
|
||||
v = super.encodeValue(v);
|
||||
return v.replace(/\+/gi, '%2B');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user