diff --git a/src/constants/index.ts b/src/constants/index.ts index 4db6495ce..2568d34b3 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -15,6 +15,12 @@ export const generalJSTypesWithArray = generalJSTypes.reduce( [], ); -export const VERBS_WITH_BODY = [Verbs.POST, Verbs.PUT, Verbs.PATCH, Verbs.DELETE]; +export const VERBS_WITH_BODY = [ + Verbs.POST, + Verbs.PUT, + Verbs.PATCH, + Verbs.DELETE, +]; -export const URL_REGEX = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/; +export const URL_REGEX = + /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/; diff --git a/src/core/generators/axios.ts b/src/core/generators/axios.ts index 814ac0b3a..557eca1e5 100644 --- a/src/core/generators/axios.ts +++ b/src/core/generators/axios.ts @@ -83,14 +83,15 @@ const generateAxiosImplementation = ( ) : ''; - return `const ${operationName} = (\n ${toObjectString(props, 'implementation')}\n ${ + return `const ${operationName} = ${toObjectString( + props, + 'implementation', + )}\n ${ isRequestOptions && isMutatorHasSecondArg ? `options?: SecondParameter` : '' }) => {${bodyForm} - return ${mutator.name}( + return ${mutator.name}<${response.definition.success || 'unknown'}>( ${mutatorConfig}, ${requestOptions}); } diff --git a/src/core/getters/parameters.ts b/src/core/getters/parameters.ts index 28c60fe3d..9a1b4a4bb 100644 --- a/src/core/getters/parameters.ts +++ b/src/core/getters/parameters.ts @@ -16,10 +16,8 @@ export const getParameters = async ({ parameters, async (acc, p) => { if (isReference(p)) { - const { - schema: parameter, - imports, - } = await resolveRef(p, context); + const { schema: parameter, imports } = + await resolveRef(p, context); if (parameter.in === 'path' || parameter.in === 'query') { return { diff --git a/src/utils/async-reduce.ts b/src/utils/async-reduce.ts index 62096226b..af28f3be1 100644 --- a/src/utils/async-reduce.ts +++ b/src/utils/async-reduce.ts @@ -1,6 +1,6 @@ export const asyncReduce = < Result extends unknown, - Item extends unknown = unknown + Item extends unknown = unknown, >( arr: Item[], func: (acc: Result, it: Item, index: number, arr: Item[]) => Promise, diff --git a/src/utils/debug.ts b/src/utils/debug.ts index 0e6adb70a..c8828e618 100644 --- a/src/utils/debug.ts +++ b/src/utils/debug.ts @@ -1,26 +1,26 @@ -import debug from 'debug' +import debug from 'debug'; -const filter = process.env.ORVAL_DEBUG_FILTER -const DEBUG = process.env.DEBUG +const filter = process.env.ORVAL_DEBUG_FILTER; +const DEBUG = process.env.DEBUG; interface DebuggerOptions { - onlyWhenFocused?: boolean | string + onlyWhenFocused?: boolean | string; } export function createDebugger( ns: string, - options: DebuggerOptions = {} + options: DebuggerOptions = {}, ): debug.Debugger['log'] { - const log = debug(ns) - const { onlyWhenFocused } = options - const focus = typeof onlyWhenFocused === 'string' ? onlyWhenFocused : ns + const log = debug(ns); + const { onlyWhenFocused } = options; + const focus = typeof onlyWhenFocused === 'string' ? onlyWhenFocused : ns; return (msg: string, ...args: any[]) => { if (filter && !msg.includes(filter)) { - return + return; } if (onlyWhenFocused && !DEBUG?.includes(focus)) { - return + return; } - log(msg, ...args) - } + log(msg, ...args); + }; }