mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
- Added credentials mode for more granular controll
This commit is contained in:
parent
11a5254710
commit
697de58134
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "openapi-typescript-codegen",
|
||||
"version": "0.12.0-alpha.0",
|
||||
"version": "0.12.0-alpha",
|
||||
"description": "Library that generates Typescript clients based on the OpenAPI specification.",
|
||||
"author": "Ferdi Koomen",
|
||||
"homepage": "https://github.com/ferdikoomen/openapi-typescript-codegen",
|
||||
@ -56,7 +56,7 @@
|
||||
"eslint:fix": "eslint \"./src/**/*.ts\" \"./bin/index.js\" \"./types/index.d.ts\" --fix",
|
||||
"prettier": "prettier \"./src/**/*.ts\" \"./bin/index.js\" \"./types/index.d.ts\" --check",
|
||||
"prettier:fix": "prettier \"./src/**/*.ts\" \"./bin/index.js\" \"./types/index.d.ts\" --write",
|
||||
"prepublish": "yarn run clean && yarn run release",
|
||||
"prepublishOnly": "yarn run clean && yarn run release",
|
||||
"codecov": "codecov --token=66c30c23-8954-4892-bef9-fbaed0a2e42b"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@ -4,11 +4,13 @@ import type { ApiRequestOptions } from './ApiRequestOptions';
|
||||
|
||||
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
|
||||
type Headers = Record<string, string>;
|
||||
type CredentialModes = 'include' | 'omit' | 'same-origin';
|
||||
|
||||
type Config = {
|
||||
BASE: string;
|
||||
VERSION: string;
|
||||
WITH_CREDENTIALS: boolean;
|
||||
CREDENTIALS: CredentialModes;
|
||||
TOKEN?: string | Resolver<string>;
|
||||
USERNAME?: string | Resolver<string>;
|
||||
PASSWORD?: string | Resolver<string>;
|
||||
@ -20,6 +22,7 @@ export const OpenAPI: Config = {
|
||||
BASE: '{{{server}}}',
|
||||
VERSION: '{{{version}}}',
|
||||
WITH_CREDENTIALS: false,
|
||||
CREDENTIALS: 'include',
|
||||
TOKEN: undefined,
|
||||
USERNAME: undefined,
|
||||
PASSWORD: undefined,
|
||||
|
||||
@ -13,6 +13,7 @@ async function sendRequest(
|
||||
headers,
|
||||
data: body || formData,
|
||||
method: options.method,
|
||||
withCredentials: OpenAPI.WITH_CREDENTIALS,
|
||||
cancelToken: source.token,
|
||||
};
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@ async function sendRequest(
|
||||
};
|
||||
|
||||
if (OpenAPI.WITH_CREDENTIALS) {
|
||||
request.credentials = 'include';
|
||||
request.credentials = OpenAPI.CREDENTIALS;
|
||||
}
|
||||
|
||||
onCancel(() => controller.abort());
|
||||
|
||||
@ -180,11 +180,13 @@ import type { ApiRequestOptions } from './ApiRequestOptions';
|
||||
|
||||
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
|
||||
type Headers = Record<string, string>;
|
||||
type CredentialModes = 'include' | 'omit' | 'same-origin';
|
||||
|
||||
type Config = {
|
||||
BASE: string;
|
||||
VERSION: string;
|
||||
WITH_CREDENTIALS: boolean;
|
||||
CREDENTIALS: CredentialModes;
|
||||
TOKEN?: string | Resolver<string>;
|
||||
USERNAME?: string | Resolver<string>;
|
||||
PASSWORD?: string | Resolver<string>;
|
||||
@ -196,6 +198,7 @@ export const OpenAPI: Config = {
|
||||
BASE: 'http://localhost:3000/base',
|
||||
VERSION: '1.0',
|
||||
WITH_CREDENTIALS: false,
|
||||
CREDENTIALS: 'include',
|
||||
TOKEN: undefined,
|
||||
USERNAME: undefined,
|
||||
PASSWORD: undefined,
|
||||
@ -374,7 +377,7 @@ async function sendRequest(
|
||||
};
|
||||
|
||||
if (OpenAPI.WITH_CREDENTIALS) {
|
||||
request.credentials = 'include';
|
||||
request.credentials = OpenAPI.CREDENTIALS;
|
||||
}
|
||||
|
||||
onCancel(() => controller.abort());
|
||||
@ -2691,11 +2694,13 @@ import type { ApiRequestOptions } from './ApiRequestOptions';
|
||||
|
||||
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
|
||||
type Headers = Record<string, string>;
|
||||
type CredentialModes = 'include' | 'omit' | 'same-origin';
|
||||
|
||||
type Config = {
|
||||
BASE: string;
|
||||
VERSION: string;
|
||||
WITH_CREDENTIALS: boolean;
|
||||
CREDENTIALS: CredentialModes;
|
||||
TOKEN?: string | Resolver<string>;
|
||||
USERNAME?: string | Resolver<string>;
|
||||
PASSWORD?: string | Resolver<string>;
|
||||
@ -2707,6 +2712,7 @@ export const OpenAPI: Config = {
|
||||
BASE: 'http://localhost:3000/base',
|
||||
VERSION: '1.0',
|
||||
WITH_CREDENTIALS: false,
|
||||
CREDENTIALS: 'include',
|
||||
TOKEN: undefined,
|
||||
USERNAME: undefined,
|
||||
PASSWORD: undefined,
|
||||
@ -2885,7 +2891,7 @@ async function sendRequest(
|
||||
};
|
||||
|
||||
if (OpenAPI.WITH_CREDENTIALS) {
|
||||
request.credentials = 'include';
|
||||
request.credentials = OpenAPI.CREDENTIALS;
|
||||
}
|
||||
|
||||
onCancel(() => controller.abort());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user