🎨 Run biome after OpenAPI client generation (#1226)

This commit is contained in:
Tomer Barletz
2024-06-27 14:53:51 -05:00
committed by GitHub
parent dabeff7801
commit 960a38aeb6
13 changed files with 1419 additions and 1373 deletions
+38 -39
View File
@@ -1,58 +1,57 @@
import type { AxiosRequestConfig, AxiosResponse } from 'axios';import type { ApiRequestOptions } from './ApiRequestOptions';
import type { TResult } from './types';
import type { AxiosRequestConfig, AxiosResponse } from "axios"
import type { ApiRequestOptions } from "./ApiRequestOptions"
import type { TResult } from "./types"
type Headers = Record<string, string>;
type Middleware<T> = (value: T) => T | Promise<T>;
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
type Headers = Record<string, string>
type Middleware<T> = (value: T) => T | Promise<T>
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>
export class Interceptors<T> {
_fns: Middleware<T>[];
_fns: Middleware<T>[]
constructor() {
this._fns = [];
this._fns = []
}
eject(fn: Middleware<T>) {
const index = this._fns.indexOf(fn);
const index = this._fns.indexOf(fn)
if (index !== -1) {
this._fns = [
...this._fns.slice(0, index),
...this._fns.slice(index + 1),
];
this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]
}
}
use(fn: Middleware<T>) {
this._fns = [...this._fns, fn];
this._fns = [...this._fns, fn]
}
}
export type OpenAPIConfig = {
BASE: string;
CREDENTIALS: 'include' | 'omit' | 'same-origin';
ENCODE_PATH?: ((path: string) => string) | undefined;
HEADERS?: Headers | Resolver<Headers> | undefined;
PASSWORD?: string | Resolver<string> | undefined;
RESULT?: TResult;
TOKEN?: string | Resolver<string> | undefined;
USERNAME?: string | Resolver<string> | undefined;
VERSION: string;
WITH_CREDENTIALS: boolean;
interceptors: {request: Interceptors<AxiosRequestConfig>;
response: Interceptors<AxiosResponse>;};
};
BASE: string
CREDENTIALS: "include" | "omit" | "same-origin"
ENCODE_PATH?: ((path: string) => string) | undefined
HEADERS?: Headers | Resolver<Headers> | undefined
PASSWORD?: string | Resolver<string> | undefined
RESULT?: TResult
TOKEN?: string | Resolver<string> | undefined
USERNAME?: string | Resolver<string> | undefined
VERSION: string
WITH_CREDENTIALS: boolean
interceptors: {
request: Interceptors<AxiosRequestConfig>
response: Interceptors<AxiosResponse>
}
}
export const OpenAPI: OpenAPIConfig = {
BASE: '',
CREDENTIALS: 'include',
ENCODE_PATH: undefined,
HEADERS: undefined,
PASSWORD: undefined,
RESULT: 'body',
TOKEN: undefined,
USERNAME: undefined,
VERSION: '0.1.0',
WITH_CREDENTIALS: false,
interceptors: {request: new Interceptors(),response: new Interceptors(),
},
};
BASE: "",
CREDENTIALS: "include",
ENCODE_PATH: undefined,
HEADERS: undefined,
PASSWORD: undefined,
RESULT: "body",
TOKEN: undefined,
USERNAME: undefined,
VERSION: "0.1.0",
WITH_CREDENTIALS: false,
interceptors: { request: new Interceptors(), response: new Interceptors() },
}