Updated snapshots

This commit is contained in:
Ferdi Koomen 2023-04-11 08:45:27 +02:00
parent 30bc235ac7
commit d24d8f1d7d

View File

@ -242,19 +242,19 @@ import { CancelablePromise } from './CancelablePromise';
import type { OnCancel } from './CancelablePromise';
import type { OpenAPIConfig } from './OpenAPI';
const isDefined = <T>(value: T | null | undefined): value is Exclude<T, null | undefined> => {
export const isDefined = <T>(value: T | null | undefined): value is Exclude<T, null | undefined> => {
return value !== undefined && value !== null;
};
const isString = (value: any): value is string => {
export const isString = (value: any): value is string => {
return typeof value === 'string';
};
const isStringWithValue = (value: any): value is string => {
export const isStringWithValue = (value: any): value is string => {
return isString(value) && value !== '';
};
const isBlob = (value: any): value is Blob => {
export const isBlob = (value: any): value is Blob => {
return (
typeof value === 'object' &&
typeof value.type === 'string' &&
@ -267,11 +267,11 @@ const isBlob = (value: any): value is Blob => {
);
};
const isFormData = (value: any): value is FormData => {
export const isFormData = (value: any): value is FormData => {
return value instanceof FormData;
};
const base64 = (str: string): string => {
export const base64 = (str: string): string => {
try {
return btoa(str);
} catch (err) {
@ -280,7 +280,7 @@ const base64 = (str: string): string => {
}
};
const getQueryString = (params: Record<string, any>): string => {
export const getQueryString = (params: Record<string, any>): string => {
const qs: string[] = [];
const append = (key: string, value: any) => {
@ -333,7 +333,7 @@ const getUrl = (config: OpenAPIConfig, options: ApiRequestOptions): string => {
return url;
};
const getFormData = (options: ApiRequestOptions): FormData | undefined => {
export const getFormData = (options: ApiRequestOptions): FormData | undefined => {
if (options.formData) {
const formData = new FormData();
@ -362,14 +362,14 @@ const getFormData = (options: ApiRequestOptions): FormData | undefined => {
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
const resolve = async <T>(options: ApiRequestOptions, resolver?: T | Resolver<T>): Promise<T | undefined> => {
export const resolve = async <T>(options: ApiRequestOptions, resolver?: T | Resolver<T>): Promise<T | undefined> => {
if (typeof resolver === 'function') {
return (resolver as Resolver<T>)(options);
}
return resolver;
};
const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions): Promise<Headers> => {
export const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions): Promise<Headers> => {
const token = await resolve(options, config.TOKEN);
const username = await resolve(options, config.USERNAME);
const password = await resolve(options, config.PASSWORD);
@ -410,7 +410,7 @@ const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions): Pr
return new Headers(headers);
};
const getRequestBody = (options: ApiRequestOptions): any => {
export const getRequestBody = (options: ApiRequestOptions): any => {
if (options.body !== undefined) {
if (options.mediaType?.includes('/json')) {
return JSON.stringify(options.body)
@ -450,7 +450,7 @@ export const sendRequest = async (
return await fetch(url, request);
};
const getResponseHeader = (response: Response, responseHeader?: string): string | undefined => {
export const getResponseHeader = (response: Response, responseHeader?: string): string | undefined => {
if (responseHeader) {
const content = response.headers.get(responseHeader);
if (isString(content)) {
@ -460,7 +460,7 @@ const getResponseHeader = (response: Response, responseHeader?: string): string
return undefined;
};
const getResponseBody = async (response: Response): Promise<any> => {
export const getResponseBody = async (response: Response): Promise<any> => {
if (response.status !== 204) {
try {
const contentType = response.headers.get('Content-Type');
@ -480,7 +480,7 @@ const getResponseBody = async (response: Response): Promise<any> => {
return undefined;
};
const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): void => {
export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): void => {
const errors: Record<number, string> = {
400: 'Bad Request',
401: 'Unauthorized',
@ -3337,19 +3337,19 @@ import { CancelablePromise } from './CancelablePromise';
import type { OnCancel } from './CancelablePromise';
import type { OpenAPIConfig } from './OpenAPI';
const isDefined = <T>(value: T | null | undefined): value is Exclude<T, null | undefined> => {
export const isDefined = <T>(value: T | null | undefined): value is Exclude<T, null | undefined> => {
return value !== undefined && value !== null;
};
const isString = (value: any): value is string => {
export const isString = (value: any): value is string => {
return typeof value === 'string';
};
const isStringWithValue = (value: any): value is string => {
export const isStringWithValue = (value: any): value is string => {
return isString(value) && value !== '';
};
const isBlob = (value: any): value is Blob => {
export const isBlob = (value: any): value is Blob => {
return (
typeof value === 'object' &&
typeof value.type === 'string' &&
@ -3362,11 +3362,11 @@ const isBlob = (value: any): value is Blob => {
);
};
const isFormData = (value: any): value is FormData => {
export const isFormData = (value: any): value is FormData => {
return value instanceof FormData;
};
const base64 = (str: string): string => {
export const base64 = (str: string): string => {
try {
return btoa(str);
} catch (err) {
@ -3375,7 +3375,7 @@ const base64 = (str: string): string => {
}
};
const getQueryString = (params: Record<string, any>): string => {
export const getQueryString = (params: Record<string, any>): string => {
const qs: string[] = [];
const append = (key: string, value: any) => {
@ -3428,7 +3428,7 @@ const getUrl = (config: OpenAPIConfig, options: ApiRequestOptions): string => {
return url;
};
const getFormData = (options: ApiRequestOptions): FormData | undefined => {
export const getFormData = (options: ApiRequestOptions): FormData | undefined => {
if (options.formData) {
const formData = new FormData();
@ -3457,14 +3457,14 @@ const getFormData = (options: ApiRequestOptions): FormData | undefined => {
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
const resolve = async <T>(options: ApiRequestOptions, resolver?: T | Resolver<T>): Promise<T | undefined> => {
export const resolve = async <T>(options: ApiRequestOptions, resolver?: T | Resolver<T>): Promise<T | undefined> => {
if (typeof resolver === 'function') {
return (resolver as Resolver<T>)(options);
}
return resolver;
};
const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions): Promise<Headers> => {
export const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions): Promise<Headers> => {
const token = await resolve(options, config.TOKEN);
const username = await resolve(options, config.USERNAME);
const password = await resolve(options, config.PASSWORD);
@ -3505,7 +3505,7 @@ const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions): Pr
return new Headers(headers);
};
const getRequestBody = (options: ApiRequestOptions): any => {
export const getRequestBody = (options: ApiRequestOptions): any => {
if (options.body !== undefined) {
if (options.mediaType?.includes('/json')) {
return JSON.stringify(options.body)
@ -3545,7 +3545,7 @@ export const sendRequest = async (
return await fetch(url, request);
};
const getResponseHeader = (response: Response, responseHeader?: string): string | undefined => {
export const getResponseHeader = (response: Response, responseHeader?: string): string | undefined => {
if (responseHeader) {
const content = response.headers.get(responseHeader);
if (isString(content)) {
@ -3555,7 +3555,7 @@ const getResponseHeader = (response: Response, responseHeader?: string): string
return undefined;
};
const getResponseBody = async (response: Response): Promise<any> => {
export const getResponseBody = async (response: Response): Promise<any> => {
if (response.status !== 204) {
try {
const contentType = response.headers.get('Content-Type');
@ -3575,7 +3575,7 @@ const getResponseBody = async (response: Response): Promise<any> => {
return undefined;
};
const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): void => {
export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): void => {
const errors: Record<number, string> = {
400: 'Bad Request',
401: 'Unauthorized',
@ -3711,6 +3711,7 @@ export type { Pageable } from './models/Pageable';
export type { SimpleBoolean } from './models/SimpleBoolean';
export type { SimpleFile } from './models/SimpleFile';
export type { SimpleInteger } from './models/SimpleInteger';
export type { SimpleParameter } from './models/SimpleParameter';
export type { SimpleReference } from './models/SimpleReference';
export type { SimpleString } from './models/SimpleString';
export type { SimpleStringWithPattern } from './models/SimpleStringWithPattern';
@ -3780,6 +3781,7 @@ export { $Pageable } from './schemas/$Pageable';
export { $SimpleBoolean } from './schemas/$SimpleBoolean';
export { $SimpleFile } from './schemas/$SimpleFile';
export { $SimpleInteger } from './schemas/$SimpleInteger';
export { $SimpleParameter } from './schemas/$SimpleParameter';
export { $SimpleReference } from './schemas/$SimpleReference';
export { $SimpleString } from './schemas/$SimpleString';
export { $SimpleStringWithPattern } from './schemas/$SimpleStringWithPattern';
@ -4907,6 +4909,19 @@ export type SimpleInteger = number;
"
`;
exports[`v3 should generate: test/generated/v3/models/SimpleParameter.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
/**
* This is a reusable parameter
*/
export type SimpleParameter = string;
"
`;
exports[`v3 should generate: test/generated/v3/models/SimpleReference.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
@ -6234,6 +6249,17 @@ export const $SimpleInteger = {
"
`;
exports[`v3 should generate: test/generated/v3/schemas/$SimpleParameter.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $SimpleParameter = {
type: 'string',
description: \`This is a reusable parameter\`,
} as const;
"
`;
exports[`v3 should generate: test/generated/v3/schemas/$SimpleReference.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */