I want to be able to pass the basePath as a parameter to the sdk/api. At the moment, it seems to be hardcoded as a variable called _var defaultBasePath = "https://localhost/api"_
If you want to override it currently, you have to pass a parameter to each model constructor
I would like to be able to call a function / method / property in order to modify it
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i ./spec.json -l typescript-node
probably need to modify the typescript templates to add the missing functionality
@jmls do you mean making the basePath property public instead of protected?
cc @Vrolijkx
@wing328 : indeed I do ;)
Much better than the way I was trying to do it. Keep forgetting about protected / private / public ;)
@jmls may I know if you've time to submit a PR for the enhancement?
Personally I would also make defaultHeaders public: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/typescript-node/npm/api.ts#L154
Actually - looking at the proposed solution, this would mean that I would have to set the basepath for _every_ api : rather than just changing defaultBasePath, so that every api would use that by default.
@wing328 : sure, I could create a PR : I just want to ensure that the way it's implemented is appropriate :)
cc @Vrolijkx
my initial thought was to add
let defaultHeaders = {};
export let config = (options) => {
defaultBasePath = options.basePath || defaultBasePath;
defaultHeaders = options.headers || defaultHeaders;
};
and then change the template to remove
protected defaultHeaders : any = {};
and change
let headerParams: any = this.extendObj({}, this.defaultHeaders);
to
let headerParams: any = this.extendObj({}, defaultHeaders);
It seems to work ok - how does that look to you guys ?
@jmls looks like a perfect solution. We are doing almost the same in the angular2 version.
cool, I'll get onto it
Most helpful comment
cool, I'll get onto it