Skip to content

Commit fb05bcc

Browse files
authored
Remove the need of qs package (#46)
1 parent 2ccd5ec commit fb05bcc

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Follow the steps, this will generate a configuration file for you (openapi-codeg
2626

2727
You should have a bunch of types / components ready to be used.
2828

29-
Note: The generated `{namespace}Fetcher.ts` assume a global `fetch` and the `qs` package, this is just a suggestion, you can do what ever you want on this file as soon as the types are compliant.
29+
Note: The generated `{namespace}Fetcher.ts` assume a global `fetch`, if you want to use this in a nodejs environment, please update this file (this is just a template)
3030

3131
## Philosophy
3232

plugins/typescript/src/templates/fetcher.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ export const getFetcher = ({
1414
contextPath?: string;
1515
baseUrl?: string;
1616
}) =>
17-
`import qs from "qs";
18-
${
17+
`${
1918
contextPath
2019
? `import { ${pascal(prefix)}Context } from "./${contextPath}";`
2120
: `
@@ -88,10 +87,10 @@ export async function ${camel(prefix)}Fetch<
8887
8988
const resolveUrl = (
9089
url: string,
91-
queryParams: Record<string, unknown> = {},
90+
queryParams: Record<string, string> = {},
9291
pathParams: Record<string, string> = {}
9392
) => {
94-
let query = qs.stringify(queryParams);
93+
let query = new URLSearchParams(queryParams).toString();
9594
if (query) query = \`?\${query}\`;
9695
return url.replace(/\\{\\w*\\}/g, (key) => pathParams[key.slice(1, -1)]) + query;
9796
};

0 commit comments

Comments
 (0)