mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
Merge branch 'master' into feature/angular
This commit is contained in:
commit
5a8c2a4d36
@ -1,6 +1,14 @@
|
||||
# Changelog
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [0.16.2] - 2021-01-26
|
||||
### Fixed
|
||||
- Removed dependency on `URLSearchParams` to support browser and node without any additional imports
|
||||
|
||||
## [0.16.1] - 2021-01-26
|
||||
### Fixed
|
||||
- Correct export inside `index.ts` when giving a custom name
|
||||
|
||||
## [0.16.0] - 2021-01-25
|
||||
### Added
|
||||
- Added option to set the indentation (spaces and tabs)
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
- Supports generation through CLI, Node.js and NPX
|
||||
- Supports tsc and @babel/plugin-transform-typescript
|
||||
- Supports aborting of requests (cancelable promise pattern)
|
||||
- Supports external references using [`json-schema-ref-parser`](https://github.com/APIDevTools/json-schema-ref-parser/)
|
||||
- Supports external references using [json-schema-ref-parser](https://github.com/APIDevTools/json-schema-ref-parser/)
|
||||
|
||||
## Install
|
||||
|
||||
@ -117,7 +117,7 @@ const appClient = new AppClient({
|
||||
});
|
||||
|
||||
// Use the client instance to make the API call
|
||||
const res = await appClient.organizations.createOrganization({
|
||||
const response = await appClient.organizations.createOrganization({
|
||||
name: 'OrgName',
|
||||
description: 'OrgDescription',
|
||||
});
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "openapi-typescript-codegen",
|
||||
"version": "0.16.0",
|
||||
"version": "0.16.2",
|
||||
"description": "Library that generates Typescript clients based on the OpenAPI specification.",
|
||||
"author": "Ferdi Koomen",
|
||||
"homepage": "https://github.com/ferdikoomen/openapi-typescript-codegen",
|
||||
|
||||
@ -1,5 +1,9 @@
|
||||
const getQueryString = (params: Record<string, any>): string => {
|
||||
const searchParams = new URLSearchParams();
|
||||
const qs: string[] = [];
|
||||
|
||||
const append = (key: string, value: any) => {
|
||||
qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
||||
};
|
||||
|
||||
const process = (key: string, value: any) => {
|
||||
if (isDefined(value)) {
|
||||
@ -12,7 +16,7 @@ const getQueryString = (params: Record<string, any>): string => {
|
||||
process(`${key}[${k}]`, v);
|
||||
});
|
||||
} else {
|
||||
searchParams.append(key, value);
|
||||
append(key, value);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -21,9 +25,8 @@ const getQueryString = (params: Record<string, any>): string => {
|
||||
process(key, value);
|
||||
});
|
||||
|
||||
const query = searchParams.toString();
|
||||
if (query.length) {
|
||||
return `?${query}`;
|
||||
if (qs.length > 0) {
|
||||
return `?${qs.join('&')}`;
|
||||
}
|
||||
|
||||
return '';
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{{>header}}
|
||||
|
||||
{{#if @root.exportClient}}
|
||||
export { AppClient } from './client';
|
||||
export { {{{clientName}}} } from './client';
|
||||
{{/if}}
|
||||
{{#if @root.exportCore}}
|
||||
export { ApiError } from './core/ApiError';
|
||||
|
||||
@ -41,6 +41,7 @@ export const writeClientIndex = async (
|
||||
exportSchemas,
|
||||
useUnionTypes,
|
||||
postfix,
|
||||
clientName,
|
||||
server: client.server,
|
||||
version: client.version,
|
||||
models: sortModelsByName(client.models),
|
||||
|
||||
@ -271,7 +271,11 @@ const base64 = (str: string): string => {
|
||||
};
|
||||
|
||||
const getQueryString = (params: Record<string, any>): string => {
|
||||
const searchParams = new URLSearchParams();
|
||||
const qs: string[] = [];
|
||||
|
||||
const append = (key: string, value: any) => {
|
||||
qs.push(\`\${encodeURIComponent(key)}=\${encodeURIComponent(String(value))}\`);
|
||||
};
|
||||
|
||||
const process = (key: string, value: any) => {
|
||||
if (isDefined(value)) {
|
||||
@ -284,7 +288,7 @@ const getQueryString = (params: Record<string, any>): string => {
|
||||
process(\`\${key}[\${k}]\`, v);
|
||||
});
|
||||
} else {
|
||||
searchParams.append(key, value);
|
||||
append(key, value);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -293,9 +297,8 @@ const getQueryString = (params: Record<string, any>): string => {
|
||||
process(key, value);
|
||||
});
|
||||
|
||||
const query = searchParams.toString();
|
||||
if (query.length) {
|
||||
return \`?\${query}\`;
|
||||
if (qs.length > 0) {
|
||||
return \`?\${qs.join('&')}\`;
|
||||
}
|
||||
|
||||
return '';
|
||||
@ -3171,7 +3174,11 @@ const base64 = (str: string): string => {
|
||||
};
|
||||
|
||||
const getQueryString = (params: Record<string, any>): string => {
|
||||
const searchParams = new URLSearchParams();
|
||||
const qs: string[] = [];
|
||||
|
||||
const append = (key: string, value: any) => {
|
||||
qs.push(\`\${encodeURIComponent(key)}=\${encodeURIComponent(String(value))}\`);
|
||||
};
|
||||
|
||||
const process = (key: string, value: any) => {
|
||||
if (isDefined(value)) {
|
||||
@ -3184,7 +3191,7 @@ const getQueryString = (params: Record<string, any>): string => {
|
||||
process(\`\${key}[\${k}]\`, v);
|
||||
});
|
||||
} else {
|
||||
searchParams.append(key, value);
|
||||
append(key, value);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -3193,9 +3200,8 @@ const getQueryString = (params: Record<string, any>): string => {
|
||||
process(key, value);
|
||||
});
|
||||
|
||||
const query = searchParams.toString();
|
||||
if (query.length) {
|
||||
return \`?\${query}\`;
|
||||
if (qs.length > 0) {
|
||||
return \`?\${qs.join('&')}\`;
|
||||
}
|
||||
|
||||
return '';
|
||||
|
||||
@ -14,7 +14,7 @@ const generate = async (input, output) => {
|
||||
exportSchemas: true,
|
||||
exportModels: true,
|
||||
exportServices: true,
|
||||
// clientName: 'AppClient',
|
||||
// clientName: 'DemoAppClient',
|
||||
// indent: OpenAPI.Indent.SPACE_2,
|
||||
// postfix: 'Api',
|
||||
// request: './test/custom/request.ts',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user