docs(api): 更新Swagger文档以统一路径和定义引用格式

Swagger文档中的路径和定义引用格式已标准化,确保一致性和减少混乱。此更改包括将所有路径和引用转换为小写,并移除定义中的重复引号。

修复了由不一致的引用格式引起的解析错误,提高了文档的准确性和可读性。
```
This commit is contained in:
ivamp 2024-08-04 17:24:36 +08:00
parent 4439b142e3
commit 43a79e9bd4
6 changed files with 2549 additions and 3414 deletions

View File

@ -32,7 +32,7 @@ definitions:
rag-new_internal_entity.AssistantToolType: rag-new_internal_entity.AssistantToolType:
properties: properties:
assistant: assistant:
$ref: "#/definitions/rag-new_internal_entity.Assistant" $ref: '#/definitions/rag-new_internal_entity.Assistant'
assistant_id: assistant_id:
type: integer type: integer
created_at: created_at:
@ -40,7 +40,7 @@ definitions:
id: id:
type: integer type: integer
tool: tool:
$ref: "#/definitions/rag-new_internal_entity.Tool" $ref: '#/definitions/rag-new_internal_entity.Tool'
tool_id: tool_id:
type: integer type: integer
updated_at: updated_at:
@ -89,7 +89,7 @@ definitions:
created_at: created_at:
type: string type: string
data: data:
$ref: "#/definitions/rag-new_internal_schema.ToolDiscoveryOutput" $ref: '#/definitions/rag-new_internal_schema.ToolDiscoveryOutput'
description: description:
type: string type: string
discovery_url: discovery_url:
@ -189,7 +189,7 @@ definitions:
type: string type: string
function: function:
items: items:
$ref: "#/definitions/rag-new_internal_schema.ToolDiscoveryOutputFunctions" $ref: '#/definitions/rag-new_internal_schema.ToolDiscoveryOutputFunctions'
type: array type: array
homepage_url: homepage_url:
type: string type: string
@ -212,7 +212,7 @@ definitions:
properties: properties:
function: function:
items: items:
$ref: "#/definitions/rag-new_internal_schema.ToolDiscoveryOutputFunction" $ref: '#/definitions/rag-new_internal_schema.ToolDiscoveryOutputFunction'
type: array type: array
type: type:
type: string type: string
@ -233,17 +233,17 @@ paths:
description: OK description: OK
schema: schema:
allOf: allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody" - $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties: - properties:
data: data:
items: items:
$ref: "#/definitions/rag-new_internal_entity.Assistant" $ref: '#/definitions/rag-new_internal_entity.Assistant'
type: array type: array
type: object type: object
"400": "400":
description: Bad Request description: Bad Request
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security: security:
- ApiKeyAuth: [] - ApiKeyAuth: []
summary: 获取 Assistant 列表 summary: 获取 Assistant 列表
@ -258,7 +258,7 @@ paths:
name: assistant name: assistant
required: true required: true
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.AssistantCreateRequest" $ref: '#/definitions/rag-new_internal_schema.AssistantCreateRequest'
produces: produces:
- application/json - application/json
responses: responses:
@ -266,15 +266,15 @@ paths:
description: OK description: OK
schema: schema:
allOf: allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody" - $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties: - properties:
data: data:
$ref: "#/definitions/rag-new_internal_entity.Assistant" $ref: '#/definitions/rag-new_internal_entity.Assistant'
type: object type: object
"400": "400":
description: Bad Request description: Bad Request
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security: security:
- ApiKeyAuth: [] - ApiKeyAuth: []
summary: 创建 Assistant summary: 创建 Assistant
@ -298,11 +298,11 @@ paths:
"404": "404":
description: Not Found description: Not Found
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"500": "500":
description: Internal Server Error description: Internal Server Error
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security: security:
- ApiKeyAuth: [] - ApiKeyAuth: []
summary: 删除 Assistant summary: 删除 Assistant
@ -324,15 +324,15 @@ paths:
description: OK description: OK
schema: schema:
allOf: allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody" - $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties: - properties:
data: data:
$ref: "#/definitions/rag-new_internal_entity.Assistant" $ref: '#/definitions/rag-new_internal_entity.Assistant'
type: object type: object
"400": "400":
description: Bad Request description: Bad Request
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security: security:
- ApiKeyAuth: [] - ApiKeyAuth: []
summary: 获取指定的 Assistant summary: 获取指定的 Assistant
@ -355,17 +355,17 @@ paths:
description: OK description: OK
schema: schema:
allOf: allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody" - $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties: - properties:
data: data:
items: items:
$ref: "#/definitions/rag-new_internal_entity.AssistantToolType" $ref: '#/definitions/rag-new_internal_entity.AssistantToolType'
type: array type: array
type: object type: object
"500": "500":
description: Internal Server Error description: Internal Server Error
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security: security:
- ApiKeyAuth: [] - ApiKeyAuth: []
summary: 获取 Assistant 所绑定的 Tool summary: 获取 Assistant 所绑定的 Tool
@ -393,15 +393,15 @@ paths:
description: OK description: OK
schema: schema:
allOf: allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody" - $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties: - properties:
data: data:
$ref: "#/definitions/rag-new_internal_entity.AssistantTool" $ref: '#/definitions/rag-new_internal_entity.AssistantTool'
type: object type: object
"500": "500":
description: Internal Server Error description: Internal Server Error
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security: security:
- ApiKeyAuth: [] - ApiKeyAuth: []
summary: 解绑 Tool summary: 解绑 Tool
@ -428,15 +428,15 @@ paths:
description: OK description: OK
schema: schema:
allOf: allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody" - $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties: - properties:
data: data:
$ref: "#/definitions/rag-new_internal_entity.AssistantTool" $ref: '#/definitions/rag-new_internal_entity.AssistantTool'
type: object type: object
"500": "500":
description: Internal Server Error description: Internal Server Error
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security: security:
- ApiKeyAuth: [] - ApiKeyAuth: []
summary: 绑定 Tool summary: 绑定 Tool
@ -459,17 +459,19 @@ paths:
description: OK description: OK
schema: schema:
allOf: allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody" - $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties: - properties:
data: data:
items: items:
$ref: "#/definitions/rag-new_internal_entity.Chat" $ref: '#/definitions/rag-new_internal_entity.Chat'
type: array type: array
type: object type: object
"400": "400":
description: Bad Request description: Bad Request
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- ApiKeyAuth: []
summary: 获取所有 Chat summary: 获取所有 Chat
tags: tags:
- chat - chat
@ -483,7 +485,7 @@ paths:
name: chat name: chat
required: true required: true
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ChatCreateRequest" $ref: '#/definitions/rag-new_internal_schema.ChatCreateRequest'
produces: produces:
- application/json - application/json
responses: responses:
@ -491,19 +493,21 @@ paths:
description: OK description: OK
schema: schema:
allOf: allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody" - $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties: - properties:
data: data:
$ref: "#/definitions/rag-new_internal_entity.Chat" $ref: '#/definitions/rag-new_internal_entity.Chat'
type: object type: object
"400": "400":
description: Bad Request description: Bad Request
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"500": "500":
description: Internal Server Error description: Internal Server Error
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security:
- ApiKeyAuth: []
summary: Create Chat summary: Create Chat
tags: tags:
- chat - chat
@ -524,19 +528,19 @@ paths:
"200": "200":
description: OK description: OK
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"400": "400":
description: Bad Request description: Bad Request
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"404": "404":
description: Not Found description: Not Found
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"500": "500":
description: Internal Server Error description: Internal Server Error
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security: security:
- ApiKeyAuth: [] - ApiKeyAuth: []
summary: Delete Chat summary: Delete Chat
@ -560,25 +564,25 @@ paths:
description: OK description: OK
schema: schema:
allOf: allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody" - $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties: - properties:
data: data:
items: items:
$ref: "#/definitions/rag-new_internal_entity.ChatMessage" $ref: '#/definitions/rag-new_internal_entity.ChatMessage'
type: array type: array
type: object type: object
"400": "400":
description: Bad Request description: Bad Request
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"404": "404":
description: Not Found description: Not Found
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"500": "500":
description: Internal Server Error description: Internal Server Error
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security: security:
- ApiKeyAuth: [] - ApiKeyAuth: []
summary: 查看聊天记录 summary: 查看聊天记录
@ -599,7 +603,7 @@ paths:
name: message name: message
required: true required: true
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ChatMessageAddRequest" $ref: '#/definitions/rag-new_internal_schema.ChatMessageAddRequest'
produces: produces:
- application/json - application/json
responses: responses:
@ -607,32 +611,32 @@ paths:
description: OK description: OK
schema: schema:
allOf: allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody" - $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties: - properties:
data: data:
$ref: "#/definitions/rag-new_internal_schema.ChatMessageResponse" $ref: '#/definitions/rag-new_internal_schema.ChatMessageResponse'
type: object type: object
"400": "400":
description: Bad Request description: Bad Request
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"404": "404":
description: Not Found description: Not Found
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"409": "409":
description: Conflict description: Conflict
schema: schema:
allOf: allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody" - $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties: - properties:
data: data:
$ref: "#/definitions/rag-new_internal_schema.ChatMessageResponse" $ref: '#/definitions/rag-new_internal_schema.ChatMessageResponse'
type: object type: object
"500": "500":
description: Internal Server Error description: Internal Server Error
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security: security:
- ApiKeyAuth: [] - ApiKeyAuth: []
summary: 添加聊天记录 summary: 添加聊天记录
@ -650,15 +654,15 @@ paths:
description: OK description: OK
schema: schema:
allOf: allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody" - $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties: - properties:
data: data:
$ref: "#/definitions/rag-new_internal_schema.CurrentUserResponse" $ref: '#/definitions/rag-new_internal_schema.CurrentUserResponse'
type: object type: object
"400": "400":
description: Bad Request description: Bad Request
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security: security:
- ApiKeyAuth: [] - ApiKeyAuth: []
summary: Greet summary: Greet
@ -687,32 +691,32 @@ paths:
description: OK description: OK
schema: schema:
allOf: allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody" - $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties: - properties:
data: data:
$ref: "#/definitions/rag-new_internal_schema.ChatMessageResponse" $ref: '#/definitions/rag-new_internal_schema.ChatMessageResponse'
type: object type: object
"400": "400":
description: Bad Request description: Bad Request
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"404": "404":
description: Not Found description: Not Found
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"409": "409":
description: Conflict description: Conflict
schema: schema:
allOf: allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody" - $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties: - properties:
data: data:
$ref: "#/definitions/rag-new_internal_schema.ChatMessageResponse" $ref: '#/definitions/rag-new_internal_schema.ChatMessageResponse'
type: object type: object
"500": "500":
description: Internal Server Error description: Internal Server Error
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security: security:
- none: [] - none: []
summary: 流式传输聊天内容 summary: 流式传输聊天内容
@ -730,17 +734,17 @@ paths:
description: OK description: OK
schema: schema:
allOf: allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody" - $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties: - properties:
data: data:
items: items:
$ref: "#/definitions/rag-new_internal_entity.Tool" $ref: '#/definitions/rag-new_internal_entity.Tool'
type: array type: array
type: object type: object
"400": "400":
description: Bad Request description: Bad Request
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security: security:
- ApiKeyAuth: [] - ApiKeyAuth: []
summary: List Tool summary: List Tool
@ -756,7 +760,7 @@ paths:
name: tool name: tool
required: true required: true
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ToolCreateRequest" $ref: '#/definitions/rag-new_internal_schema.ToolCreateRequest'
produces: produces:
- application/json - application/json
responses: responses:
@ -764,15 +768,15 @@ paths:
description: OK description: OK
schema: schema:
allOf: allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody" - $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties: - properties:
data: data:
$ref: "#/definitions/rag-new_internal_entity.Tool" $ref: '#/definitions/rag-new_internal_entity.Tool'
type: object type: object
"400": "400":
description: Bad Request description: Bad Request
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security: security:
- ApiKeyAuth: [] - ApiKeyAuth: []
summary: Create Tool summary: Create Tool
@ -797,11 +801,11 @@ paths:
"400": "400":
description: Bad Request description: Bad Request
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"404": "404":
description: Not Found description: Not Found
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security: security:
- ApiKeyAuth: [] - ApiKeyAuth: []
summary: DeleteTool summary: DeleteTool
@ -824,19 +828,19 @@ paths:
description: OK description: OK
schema: schema:
allOf: allOf:
- $ref: "#/definitions/rag-new_internal_schema.ResponseBody" - $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
- properties: - properties:
data: data:
$ref: "#/definitions/rag-new_internal_entity.Tool" $ref: '#/definitions/rag-new_internal_entity.Tool'
type: object type: object
"400": "400":
description: Bad Request description: Bad Request
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
"404": "404":
description: Not Found description: Not Found
schema: schema:
$ref: "#/definitions/rag-new_internal_schema.ResponseBody" $ref: '#/definitions/rag-new_internal_schema.ResponseBody'
security: security:
- ApiKeyAuth: [] - ApiKeyAuth: []
summary: Get Tool summary: Get Tool

File diff suppressed because it is too large Load Diff

View File

@ -12,11 +12,12 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import type { Configuration } from "./configuration";
import type { Configuration } from './configuration';
// Some imports not used depending on template conditions // Some imports not used depending on template conditions
// @ts-ignore // @ts-ignore
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from "axios"; import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
import globalAxios from "axios"; import globalAxios from 'axios';
export const BASE_PATH = "http://localhost".replace(/\/+$/, ""); export const BASE_PATH = "http://localhost".replace(/\/+$/, "");
@ -49,17 +50,13 @@ export interface RequestArgs {
export class BaseAPI { export class BaseAPI {
protected configuration: Configuration | undefined; protected configuration: Configuration | undefined;
constructor( constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
configuration?: Configuration,
protected basePath: string = BASE_PATH,
protected axios: AxiosInstance = globalAxios,
) {
if (configuration) { if (configuration) {
this.configuration = configuration; this.configuration = configuration;
this.basePath = configuration.basePath ?? basePath; this.basePath = configuration.basePath ?? basePath;
} }
} }
} };
/** /**
* *
@ -68,19 +65,16 @@ export class BaseAPI {
* @extends {Error} * @extends {Error}
*/ */
export class RequiredError extends Error { export class RequiredError extends Error {
constructor( constructor(public field: string, msg?: string) {
public field: string,
msg?: string,
) {
super(msg); super(msg);
this.name = "RequiredError"; this.name = "RequiredError"
} }
} }
interface ServerMap { interface ServerMap {
[key: string]: { [key: string]: {
url: string; url: string,
description: string; description: string,
}[]; }[];
} }
@ -88,4 +82,5 @@ interface ServerMap {
* *
* @export * @export
*/ */
export const operationServerMap: ServerMap = {}; export const operationServerMap: ServerMap = {
}

View File

@ -12,129 +12,95 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
import type { Configuration } from "./configuration"; import type { Configuration } from "./configuration";
import type { RequestArgs } from "./base"; import type { RequestArgs } from "./base";
import type { AxiosInstance, AxiosResponse } from "axios"; import type { AxiosInstance, AxiosResponse } from 'axios';
import { RequiredError } from "./base"; import { RequiredError } from "./base";
/** /**
* *
* @export * @export
*/ */
export const DUMMY_BASE_URL = "https://example.com"; export const DUMMY_BASE_URL = 'https://example.com'
/** /**
* *
* @throws {RequiredError} * @throws {RequiredError}
* @export * @export
*/ */
export const assertParamExists = function ( export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) {
functionName: string,
paramName: string,
paramValue: unknown,
) {
if (paramValue === null || paramValue === undefined) { if (paramValue === null || paramValue === undefined) {
throw new RequiredError( throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
paramName,
`Required parameter ${paramName} was null or undefined when calling ${functionName}.`,
);
} }
}; }
/** /**
* *
* @export * @export
*/ */
export const setApiKeyToObject = async function ( export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) {
object: any,
keyParamName: string,
configuration?: Configuration,
) {
if (configuration && configuration.apiKey) { if (configuration && configuration.apiKey) {
const localVarApiKeyValue = const localVarApiKeyValue = typeof configuration.apiKey === 'function'
typeof configuration.apiKey === "function"
? await configuration.apiKey(keyParamName) ? await configuration.apiKey(keyParamName)
: await configuration.apiKey; : await configuration.apiKey;
object[keyParamName] = localVarApiKeyValue; object[keyParamName] = localVarApiKeyValue;
} }
}; }
/** /**
* *
* @export * @export
*/ */
export const setBasicAuthToObject = function ( export const setBasicAuthToObject = function (object: any, configuration?: Configuration) {
object: any,
configuration?: Configuration,
) {
if (configuration && (configuration.username || configuration.password)) { if (configuration && (configuration.username || configuration.password)) {
object["auth"] = { object["auth"] = { username: configuration.username, password: configuration.password };
username: configuration.username,
password: configuration.password,
};
} }
}; }
/** /**
* *
* @export * @export
*/ */
export const setBearerAuthToObject = async function ( export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) {
object: any,
configuration?: Configuration,
) {
if (configuration && configuration.accessToken) { if (configuration && configuration.accessToken) {
const accessToken = const accessToken = typeof configuration.accessToken === 'function'
typeof configuration.accessToken === "function"
? await configuration.accessToken() ? await configuration.accessToken()
: await configuration.accessToken; : await configuration.accessToken;
object["Authorization"] = "Bearer " + accessToken; object["Authorization"] = "Bearer " + accessToken;
} }
}; }
/** /**
* *
* @export * @export
*/ */
export const setOAuthToObject = async function ( export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) {
object: any,
name: string,
scopes: string[],
configuration?: Configuration,
) {
if (configuration && configuration.accessToken) { if (configuration && configuration.accessToken) {
const localVarAccessTokenValue = const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
typeof configuration.accessToken === "function"
? await configuration.accessToken(name, scopes) ? await configuration.accessToken(name, scopes)
: await configuration.accessToken; : await configuration.accessToken;
object["Authorization"] = "Bearer " + localVarAccessTokenValue; object["Authorization"] = "Bearer " + localVarAccessTokenValue;
} }
}; }
function setFlattenedQueryParams( function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void {
urlSearchParams: URLSearchParams,
parameter: any,
key: string = "",
): void {
if (parameter == null) return; if (parameter == null) return;
if (typeof parameter === "object") { if (typeof parameter === "object") {
if (Array.isArray(parameter)) { if (Array.isArray(parameter)) {
(parameter as any[]).forEach((item) => (parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
setFlattenedQueryParams(urlSearchParams, item, key), }
); else {
} else { Object.keys(parameter).forEach(currentKey =>
Object.keys(parameter).forEach((currentKey) => setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`)
setFlattenedQueryParams(
urlSearchParams,
parameter[currentKey],
`${key}${key !== "" ? "." : ""}${currentKey}`,
),
); );
} }
} else { }
else {
if (urlSearchParams.has(key)) { if (urlSearchParams.has(key)) {
urlSearchParams.append(key, parameter); urlSearchParams.append(key, parameter);
} else { }
else {
urlSearchParams.set(key, parameter); urlSearchParams.set(key, parameter);
} }
} }
@ -148,55 +114,37 @@ export const setSearchParams = function (url: URL, ...objects: any[]) {
const searchParams = new URLSearchParams(url.search); const searchParams = new URLSearchParams(url.search);
setFlattenedQueryParams(searchParams, objects); setFlattenedQueryParams(searchParams, objects);
url.search = searchParams.toString(); url.search = searchParams.toString();
}; }
/** /**
* *
* @export * @export
*/ */
export const serializeDataIfNeeded = function ( export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) {
value: any, const nonString = typeof value !== 'string';
requestOptions: any, const needsSerialization = nonString && configuration && configuration.isJsonMime
configuration?: Configuration, ? configuration.isJsonMime(requestOptions.headers['Content-Type'])
) {
const nonString = typeof value !== "string";
const needsSerialization =
nonString && configuration && configuration.isJsonMime
? configuration.isJsonMime(requestOptions.headers["Content-Type"])
: nonString; : nonString;
return needsSerialization return needsSerialization
? JSON.stringify(value !== undefined ? value : {}) ? JSON.stringify(value !== undefined ? value : {})
: value || ""; : (value || "");
}; }
/** /**
* *
* @export * @export
*/ */
export const toPathString = function (url: URL) { export const toPathString = function (url: URL) {
return url.pathname + url.search + url.hash; return url.pathname + url.search + url.hash
}; }
/** /**
* *
* @export * @export
*/ */
export const createRequestFunction = function ( export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
axiosArgs: RequestArgs, return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
globalAxios: AxiosInstance, const axiosRequestArgs = {...axiosArgs.options, url: (axios.defaults.baseURL ? '' : configuration?.basePath ?? basePath) + axiosArgs.url};
BASE_PATH: string,
configuration?: Configuration,
) {
return <T = unknown, R = AxiosResponse<T>>(
axios: AxiosInstance = globalAxios,
basePath: string = BASE_PATH,
) => {
const axiosRequestArgs = {
...axiosArgs.options,
url:
(axios.defaults.baseURL ? "" : (configuration?.basePath ?? basePath)) +
axiosArgs.url,
};
return axios.request<T, R>(axiosRequestArgs); return axios.request<T, R>(axiosRequestArgs);
}; };
}; }

View File

@ -12,19 +12,12 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
export interface ConfigurationParameters { export interface ConfigurationParameters {
apiKey?: apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
| string
| Promise<string>
| ((name: string) => string)
| ((name: string) => Promise<string>);
username?: string; username?: string;
password?: string; password?: string;
accessToken?: accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
| string
| Promise<string>
| ((name?: string, scopes?: string[]) => string)
| ((name?: string, scopes?: string[]) => Promise<string>);
basePath?: string; basePath?: string;
serverIndex?: number; serverIndex?: number;
baseOptions?: any; baseOptions?: any;
@ -37,11 +30,7 @@ export class Configuration {
* @param name security name * @param name security name
* @memberof Configuration * @memberof Configuration
*/ */
apiKey?: apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
| string
| Promise<string>
| ((name: string) => string)
| ((name: string) => Promise<string>);
/** /**
* parameter for basic security * parameter for basic security
* *
@ -62,11 +51,7 @@ export class Configuration {
* @param scopes oauth2 scope * @param scopes oauth2 scope
* @memberof Configuration * @memberof Configuration
*/ */
accessToken?: accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
| string
| Promise<string>
| ((name?: string, scopes?: string[]) => string)
| ((name?: string, scopes?: string[]) => Promise<string>);
/** /**
* override base path * override base path
* *
@ -119,14 +104,7 @@ export class Configuration {
* @return True if the given MIME is JSON, false otherwise. * @return True if the given MIME is JSON, false otherwise.
*/ */
public isJsonMime(mime: string): boolean { public isJsonMime(mime: string): boolean {
const jsonMime: RegExp = new RegExp( const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
"^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$", return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
"i",
);
return (
mime !== null &&
(jsonMime.test(mime) ||
mime.toLowerCase() === "application/json-patch+json")
);
} }
} }

View File

@ -12,5 +12,7 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
export * from "./api"; export * from "./api";
export * from "./configuration"; export * from "./configuration";