From 66f6e7ed5707ea3741be4e7f11ca97a2bc668a7a Mon Sep 17 00:00:00 2001 From: Lubos Date: Fri, 1 Mar 2024 03:40:10 +0000 Subject: [PATCH] feat(templates): support printing Date instead of string for date-time formats in models --- README.md | 2 + bin/index.js | 2 + rollup.config.mjs | 1 + samples/spec/v3.json | 2 +- src/client/interfaces/Options.d.ts | 1 + src/index.ts | 54 +++++---- src/templates/partials/base.hbs | 4 + src/utils/registerHandlebarHelpers.spec.ts | 1 + src/utils/registerHandlebarHelpers.ts | 116 ++++++++++-------- src/utils/writeClient.spec.ts | 34 +++--- src/utils/writeClient.ts | 131 ++++++++++++--------- src/utils/writeClientModels.spec.ts | 7 +- src/utils/writeClientModels.ts | 13 +- test/__snapshots__/index.spec.ts.snap | 88 ++++++++++++++ test/index.js | 15 +-- test/index.spec.ts | 21 ++++ types/index.d.ts | 17 +-- 17 files changed, 331 insertions(+), 178 deletions(-) diff --git a/README.md b/README.md index 615375052..66fd550ff 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,8 @@ $ openapi --help --postfixServices Service name postfix (default: "Service") --postfixModels Model name postfix --request Path to custom request file + --useDateType Output Date instead of string for the format "date-time" in the models (default: false) + --useOperationId Use operation id to generate operation names (default: true) -h, --help display help for command Examples diff --git a/bin/index.js b/bin/index.js index 1f6d3aa00..3c28d211b 100755 --- a/bin/index.js +++ b/bin/index.js @@ -23,6 +23,7 @@ const params = program .option('--exportSchemas ', 'Write schemas to disk', false) .option('--indent ', 'Indentation options [4, 2, tab]', '4') .option('--postfixServices ', 'Service name postfix', 'Service') + .option('--useDateType ', 'Output Date instead of string for the format "date-time" in the models', false) .option('--useOperationId ', 'Use operation id to generate operation names', true) .option('--postfixModels ', 'Model name postfix') .option('--request ', 'Path to custom request file') @@ -54,6 +55,7 @@ if (OpenAPI) { postfixModels: params.postfixModels, postfixServices: params.postfixServices, request: params.request, + useDateType: JSON.parse(params.useDateType) === true, useOperationId: JSON.parse(params.useOperationId) === true, useOptions: params.useOptions, useUnionTypes: params.useUnionTypes, diff --git a/rollup.config.mjs b/rollup.config.mjs index 240c054a5..5253a0782 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -41,6 +41,7 @@ const handlebarsPlugin = () => ({ intersection: true, notEquals: true, union: true, + useDateType: true, }, }); return `export default ${templateSpec};`; diff --git a/samples/spec/v3.json b/samples/spec/v3.json index 7c39dde22..2cddc31b1 100644 --- a/samples/spec/v3.json +++ b/samples/spec/v3.json @@ -773,7 +773,7 @@ } }, "X-Expires-After": { - "description": "date in UTC when toekn expires", + "description": "date in UTC when token expires", "schema": { "type": "string", "format": "date-time" diff --git a/src/client/interfaces/Options.d.ts b/src/client/interfaces/Options.d.ts index 3d030a8d1..2abd2eb2d 100644 --- a/src/client/interfaces/Options.d.ts +++ b/src/client/interfaces/Options.d.ts @@ -12,6 +12,7 @@ export interface Options { postfixModels?: string; postfixServices?: string; request?: string; + useDateType?: boolean; useOperationId?: boolean; useOptions?: boolean; useUnionTypes?: boolean; diff --git a/src/index.ts b/src/index.ts index f78c8b7ee..9268fb32a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -28,6 +28,7 @@ export { Indent } from './Indent'; * @param exportServices Generate services * @param exportModels Generate models * @param exportSchemas Generate schemas + * @param useDateType Output Date instead of string for the format "date-time" in the models * @param useOperationId should the operationId be used when generating operation names * @param indent Indentation options (4, 2 or tab) * @param postfixServices Service name postfix @@ -37,16 +38,17 @@ export { Indent } from './Indent'; */ export const generate = async (options: Options): Promise => { const { - httpClient = HttpClient.FETCH, - useOptions = false, - useUnionTypes = false, exportCore = true, - exportServices = true, exportModels = true, exportSchemas = false, + exportServices = true, + httpClient = HttpClient.FETCH, indent = Indent.SPACE_4, - postfixServices = 'Service', postfixModels = '', + postfixServices = 'Service', + useDateType = false, + useOptions = false, + useUnionTypes = false, write = true, } = options; const openApi = isString(options.input) ? await getOpenApiSpec(options.input) : options.input; @@ -71,27 +73,27 @@ export const generate = async (options: Options): Promise => { } } - if (parser) { - const client = parser(openApi, options); - const clientFinal = postProcessClient(client); - if (write) { - await writeClient( - clientFinal, - templates, - options.output, - httpClient, - useOptions, - useUnionTypes, - exportCore, - exportServices, - exportModels, - exportSchemas, - indent, - postfixServices, - postfixModels, - options - ); - } + if (!parser) { + return; + } + + const client = parser(openApi, options); + const clientFinal = postProcessClient(client); + if (write) { + await writeClient(clientFinal, templates, { + ...options, + exportCore, + exportModels, + exportSchemas, + exportServices, + httpClient, + indent, + postfixModels, + postfixServices, + useDateType, + useOptions, + useUnionTypes, + }); } }; diff --git a/src/templates/partials/base.hbs b/src/templates/partials/base.hbs index 1799e7d2a..d20427396 100644 --- a/src/templates/partials/base.hbs +++ b/src/templates/partials/base.hbs @@ -5,5 +5,9 @@ {{~#equals @root.httpClient 'angular'}}Blob{{/equals~}} {{~#equals @root.httpClient 'node'}}Blob{{/equals~}} {{~else~}} +{{~#useDateType @root.useDateType format~}} +Date +{{~else~}} {{{base}}} +{{~/useDateType~}} {{~/equals~}} diff --git a/src/utils/registerHandlebarHelpers.spec.ts b/src/utils/registerHandlebarHelpers.spec.ts index bcb439a3d..f870a628b 100644 --- a/src/utils/registerHandlebarHelpers.spec.ts +++ b/src/utils/registerHandlebarHelpers.spec.ts @@ -23,5 +23,6 @@ describe('registerHandlebarHelpers', () => { expect(helpers).toContain('intersection'); expect(helpers).toContain('notEquals'); expect(helpers).toContain('union'); + expect(helpers).toContain('useDateType'); }); }); diff --git a/src/utils/registerHandlebarHelpers.ts b/src/utils/registerHandlebarHelpers.ts index 5c3e288ec..07942150c 100644 --- a/src/utils/registerHandlebarHelpers.ts +++ b/src/utils/registerHandlebarHelpers.ts @@ -28,28 +28,10 @@ export const registerHandlebarHelpers = (root: { useOptions: boolean; useUnionTypes: boolean; }): void => { - Handlebars.registerHelper('ifdef', function (this: any, ...args): string { - const options = args.pop(); - if (!args.every(value => !value)) { - return options.fn(this); - } - return options.inverse(this); + Handlebars.registerHelper('camelCase', function (value: string): string { + return camelCase(value); }); - Handlebars.registerHelper( - 'equals', - function (this: any, a: string, b: string, options: Handlebars.HelperOptions): string { - return a === b ? options.fn(this) : options.inverse(this); - } - ); - - Handlebars.registerHelper( - 'notEquals', - function (this: any, a: string, b: string, options: Handlebars.HelperOptions): string { - return a !== b ? options.fn(this) : options.inverse(this); - } - ); - Handlebars.registerHelper( 'containsSpaces', function (this: any, value: string, options: Handlebars.HelperOptions): string { @@ -57,34 +39,6 @@ export const registerHandlebarHelpers = (root: { } ); - Handlebars.registerHelper( - 'union', - function (this: any, properties: Model[], parent: string | undefined, options: Handlebars.HelperOptions) { - const type = Handlebars.partials['type']; - const types = properties.map(property => type({ ...root, ...property, parent })); - const uniqueTypes = types.filter(unique); - let uniqueTypesString = uniqueTypes.join(' | '); - if (uniqueTypes.length > 1) { - uniqueTypesString = `(${uniqueTypesString})`; - } - return options.fn(uniqueTypesString); - } - ); - - Handlebars.registerHelper( - 'intersection', - function (this: any, properties: Model[], parent: string | undefined, options: Handlebars.HelperOptions) { - const type = Handlebars.partials['type']; - const types = properties.map(property => type({ ...root, ...property, parent })); - const uniqueTypes = types.filter(unique); - let uniqueTypesString = uniqueTypes.join(' & '); - if (uniqueTypes.length > 1) { - uniqueTypesString = `(${uniqueTypesString})`; - } - return options.fn(uniqueTypesString); - } - ); - Handlebars.registerHelper( 'enumerator', function ( @@ -106,6 +60,13 @@ export const registerHandlebarHelpers = (root: { } ); + Handlebars.registerHelper( + 'equals', + function (this: any, a: string, b: string, options: Handlebars.HelperOptions): string { + return a === b ? options.fn(this) : options.inverse(this); + } + ); + Handlebars.registerHelper('escapeComment', function (value: string): string { return value .replace(/\*\//g, '*') @@ -121,11 +82,62 @@ export const registerHandlebarHelpers = (root: { return escapeEnumName(name); }); - Handlebars.registerHelper('camelCase', function (value: string): string { - return camelCase(value); - }); - Handlebars.registerHelper('escapeNewline', function (value: string): string { return value.replace(/\n/g, '\\n'); }); + + Handlebars.registerHelper('ifdef', function (this: any, ...args): string { + const options = args.pop(); + if (!args.every(value => !value)) { + return options.fn(this); + } + return options.inverse(this); + }); + + Handlebars.registerHelper( + 'intersection', + function (this: any, properties: Model[], parent: string | undefined, options: Handlebars.HelperOptions) { + const type = Handlebars.partials['type']; + const types = properties.map(property => type({ ...root, ...property, parent })); + const uniqueTypes = types.filter(unique); + let uniqueTypesString = uniqueTypes.join(' & '); + if (uniqueTypes.length > 1) { + uniqueTypesString = `(${uniqueTypesString})`; + } + return options.fn(uniqueTypesString); + } + ); + + Handlebars.registerHelper( + 'notEquals', + function (this: any, a: string, b: string, options: Handlebars.HelperOptions): string { + return a !== b ? options.fn(this) : options.inverse(this); + } + ); + + Handlebars.registerHelper( + 'union', + function (this: any, properties: Model[], parent: string | undefined, options: Handlebars.HelperOptions) { + const type = Handlebars.partials['type']; + const types = properties.map(property => type({ ...root, ...property, parent })); + const uniqueTypes = types.filter(unique); + let uniqueTypesString = uniqueTypes.join(' | '); + if (uniqueTypes.length > 1) { + uniqueTypesString = `(${uniqueTypesString})`; + } + return options.fn(uniqueTypesString); + } + ); + + Handlebars.registerHelper( + 'useDateType', + function ( + this: any, + useDateType: boolean | undefined, + format: string | undefined, + options: Handlebars.HelperOptions + ) { + return useDateType && format === 'date-time' ? options.fn(this) : options.inverse(this); + } + ); }; diff --git a/src/utils/writeClient.spec.ts b/src/utils/writeClient.spec.ts index 922a21a2e..c9cd85afd 100644 --- a/src/utils/writeClient.spec.ts +++ b/src/utils/writeClient.spec.ts @@ -36,25 +36,21 @@ describe('writeClient', () => { }, }; - await writeClient( - client, - templates, - './dist', - HttpClient.FETCH, - false, - false, - true, - true, - true, - true, - Indent.SPACE_4, - 'Service', - 'AppClient', - { - input: '', - output: '', - } - ); + await writeClient(client, templates, { + exportCore: true, + exportModels: true, + exportSchemas: true, + exportServices: true, + indent: Indent.SPACE_4, + input: '', + output: './dist', + httpClient: HttpClient.FETCH, + postfixModels: 'AppClient', + postfixServices: 'Service', + useDateType: false, + useOptions: false, + useUnionTypes: false, + }); expect(rmdir).toBeCalled(); expect(mkdir).toBeCalled(); diff --git a/src/utils/writeClient.ts b/src/utils/writeClient.ts index e56569437..b3d27c9b7 100644 --- a/src/utils/writeClient.ts +++ b/src/utils/writeClient.ts @@ -4,8 +4,6 @@ import { resolve } from 'path'; import type { Client } from '../client/interfaces/Client'; import type { Options } from '../client/interfaces/Options'; -import type { HttpClient } from '../HttpClient'; -import type { Indent } from '../Indent'; import { mkdir, rmdir } from './fileSystem'; import { isDefined } from './isDefined'; import { isSubDirectory } from './isSubdirectory'; @@ -21,116 +19,137 @@ import { writeClientServices } from './writeClientServices'; * Write our OpenAPI client, using the given templates at the given output * @param client Client object with all the models, services, etc. * @param templates Templates wrapper with all loaded Handlebars templates - * @param output The relative location of the output directory - * @param httpClient The selected httpClient (fetch, xhr, node or axios) - * @param useOptions Use options or arguments functions - * @param useUnionTypes Use union types instead of enums - * @param exportCore Generate core client classes - * @param exportServices Generate services - * @param exportModels Generate models - * @param exportSchemas Generate schemas - * @param indent Indentation options (4, 2 or tab) - * @param postfixServices Service name postfix - * @param postfixModels Model name postfix - * @param clientName Custom client class name - * @param request Path to custom request file + * @param options Options passed to the `generate()` function */ export const writeClient = async ( client: Client, templates: Templates, - output: string, - httpClient: HttpClient, - useOptions: boolean, - useUnionTypes: boolean, - exportCore: boolean, - exportServices: boolean | string, - exportModels: boolean | string, - exportSchemas: boolean, - indent: Indent, - postfixServices: string, - postfixModels: string, - options: Options + options: Pick< + Required, + | 'exportCore' + | 'exportModels' + | 'exportSchemas' + | 'exportServices' + | 'httpClient' + | 'indent' + | 'output' + | 'postfixModels' + | 'postfixServices' + | 'useDateType' + | 'useOptions' + | 'useUnionTypes' + > & + Omit< + Options, + | 'exportCore' + | 'exportModels' + | 'exportSchemas' + | 'exportServices' + | 'httpClient' + | 'indent' + | 'output' + | 'postfixModels' + | 'postfixServices' + | 'useDateType' + | 'useOptions' + | 'useUnionTypes' + > ): Promise => { - const outputPath = resolve(process.cwd(), output); + const outputPath = resolve(process.cwd(), options.output); const outputPathCore = resolve(outputPath, 'core'); const outputPathModels = resolve(outputPath, 'models'); const outputPathSchemas = resolve(outputPath, 'schemas'); const outputPathServices = resolve(outputPath, 'services'); - if (!isSubDirectory(process.cwd(), output)) { + if (!isSubDirectory(process.cwd(), options.output)) { throw new Error(`Output folder is not a subdirectory of the current working directory`); } - if (typeof exportServices === 'string') { - const regexp = new RegExp(exportServices); + if (typeof options.exportServices === 'string') { + const regexp = new RegExp(options.exportServices); client.services = client.services.filter(service => regexp.test(service.name)); } - if (typeof exportModels === 'string') { - const regexp = new RegExp(exportModels); + if (typeof options.exportModels === 'string') { + const regexp = new RegExp(options.exportModels); client.models = client.models.filter(model => regexp.test(model.name)); } - if (exportCore) { + if (options.exportCore) { await rmdir(outputPathCore); await mkdir(outputPathCore); await writeClientCore( client, templates, outputPathCore, - httpClient, - indent, + options.httpClient, + options.indent, options.clientName, options.request ); } - if (exportServices) { + if (options.exportServices) { await rmdir(outputPathServices); await mkdir(outputPathServices); await writeClientServices( client.services, templates, outputPathServices, - httpClient, - useUnionTypes, - useOptions, - indent, - postfixServices, + options.httpClient, + options.useUnionTypes, + options.useOptions, + options.indent, + options.postfixServices, options.clientName ); } - if (exportSchemas) { + if (options.exportSchemas) { await rmdir(outputPathSchemas); await mkdir(outputPathSchemas); - await writeClientSchemas(client.models, templates, outputPathSchemas, httpClient, useUnionTypes, indent); + await writeClientSchemas( + client.models, + templates, + outputPathSchemas, + options.httpClient, + options.useUnionTypes, + options.indent + ); } - if (exportModels) { + if (options.exportModels) { await rmdir(outputPathModels); await mkdir(outputPathModels); - await writeClientModels(client.models, templates, outputPathModels, httpClient, useUnionTypes, indent); + await writeClientModels(client.models, templates, outputPathModels, options); } if (isDefined(options.clientName)) { await mkdir(outputPath); - await writeClientClass(client, templates, outputPath, httpClient, options.clientName, indent, postfixServices); + await writeClientClass( + client, + templates, + outputPath, + options.httpClient, + options.clientName, + options.indent, + options.postfixServices + ); } - if (exportCore || exportServices || exportSchemas || exportModels) { + if (options.exportCore || options.exportServices || options.exportSchemas || options.exportModels) { await mkdir(outputPath); await writeClientIndex( client, templates, outputPath, - useUnionTypes, - exportCore, - exportServices, - exportModels, - exportSchemas, - postfixServices, - postfixModels, + options.useUnionTypes, + options.exportCore, + options.exportServices, + options.exportModels, + options.exportSchemas, + options.postfixServices, + options.postfixModels, options.clientName ); } @@ -141,7 +160,7 @@ export const writeClient = async ( const json = require(pathPackageJson); const usesPrettier = [json.dependencies, json.devDependencies].some(deps => Boolean(deps.prettier)); if (usesPrettier) { - spawnSync('prettier', ['--ignore-unknown', '--write', output]); + spawnSync('prettier', ['--ignore-unknown', '--write', options.output]); } } }; diff --git a/src/utils/writeClientModels.spec.ts b/src/utils/writeClientModels.spec.ts index ee0f2b4f6..4cca63231 100644 --- a/src/utils/writeClientModels.spec.ts +++ b/src/utils/writeClientModels.spec.ts @@ -52,7 +52,12 @@ describe('writeClientModels', () => { }, }; - await writeClientModels(models, templates, '/', HttpClient.FETCH, false, Indent.SPACE_4); + await writeClientModels(models, templates, '/', { + httpClient: HttpClient.FETCH, + indent: Indent.SPACE_4, + useDateType: false, + useUnionTypes: false, + }); expect(writeFile).toBeCalledWith(resolve('/', '/User.ts'), `model${EOL}`); }); diff --git a/src/utils/writeClientModels.ts b/src/utils/writeClientModels.ts index 997569b9f..ebe0e068f 100644 --- a/src/utils/writeClientModels.ts +++ b/src/utils/writeClientModels.ts @@ -1,8 +1,7 @@ import { resolve } from 'path'; import type { Model } from '../client/interfaces/Model'; -import type { HttpClient } from '../HttpClient'; -import type { Indent } from '../Indent'; +import type { Options } from '../client/interfaces/Options'; import { writeFile } from './fileSystem'; import { formatCode as f } from './formatCode'; import { formatIndentation as i } from './formatIndentation'; @@ -13,23 +12,21 @@ import type { Templates } from './registerHandlebarTemplates'; * @param models Array of Models to write * @param templates The loaded handlebar templates * @param outputPath Directory to write the generated files to - * @param httpClient The selected httpClient (fetch, xhr, node or axios) - * @param useUnionTypes Use union types instead of enums - * @param indent Indentation options (4, 2 or tab) + * @param options Options passed to the `generate()` function */ export const writeClientModels = async ( models: Model[], templates: Templates, outputPath: string, - httpClient: HttpClient, - useUnionTypes: boolean, - indent: Indent + options: Pick, 'httpClient' | 'indent' | 'useDateType' | 'useUnionTypes'> ): Promise => { + const { httpClient, indent, useDateType, useUnionTypes } = options; for (const model of models) { const file = resolve(outputPath, `${model.name}.ts`); const templateResult = templates.exports.model({ ...model, httpClient, + useDateType, useUnionTypes, }); await writeFile(file, i(f(templateResult), indent)); diff --git a/test/__snapshots__/index.spec.ts.snap b/test/__snapshots__/index.spec.ts.snap index 52bcf94f6..06abb30ac 100644 --- a/test/__snapshots__/index.spec.ts.snap +++ b/test/__snapshots__/index.spec.ts.snap @@ -3186,6 +3186,94 @@ export class TypesService { " `; +exports[`v3 should generate Date types: test/generated/v3_date/index.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type { ModelWithPattern } from './models/ModelWithPattern'; + +export { $ModelWithPattern } from './schemas/$ModelWithPattern'; +" +`; + +exports[`v3 should generate Date types: test/generated/v3_date/models/ModelWithPattern.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: Date; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +" +`; + +exports[`v3 should generate Date types: test/generated/v3_date/schemas/$ModelWithPattern.ts 1`] = ` +"/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export const $ModelWithPattern = { + description: \`This is a model that contains a some patterns\`, + properties: { + key: { + type: 'string', + isRequired: true, + maxLength: 64, + pattern: '^[a-zA-Z0-9_]*$', + }, + name: { + type: 'string', + isRequired: true, + maxLength: 255, + }, + enabled: { + type: 'boolean', + isReadOnly: true, + }, + modified: { + type: 'string', + isReadOnly: true, + format: 'date-time', + }, + id: { + type: 'string', + pattern: '^\\\\d{2}-\\\\d{3}-\\\\d{4}$', + }, + text: { + type: 'string', + pattern: '^\\\\w+$', + }, + patternWithSingleQuotes: { + type: 'string', + pattern: '^[a-zA-Z0-9\\']*$', + }, + patternWithNewline: { + type: 'string', + pattern: 'aaa\\nbbb', + }, + patternWithBacktick: { + type: 'string', + pattern: 'aaa\`bbb', + }, + }, +} as const; +" +`; + exports[`v3 should generate: test/generated/v3/core/ApiError.ts 1`] = ` "/* generated using openapi-typescript-codegen -- do not edit */ /* istanbul ignore file */ diff --git a/test/index.js b/test/index.js index f60c9b047..4d0ad4ab0 100644 --- a/test/index.js +++ b/test/index.js @@ -5,20 +5,21 @@ const fetch = require('node-fetch'); const generate = async (input, output) => { await OpenAPI.generate({ - input, - output, - httpClient: OpenAPI.HttpClient.FETCH, - useOptions: true, - useUnionTypes: false, autoformat: false, + // clientName: 'Demo', exportCore: true, - exportSchemas: true, exportModels: true, + exportSchemas: true, exportServices: true, - // clientName: 'Demo', + httpClient: OpenAPI.HttpClient.FETCH, // indent: OpenAPI.Indent.SPACE_2, + input, + output, // postfix: 'Service', // request: './test/custom/request.ts', + useDateType: false, + useOptions: true, + useUnionTypes: false, }); }; diff --git a/test/index.spec.ts b/test/index.spec.ts index 118a293ad..3fb06de59 100644 --- a/test/index.spec.ts +++ b/test/index.spec.ts @@ -45,4 +45,25 @@ describe('v3', () => { expect(content).toMatchSnapshot(file); }); }); + + it('should generate Date types', async () => { + await generate({ + autoformat: false, + exportCore: false, + exportModels: '^ModelWithPattern', + exportSchemas: true, + exportServices: false, + httpClient: HttpClient.FETCH, + input: './test/spec/v3.json', + output: './test/generated/v3_date/', + useDateType: true, + useOptions: false, + useUnionTypes: false, + }); + + sync('./test/generated/v3_date/**/*.ts').forEach(file => { + const content = readFileSync(file, 'utf8').toString(); + expect(content).toMatchSnapshot(file); + }); + }); }); diff --git a/types/index.d.ts b/types/index.d.ts index 4b4b2beda..ea40914c6 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -13,21 +13,22 @@ export declare enum Indent { } export type Options = { - input: string | Record; - output: string; - httpClient?: HttpClient | 'fetch' | 'xhr' | 'node' | 'axios' | 'angular'; - clientName?: string; - useOptions?: boolean; - useUnionTypes?: boolean; autoformat?: boolean; + clientName?: string; exportCore?: boolean; - exportServices?: boolean | string; exportModels?: boolean | string; exportSchemas?: boolean; + exportServices?: boolean | string; + httpClient?: HttpClient | 'fetch' | 'xhr' | 'node' | 'axios' | 'angular'; indent?: Indent | '4' | '2' | 'tab'; - postfixServices?: string; + input: string | Record; + output: string; postfixModels?: string; + postfixServices?: string; request?: string; + useDateType?: boolean; + useOptions?: boolean; + useUnionTypes?: boolean; write?: boolean; };