-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update libraries
- Loading branch information
Showing
11 changed files
with
654 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
function serializeQueryParam(obj: any) { | ||
if (obj === null || obj === undefined) return ''; | ||
if (obj instanceof Date) return obj.toJSON(); | ||
if (typeof obj !== 'object' || Array.isArray(obj)) return obj; | ||
return Object.keys(obj) | ||
.reduce((a: any, b) => a.push(b + '=' + obj[b]) && a, []) | ||
.join('&'); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
//---------------------- | ||
// <auto-generated> | ||
// Generated using Swaggie (https://github.com/yhnavein/swaggie) | ||
// Please avoid doing any manual changes in this file | ||
// </auto-generated> | ||
//---------------------- | ||
// ReSharper disable InconsistentNaming | ||
// deno-lint-ignore-file | ||
|
||
import xior, { type XiorResponse, type XiorRequestConfig } from "xior"; | ||
|
||
export const http = xior.create({ | ||
baseURL: '<%= it.baseUrl || '' %>', | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const <%= it.camelCaseName %>Client = { | ||
<% it.operations.forEach((operation) => { %> | ||
<%~ include('operation.ejs', operation); %> | ||
<% }); %> | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
<% it.parameters.forEach((parameter) => { %> | ||
* @param <%= parameter.name %> <%= parameter.optional ? '(optional)' : '' %> <%= parameter.name !== parameter.originalName ? `(API name: ${parameter.originalName})` : '' %> | ||
<% }); -%> | ||
*/ | ||
<%= it.name %>(<% it.parameters.forEach((parameter) => { %> | ||
<%= parameter.name %>: <%~ parameter.type %> <%= parameter.optional ? '| null | undefined' : '' %>, | ||
<% }); %> | ||
$config?: XiorRequestConfig | ||
): Promise<XiorResponse<<%~ it.returnType %>>> { | ||
let url = '<%= it.url %>'; | ||
<% if(it.pathParams && it.pathParams.length > 0) { | ||
it.pathParams.forEach((parameter) => { %> | ||
url = url.replace('{<%= parameter.name %>}', encodeURIComponent("" + <%= parameter.name %>)); | ||
<% }); | ||
} %> | ||
<% if(it.formData && it.formData.length > 0) { %> | ||
const formDataBody = new FormData(); | ||
<% it.formData.forEach((parameter) => { %> | ||
if (!!<%= parameter.name %>) { | ||
<% if(parameter.original && parameter.original.type === 'array') { %> | ||
<%= parameter.name %>.forEach((f: any) => formDataBody.append("<%= parameter.originalName %>", f)); | ||
<% } else { %> | ||
formDataBody.append("<%= parameter.originalName %>", <%= parameter.name %><%= parameter.type !== 'string' && parameter.type !== 'File' && parameter.type !== 'Blob' ? '.toString()' : '' %>); | ||
<% } %> | ||
} | ||
<% }); | ||
} %> | ||
|
||
return http.request<<%~ it.returnType %>>({ | ||
url: url, | ||
method: '<%= it.method %>', | ||
<% if(it.formData && it.formData.length > 0) { %> | ||
data: formDataBody, | ||
<% } else if(it.body) { %> | ||
data: <%= it.body.name %>, | ||
<% } %> | ||
<% if(it.query && it.query.length > 0) { %> | ||
params: { | ||
<% it.query.forEach((parameter) => { %> | ||
'<%= parameter.originalName %>': serializeQueryParam(<%= parameter.name %>), | ||
<% }); %> | ||
}, | ||
<% } %> | ||
<% if(it.headers && it.headers.length > 0) { %> | ||
headers: { | ||
<% it.headers.forEach((parameter) => { %> | ||
<% if (parameter.value) { %> | ||
'<%= parameter.originalName %>': '<%= parameter.value %>', | ||
<% } else { %> | ||
'<%= parameter.originalName %>': <%= parameter.name %>, | ||
<% } %> | ||
<% }); %> | ||
}, | ||
<% } %> | ||
...$config, | ||
}); | ||
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.