diff --git a/bin/index.js b/bin/index.js index 77a913ee..1620ebd7 100755 --- a/bin/index.js +++ b/bin/index.js @@ -10,8 +10,8 @@ program .version(pkg.version) .option('--input [value]', 'Path to swagger specification', './spec.json') .option('--output [value]', 'Output directory', './generated') - .option('--language', 'Language to generate [typescript, javascript]', 'typescript') - .option('--http-client', 'HTTP client to generate [fetch, xhr]', 'fetch') + .option('--language [value]', 'Language to generate [typescript, javascript]', 'typescript') + .option('--http-client [value]', 'HTTP client to generate [fetch, xhr]', 'fetch') .parse(process.argv); const SwaggerCodegen = require(path.resolve(__dirname, '../dist/index.js')); diff --git a/package.json b/package.json index 73a2965f..074e6ed8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openapi-typescript-codegen", - "version": "0.0.3", + "version": "0.0.5", "description": "NodeJS library that generates Typescript or Javascript clients based on the OpenAPI specification.", "author": "Ferdi Koomen", "homepage": "https://github.com/ferdikoomen/openapi-typescript-codegen", @@ -70,7 +70,6 @@ "@types/mkdirp": "0.5.2", "@types/node": "12.12.14", "@types/rimraf": "2.0.3", - "@types/yup": "0.26.26", "@typescript-eslint/eslint-plugin": "2.10.0", "@typescript-eslint/parser": "2.10.0", "camelcase": "5.3.1", @@ -89,7 +88,6 @@ "path": "0.12.7", "prettier": "1.19.1", "rimraf": "3.0.0", - "typescript": "3.7.2", - "yup": "0.27.0" + "typescript": "3.7.2" } } diff --git a/src/templates/javascript/index.hbs b/src/templates/javascript/index.hbs index 76dc57b4..8fff728b 100644 --- a/src/templates/javascript/index.hbs +++ b/src/templates/javascript/index.hbs @@ -8,7 +8,7 @@ export { OpenAPI } from './core/OpenAPI'; {{#if models}} {{#each models}} -{{#notEquals this 'Dictionary'}}export { {{{this}}} } from './models/{{{this}}}';{{/notEquals}} +export { {{{this}}} } from './models/{{{this}}}'; {{/each}} {{/if}} {{#if services}} diff --git a/src/templates/javascript/model.hbs b/src/templates/javascript/model.hbs index 9d4cfe3d..a21f6461 100644 --- a/src/templates/javascript/model.hbs +++ b/src/templates/javascript/model.hbs @@ -4,15 +4,12 @@ {{#if imports}} {{#each imports}} -{{#notEquals this 'Dictionary'}}import { {{{this}}} } from '../models/{{{this}}}';{{/notEquals}} +import { {{{this}}} } from '../models/{{{this}}}'; {{/each}} {{/if}} -import * as yup from 'yup'; {{#equals export 'interface'}} -{{>exportInterface}} +{{>exportEnums}} {{else equals export 'enum'}} {{>exportEnum}} -{{else}} -{{>exportGeneric}} {{/equals}} diff --git a/src/templates/javascript/partials/defaultValue.hbs b/src/templates/javascript/partials/defaultValue.hbs deleted file mode 100644 index 202b75b2..00000000 --- a/src/templates/javascript/partials/defaultValue.hbs +++ /dev/null @@ -1 +0,0 @@ -{{#if default}} = {{{default}}}{{/if}} diff --git a/src/templates/javascript/partials/exportEnum.hbs b/src/templates/javascript/partials/exportEnum.hbs index 39c67a7b..682a3317 100644 --- a/src/templates/javascript/partials/exportEnum.hbs +++ b/src/templates/javascript/partials/exportEnum.hbs @@ -10,14 +10,4 @@ export let {{{name}}}; {{{../name}}}.{{{name}}} = {{{value}}}; {{/each}} - {{{name}}}.schema = {{>validation}}; - - {{{name}}}.validate = async function(value) { - return {{{name}}}.schema.validate(value, { strict: true }); - }; - - {{{name}}}.validateSync = function(value) { - return {{{name}}}.schema.validateSync(value, { strict: true }); - }; - })({{{name}}} || ({{{name}}} = {})); diff --git a/src/templates/javascript/partials/exportInterface.hbs b/src/templates/javascript/partials/exportEnums.hbs similarity index 55% rename from src/templates/javascript/partials/exportInterface.hbs rename to src/templates/javascript/partials/exportEnums.hbs index 5403ff29..30d7dac7 100644 --- a/src/templates/javascript/partials/exportInterface.hbs +++ b/src/templates/javascript/partials/exportEnums.hbs @@ -19,14 +19,4 @@ export let {{{name}}}; }; {{/each}} - {{{name}}}.schema = {{>validation parent=name}}; - - {{{name}}}.validate = async function(value) { - return {{{name}}}.schema.validate(value, { strict: true }); - }; - - {{{name}}}.validateSync = function(value) { - return {{{name}}}.schema.validateSync(value, { strict: true }); - }; - })({{{name}}} || ({{{name}}} = {})); diff --git a/src/templates/javascript/partials/exportGeneric.hbs b/src/templates/javascript/partials/exportGeneric.hbs deleted file mode 100644 index f2159556..00000000 --- a/src/templates/javascript/partials/exportGeneric.hbs +++ /dev/null @@ -1,19 +0,0 @@ -{{#if description}} -/** - * {{{description}}} - */ -{{/if}} -export let {{{name}}}; -(function ({{{name}}}) { - - {{{name}}}.schema = {{>validation}}; - - {{{name}}}.validate = async function(value) { - return {{{name}}}.schema.validate(value, { strict: true }); - }; - - {{{name}}}.validateSync = function(value) { - return {{{name}}}.schema.validateSync(value, { strict: true }); - }; - -})({{{name}}} || ({{{name}}} = {})); diff --git a/src/templates/javascript/partials/validation.hbs b/src/templates/javascript/partials/validation.hbs deleted file mode 100644 index 99ffa165..00000000 --- a/src/templates/javascript/partials/validation.hbs +++ /dev/null @@ -1,13 +0,0 @@ -{{#equals export 'interface'}} -{{>validationInterface}} -{{else equals export 'reference'}} -{{>validationReference}} -{{else equals export 'enum'}} -{{>validationEnum}} -{{else equals export 'array'}} -{{>validationArray}} -{{else equals export 'dictionary'}} -{{>validationDictionary}} -{{else}} -{{>validationGeneric}} -{{/equals}} diff --git a/src/templates/javascript/partials/validationArray.hbs b/src/templates/javascript/partials/validationArray.hbs deleted file mode 100644 index 9fe4fecf..00000000 --- a/src/templates/javascript/partials/validationArray.hbs +++ /dev/null @@ -1,5 +0,0 @@ -{{~#if link~}} -yup.array().of({{>validation link}}){{>validationBasics}} -{{~else~}} -yup.array().of({{{base}}}.schema){{>validationBasics}} -{{~/if~}} diff --git a/src/templates/javascript/partials/validationBasics.hbs b/src/templates/javascript/partials/validationBasics.hbs deleted file mode 100644 index 7bd5d6f6..00000000 --- a/src/templates/javascript/partials/validationBasics.hbs +++ /dev/null @@ -1 +0,0 @@ -{{#if isNullable}}.nullable(){{/if}}{{#if isRequired}}.required(){{/if}} diff --git a/src/templates/javascript/partials/validationDictionary.hbs b/src/templates/javascript/partials/validationDictionary.hbs deleted file mode 100644 index a96a5516..00000000 --- a/src/templates/javascript/partials/validationDictionary.hbs +++ /dev/null @@ -1,19 +0,0 @@ -{{~#if link~}} -yup.lazy(value => { - return yup.object().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: {{>validation link}} - }), {}) - ).noUnknown(); -}) -{{~else~}} -yup.lazy(value => { - return yup.object().shape( - Object.keys(value).reduce((key, item) => ({ - ...object, - [key]: {{{base}}}.schema - }), {}) - ).noUnknown(); -}) -{{~/if~}} diff --git a/src/templates/javascript/partials/validationEnum.hbs b/src/templates/javascript/partials/validationEnum.hbs deleted file mode 100644 index e0b712db..00000000 --- a/src/templates/javascript/partials/validationEnum.hbs +++ /dev/null @@ -1,13 +0,0 @@ -{{~#equals parent name~}} -yup.mixed().oneOf([ - {{#each enum}} - {{{../parent}}}.{{{name}}}{{>comma}} - {{/each}} -]){{>validationBasics}} -{{~else~}} -yup.mixed().oneOf([ - {{#each enum}} - {{{value}}}{{>comma}} - {{/each}} -]){{>validationBasics}} -{{~/equals~}} diff --git a/src/templates/javascript/partials/validationGeneric.hbs b/src/templates/javascript/partials/validationGeneric.hbs deleted file mode 100644 index 8d8ce9a5..00000000 --- a/src/templates/javascript/partials/validationGeneric.hbs +++ /dev/null @@ -1,9 +0,0 @@ -{{~#equals type 'boolean'~}} -yup.boolean(){{>validationBasics}} -{{~else equals type 'number'~}} -yup.number(){{>validationBasics}} -{{~else equals type 'string'~}} -yup.string(){{>validationBasics}} -{{~else~}} -yup.mixed(){{>validationBasics}} -{{~/equals~}} diff --git a/src/templates/javascript/partials/validationInterface.hbs b/src/templates/javascript/partials/validationInterface.hbs deleted file mode 100644 index 1eb58318..00000000 --- a/src/templates/javascript/partials/validationInterface.hbs +++ /dev/null @@ -1,25 +0,0 @@ -( -{{#if extends}} -{{#each extends}} -{{{this}}}.schema.concat( -{{/each}} -{{/if}} -{{#if properties}} -yup.object().shape({ - {{#each properties}} - {{#equals ../parent name}} - {{{name}}}: {{>validation parent=name}}{{>comma}} - {{else}} - {{{name}}}: {{>validation}}{{>comma}} - {{/equals}} - {{/each}} -}).noUnknown() -{{else}} -yup.object() -{{/if}} -{{#if extends}} -{{#each extends}} -) -{{/each}} -{{/if}} -){{>validationBasics}} diff --git a/src/templates/javascript/partials/validationReference.hbs b/src/templates/javascript/partials/validationReference.hbs deleted file mode 100644 index 9ad7d945..00000000 --- a/src/templates/javascript/partials/validationReference.hbs +++ /dev/null @@ -1 +0,0 @@ -{{{base}}}.schema{{>validationBasics}} diff --git a/src/templates/javascript/service.hbs b/src/templates/javascript/service.hbs index c4c5cf05..f65aea99 100644 --- a/src/templates/javascript/service.hbs +++ b/src/templates/javascript/service.hbs @@ -3,7 +3,7 @@ /* prettier-ignore */ import { ApiError, catchGenericError } from '../core/ApiError'; -import { request } from '../core/request'; +import { request as $request } from '../core/request'; import { OpenAPI } from '../core/OpenAPI'; export class {{{name}}} { @@ -31,11 +31,11 @@ export class {{{name}}} { */ static async {{{name}}}({{#if parameters}} {{#each parameters}} - {{{name}}}{{>defaultValue}}{{>comma}} + {{{name}}}{{#if default}} = {{{default}}}{{/if}}{{>comma}} {{/each}} {{/if}}) { - const result = await request({ + const result = await $request({ method: '{{{method}}}', path: `{{{path}}}`{{#if parametersCookie}}, cookies: { diff --git a/src/templates/typescript/model.hbs b/src/templates/typescript/model.hbs index 253d6b52..159d5bfc 100644 --- a/src/templates/typescript/model.hbs +++ b/src/templates/typescript/model.hbs @@ -2,13 +2,12 @@ /* tslint:disable */ /* eslint-disable */ /* prettier-ignore */ - {{#if imports}} + {{#each imports}} import { {{{this}}} } from '../models/{{{this}}}'; {{/each}} {{/if}} -import * as yup from 'yup'; {{#equals export 'interface'}} {{>exportInterface}} diff --git a/src/templates/typescript/partials/defaultValue.hbs b/src/templates/typescript/partials/defaultValue.hbs deleted file mode 100644 index 202b75b2..00000000 --- a/src/templates/typescript/partials/defaultValue.hbs +++ /dev/null @@ -1 +0,0 @@ -{{#if default}} = {{{default}}}{{/if}} diff --git a/src/templates/typescript/partials/exportEnum.hbs b/src/templates/typescript/partials/exportEnum.hbs index 8b8b7079..3e0bad1a 100644 --- a/src/templates/typescript/partials/exportEnum.hbs +++ b/src/templates/typescript/partials/exportEnum.hbs @@ -8,16 +8,3 @@ export enum {{{name}}} { {{{name}}} = {{{value}}}{{>comma}} {{/each}} } - -export namespace {{{name}}} { - - export const schema = {{>validation parent=name}}; - - export async function validate(value: any): Promise<{{{name}}}> { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): {{{name}}} { - return schema.validateSync(value, { strict: true }); - } -} diff --git a/src/templates/typescript/partials/exportGeneric.hbs b/src/templates/typescript/partials/exportGeneric.hbs index 22df6b95..d4d5b83b 100644 --- a/src/templates/typescript/partials/exportGeneric.hbs +++ b/src/templates/typescript/partials/exportGeneric.hbs @@ -4,16 +4,3 @@ */ {{/if}} export type {{{name}}} = {{>type}}; - -export namespace {{{name}}} { - - export const schema = {{>validation}}; - - export async function validate(value: any): Promise<{{{name}}}{{>isNullable}}> { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): {{{name}}}{{>isNullable}} { - return schema.validateSync(value, { strict: true }); - } -} diff --git a/src/templates/typescript/partials/exportInterface.hbs b/src/templates/typescript/partials/exportInterface.hbs index d8e32f2a..d06a65e7 100644 --- a/src/templates/typescript/partials/exportInterface.hbs +++ b/src/templates/typescript/partials/exportInterface.hbs @@ -29,13 +29,4 @@ export namespace {{{name}}} { } {{/each}} - export const schema: yup.ObjectSchema<{{{name}}}> = {{>validation parent=name}}; - - export async function validate(value: any): Promise<{{{name}}}> { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): {{{name}}} { - return schema.validateSync(value, { strict: true }); - } } diff --git a/src/templates/typescript/partials/validation.hbs b/src/templates/typescript/partials/validation.hbs deleted file mode 100644 index 99ffa165..00000000 --- a/src/templates/typescript/partials/validation.hbs +++ /dev/null @@ -1,13 +0,0 @@ -{{#equals export 'interface'}} -{{>validationInterface}} -{{else equals export 'reference'}} -{{>validationReference}} -{{else equals export 'enum'}} -{{>validationEnum}} -{{else equals export 'array'}} -{{>validationArray}} -{{else equals export 'dictionary'}} -{{>validationDictionary}} -{{else}} -{{>validationGeneric}} -{{/equals}} diff --git a/src/templates/typescript/partials/validationArray.hbs b/src/templates/typescript/partials/validationArray.hbs deleted file mode 100644 index 45b32d06..00000000 --- a/src/templates/typescript/partials/validationArray.hbs +++ /dev/null @@ -1,6 +0,0 @@ -{{~#if link~}} -yup.array<{{>type link}}>().of({{>validation link}}) -{{~else~}} -yup.array<{{{type}}}{{>isNullable}}>().of({{{base}}}.schema) -{{~/if~}} -{{>validationBasics}} diff --git a/src/templates/typescript/partials/validationBasics.hbs b/src/templates/typescript/partials/validationBasics.hbs deleted file mode 100644 index 7bd5d6f6..00000000 --- a/src/templates/typescript/partials/validationBasics.hbs +++ /dev/null @@ -1 +0,0 @@ -{{#if isNullable}}.nullable(){{/if}}{{#if isRequired}}.required(){{/if}} diff --git a/src/templates/typescript/partials/validationDictionary.hbs b/src/templates/typescript/partials/validationDictionary.hbs deleted file mode 100644 index 48df90de..00000000 --- a/src/templates/typescript/partials/validationDictionary.hbs +++ /dev/null @@ -1,19 +0,0 @@ -{{~#if link~}} -yup.lazytype link}}>>(value => { - return yup.objecttype link}}>>().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: {{>validation link}} - }), {}) - ).noUnknown(); -}) -{{~else~}} -yup.lazyisNullable}}>>(value => { - return yup.objectisNullable}}>>().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: {{{base}}}.schema - }), {}) - ).noUnknown(); -}) -{{~/if~}} diff --git a/src/templates/typescript/partials/validationEnum.hbs b/src/templates/typescript/partials/validationEnum.hbs deleted file mode 100644 index 59c9ecd4..00000000 --- a/src/templates/typescript/partials/validationEnum.hbs +++ /dev/null @@ -1,14 +0,0 @@ -{{~#equals parent name~}} -yup.mixed<{{{name}}}>().oneOf([ - {{#each enum}} - {{{../parent}}}.{{{name}}}{{>comma}} - {{/each}} -]){{>validationBasics}} -{{~else~}} -yup.mixed<{{{type}}}{{>isNullable}}>().oneOf([ - {{#each enum}} - {{{value}}}{{>comma}} - {{/each}} -]){{>validationBasics}} -{{~/equals~}} - diff --git a/src/templates/typescript/partials/validationGeneric.hbs b/src/templates/typescript/partials/validationGeneric.hbs deleted file mode 100644 index 860b8288..00000000 --- a/src/templates/typescript/partials/validationGeneric.hbs +++ /dev/null @@ -1,9 +0,0 @@ -{{~#equals type 'boolean'~}} -yup.boolean(){{>validationBasics}} -{{~else equals type 'number'~}} -yup.number(){{>validationBasics}} -{{~else equals type 'string'~}} -yup.string(){{>validationBasics}} -{{~else~}} -yup.mixed<{{{type}}}{{>isNullable}}>(){{>validationBasics}} -{{~/equals~}} diff --git a/src/templates/typescript/partials/validationInterface.hbs b/src/templates/typescript/partials/validationInterface.hbs deleted file mode 100644 index 2eb769af..00000000 --- a/src/templates/typescript/partials/validationInterface.hbs +++ /dev/null @@ -1,25 +0,0 @@ -( -{{#if extends}} -{{#each extends}} -{{{this}}}.schema.concat( -{{/each}} -{{/if}} -{{#if properties}} -yup.object().shape({ - {{#each properties}} - {{#equals ../parent name}} - {{{name}}}: {{>validation parent=name}}{{>comma}} - {{else}} - {{{name}}}: {{>validation}}{{>comma}} - {{/equals}} - {{/each}} -}).noUnknown() -{{else}} -yup.object() -{{/if}} -{{#if extends}} -{{#each extends}} -) -{{/each}} -{{/if}} -){{>validationBasics}} diff --git a/src/templates/typescript/partials/validationReference.hbs b/src/templates/typescript/partials/validationReference.hbs deleted file mode 100644 index 9ad7d945..00000000 --- a/src/templates/typescript/partials/validationReference.hbs +++ /dev/null @@ -1 +0,0 @@ -{{{base}}}.schema{{>validationBasics}} diff --git a/src/templates/typescript/service.hbs b/src/templates/typescript/service.hbs index f51be531..a06d238f 100644 --- a/src/templates/typescript/service.hbs +++ b/src/templates/typescript/service.hbs @@ -9,7 +9,7 @@ import { {{{this}}} } from '../models/{{{this}}}'; {{/each}} {{/if}} import { ApiError, catchGenericError } from '../core/ApiError'; -import { request } from '../core/request'; +import { request as $request } from '../core/request'; import { OpenAPI } from '../core/OpenAPI'; export class {{{name}}} { @@ -37,11 +37,11 @@ export class {{{name}}} { */ public static async {{{name}}}({{#if parameters}} {{#each parameters}} - {{{name}}}{{>isRequired}}: {{>type}}{{>defaultValue}}{{>comma}} + {{{name}}}{{>isRequired}}: {{>type}}{{#if default}} = {{{default}}}{{/if}}{{>comma}} {{/each}} {{/if}}): Promise<{{>result}}> { - const result = await request({ + const result = await $request({ method: '{{{method}}}', path: `{{{path}}}`{{#if parametersCookie}}, cookies: { diff --git a/src/utils/getImports.ts b/src/utils/getImports.ts new file mode 100644 index 00000000..1c921f64 --- /dev/null +++ b/src/utils/getImports.ts @@ -0,0 +1,13 @@ +import * as glob from 'glob'; +import * as path from 'path'; + +export function getImports(folder: string): string[] { + const files = glob.sync('**/*.{ts,js}', { cwd: folder }); + return files + .map(file => path.basename(file)) + .sort((a, b) => { + const nameA = a.toLowerCase(); + const nameB = b.toLowerCase(); + return nameA.localeCompare(nameB, 'en'); + }); +} diff --git a/src/utils/getModelNames.spec.ts b/src/utils/getModelNames.spec.ts deleted file mode 100644 index 38ea1b8a..00000000 --- a/src/utils/getModelNames.spec.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { Model } from '../client/interfaces/Model'; -import { getModelNames } from './getModelNames'; - -describe('getModelNames', () => { - it('should return sorted list', () => { - const models = new Map(); - models.set('John', { - export: 'interface', - name: 'John', - type: 'John', - base: 'John', - template: null, - link: null, - description: null, - isProperty: false, - isReadOnly: false, - isRequired: false, - isNullable: false, - imports: [], - extends: [], - enum: [], - enums: [], - properties: [], - }); - models.set('Jane', { - export: 'interface', - name: 'Jane', - type: 'Jane', - base: 'Jane', - template: null, - link: null, - description: null, - isProperty: false, - isReadOnly: false, - isRequired: false, - isNullable: false, - imports: [], - extends: [], - enum: [], - enums: [], - properties: [], - }); - models.set('Doe', { - export: 'interface', - name: 'Doe', - type: 'Doe', - base: 'Doe', - template: null, - link: null, - description: null, - isProperty: false, - isReadOnly: false, - isRequired: false, - isNullable: false, - imports: [], - extends: [], - enum: [], - enums: [], - properties: [], - }); - - expect(getModelNames(new Map())).toEqual(['Dictionary']); - expect(getModelNames(models)).toEqual(['Dictionary', 'Doe', 'Jane', 'John']); - }); -}); diff --git a/src/utils/getModelNames.ts b/src/utils/getModelNames.ts deleted file mode 100644 index 9d04f6c8..00000000 --- a/src/utils/getModelNames.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Model } from '../client/interfaces/Model'; - -export function getModelNames(models: Map): string[] { - return Array.from(models.values()) - .map(model => model.name) - .concat(['Dictionary']) - .sort((a, b) => { - const nameA = a.toLowerCase(); - const nameB = b.toLowerCase(); - return nameA.localeCompare(nameB, 'en'); - }); -} diff --git a/src/utils/getServiceNames.spec.ts b/src/utils/getServiceNames.spec.ts deleted file mode 100644 index c41a5150..00000000 --- a/src/utils/getServiceNames.spec.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Service } from '../client/interfaces/Service'; -import { getServiceNames } from './getServiceNames'; - -describe('getServiceNames', () => { - it('should return sorted list', () => { - const services = new Map(); - services.set('John', { - name: 'John', - operations: [], - imports: [], - }); - services.set('Jane', { - name: 'Jane', - operations: [], - imports: [], - }); - services.set('Doe', { - name: 'Doe', - operations: [], - imports: [], - }); - - expect(getServiceNames(new Map())).toEqual([]); - expect(getServiceNames(services)).toEqual(['Doe', 'Jane', 'John']); - }); -}); diff --git a/src/utils/getServiceNames.ts b/src/utils/getServiceNames.ts deleted file mode 100644 index 17251252..00000000 --- a/src/utils/getServiceNames.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Service } from '../client/interfaces/Service'; - -export function getServiceNames(services: Map): string[] { - return Array.from(services.values()) - .map(service => service.name) - .sort((a, b) => { - const nameA = a.toLowerCase(); - const nameB = b.toLowerCase(); - return nameA.localeCompare(nameB, 'en'); - }); -} diff --git a/src/utils/shouldExportModel.ts b/src/utils/shouldExportModel.ts new file mode 100644 index 00000000..933978b0 --- /dev/null +++ b/src/utils/shouldExportModel.ts @@ -0,0 +1,12 @@ +import { Language } from '../index'; +import { Model } from '../client/interfaces/Model'; + +export function shouldExportModel(model: Model, language: Language): boolean { + if (language === Language.JAVASCRIPT) { + const hasEnum = model.enum.length > 0; + const hasEnums = model.enums.length > 0; + return hasEnum || hasEnums; + } + + return true; +} diff --git a/src/utils/writeClient.ts b/src/utils/writeClient.ts index 351f8ac5..abfa6914 100644 --- a/src/utils/writeClient.ts +++ b/src/utils/writeClient.ts @@ -53,10 +53,10 @@ export function writeClient(client: Client, language: Language, httpClient: Http // Write the client files try { - writeClientIndex(client, language, templates, outputPath); + writeClientSettings(client, language, httpClient, templates, outputPathCore); writeClientModels(client.models, language, templates, outputPathModels); writeClientServices(client.services, language, templates, outputPathServices); - writeClientSettings(client, language, httpClient, templates, outputPathCore); + writeClientIndex(client, language, templates, outputPathModels, outputPathServices, outputPath); } catch (e) { throw e; } diff --git a/src/utils/writeClientIndex.spec.ts b/src/utils/writeClientIndex.spec.ts index cb72a728..7bb4d59d 100644 --- a/src/utils/writeClientIndex.spec.ts +++ b/src/utils/writeClientIndex.spec.ts @@ -1,4 +1,5 @@ import * as fs from 'fs'; +import * as glob from 'glob'; import { Client } from '../client/interfaces/Client'; import { Language } from '../index'; import { Model } from '../client/interfaces/Model'; @@ -7,8 +8,10 @@ import { Templates } from './readHandlebarsTemplates'; import { writeClientIndex } from './writeClientIndex'; jest.mock('fs'); +jest.mock('glob'); const fsWriteFileSync = fs.writeFileSync as jest.MockedFunction; +const globSync = glob.sync as jest.MockedFunction; describe('writeClientIndex', () => { it('should write to filesystem', () => { @@ -18,13 +21,18 @@ describe('writeClientIndex', () => { models: new Map(), services: new Map(), }; + const templates: Templates = { index: () => 'dummy', model: () => 'dummy', service: () => 'dummy', settings: () => 'dummy', }; - writeClientIndex(client, Language.TYPESCRIPT, templates, '/'); + + globSync.mockReturnValue([]); + + writeClientIndex(client, Language.TYPESCRIPT, templates, '/', '/', '/'); + expect(fsWriteFileSync).toBeCalledWith('/index.ts', 'dummy'); }); }); diff --git a/src/utils/writeClientIndex.ts b/src/utils/writeClientIndex.ts index 32cd6ac7..324a48a4 100644 --- a/src/utils/writeClientIndex.ts +++ b/src/utils/writeClientIndex.ts @@ -4,8 +4,7 @@ import { Client } from '../client/interfaces/Client'; import { Language } from '../index'; import { Templates } from './readHandlebarsTemplates'; import { getFileName } from './getFileName'; -import { getModelNames } from './getModelNames'; -import { getServiceNames } from './getServiceNames'; +import { getImports } from './getImports'; /** * Generate the OpenAPI client index file using the Handlebar template and write it to disk. @@ -14,22 +13,23 @@ import { getServiceNames } from './getServiceNames'; * @param client Client object, containing, models, schemas and services. * @param language The output language (Typescript or javascript). * @param templates The loaded handlebar templates. + * @param outputPathModels + * @param outputPathServices * @param outputPath */ -export function writeClientIndex(client: Client, language: Language, templates: Templates, outputPath: string): void { +export function writeClientIndex(client: Client, language: Language, templates: Templates, outputPathModels: string, outputPathServices: string, outputPath: string): void { const fileName = getFileName('index', language); - // try { - console.log(fileName); - fs.writeFileSync( - path.resolve(outputPath, fileName), - templates.index({ - server: client.server, - version: client.version, - models: getModelNames(client.models), - services: getServiceNames(client.services), - }) - ); - // } catch (e) { - // throw new Error(`Could not write index: "${fileName}"`); - // } + try { + fs.writeFileSync( + path.resolve(outputPath, fileName), + templates.index({ + server: client.server, + version: client.version, + models: getImports(outputPathModels), + services: getImports(outputPathServices), + }) + ); + } catch (e) { + throw new Error(`Could not write index: "${fileName}"`); + } } diff --git a/src/utils/writeClientModels.spec.ts b/src/utils/writeClientModels.spec.ts index 3628c2e3..1a0d5948 100644 --- a/src/utils/writeClientModels.spec.ts +++ b/src/utils/writeClientModels.spec.ts @@ -29,13 +29,16 @@ describe('writeClientModels', () => { enums: [], properties: [], }); + const templates: Templates = { index: () => 'dummy', model: () => 'dummy', service: () => 'dummy', settings: () => 'dummy', }; + writeClientModels(models, Language.TYPESCRIPT, templates, '/'); + expect(fsWriteFileSync).toBeCalledWith('/Item.ts', 'dummy'); }); }); diff --git a/src/utils/writeClientModels.ts b/src/utils/writeClientModels.ts index 370bf662..40c5cb0d 100644 --- a/src/utils/writeClientModels.ts +++ b/src/utils/writeClientModels.ts @@ -6,6 +6,7 @@ import { Templates } from './readHandlebarsTemplates'; import { exportModel } from './exportModel'; import { format } from './format'; import { getFileName } from './getFileName'; +import { shouldExportModel } from './shouldExportModel'; /** * Generate Models using the Handlebar template and write to disk. @@ -16,14 +17,15 @@ import { getFileName } from './getFileName'; */ export function writeClientModels(models: Map, language: Language, templates: Templates, outputPath: string): void { models.forEach(model => { - const fileName = getFileName(model.name, language); - // try { - console.log(fileName); - const templateData = exportModel(model); - const templateResult = templates.model(templateData); - fs.writeFileSync(path.resolve(outputPath, fileName), format(templateResult)); - // } catch (e) { - // throw new Error(`Could not write model: "${fileName}"`); - // } + if (shouldExportModel(model, language)) { + const fileName = getFileName(model.name, language); + try { + const templateData = exportModel(model); + const templateResult = templates.model(templateData); + fs.writeFileSync(path.resolve(outputPath, fileName), format(templateResult)); + } catch (e) { + throw new Error(`Could not write model: "${fileName}"`); + } + } }); } diff --git a/src/utils/writeClientServices.spec.ts b/src/utils/writeClientServices.spec.ts index c191d76a..6610c9e7 100644 --- a/src/utils/writeClientServices.spec.ts +++ b/src/utils/writeClientServices.spec.ts @@ -16,13 +16,16 @@ describe('writeClientServices', () => { operations: [], imports: [], }); + const templates: Templates = { index: () => 'dummy', model: () => 'dummy', service: () => 'dummy', settings: () => 'dummy', }; + writeClientServices(services, Language.TYPESCRIPT, templates, '/'); + expect(fsWriteFileSync).toBeCalledWith('/Item.ts', 'dummy'); }); }); diff --git a/src/utils/writeClientServices.ts b/src/utils/writeClientServices.ts index 7693da87..88aea452 100644 --- a/src/utils/writeClientServices.ts +++ b/src/utils/writeClientServices.ts @@ -17,13 +17,12 @@ import { getFileName } from './getFileName'; export function writeClientServices(services: Map, language: Language, templates: Templates, outputPath: string): void { services.forEach(service => { const fileName = getFileName(service.name, language); - // try { - console.log(fileName); - const templateData = exportService(service); - const templateResult = templates.service(templateData); - fs.writeFileSync(path.resolve(outputPath, fileName), format(templateResult)); - // } catch (e) { - // throw new Error(`Could not write service: "${fileName}"`); - // } + try { + const templateData = exportService(service); + const templateResult = templates.service(templateData); + fs.writeFileSync(path.resolve(outputPath, fileName), format(templateResult)); + } catch (e) { + throw new Error(`Could not write service: "${fileName}"`); + } }); } diff --git a/test/__snapshots__/index.spec.js.snap b/test/__snapshots__/index.spec.js.snap index 077865aa..f915d130 100644 --- a/test/__snapshots__/index.spec.js.snap +++ b/test/__snapshots__/index.spec.js.snap @@ -360,407 +360,26 @@ export { ApiError } from './core/ApiError'; export { isSuccess } from './core/isSuccess'; export { OpenAPI } from './core/OpenAPI'; -export { ArrayWithArray } from './models/ArrayWithArray'; -export { ArrayWithBooleans } from './models/ArrayWithBooleans'; -export { ArrayWithNumbers } from './models/ArrayWithNumbers'; -export { ArrayWithProperties } from './models/ArrayWithProperties'; -export { ArrayWithReferences } from './models/ArrayWithReferences'; -export { ArrayWithStrings } from './models/ArrayWithStrings'; +export { EnumFromDescription.js } from './models/EnumFromDescription.js'; +export { EnumWithNumbers.js } from './models/EnumWithNumbers.js'; +export { EnumWithStrings.js } from './models/EnumWithStrings.js'; +export { ModelWithEnum.js } from './models/ModelWithEnum.js'; +export { ModelWithEnumFromDescription.js } from './models/ModelWithEnumFromDescription.js'; -export { DictionaryWithArray } from './models/DictionaryWithArray'; -export { DictionaryWithDictionary } from './models/DictionaryWithDictionary'; -export { DictionaryWithProperties } from './models/DictionaryWithProperties'; -export { DictionaryWithReference } from './models/DictionaryWithReference'; -export { DictionaryWithString } from './models/DictionaryWithString'; -export { EnumFromDescription } from './models/EnumFromDescription'; -export { EnumWithNumbers } from './models/EnumWithNumbers'; -export { EnumWithStrings } from './models/EnumWithStrings'; -export { ModelLink } from './models/ModelLink'; -export { ModelThatExtends } from './models/ModelThatExtends'; -export { ModelThatExtendsExtends } from './models/ModelThatExtendsExtends'; -export { ModelWithArray } from './models/ModelWithArray'; -export { ModelWithBoolean } from './models/ModelWithBoolean'; -export { ModelWithCircularReference } from './models/ModelWithCircularReference'; -export { ModelWithDictionary } from './models/ModelWithDictionary'; -export { ModelWithDuplicateImports } from './models/ModelWithDuplicateImports'; -export { ModelWithDuplicateProperties } from './models/ModelWithDuplicateProperties'; -export { ModelWithEnum } from './models/ModelWithEnum'; -export { ModelWithEnumFromDescription } from './models/ModelWithEnumFromDescription'; -export { ModelWithInteger } from './models/ModelWithInteger'; -export { ModelWithLink } from './models/ModelWithLink'; -export { ModelWithNestedEnums } from './models/ModelWithNestedEnums'; -export { ModelWithNestedProperties } from './models/ModelWithNestedProperties'; -export { ModelWithProperties } from './models/ModelWithProperties'; -export { ModelWithReference } from './models/ModelWithReference'; -export { ModelWithString } from './models/ModelWithString'; -export { SimpleBoolean } from './models/SimpleBoolean'; -export { SimpleFile } from './models/SimpleFile'; -export { SimpleInteger } from './models/SimpleInteger'; -export { SimpleReference } from './models/SimpleReference'; -export { SimpleString } from './models/SimpleString'; - -export { ComplexService } from './services/ComplexService'; -export { DefaultsService } from './services/DefaultsService'; -export { ParametersService } from './services/ParametersService'; -export { ResponseService } from './services/ResponseService'; -export { SimpleService } from './services/SimpleService'; -export { TypesService } from './services/TypesService'; +export { ComplexService.js } from './services/ComplexService.js'; +export { DefaultsService.js } from './services/DefaultsService.js'; +export { ParametersService.js } from './services/ParametersService.js'; +export { ResponseService.js } from './services/ResponseService.js'; +export { SimpleService.js } from './services/SimpleService.js'; +export { TypesService.js } from './services/TypesService.js'; " `; -exports[`generation v2 javascript file(./test/result/v2/javascript/models/ArrayWithArray.js): ./test/result/v2/javascript/models/ArrayWithArray.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; - -/** - * This is a simple array containing an array - */ -export let ArrayWithArray; -(function (ArrayWithArray) { - - ArrayWithArray.schema = yup.array().of(yup.array().of(ModelWithString.schema)); - - ArrayWithArray.validate = async function(value) { - return ArrayWithArray.schema.validate(value, { strict: true }); - }; - - ArrayWithArray.validateSync = function(value) { - return ArrayWithArray.schema.validateSync(value, { strict: true }); - }; - -})(ArrayWithArray || (ArrayWithArray = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/ArrayWithBooleans.js): ./test/result/v2/javascript/models/ArrayWithBooleans.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a simple array with booleans - */ -export let ArrayWithBooleans; -(function (ArrayWithBooleans) { - - ArrayWithBooleans.schema = yup.array().of(yup.boolean()); - - ArrayWithBooleans.validate = async function(value) { - return ArrayWithBooleans.schema.validate(value, { strict: true }); - }; - - ArrayWithBooleans.validateSync = function(value) { - return ArrayWithBooleans.schema.validateSync(value, { strict: true }); - }; - -})(ArrayWithBooleans || (ArrayWithBooleans = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/ArrayWithNumbers.js): ./test/result/v2/javascript/models/ArrayWithNumbers.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a simple array with numbers - */ -export let ArrayWithNumbers; -(function (ArrayWithNumbers) { - - ArrayWithNumbers.schema = yup.array().of(yup.number()); - - ArrayWithNumbers.validate = async function(value) { - return ArrayWithNumbers.schema.validate(value, { strict: true }); - }; - - ArrayWithNumbers.validateSync = function(value) { - return ArrayWithNumbers.schema.validateSync(value, { strict: true }); - }; - -})(ArrayWithNumbers || (ArrayWithNumbers = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/ArrayWithProperties.js): ./test/result/v2/javascript/models/ArrayWithProperties.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a simple array with properties - */ -export let ArrayWithProperties; -(function (ArrayWithProperties) { - - ArrayWithProperties.schema = yup.array().of(( - yup.object().shape({ - foo: yup.string(), - bar: yup.string() - }).noUnknown() - )); - - ArrayWithProperties.validate = async function(value) { - return ArrayWithProperties.schema.validate(value, { strict: true }); - }; - - ArrayWithProperties.validateSync = function(value) { - return ArrayWithProperties.schema.validateSync(value, { strict: true }); - }; - -})(ArrayWithProperties || (ArrayWithProperties = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/ArrayWithReferences.js): ./test/result/v2/javascript/models/ArrayWithReferences.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; - -/** - * This is a simple array with references - */ -export let ArrayWithReferences; -(function (ArrayWithReferences) { - - ArrayWithReferences.schema = yup.array().of(ModelWithString.schema); - - ArrayWithReferences.validate = async function(value) { - return ArrayWithReferences.schema.validate(value, { strict: true }); - }; - - ArrayWithReferences.validateSync = function(value) { - return ArrayWithReferences.schema.validateSync(value, { strict: true }); - }; - -})(ArrayWithReferences || (ArrayWithReferences = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/ArrayWithStrings.js): ./test/result/v2/javascript/models/ArrayWithStrings.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a simple array with strings - */ -export let ArrayWithStrings; -(function (ArrayWithStrings) { - - ArrayWithStrings.schema = yup.array().of(yup.string()); - - ArrayWithStrings.validate = async function(value) { - return ArrayWithStrings.schema.validate(value, { strict: true }); - }; - - ArrayWithStrings.validateSync = function(value) { - return ArrayWithStrings.schema.validateSync(value, { strict: true }); - }; - -})(ArrayWithStrings || (ArrayWithStrings = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/DictionaryWithArray.js): ./test/result/v2/javascript/models/DictionaryWithArray.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - - -import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; - -/** - * This is a complex dictionary - */ -export let DictionaryWithArray; -(function (DictionaryWithArray) { - - DictionaryWithArray.schema = yup.lazy(value => { - return yup.object().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.array().of(ModelWithString.schema) - }), {}) - ).noUnknown(); - }); - - DictionaryWithArray.validate = async function(value) { - return DictionaryWithArray.schema.validate(value, { strict: true }); - }; - - DictionaryWithArray.validateSync = function(value) { - return DictionaryWithArray.schema.validateSync(value, { strict: true }); - }; - -})(DictionaryWithArray || (DictionaryWithArray = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/DictionaryWithDictionary.js): ./test/result/v2/javascript/models/DictionaryWithDictionary.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - - -import * as yup from 'yup'; - -/** - * This is a string dictionary - */ -export let DictionaryWithDictionary; -(function (DictionaryWithDictionary) { - - DictionaryWithDictionary.schema = yup.lazy(value => { - return yup.object().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.lazy(value => { - return yup.object().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.string() - }), {}) - ).noUnknown(); - }) - }), {}) - ).noUnknown(); - }); - - DictionaryWithDictionary.validate = async function(value) { - return DictionaryWithDictionary.schema.validate(value, { strict: true }); - }; - - DictionaryWithDictionary.validateSync = function(value) { - return DictionaryWithDictionary.schema.validateSync(value, { strict: true }); - }; - -})(DictionaryWithDictionary || (DictionaryWithDictionary = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/DictionaryWithProperties.js): ./test/result/v2/javascript/models/DictionaryWithProperties.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - - -import * as yup from 'yup'; - -/** - * This is a complex dictionary - */ -export let DictionaryWithProperties; -(function (DictionaryWithProperties) { - - DictionaryWithProperties.schema = yup.lazy(value => { - return yup.object().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: ( - yup.object().shape({ - foo: yup.string(), - bar: yup.string() - }).noUnknown() - ) - }), {}) - ).noUnknown(); - }); - - DictionaryWithProperties.validate = async function(value) { - return DictionaryWithProperties.schema.validate(value, { strict: true }); - }; - - DictionaryWithProperties.validateSync = function(value) { - return DictionaryWithProperties.schema.validateSync(value, { strict: true }); - }; - -})(DictionaryWithProperties || (DictionaryWithProperties = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/DictionaryWithReference.js): ./test/result/v2/javascript/models/DictionaryWithReference.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - - -import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; - -/** - * This is a string reference - */ -export let DictionaryWithReference; -(function (DictionaryWithReference) { - - DictionaryWithReference.schema = yup.lazy(value => { - return yup.object().shape( - Object.keys(value).reduce((key, item) => ({ - ...object, - [key]: ModelWithString.schema - }), {}) - ).noUnknown(); - }); - - DictionaryWithReference.validate = async function(value) { - return DictionaryWithReference.schema.validate(value, { strict: true }); - }; - - DictionaryWithReference.validateSync = function(value) { - return DictionaryWithReference.schema.validateSync(value, { strict: true }); - }; - -})(DictionaryWithReference || (DictionaryWithReference = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/DictionaryWithString.js): ./test/result/v2/javascript/models/DictionaryWithString.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - - -import * as yup from 'yup'; - -/** - * This is a string dictionary - */ -export let DictionaryWithString; -(function (DictionaryWithString) { - - DictionaryWithString.schema = yup.lazy(value => { - return yup.object().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.string() - }), {}) - ).noUnknown(); - }); - - DictionaryWithString.validate = async function(value) { - return DictionaryWithString.schema.validate(value, { strict: true }); - }; - - DictionaryWithString.validateSync = function(value) { - return DictionaryWithString.schema.validateSync(value, { strict: true }); - }; - -})(DictionaryWithString || (DictionaryWithString = {}));" -`; - exports[`generation v2 javascript file(./test/result/v2/javascript/models/EnumFromDescription.js): ./test/result/v2/javascript/models/EnumFromDescription.js 1`] = ` "/* istanbul ignore file */ /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; /** * Success=1,Warning=2,Error=3 @@ -772,20 +391,6 @@ export let EnumFromDescription; EnumFromDescription.SUCCESS = 1; EnumFromDescription.WARNING = 2; - EnumFromDescription.schema = yup.mixed().oneOf([ - 3, - 1, - 2 - ]); - - EnumFromDescription.validate = async function(value) { - return EnumFromDescription.schema.validate(value, { strict: true }); - }; - - EnumFromDescription.validateSync = function(value) { - return EnumFromDescription.schema.validateSync(value, { strict: true }); - }; - })(EnumFromDescription || (EnumFromDescription = {}));" `; @@ -794,7 +399,6 @@ exports[`generation v2 javascript file(./test/result/v2/javascript/models/EnumWi /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; /** * This is a simple enum with numbers @@ -806,20 +410,6 @@ export let EnumWithNumbers; EnumWithNumbers.NUM_2 = 2; EnumWithNumbers.NUM_3 = 3; - EnumWithNumbers.schema = yup.mixed().oneOf([ - 1, - 2, - 3 - ]); - - EnumWithNumbers.validate = async function(value) { - return EnumWithNumbers.schema.validate(value, { strict: true }); - }; - - EnumWithNumbers.validateSync = function(value) { - return EnumWithNumbers.schema.validateSync(value, { strict: true }); - }; - })(EnumWithNumbers || (EnumWithNumbers = {}));" `; @@ -828,7 +418,6 @@ exports[`generation v2 javascript file(./test/result/v2/javascript/models/EnumWi /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; /** * This is a simple enum with strings @@ -840,325 +429,14 @@ export let EnumWithStrings; EnumWithStrings.SUCCESS = 'Success'; EnumWithStrings.WARNING = 'Warning'; - EnumWithStrings.schema = yup.mixed().oneOf([ - 'Error', - 'Success', - 'Warning' - ]); - - EnumWithStrings.validate = async function(value) { - return EnumWithStrings.schema.validate(value, { strict: true }); - }; - - EnumWithStrings.validateSync = function(value) { - return EnumWithStrings.schema.validateSync(value, { strict: true }); - }; - })(EnumWithStrings || (EnumWithStrings = {}));" `; -exports[`generation v2 javascript file(./test/result/v2/javascript/models/ModelLink.js): ./test/result/v2/javascript/models/ModelLink.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a model that can have a template?? - */ -export let ModelLink; -(function (ModelLink) { - - ModelLink.schema = ( - yup.object().shape({ - id: yup.string() - }).noUnknown() - ); - - ModelLink.validate = async function(value) { - return ModelLink.schema.validate(value, { strict: true }); - }; - - ModelLink.validateSync = function(value) { - return ModelLink.schema.validateSync(value, { strict: true }); - }; - -})(ModelLink || (ModelLink = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/ModelThatExtends.js): ./test/result/v2/javascript/models/ModelThatExtends.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; - -/** - * This is a model that extends another model - */ -export let ModelThatExtends; -(function (ModelThatExtends) { - - ModelThatExtends.schema = ( - ModelWithString.schema.concat( - yup.object().shape({ - propExtendsA: yup.string(), - propExtendsB: ModelWithString.schema - }).noUnknown() - ) - ); - - ModelThatExtends.validate = async function(value) { - return ModelThatExtends.schema.validate(value, { strict: true }); - }; - - ModelThatExtends.validateSync = function(value) { - return ModelThatExtends.schema.validateSync(value, { strict: true }); - }; - -})(ModelThatExtends || (ModelThatExtends = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/ModelThatExtendsExtends.js): ./test/result/v2/javascript/models/ModelThatExtendsExtends.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import { ModelThatExtends } from '../models/ModelThatExtends'; -import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; - -/** - * This is a model that extends another model - */ -export let ModelThatExtendsExtends; -(function (ModelThatExtendsExtends) { - - ModelThatExtendsExtends.schema = ( - ModelWithString.schema.concat( - ModelThatExtends.schema.concat( - yup.object().shape({ - propExtendsC: yup.string(), - propExtendsD: ModelWithString.schema - }).noUnknown() - ) - ) - ); - - ModelThatExtendsExtends.validate = async function(value) { - return ModelThatExtendsExtends.schema.validate(value, { strict: true }); - }; - - ModelThatExtendsExtends.validateSync = function(value) { - return ModelThatExtendsExtends.schema.validateSync(value, { strict: true }); - }; - -})(ModelThatExtendsExtends || (ModelThatExtendsExtends = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/ModelWithArray.js): ./test/result/v2/javascript/models/ModelWithArray.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; - -/** - * This is a model with one property containing an array - */ -export let ModelWithArray; -(function (ModelWithArray) { - - ModelWithArray.schema = ( - yup.object().shape({ - prop: yup.array().of(ModelWithString.schema), - propWithFile: yup.array().of(yup.mixed()), - propWithNumber: yup.array().of(yup.number()) - }).noUnknown() - ); - - ModelWithArray.validate = async function(value) { - return ModelWithArray.schema.validate(value, { strict: true }); - }; - - ModelWithArray.validateSync = function(value) { - return ModelWithArray.schema.validateSync(value, { strict: true }); - }; - -})(ModelWithArray || (ModelWithArray = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/ModelWithBoolean.js): ./test/result/v2/javascript/models/ModelWithBoolean.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a model with one boolean property - */ -export let ModelWithBoolean; -(function (ModelWithBoolean) { - - ModelWithBoolean.schema = ( - yup.object().shape({ - prop: yup.boolean() - }).noUnknown() - ); - - ModelWithBoolean.validate = async function(value) { - return ModelWithBoolean.schema.validate(value, { strict: true }); - }; - - ModelWithBoolean.validateSync = function(value) { - return ModelWithBoolean.schema.validateSync(value, { strict: true }); - }; - -})(ModelWithBoolean || (ModelWithBoolean = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/ModelWithCircularReference.js): ./test/result/v2/javascript/models/ModelWithCircularReference.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a model with one property containing a circular reference - */ -export let ModelWithCircularReference; -(function (ModelWithCircularReference) { - - ModelWithCircularReference.schema = ( - yup.object().shape({ - prop: ModelWithCircularReference.schema - }).noUnknown() - ); - - ModelWithCircularReference.validate = async function(value) { - return ModelWithCircularReference.schema.validate(value, { strict: true }); - }; - - ModelWithCircularReference.validateSync = function(value) { - return ModelWithCircularReference.schema.validateSync(value, { strict: true }); - }; - -})(ModelWithCircularReference || (ModelWithCircularReference = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/ModelWithDictionary.js): ./test/result/v2/javascript/models/ModelWithDictionary.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - - -import * as yup from 'yup'; - -/** - * This is a model with one property containing a dictionary - */ -export let ModelWithDictionary; -(function (ModelWithDictionary) { - - ModelWithDictionary.schema = ( - yup.object().shape({ - prop: yup.lazy(value => { - return yup.object().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.string() - }), {}) - ).noUnknown(); - }) - }).noUnknown() - ); - - ModelWithDictionary.validate = async function(value) { - return ModelWithDictionary.schema.validate(value, { strict: true }); - }; - - ModelWithDictionary.validateSync = function(value) { - return ModelWithDictionary.schema.validateSync(value, { strict: true }); - }; - -})(ModelWithDictionary || (ModelWithDictionary = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/ModelWithDuplicateImports.js): ./test/result/v2/javascript/models/ModelWithDuplicateImports.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; - -/** - * This is a model with duplicated imports - */ -export let ModelWithDuplicateImports; -(function (ModelWithDuplicateImports) { - - ModelWithDuplicateImports.schema = ( - yup.object().shape({ - propA: ModelWithString.schema, - propB: ModelWithString.schema, - propC: ModelWithString.schema - }).noUnknown() - ); - - ModelWithDuplicateImports.validate = async function(value) { - return ModelWithDuplicateImports.schema.validate(value, { strict: true }); - }; - - ModelWithDuplicateImports.validateSync = function(value) { - return ModelWithDuplicateImports.schema.validateSync(value, { strict: true }); - }; - -})(ModelWithDuplicateImports || (ModelWithDuplicateImports = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/ModelWithDuplicateProperties.js): ./test/result/v2/javascript/models/ModelWithDuplicateProperties.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; - -/** - * This is a model with duplicated properties - */ -export let ModelWithDuplicateProperties; -(function (ModelWithDuplicateProperties) { - - ModelWithDuplicateProperties.schema = ( - yup.object().shape({ - prop: ModelWithString.schema - }).noUnknown() - ); - - ModelWithDuplicateProperties.validate = async function(value) { - return ModelWithDuplicateProperties.schema.validate(value, { strict: true }); - }; - - ModelWithDuplicateProperties.validateSync = function(value) { - return ModelWithDuplicateProperties.schema.validateSync(value, { strict: true }); - }; - -})(ModelWithDuplicateProperties || (ModelWithDuplicateProperties = {}));" -`; - exports[`generation v2 javascript file(./test/result/v2/javascript/models/ModelWithEnum.js): ./test/result/v2/javascript/models/ModelWithEnum.js 1`] = ` "/* istanbul ignore file */ /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; /** * This is a model with one enum @@ -1175,24 +453,6 @@ export let ModelWithEnum; ERROR: 'Error' }; - ModelWithEnum.schema = ( - yup.object().shape({ - test: yup.mixed().oneOf([ - 'Success', - 'Warning', - 'Error' - ]) - }).noUnknown() - ); - - ModelWithEnum.validate = async function(value) { - return ModelWithEnum.schema.validate(value, { strict: true }); - }; - - ModelWithEnum.validateSync = function(value) { - return ModelWithEnum.schema.validateSync(value, { strict: true }); - }; - })(ModelWithEnum || (ModelWithEnum = {}));" `; @@ -1201,7 +461,6 @@ exports[`generation v2 javascript file(./test/result/v2/javascript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; /** * This is a model with one enum @@ -1218,426 +477,16 @@ export let ModelWithEnumFromDescription; ERROR: 3 }; - ModelWithEnumFromDescription.schema = ( - yup.object().shape({ - test: yup.mixed().oneOf([ - 1, - 2, - 3 - ]) - }).noUnknown() - ); - - ModelWithEnumFromDescription.validate = async function(value) { - return ModelWithEnumFromDescription.schema.validate(value, { strict: true }); - }; - - ModelWithEnumFromDescription.validateSync = function(value) { - return ModelWithEnumFromDescription.schema.validateSync(value, { strict: true }); - }; - })(ModelWithEnumFromDescription || (ModelWithEnumFromDescription = {}));" `; -exports[`generation v2 javascript file(./test/result/v2/javascript/models/ModelWithInteger.js): ./test/result/v2/javascript/models/ModelWithInteger.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a model with one number property - */ -export let ModelWithInteger; -(function (ModelWithInteger) { - - ModelWithInteger.schema = ( - yup.object().shape({ - prop: yup.number() - }).noUnknown() - ); - - ModelWithInteger.validate = async function(value) { - return ModelWithInteger.schema.validate(value, { strict: true }); - }; - - ModelWithInteger.validateSync = function(value) { - return ModelWithInteger.schema.validateSync(value, { strict: true }); - }; - -})(ModelWithInteger || (ModelWithInteger = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/ModelWithLink.js): ./test/result/v2/javascript/models/ModelWithLink.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import { ModelLink } from '../models/ModelLink'; -import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; - -/** - * This is a model that can have a template?? - */ -export let ModelWithLink; -(function (ModelWithLink) { - - ModelWithLink.schema = ( - yup.object().shape({ - prop: ModelLink.schema - }).noUnknown() - ); - - ModelWithLink.validate = async function(value) { - return ModelWithLink.schema.validate(value, { strict: true }); - }; - - ModelWithLink.validateSync = function(value) { - return ModelWithLink.schema.validateSync(value, { strict: true }); - }; - -})(ModelWithLink || (ModelWithLink = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/ModelWithNestedEnums.js): ./test/result/v2/javascript/models/ModelWithNestedEnums.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - - -import * as yup from 'yup'; - -/** - * This is a model with nested enums - */ -export let ModelWithNestedEnums; -(function (ModelWithNestedEnums) { - - ModelWithNestedEnums.schema = ( - yup.object().shape({ - arrayWithDescription: yup.array().of(yup.mixed().oneOf([ - 1, - 2, - 3 - ])), - arrayWithEnum: yup.array().of(yup.mixed().oneOf([ - 'Success', - 'Warning', - 'Error' - ])), - dictionaryWithEnum: yup.lazy(value => { - return yup.object().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.mixed().oneOf([ - 'Success', - 'Warning', - 'Error' - ]) - }), {}) - ).noUnknown(); - }), - dictionaryWithEnumFromDescription: yup.lazy(value => { - return yup.object().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.mixed().oneOf([ - 1, - 2, - 3 - ]) - }), {}) - ).noUnknown(); - }) - }).noUnknown() - ); - - ModelWithNestedEnums.validate = async function(value) { - return ModelWithNestedEnums.schema.validate(value, { strict: true }); - }; - - ModelWithNestedEnums.validateSync = function(value) { - return ModelWithNestedEnums.schema.validateSync(value, { strict: true }); - }; - -})(ModelWithNestedEnums || (ModelWithNestedEnums = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/ModelWithNestedProperties.js): ./test/result/v2/javascript/models/ModelWithNestedProperties.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a model with one nested property - */ -export let ModelWithNestedProperties; -(function (ModelWithNestedProperties) { - - ModelWithNestedProperties.schema = ( - yup.object().shape({ - first: ( - yup.object().shape({ - second: ( - yup.object().shape({ - third: yup.string().required() - }).noUnknown() - ).required() - }).noUnknown() - ).required() - }).noUnknown() - ); - - ModelWithNestedProperties.validate = async function(value) { - return ModelWithNestedProperties.schema.validate(value, { strict: true }); - }; - - ModelWithNestedProperties.validateSync = function(value) { - return ModelWithNestedProperties.schema.validateSync(value, { strict: true }); - }; - -})(ModelWithNestedProperties || (ModelWithNestedProperties = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/ModelWithProperties.js): ./test/result/v2/javascript/models/ModelWithProperties.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; - -/** - * This is a model with one nested property - */ -export let ModelWithProperties; -(function (ModelWithProperties) { - - ModelWithProperties.schema = ( - yup.object().shape({ - boolean: yup.boolean(), - number: yup.number(), - reference: ModelWithString.schema, - required: yup.string().required(), - requiredAndReadOnly: yup.string().required(), - string: yup.string() - }).noUnknown() - ); - - ModelWithProperties.validate = async function(value) { - return ModelWithProperties.schema.validate(value, { strict: true }); - }; - - ModelWithProperties.validateSync = function(value) { - return ModelWithProperties.schema.validateSync(value, { strict: true }); - }; - -})(ModelWithProperties || (ModelWithProperties = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/ModelWithReference.js): ./test/result/v2/javascript/models/ModelWithReference.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; - -/** - * This is a model with one property containing a reference - */ -export let ModelWithReference; -(function (ModelWithReference) { - - ModelWithReference.schema = ( - yup.object().shape({ - prop: ModelWithString.schema - }).noUnknown() - ); - - ModelWithReference.validate = async function(value) { - return ModelWithReference.schema.validate(value, { strict: true }); - }; - - ModelWithReference.validateSync = function(value) { - return ModelWithReference.schema.validateSync(value, { strict: true }); - }; - -})(ModelWithReference || (ModelWithReference = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/ModelWithString.js): ./test/result/v2/javascript/models/ModelWithString.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a model with one string property - */ -export let ModelWithString; -(function (ModelWithString) { - - ModelWithString.schema = ( - yup.object().shape({ - prop: yup.string() - }).noUnknown() - ); - - ModelWithString.validate = async function(value) { - return ModelWithString.schema.validate(value, { strict: true }); - }; - - ModelWithString.validateSync = function(value) { - return ModelWithString.schema.validateSync(value, { strict: true }); - }; - -})(ModelWithString || (ModelWithString = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/SimpleBoolean.js): ./test/result/v2/javascript/models/SimpleBoolean.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a simple boolean - */ -export let SimpleBoolean; -(function (SimpleBoolean) { - - SimpleBoolean.schema = yup.boolean(); - - SimpleBoolean.validate = async function(value) { - return SimpleBoolean.schema.validate(value, { strict: true }); - }; - - SimpleBoolean.validateSync = function(value) { - return SimpleBoolean.schema.validateSync(value, { strict: true }); - }; - -})(SimpleBoolean || (SimpleBoolean = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/SimpleFile.js): ./test/result/v2/javascript/models/SimpleFile.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a simple file - */ -export let SimpleFile; -(function (SimpleFile) { - - SimpleFile.schema = yup.mixed(); - - SimpleFile.validate = async function(value) { - return SimpleFile.schema.validate(value, { strict: true }); - }; - - SimpleFile.validateSync = function(value) { - return SimpleFile.schema.validateSync(value, { strict: true }); - }; - -})(SimpleFile || (SimpleFile = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/SimpleInteger.js): ./test/result/v2/javascript/models/SimpleInteger.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a simple number - */ -export let SimpleInteger; -(function (SimpleInteger) { - - SimpleInteger.schema = yup.number(); - - SimpleInteger.validate = async function(value) { - return SimpleInteger.schema.validate(value, { strict: true }); - }; - - SimpleInteger.validateSync = function(value) { - return SimpleInteger.schema.validateSync(value, { strict: true }); - }; - -})(SimpleInteger || (SimpleInteger = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/SimpleReference.js): ./test/result/v2/javascript/models/SimpleReference.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; - -/** - * This is a simple reference - */ -export let SimpleReference; -(function (SimpleReference) { - - SimpleReference.schema = ModelWithString.schema; - - SimpleReference.validate = async function(value) { - return SimpleReference.schema.validate(value, { strict: true }); - }; - - SimpleReference.validateSync = function(value) { - return SimpleReference.schema.validateSync(value, { strict: true }); - }; - -})(SimpleReference || (SimpleReference = {}));" -`; - -exports[`generation v2 javascript file(./test/result/v2/javascript/models/SimpleString.js): ./test/result/v2/javascript/models/SimpleString.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a simple string - */ -export let SimpleString; -(function (SimpleString) { - - SimpleString.schema = yup.string(); - - SimpleString.validate = async function(value) { - return SimpleString.schema.validate(value, { strict: true }); - }; - - SimpleString.validateSync = function(value) { - return SimpleString.schema.validateSync(value, { strict: true }); - }; - -})(SimpleString || (SimpleString = {}));" -`; - exports[`generation v2 javascript file(./test/result/v2/javascript/services/ComplexService.js): ./test/result/v2/javascript/services/ComplexService.js 1`] = ` "/* istanbul ignore file */ /* eslint-disable */ /* prettier-ignore */ import { ApiError, catchGenericError } from '../core/ApiError'; -import { request } from '../core/request'; +import { request as $request } from '../core/request'; import { OpenAPI } from '../core/OpenAPI'; export class ComplexService { @@ -1653,7 +502,7 @@ export class ComplexService { parameterReference ) { - const result = await request({ + const result = await $request({ method: 'get', path: \`/api/v\${OpenAPI.VERSION}/complex\`, query: { @@ -1683,7 +532,7 @@ exports[`generation v2 javascript file(./test/result/v2/javascript/services/Defa /* prettier-ignore */ import { ApiError, catchGenericError } from '../core/ApiError'; -import { request } from '../core/request'; +import { request as $request } from '../core/request'; import { OpenAPI } from '../core/OpenAPI'; export class DefaultsService { @@ -1706,7 +555,7 @@ export class DefaultsService { } ) { - const result = await request({ + const result = await $request({ method: 'get', path: \`/api/v\${OpenAPI.VERSION}/defaults\`, query: { @@ -1732,7 +581,7 @@ exports[`generation v2 javascript file(./test/result/v2/javascript/services/Para /* prettier-ignore */ import { ApiError, catchGenericError } from '../core/ApiError'; -import { request } from '../core/request'; +import { request as $request } from '../core/request'; import { OpenAPI } from '../core/OpenAPI'; export class ParametersService { @@ -1751,7 +600,7 @@ export class ParametersService { parameterBody ) { - const result = await request({ + const result = await $request({ method: 'get', path: \`/api/v\${OpenAPI.VERSION}/parameters\`, query: { @@ -1777,7 +626,7 @@ exports[`generation v2 javascript file(./test/result/v2/javascript/services/Resp /* prettier-ignore */ import { ApiError, catchGenericError } from '../core/ApiError'; -import { request } from '../core/request'; +import { request as $request } from '../core/request'; import { OpenAPI } from '../core/OpenAPI'; export class ResponseService { @@ -1788,7 +637,7 @@ export class ResponseService { */ static async callWithDuplicateResponses() { - const result = await request({ + const result = await $request({ method: 'post', path: \`/api/v\${OpenAPI.VERSION}/response\` }); @@ -1812,7 +661,7 @@ export class ResponseService { */ static async callWithResponse() { - const result = await request({ + const result = await $request({ method: 'get', path: \`/api/v\${OpenAPI.VERSION}/response\` }); @@ -1830,7 +679,7 @@ export class ResponseService { */ static async callWithResponses() { - const result = await request({ + const result = await $request({ method: 'put', path: \`/api/v\${OpenAPI.VERSION}/response\` }); @@ -1857,7 +706,7 @@ exports[`generation v2 javascript file(./test/result/v2/javascript/services/Simp /* prettier-ignore */ import { ApiError, catchGenericError } from '../core/ApiError'; -import { request } from '../core/request'; +import { request as $request } from '../core/request'; import { OpenAPI } from '../core/OpenAPI'; export class SimpleService { @@ -1867,7 +716,7 @@ export class SimpleService { */ static async deleteCallWithoutParametersAndResponse() { - const result = await request({ + const result = await $request({ method: 'delete', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -1882,7 +731,7 @@ export class SimpleService { */ static async getCallWithoutParametersAndResponse() { - const result = await request({ + const result = await $request({ method: 'get', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -1897,7 +746,7 @@ export class SimpleService { */ static async headCallWithoutParametersAndResponse() { - const result = await request({ + const result = await $request({ method: 'head', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -1912,7 +761,7 @@ export class SimpleService { */ static async optionsCallWithoutParametersAndResponse() { - const result = await request({ + const result = await $request({ method: 'options', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -1927,7 +776,7 @@ export class SimpleService { */ static async patchCallWithoutParametersAndResponse() { - const result = await request({ + const result = await $request({ method: 'patch', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -1942,7 +791,7 @@ export class SimpleService { */ static async postCallWithoutParametersAndResponse() { - const result = await request({ + const result = await $request({ method: 'post', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -1957,7 +806,7 @@ export class SimpleService { */ static async putCallWithoutParametersAndResponse() { - const result = await request({ + const result = await $request({ method: 'put', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -1976,7 +825,7 @@ exports[`generation v2 javascript file(./test/result/v2/javascript/services/Type /* prettier-ignore */ import { ApiError, catchGenericError } from '../core/ApiError'; -import { request } from '../core/request'; +import { request as $request } from '../core/request'; import { OpenAPI } from '../core/OpenAPI'; export class TypesService { @@ -2007,7 +856,7 @@ export class TypesService { id ) { - const result = await request({ + const result = await $request({ method: 'get', path: \`/api/v\${OpenAPI.VERSION}/types\`, query: { @@ -2440,51 +1289,51 @@ export { ApiError } from './core/ApiError'; export { isSuccess } from './core/isSuccess'; export { OpenAPI } from './core/OpenAPI'; -export { ArrayWithArray } from './models/ArrayWithArray'; -export { ArrayWithBooleans } from './models/ArrayWithBooleans'; -export { ArrayWithNumbers } from './models/ArrayWithNumbers'; -export { ArrayWithProperties } from './models/ArrayWithProperties'; -export { ArrayWithReferences } from './models/ArrayWithReferences'; -export { ArrayWithStrings } from './models/ArrayWithStrings'; -export { Dictionary } from './models/Dictionary'; -export { DictionaryWithArray } from './models/DictionaryWithArray'; -export { DictionaryWithDictionary } from './models/DictionaryWithDictionary'; -export { DictionaryWithProperties } from './models/DictionaryWithProperties'; -export { DictionaryWithReference } from './models/DictionaryWithReference'; -export { DictionaryWithString } from './models/DictionaryWithString'; -export { EnumFromDescription } from './models/EnumFromDescription'; -export { EnumWithNumbers } from './models/EnumWithNumbers'; -export { EnumWithStrings } from './models/EnumWithStrings'; -export { ModelLink } from './models/ModelLink'; -export { ModelThatExtends } from './models/ModelThatExtends'; -export { ModelThatExtendsExtends } from './models/ModelThatExtendsExtends'; -export { ModelWithArray } from './models/ModelWithArray'; -export { ModelWithBoolean } from './models/ModelWithBoolean'; -export { ModelWithCircularReference } from './models/ModelWithCircularReference'; -export { ModelWithDictionary } from './models/ModelWithDictionary'; -export { ModelWithDuplicateImports } from './models/ModelWithDuplicateImports'; -export { ModelWithDuplicateProperties } from './models/ModelWithDuplicateProperties'; -export { ModelWithEnum } from './models/ModelWithEnum'; -export { ModelWithEnumFromDescription } from './models/ModelWithEnumFromDescription'; -export { ModelWithInteger } from './models/ModelWithInteger'; -export { ModelWithLink } from './models/ModelWithLink'; -export { ModelWithNestedEnums } from './models/ModelWithNestedEnums'; -export { ModelWithNestedProperties } from './models/ModelWithNestedProperties'; -export { ModelWithProperties } from './models/ModelWithProperties'; -export { ModelWithReference } from './models/ModelWithReference'; -export { ModelWithString } from './models/ModelWithString'; -export { SimpleBoolean } from './models/SimpleBoolean'; -export { SimpleFile } from './models/SimpleFile'; -export { SimpleInteger } from './models/SimpleInteger'; -export { SimpleReference } from './models/SimpleReference'; -export { SimpleString } from './models/SimpleString'; +export { ArrayWithArray.ts } from './models/ArrayWithArray.ts'; +export { ArrayWithBooleans.ts } from './models/ArrayWithBooleans.ts'; +export { ArrayWithNumbers.ts } from './models/ArrayWithNumbers.ts'; +export { ArrayWithProperties.ts } from './models/ArrayWithProperties.ts'; +export { ArrayWithReferences.ts } from './models/ArrayWithReferences.ts'; +export { ArrayWithStrings.ts } from './models/ArrayWithStrings.ts'; +export { Dictionary.ts } from './models/Dictionary.ts'; +export { DictionaryWithArray.ts } from './models/DictionaryWithArray.ts'; +export { DictionaryWithDictionary.ts } from './models/DictionaryWithDictionary.ts'; +export { DictionaryWithProperties.ts } from './models/DictionaryWithProperties.ts'; +export { DictionaryWithReference.ts } from './models/DictionaryWithReference.ts'; +export { DictionaryWithString.ts } from './models/DictionaryWithString.ts'; +export { EnumFromDescription.ts } from './models/EnumFromDescription.ts'; +export { EnumWithNumbers.ts } from './models/EnumWithNumbers.ts'; +export { EnumWithStrings.ts } from './models/EnumWithStrings.ts'; +export { ModelLink.ts } from './models/ModelLink.ts'; +export { ModelThatExtends.ts } from './models/ModelThatExtends.ts'; +export { ModelThatExtendsExtends.ts } from './models/ModelThatExtendsExtends.ts'; +export { ModelWithArray.ts } from './models/ModelWithArray.ts'; +export { ModelWithBoolean.ts } from './models/ModelWithBoolean.ts'; +export { ModelWithCircularReference.ts } from './models/ModelWithCircularReference.ts'; +export { ModelWithDictionary.ts } from './models/ModelWithDictionary.ts'; +export { ModelWithDuplicateImports.ts } from './models/ModelWithDuplicateImports.ts'; +export { ModelWithDuplicateProperties.ts } from './models/ModelWithDuplicateProperties.ts'; +export { ModelWithEnum.ts } from './models/ModelWithEnum.ts'; +export { ModelWithEnumFromDescription.ts } from './models/ModelWithEnumFromDescription.ts'; +export { ModelWithInteger.ts } from './models/ModelWithInteger.ts'; +export { ModelWithLink.ts } from './models/ModelWithLink.ts'; +export { ModelWithNestedEnums.ts } from './models/ModelWithNestedEnums.ts'; +export { ModelWithNestedProperties.ts } from './models/ModelWithNestedProperties.ts'; +export { ModelWithProperties.ts } from './models/ModelWithProperties.ts'; +export { ModelWithReference.ts } from './models/ModelWithReference.ts'; +export { ModelWithString.ts } from './models/ModelWithString.ts'; +export { SimpleBoolean.ts } from './models/SimpleBoolean.ts'; +export { SimpleFile.ts } from './models/SimpleFile.ts'; +export { SimpleInteger.ts } from './models/SimpleInteger.ts'; +export { SimpleReference.ts } from './models/SimpleReference.ts'; +export { SimpleString.ts } from './models/SimpleString.ts'; -export { ComplexService } from './services/ComplexService'; -export { DefaultsService } from './services/DefaultsService'; -export { ParametersService } from './services/ParametersService'; -export { ResponseService } from './services/ResponseService'; -export { SimpleService } from './services/SimpleService'; -export { TypesService } from './services/TypesService'; +export { ComplexService.ts } from './services/ComplexService.ts'; +export { DefaultsService.ts } from './services/DefaultsService.ts'; +export { ParametersService.ts } from './services/ParametersService.ts'; +export { ResponseService.ts } from './services/ResponseService.ts'; +export { SimpleService.ts } from './services/SimpleService.ts'; +export { TypesService.ts } from './services/TypesService.ts'; " `; @@ -2495,25 +1344,11 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ArrayW /* prettier-ignore */ import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; /** * This is a simple array containing an array */ -export type ArrayWithArray = Array>; - -export namespace ArrayWithArray { - - export const schema = yup.array>().of(yup.array().of(ModelWithString.schema)); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ArrayWithArray { - return schema.validateSync(value, { strict: true }); - } -}" +export type ArrayWithArray = Array>;" `; exports[`generation v2 typescript file(./test/result/v2/typescript/models/ArrayWithBooleans.ts): ./test/result/v2/typescript/models/ArrayWithBooleans.ts 1`] = ` @@ -2522,25 +1357,10 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ArrayW /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a simple array with booleans */ -export type ArrayWithBooleans = Array; - -export namespace ArrayWithBooleans { - - export const schema = yup.array().of(yup.boolean()); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ArrayWithBooleans { - return schema.validateSync(value, { strict: true }); - } -}" +export type ArrayWithBooleans = Array;" `; exports[`generation v2 typescript file(./test/result/v2/typescript/models/ArrayWithNumbers.ts): ./test/result/v2/typescript/models/ArrayWithNumbers.ts 1`] = ` @@ -2549,25 +1369,10 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ArrayW /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a simple array with numbers */ -export type ArrayWithNumbers = Array; - -export namespace ArrayWithNumbers { - - export const schema = yup.array().of(yup.number()); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ArrayWithNumbers { - return schema.validateSync(value, { strict: true }); - } -}" +export type ArrayWithNumbers = Array;" `; exports[`generation v2 typescript file(./test/result/v2/typescript/models/ArrayWithProperties.ts): ./test/result/v2/typescript/models/ArrayWithProperties.ts 1`] = ` @@ -2576,36 +1381,13 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ArrayW /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a simple array with properties */ export type ArrayWithProperties = Array<{ foo?: string, bar?: string -}>; - -export namespace ArrayWithProperties { - - export const schema = yup.array<{ - foo?: string, - bar?: string - }>().of(( - yup.object().shape({ - foo: yup.string(), - bar: yup.string() - }).noUnknown() - )); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ArrayWithProperties { - return schema.validateSync(value, { strict: true }); - } -}" +}>;" `; exports[`generation v2 typescript file(./test/result/v2/typescript/models/ArrayWithReferences.ts): ./test/result/v2/typescript/models/ArrayWithReferences.ts 1`] = ` @@ -2615,25 +1397,11 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ArrayW /* prettier-ignore */ import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; /** * This is a simple array with references */ -export type ArrayWithReferences = Array; - -export namespace ArrayWithReferences { - - export const schema = yup.array().of(ModelWithString.schema); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ArrayWithReferences { - return schema.validateSync(value, { strict: true }); - } -}" +export type ArrayWithReferences = Array;" `; exports[`generation v2 typescript file(./test/result/v2/typescript/models/ArrayWithStrings.ts): ./test/result/v2/typescript/models/ArrayWithStrings.ts 1`] = ` @@ -2642,25 +1410,10 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ArrayW /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a simple array with strings */ -export type ArrayWithStrings = Array; - -export namespace ArrayWithStrings { - - export const schema = yup.array().of(yup.string()); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ArrayWithStrings { - return schema.validateSync(value, { strict: true }); - } -}" +export type ArrayWithStrings = Array;" `; exports[`generation v2 typescript file(./test/result/v2/typescript/models/Dictionary.ts): ./test/result/v2/typescript/models/Dictionary.ts 1`] = ` @@ -2683,32 +1436,11 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/Dictio import { Dictionary } from '../models/Dictionary'; import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; /** * This is a complex dictionary */ -export type DictionaryWithArray = Dictionary>; - -export namespace DictionaryWithArray { - - export const schema = yup.lazy>>(value => { - return yup.object>>().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.array().of(ModelWithString.schema) - }), {}) - ).noUnknown(); - }); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): DictionaryWithArray { - return schema.validateSync(value, { strict: true }); - } -}" +export type DictionaryWithArray = Dictionary>;" `; exports[`generation v2 typescript file(./test/result/v2/typescript/models/DictionaryWithDictionary.ts): ./test/result/v2/typescript/models/DictionaryWithDictionary.ts 1`] = ` @@ -2718,39 +1450,11 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/Dictio /* prettier-ignore */ import { Dictionary } from '../models/Dictionary'; -import * as yup from 'yup'; /** * This is a string dictionary */ -export type DictionaryWithDictionary = Dictionary>; - -export namespace DictionaryWithDictionary { - - export const schema = yup.lazy>>(value => { - return yup.object>>().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.lazy>(value => { - return yup.object>().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.string() - }), {}) - ).noUnknown(); - }) - }), {}) - ).noUnknown(); - }); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): DictionaryWithDictionary { - return schema.validateSync(value, { strict: true }); - } -}" +export type DictionaryWithDictionary = Dictionary>;" `; exports[`generation v2 typescript file(./test/result/v2/typescript/models/DictionaryWithProperties.ts): ./test/result/v2/typescript/models/DictionaryWithProperties.ts 1`] = ` @@ -2760,7 +1464,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/Dictio /* prettier-ignore */ import { Dictionary } from '../models/Dictionary'; -import * as yup from 'yup'; /** * This is a complex dictionary @@ -2768,38 +1471,7 @@ import * as yup from 'yup'; export type DictionaryWithProperties = Dictionary<{ foo?: string, bar?: string -}>; - -export namespace DictionaryWithProperties { - - export const schema = yup.lazy>(value => { - return yup.object>().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: ( - yup.object().shape({ - foo: yup.string(), - bar: yup.string() - }).noUnknown() - ) - }), {}) - ).noUnknown(); - }); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): DictionaryWithProperties { - return schema.validateSync(value, { strict: true }); - } -}" +}>;" `; exports[`generation v2 typescript file(./test/result/v2/typescript/models/DictionaryWithReference.ts): ./test/result/v2/typescript/models/DictionaryWithReference.ts 1`] = ` @@ -2810,32 +1482,11 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/Dictio import { Dictionary } from '../models/Dictionary'; import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; /** * This is a string reference */ -export type DictionaryWithReference = Dictionary; - -export namespace DictionaryWithReference { - - export const schema = yup.lazy>(value => { - return yup.object>().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: ModelWithString.schema - }), {}) - ).noUnknown(); - }); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): DictionaryWithReference { - return schema.validateSync(value, { strict: true }); - } -}" +export type DictionaryWithReference = Dictionary;" `; exports[`generation v2 typescript file(./test/result/v2/typescript/models/DictionaryWithString.ts): ./test/result/v2/typescript/models/DictionaryWithString.ts 1`] = ` @@ -2845,32 +1496,11 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/Dictio /* prettier-ignore */ import { Dictionary } from '../models/Dictionary'; -import * as yup from 'yup'; /** * This is a string dictionary */ -export type DictionaryWithString = Dictionary; - -export namespace DictionaryWithString { - - export const schema = yup.lazy>(value => { - return yup.object>().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.string() - }), {}) - ).noUnknown(); - }); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): DictionaryWithString { - return schema.validateSync(value, { strict: true }); - } -}" +export type DictionaryWithString = Dictionary;" `; exports[`generation v2 typescript file(./test/result/v2/typescript/models/EnumFromDescription.ts): ./test/result/v2/typescript/models/EnumFromDescription.ts 1`] = ` @@ -2879,8 +1509,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/EnumFr /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * Success=1,Warning=2,Error=3 */ @@ -2888,23 +1516,6 @@ export enum EnumFromDescription { ERROR = 3, SUCCESS = 1, WARNING = 2 -} - -export namespace EnumFromDescription { - - export const schema = yup.mixed().oneOf([ - EnumFromDescription.ERROR, - EnumFromDescription.SUCCESS, - EnumFromDescription.WARNING - ]); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): EnumFromDescription { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -2914,8 +1525,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/EnumWi /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a simple enum with numbers */ @@ -2923,23 +1532,6 @@ export enum EnumWithNumbers { NUM_1 = 1, NUM_2 = 2, NUM_3 = 3 -} - -export namespace EnumWithNumbers { - - export const schema = yup.mixed().oneOf([ - EnumWithNumbers.NUM_1, - EnumWithNumbers.NUM_2, - EnumWithNumbers.NUM_3 - ]); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): EnumWithNumbers { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -2949,8 +1541,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/EnumWi /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a simple enum with strings */ @@ -2958,23 +1548,6 @@ export enum EnumWithStrings { ERROR = 'Error', SUCCESS = 'Success', WARNING = 'Warning' -} - -export namespace EnumWithStrings { - - export const schema = yup.mixed().oneOf([ - EnumWithStrings.ERROR, - EnumWithStrings.SUCCESS, - EnumWithStrings.WARNING - ]); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): EnumWithStrings { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -2984,8 +1557,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelL /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a model that can have a template?? */ @@ -2995,19 +1566,6 @@ export interface ModelLink { export namespace ModelLink { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - id: yup.string() - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelLink { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -3018,7 +1576,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelT /* prettier-ignore */ import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; /** * This is a model that extends another model @@ -3030,22 +1587,6 @@ export interface ModelThatExtends extends ModelWithString { export namespace ModelThatExtends { - export const schema: yup.ObjectSchema = ( - ModelWithString.schema.concat( - yup.object().shape({ - propExtendsA: yup.string(), - propExtendsB: ModelWithString.schema - }).noUnknown() - ) - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelThatExtends { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -3057,7 +1598,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelT import { ModelThatExtends } from '../models/ModelThatExtends'; import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; /** * This is a model that extends another model @@ -3069,24 +1609,6 @@ export interface ModelThatExtendsExtends extends ModelWithString, ModelThatExten export namespace ModelThatExtendsExtends { - export const schema: yup.ObjectSchema = ( - ModelWithString.schema.concat( - ModelThatExtends.schema.concat( - yup.object().shape({ - propExtendsC: yup.string(), - propExtendsD: ModelWithString.schema - }).noUnknown() - ) - ) - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelThatExtendsExtends { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -3097,7 +1619,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* prettier-ignore */ import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; /** * This is a model with one property containing an array @@ -3110,21 +1631,6 @@ export interface ModelWithArray { export namespace ModelWithArray { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - prop: yup.array().of(ModelWithString.schema), - propWithFile: yup.array().of(yup.mixed()), - propWithNumber: yup.array().of(yup.number()) - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithArray { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -3134,8 +1640,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a model with one boolean property */ @@ -3148,19 +1652,6 @@ export interface ModelWithBoolean { export namespace ModelWithBoolean { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - prop: yup.boolean() - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithBoolean { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -3170,8 +1661,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a model with one property containing a circular reference */ @@ -3181,19 +1670,6 @@ export interface ModelWithCircularReference { export namespace ModelWithCircularReference { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - prop: ModelWithCircularReference.schema - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithCircularReference { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -3204,7 +1680,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* prettier-ignore */ import { Dictionary } from '../models/Dictionary'; -import * as yup from 'yup'; /** * This is a model with one property containing a dictionary @@ -3215,26 +1690,6 @@ export interface ModelWithDictionary { export namespace ModelWithDictionary { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - prop: yup.lazy>(value => { - return yup.object>().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.string() - }), {}) - ).noUnknown(); - }) - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithDictionary { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -3245,7 +1700,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* prettier-ignore */ import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; /** * This is a model with duplicated imports @@ -3258,21 +1712,6 @@ export interface ModelWithDuplicateImports { export namespace ModelWithDuplicateImports { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - propA: ModelWithString.schema, - propB: ModelWithString.schema, - propC: ModelWithString.schema - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithDuplicateImports { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -3283,7 +1722,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* prettier-ignore */ import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; /** * This is a model with duplicated properties @@ -3294,19 +1732,6 @@ export interface ModelWithDuplicateProperties { export namespace ModelWithDuplicateProperties { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - prop: ModelWithString.schema - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithDuplicateProperties { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -3316,8 +1741,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a model with one enum */ @@ -3339,23 +1762,6 @@ export namespace ModelWithEnum { ERROR = 'Error' } - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - test: yup.mixed().oneOf([ - 'Success', - 'Warning', - 'Error' - ]) - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithEnum { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -3365,8 +1771,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a model with one enum */ @@ -3388,23 +1792,6 @@ export namespace ModelWithEnumFromDescription { ERROR = 3 } - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - test: yup.mixed().oneOf([ - 1, - 2, - 3 - ]) - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithEnumFromDescription { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -3414,8 +1801,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a model with one number property */ @@ -3428,19 +1813,6 @@ export interface ModelWithInteger { export namespace ModelWithInteger { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - prop: yup.number() - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithInteger { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -3452,7 +1824,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW import { ModelLink } from '../models/ModelLink'; import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; /** * This is a model that can have a template?? @@ -3463,19 +1834,6 @@ export interface ModelWithLink { export namespace ModelWithLink { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - prop: ModelLink.schema - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithLink { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -3486,7 +1844,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* prettier-ignore */ import { Dictionary } from '../models/Dictionary'; -import * as yup from 'yup'; /** * This is a model with nested enums @@ -3500,52 +1857,6 @@ export interface ModelWithNestedEnums { export namespace ModelWithNestedEnums { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - arrayWithDescription: yup.array<(1 | 2 | 3)>().of(yup.mixed().oneOf([ - 1, - 2, - 3 - ])), - arrayWithEnum: yup.array<('Success' | 'Warning' | 'Error')>().of(yup.mixed().oneOf([ - 'Success', - 'Warning', - 'Error' - ])), - dictionaryWithEnum: yup.lazy>(value => { - return yup.object>().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.mixed().oneOf([ - 'Success', - 'Warning', - 'Error' - ]) - }), {}) - ).noUnknown(); - }), - dictionaryWithEnumFromDescription: yup.lazy>(value => { - return yup.object>().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.mixed().oneOf([ - 1, - 2, - 3 - ]) - }), {}) - ).noUnknown(); - }) - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithNestedEnums { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -3555,8 +1866,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a model with one nested property */ @@ -3570,27 +1879,6 @@ export interface ModelWithNestedProperties { export namespace ModelWithNestedProperties { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - first: ( - yup.object().shape({ - second: ( - yup.object().shape({ - third: yup.string().required() - }).noUnknown() - ).required() - }).noUnknown() - ).required() - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithNestedProperties { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -3601,7 +1889,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* prettier-ignore */ import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; /** * This is a model with one nested property @@ -3617,24 +1904,6 @@ export interface ModelWithProperties { export namespace ModelWithProperties { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - boolean: yup.boolean(), - number: yup.number(), - reference: ModelWithString.schema, - required: yup.string().required(), - requiredAndReadOnly: yup.string().required(), - string: yup.string() - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithProperties { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -3645,7 +1914,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* prettier-ignore */ import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; /** * This is a model with one property containing a reference @@ -3656,19 +1924,6 @@ export interface ModelWithReference { export namespace ModelWithReference { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - prop: ModelWithString.schema - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithReference { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -3678,8 +1933,6 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a model with one string property */ @@ -3692,19 +1945,6 @@ export interface ModelWithString { export namespace ModelWithString { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - prop: yup.string() - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithString { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -3714,25 +1954,10 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/Simple /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a simple boolean */ -export type SimpleBoolean = boolean; - -export namespace SimpleBoolean { - - export const schema = yup.boolean(); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): SimpleBoolean { - return schema.validateSync(value, { strict: true }); - } -}" +export type SimpleBoolean = boolean;" `; exports[`generation v2 typescript file(./test/result/v2/typescript/models/SimpleFile.ts): ./test/result/v2/typescript/models/SimpleFile.ts 1`] = ` @@ -3741,25 +1966,10 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/Simple /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a simple file */ -export type SimpleFile = File; - -export namespace SimpleFile { - - export const schema = yup.mixed(); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): SimpleFile { - return schema.validateSync(value, { strict: true }); - } -}" +export type SimpleFile = File;" `; exports[`generation v2 typescript file(./test/result/v2/typescript/models/SimpleInteger.ts): ./test/result/v2/typescript/models/SimpleInteger.ts 1`] = ` @@ -3768,25 +1978,10 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/Simple /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a simple number */ -export type SimpleInteger = number; - -export namespace SimpleInteger { - - export const schema = yup.number(); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): SimpleInteger { - return schema.validateSync(value, { strict: true }); - } -}" +export type SimpleInteger = number;" `; exports[`generation v2 typescript file(./test/result/v2/typescript/models/SimpleReference.ts): ./test/result/v2/typescript/models/SimpleReference.ts 1`] = ` @@ -3796,25 +1991,11 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/Simple /* prettier-ignore */ import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; /** * This is a simple reference */ -export type SimpleReference = ModelWithString; - -export namespace SimpleReference { - - export const schema = ModelWithString.schema; - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): SimpleReference { - return schema.validateSync(value, { strict: true }); - } -}" +export type SimpleReference = ModelWithString;" `; exports[`generation v2 typescript file(./test/result/v2/typescript/models/SimpleString.ts): ./test/result/v2/typescript/models/SimpleString.ts 1`] = ` @@ -3823,25 +2004,10 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/models/Simple /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a simple string */ -export type SimpleString = string; - -export namespace SimpleString { - - export const schema = yup.string(); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): SimpleString { - return schema.validateSync(value, { strict: true }); - } -}" +export type SimpleString = string;" `; exports[`generation v2 typescript file(./test/result/v2/typescript/services/ComplexService.ts): ./test/result/v2/typescript/services/ComplexService.ts 1`] = ` @@ -3852,7 +2018,7 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/services/Comp import { ModelWithString } from '../models/ModelWithString'; import { ApiError, catchGenericError } from '../core/ApiError'; -import { request } from '../core/request'; +import { request as $request } from '../core/request'; import { OpenAPI } from '../core/OpenAPI'; export class ComplexService { @@ -3874,7 +2040,7 @@ export class ComplexService { parameterReference: ModelWithString ): Promise> { - const result = await request({ + const result = await $request({ method: 'get', path: \`/api/v\${OpenAPI.VERSION}/complex\`, query: { @@ -3906,7 +2072,7 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/services/Defa import { ModelWithString } from '../models/ModelWithString'; import { ApiError, catchGenericError } from '../core/ApiError'; -import { request } from '../core/request'; +import { request as $request } from '../core/request'; import { OpenAPI } from '../core/OpenAPI'; export class DefaultsService { @@ -3929,7 +2095,7 @@ export class DefaultsService { } ): Promise { - const result = await request({ + const result = await $request({ method: 'get', path: \`/api/v\${OpenAPI.VERSION}/defaults\`, query: { @@ -3956,7 +2122,7 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/services/Para /* prettier-ignore */ import { ApiError, catchGenericError } from '../core/ApiError'; -import { request } from '../core/request'; +import { request as $request } from '../core/request'; import { OpenAPI } from '../core/OpenAPI'; export class ParametersService { @@ -3975,7 +2141,7 @@ export class ParametersService { parameterBody: string ): Promise { - const result = await request({ + const result = await $request({ method: 'get', path: \`/api/v\${OpenAPI.VERSION}/parameters\`, query: { @@ -4005,7 +2171,7 @@ import { ModelThatExtends } from '../models/ModelThatExtends'; import { ModelThatExtendsExtends } from '../models/ModelThatExtendsExtends'; import { ModelWithString } from '../models/ModelWithString'; import { ApiError, catchGenericError } from '../core/ApiError'; -import { request } from '../core/request'; +import { request as $request } from '../core/request'; import { OpenAPI } from '../core/OpenAPI'; export class ResponseService { @@ -4016,7 +2182,7 @@ export class ResponseService { */ public static async callWithDuplicateResponses(): Promise { - const result = await request({ + const result = await $request({ method: 'post', path: \`/api/v\${OpenAPI.VERSION}/response\` }); @@ -4040,7 +2206,7 @@ export class ResponseService { */ public static async callWithResponse(): Promise { - const result = await request({ + const result = await $request({ method: 'get', path: \`/api/v\${OpenAPI.VERSION}/response\` }); @@ -4058,7 +2224,7 @@ export class ResponseService { */ public static async callWithResponses(): Promise { - const result = await request({ + const result = await $request({ method: 'put', path: \`/api/v\${OpenAPI.VERSION}/response\` }); @@ -4086,7 +2252,7 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/services/Simp /* prettier-ignore */ import { ApiError, catchGenericError } from '../core/ApiError'; -import { request } from '../core/request'; +import { request as $request } from '../core/request'; import { OpenAPI } from '../core/OpenAPI'; export class SimpleService { @@ -4096,7 +2262,7 @@ export class SimpleService { */ public static async deleteCallWithoutParametersAndResponse(): Promise { - const result = await request({ + const result = await $request({ method: 'delete', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -4111,7 +2277,7 @@ export class SimpleService { */ public static async getCallWithoutParametersAndResponse(): Promise { - const result = await request({ + const result = await $request({ method: 'get', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -4126,7 +2292,7 @@ export class SimpleService { */ public static async headCallWithoutParametersAndResponse(): Promise { - const result = await request({ + const result = await $request({ method: 'head', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -4141,7 +2307,7 @@ export class SimpleService { */ public static async optionsCallWithoutParametersAndResponse(): Promise { - const result = await request({ + const result = await $request({ method: 'options', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -4156,7 +2322,7 @@ export class SimpleService { */ public static async patchCallWithoutParametersAndResponse(): Promise { - const result = await request({ + const result = await $request({ method: 'patch', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -4171,7 +2337,7 @@ export class SimpleService { */ public static async postCallWithoutParametersAndResponse(): Promise { - const result = await request({ + const result = await $request({ method: 'post', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -4186,7 +2352,7 @@ export class SimpleService { */ public static async putCallWithoutParametersAndResponse(): Promise { - const result = await request({ + const result = await $request({ method: 'put', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -4207,7 +2373,7 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/services/Type import { Dictionary } from '../models/Dictionary'; import { ApiError, catchGenericError } from '../core/ApiError'; -import { request } from '../core/request'; +import { request as $request } from '../core/request'; import { OpenAPI } from '../core/OpenAPI'; export class TypesService { @@ -4238,7 +2404,7 @@ export class TypesService { id?: number ): Promise { - const result = await request({ + const result = await $request({ method: 'get', path: \`/api/v\${OpenAPI.VERSION}/types\`, query: { @@ -4620,407 +2786,26 @@ export { ApiError } from './core/ApiError'; export { isSuccess } from './core/isSuccess'; export { OpenAPI } from './core/OpenAPI'; -export { ArrayWithArray } from './models/ArrayWithArray'; -export { ArrayWithBooleans } from './models/ArrayWithBooleans'; -export { ArrayWithNumbers } from './models/ArrayWithNumbers'; -export { ArrayWithProperties } from './models/ArrayWithProperties'; -export { ArrayWithReferences } from './models/ArrayWithReferences'; -export { ArrayWithStrings } from './models/ArrayWithStrings'; +export { EnumFromDescription.js } from './models/EnumFromDescription.js'; +export { EnumWithNumbers.js } from './models/EnumWithNumbers.js'; +export { EnumWithStrings.js } from './models/EnumWithStrings.js'; +export { ModelWithEnum.js } from './models/ModelWithEnum.js'; +export { ModelWithEnumFromDescription.js } from './models/ModelWithEnumFromDescription.js'; -export { DictionaryWithArray } from './models/DictionaryWithArray'; -export { DictionaryWithDictionary } from './models/DictionaryWithDictionary'; -export { DictionaryWithProperties } from './models/DictionaryWithProperties'; -export { DictionaryWithReference } from './models/DictionaryWithReference'; -export { DictionaryWithString } from './models/DictionaryWithString'; -export { EnumFromDescription } from './models/EnumFromDescription'; -export { EnumWithNumbers } from './models/EnumWithNumbers'; -export { EnumWithStrings } from './models/EnumWithStrings'; -export { ModelLink } from './models/ModelLink'; -export { ModelThatExtends } from './models/ModelThatExtends'; -export { ModelThatExtendsExtends } from './models/ModelThatExtendsExtends'; -export { ModelWithArray } from './models/ModelWithArray'; -export { ModelWithBoolean } from './models/ModelWithBoolean'; -export { ModelWithCircularReference } from './models/ModelWithCircularReference'; -export { ModelWithDictionary } from './models/ModelWithDictionary'; -export { ModelWithDuplicateImports } from './models/ModelWithDuplicateImports'; -export { ModelWithDuplicateProperties } from './models/ModelWithDuplicateProperties'; -export { ModelWithEnum } from './models/ModelWithEnum'; -export { ModelWithEnumFromDescription } from './models/ModelWithEnumFromDescription'; -export { ModelWithInteger } from './models/ModelWithInteger'; -export { ModelWithLink } from './models/ModelWithLink'; -export { ModelWithNestedEnums } from './models/ModelWithNestedEnums'; -export { ModelWithNestedProperties } from './models/ModelWithNestedProperties'; -export { ModelWithProperties } from './models/ModelWithProperties'; -export { ModelWithReference } from './models/ModelWithReference'; -export { ModelWithString } from './models/ModelWithString'; -export { SimpleBoolean } from './models/SimpleBoolean'; -export { SimpleFile } from './models/SimpleFile'; -export { SimpleInteger } from './models/SimpleInteger'; -export { SimpleReference } from './models/SimpleReference'; -export { SimpleString } from './models/SimpleString'; - -export { ComplexService } from './services/ComplexService'; -export { DefaultsService } from './services/DefaultsService'; -export { ParametersService } from './services/ParametersService'; -export { ResponseService } from './services/ResponseService'; -export { SimpleService } from './services/SimpleService'; -export { TypesService } from './services/TypesService'; +export { ComplexService.js } from './services/ComplexService.js'; +export { DefaultsService.js } from './services/DefaultsService.js'; +export { ParametersService.js } from './services/ParametersService.js'; +export { ResponseService.js } from './services/ResponseService.js'; +export { SimpleService.js } from './services/SimpleService.js'; +export { TypesService.js } from './services/TypesService.js'; " `; -exports[`generation v3 javascript file(./test/result/v3/javascript/models/ArrayWithArray.js): ./test/result/v3/javascript/models/ArrayWithArray.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; - -/** - * This is a simple array containing an array - */ -export let ArrayWithArray; -(function (ArrayWithArray) { - - ArrayWithArray.schema = yup.array().of(yup.array().of(ModelWithString.schema)); - - ArrayWithArray.validate = async function(value) { - return ArrayWithArray.schema.validate(value, { strict: true }); - }; - - ArrayWithArray.validateSync = function(value) { - return ArrayWithArray.schema.validateSync(value, { strict: true }); - }; - -})(ArrayWithArray || (ArrayWithArray = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/ArrayWithBooleans.js): ./test/result/v3/javascript/models/ArrayWithBooleans.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a simple array with booleans - */ -export let ArrayWithBooleans; -(function (ArrayWithBooleans) { - - ArrayWithBooleans.schema = yup.array().of(yup.boolean()); - - ArrayWithBooleans.validate = async function(value) { - return ArrayWithBooleans.schema.validate(value, { strict: true }); - }; - - ArrayWithBooleans.validateSync = function(value) { - return ArrayWithBooleans.schema.validateSync(value, { strict: true }); - }; - -})(ArrayWithBooleans || (ArrayWithBooleans = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/ArrayWithNumbers.js): ./test/result/v3/javascript/models/ArrayWithNumbers.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a simple array with numbers - */ -export let ArrayWithNumbers; -(function (ArrayWithNumbers) { - - ArrayWithNumbers.schema = yup.array().of(yup.number()); - - ArrayWithNumbers.validate = async function(value) { - return ArrayWithNumbers.schema.validate(value, { strict: true }); - }; - - ArrayWithNumbers.validateSync = function(value) { - return ArrayWithNumbers.schema.validateSync(value, { strict: true }); - }; - -})(ArrayWithNumbers || (ArrayWithNumbers = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/ArrayWithProperties.js): ./test/result/v3/javascript/models/ArrayWithProperties.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a simple array with properties - */ -export let ArrayWithProperties; -(function (ArrayWithProperties) { - - ArrayWithProperties.schema = yup.array().of(( - yup.object().shape({ - foo: yup.string(), - bar: yup.string() - }).noUnknown() - )); - - ArrayWithProperties.validate = async function(value) { - return ArrayWithProperties.schema.validate(value, { strict: true }); - }; - - ArrayWithProperties.validateSync = function(value) { - return ArrayWithProperties.schema.validateSync(value, { strict: true }); - }; - -})(ArrayWithProperties || (ArrayWithProperties = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/ArrayWithReferences.js): ./test/result/v3/javascript/models/ArrayWithReferences.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; - -/** - * This is a simple array with references - */ -export let ArrayWithReferences; -(function (ArrayWithReferences) { - - ArrayWithReferences.schema = yup.array().of(ModelWithString.schema); - - ArrayWithReferences.validate = async function(value) { - return ArrayWithReferences.schema.validate(value, { strict: true }); - }; - - ArrayWithReferences.validateSync = function(value) { - return ArrayWithReferences.schema.validateSync(value, { strict: true }); - }; - -})(ArrayWithReferences || (ArrayWithReferences = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/ArrayWithStrings.js): ./test/result/v3/javascript/models/ArrayWithStrings.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a simple array with strings - */ -export let ArrayWithStrings; -(function (ArrayWithStrings) { - - ArrayWithStrings.schema = yup.array().of(yup.string()); - - ArrayWithStrings.validate = async function(value) { - return ArrayWithStrings.schema.validate(value, { strict: true }); - }; - - ArrayWithStrings.validateSync = function(value) { - return ArrayWithStrings.schema.validateSync(value, { strict: true }); - }; - -})(ArrayWithStrings || (ArrayWithStrings = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/DictionaryWithArray.js): ./test/result/v3/javascript/models/DictionaryWithArray.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - - -import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; - -/** - * This is a complex dictionary - */ -export let DictionaryWithArray; -(function (DictionaryWithArray) { - - DictionaryWithArray.schema = yup.lazy(value => { - return yup.object().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.array().of(ModelWithString.schema) - }), {}) - ).noUnknown(); - }); - - DictionaryWithArray.validate = async function(value) { - return DictionaryWithArray.schema.validate(value, { strict: true }); - }; - - DictionaryWithArray.validateSync = function(value) { - return DictionaryWithArray.schema.validateSync(value, { strict: true }); - }; - -})(DictionaryWithArray || (DictionaryWithArray = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/DictionaryWithDictionary.js): ./test/result/v3/javascript/models/DictionaryWithDictionary.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - - -import * as yup from 'yup'; - -/** - * This is a string dictionary - */ -export let DictionaryWithDictionary; -(function (DictionaryWithDictionary) { - - DictionaryWithDictionary.schema = yup.lazy(value => { - return yup.object().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.lazy(value => { - return yup.object().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.string() - }), {}) - ).noUnknown(); - }) - }), {}) - ).noUnknown(); - }); - - DictionaryWithDictionary.validate = async function(value) { - return DictionaryWithDictionary.schema.validate(value, { strict: true }); - }; - - DictionaryWithDictionary.validateSync = function(value) { - return DictionaryWithDictionary.schema.validateSync(value, { strict: true }); - }; - -})(DictionaryWithDictionary || (DictionaryWithDictionary = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/DictionaryWithProperties.js): ./test/result/v3/javascript/models/DictionaryWithProperties.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - - -import * as yup from 'yup'; - -/** - * This is a complex dictionary - */ -export let DictionaryWithProperties; -(function (DictionaryWithProperties) { - - DictionaryWithProperties.schema = yup.lazy(value => { - return yup.object().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: ( - yup.object().shape({ - foo: yup.string(), - bar: yup.string() - }).noUnknown() - ) - }), {}) - ).noUnknown(); - }); - - DictionaryWithProperties.validate = async function(value) { - return DictionaryWithProperties.schema.validate(value, { strict: true }); - }; - - DictionaryWithProperties.validateSync = function(value) { - return DictionaryWithProperties.schema.validateSync(value, { strict: true }); - }; - -})(DictionaryWithProperties || (DictionaryWithProperties = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/DictionaryWithReference.js): ./test/result/v3/javascript/models/DictionaryWithReference.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - - -import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; - -/** - * This is a string reference - */ -export let DictionaryWithReference; -(function (DictionaryWithReference) { - - DictionaryWithReference.schema = yup.lazy(value => { - return yup.object().shape( - Object.keys(value).reduce((key, item) => ({ - ...object, - [key]: ModelWithString.schema - }), {}) - ).noUnknown(); - }); - - DictionaryWithReference.validate = async function(value) { - return DictionaryWithReference.schema.validate(value, { strict: true }); - }; - - DictionaryWithReference.validateSync = function(value) { - return DictionaryWithReference.schema.validateSync(value, { strict: true }); - }; - -})(DictionaryWithReference || (DictionaryWithReference = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/DictionaryWithString.js): ./test/result/v3/javascript/models/DictionaryWithString.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - - -import * as yup from 'yup'; - -/** - * This is a string dictionary - */ -export let DictionaryWithString; -(function (DictionaryWithString) { - - DictionaryWithString.schema = yup.lazy(value => { - return yup.object().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.string() - }), {}) - ).noUnknown(); - }); - - DictionaryWithString.validate = async function(value) { - return DictionaryWithString.schema.validate(value, { strict: true }); - }; - - DictionaryWithString.validateSync = function(value) { - return DictionaryWithString.schema.validateSync(value, { strict: true }); - }; - -})(DictionaryWithString || (DictionaryWithString = {}));" -`; - exports[`generation v3 javascript file(./test/result/v3/javascript/models/EnumFromDescription.js): ./test/result/v3/javascript/models/EnumFromDescription.js 1`] = ` "/* istanbul ignore file */ /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; /** * Success=1,Warning=2,Error=3 @@ -5032,20 +2817,6 @@ export let EnumFromDescription; EnumFromDescription.SUCCESS = 1; EnumFromDescription.WARNING = 2; - EnumFromDescription.schema = yup.mixed().oneOf([ - 3, - 1, - 2 - ]); - - EnumFromDescription.validate = async function(value) { - return EnumFromDescription.schema.validate(value, { strict: true }); - }; - - EnumFromDescription.validateSync = function(value) { - return EnumFromDescription.schema.validateSync(value, { strict: true }); - }; - })(EnumFromDescription || (EnumFromDescription = {}));" `; @@ -5054,7 +2825,6 @@ exports[`generation v3 javascript file(./test/result/v3/javascript/models/EnumWi /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; /** * This is a simple enum with numbers @@ -5066,20 +2836,6 @@ export let EnumWithNumbers; EnumWithNumbers.NUM_2 = 2; EnumWithNumbers.NUM_3 = 3; - EnumWithNumbers.schema = yup.mixed().oneOf([ - 1, - 2, - 3 - ]); - - EnumWithNumbers.validate = async function(value) { - return EnumWithNumbers.schema.validate(value, { strict: true }); - }; - - EnumWithNumbers.validateSync = function(value) { - return EnumWithNumbers.schema.validateSync(value, { strict: true }); - }; - })(EnumWithNumbers || (EnumWithNumbers = {}));" `; @@ -5088,7 +2844,6 @@ exports[`generation v3 javascript file(./test/result/v3/javascript/models/EnumWi /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; /** * This is a simple enum with strings @@ -5100,325 +2855,14 @@ export let EnumWithStrings; EnumWithStrings.SUCCESS = 'Success'; EnumWithStrings.WARNING = 'Warning'; - EnumWithStrings.schema = yup.mixed().oneOf([ - 'Error', - 'Success', - 'Warning' - ]); - - EnumWithStrings.validate = async function(value) { - return EnumWithStrings.schema.validate(value, { strict: true }); - }; - - EnumWithStrings.validateSync = function(value) { - return EnumWithStrings.schema.validateSync(value, { strict: true }); - }; - })(EnumWithStrings || (EnumWithStrings = {}));" `; -exports[`generation v3 javascript file(./test/result/v3/javascript/models/ModelLink.js): ./test/result/v3/javascript/models/ModelLink.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a model that can have a template?? - */ -export let ModelLink; -(function (ModelLink) { - - ModelLink.schema = ( - yup.object().shape({ - id: yup.string() - }).noUnknown() - ); - - ModelLink.validate = async function(value) { - return ModelLink.schema.validate(value, { strict: true }); - }; - - ModelLink.validateSync = function(value) { - return ModelLink.schema.validateSync(value, { strict: true }); - }; - -})(ModelLink || (ModelLink = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/ModelThatExtends.js): ./test/result/v3/javascript/models/ModelThatExtends.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; - -/** - * This is a model that extends another model - */ -export let ModelThatExtends; -(function (ModelThatExtends) { - - ModelThatExtends.schema = ( - ModelWithString.schema.concat( - yup.object().shape({ - propExtendsA: yup.string(), - propExtendsB: ModelWithString.schema - }).noUnknown() - ) - ); - - ModelThatExtends.validate = async function(value) { - return ModelThatExtends.schema.validate(value, { strict: true }); - }; - - ModelThatExtends.validateSync = function(value) { - return ModelThatExtends.schema.validateSync(value, { strict: true }); - }; - -})(ModelThatExtends || (ModelThatExtends = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/ModelThatExtendsExtends.js): ./test/result/v3/javascript/models/ModelThatExtendsExtends.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import { ModelThatExtends } from '../models/ModelThatExtends'; -import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; - -/** - * This is a model that extends another model - */ -export let ModelThatExtendsExtends; -(function (ModelThatExtendsExtends) { - - ModelThatExtendsExtends.schema = ( - ModelWithString.schema.concat( - ModelThatExtends.schema.concat( - yup.object().shape({ - propExtendsC: yup.string(), - propExtendsD: ModelWithString.schema - }).noUnknown() - ) - ) - ); - - ModelThatExtendsExtends.validate = async function(value) { - return ModelThatExtendsExtends.schema.validate(value, { strict: true }); - }; - - ModelThatExtendsExtends.validateSync = function(value) { - return ModelThatExtendsExtends.schema.validateSync(value, { strict: true }); - }; - -})(ModelThatExtendsExtends || (ModelThatExtendsExtends = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/ModelWithArray.js): ./test/result/v3/javascript/models/ModelWithArray.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; - -/** - * This is a model with one property containing an array - */ -export let ModelWithArray; -(function (ModelWithArray) { - - ModelWithArray.schema = ( - yup.object().shape({ - prop: yup.array().of(ModelWithString.schema), - propWithFile: yup.array().of(yup.mixed()), - propWithNumber: yup.array().of(yup.number()) - }).noUnknown() - ); - - ModelWithArray.validate = async function(value) { - return ModelWithArray.schema.validate(value, { strict: true }); - }; - - ModelWithArray.validateSync = function(value) { - return ModelWithArray.schema.validateSync(value, { strict: true }); - }; - -})(ModelWithArray || (ModelWithArray = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/ModelWithBoolean.js): ./test/result/v3/javascript/models/ModelWithBoolean.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a model with one boolean property - */ -export let ModelWithBoolean; -(function (ModelWithBoolean) { - - ModelWithBoolean.schema = ( - yup.object().shape({ - prop: yup.boolean() - }).noUnknown() - ); - - ModelWithBoolean.validate = async function(value) { - return ModelWithBoolean.schema.validate(value, { strict: true }); - }; - - ModelWithBoolean.validateSync = function(value) { - return ModelWithBoolean.schema.validateSync(value, { strict: true }); - }; - -})(ModelWithBoolean || (ModelWithBoolean = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/ModelWithCircularReference.js): ./test/result/v3/javascript/models/ModelWithCircularReference.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a model with one property containing a circular reference - */ -export let ModelWithCircularReference; -(function (ModelWithCircularReference) { - - ModelWithCircularReference.schema = ( - yup.object().shape({ - prop: ModelWithCircularReference.schema - }).noUnknown() - ); - - ModelWithCircularReference.validate = async function(value) { - return ModelWithCircularReference.schema.validate(value, { strict: true }); - }; - - ModelWithCircularReference.validateSync = function(value) { - return ModelWithCircularReference.schema.validateSync(value, { strict: true }); - }; - -})(ModelWithCircularReference || (ModelWithCircularReference = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/ModelWithDictionary.js): ./test/result/v3/javascript/models/ModelWithDictionary.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - - -import * as yup from 'yup'; - -/** - * This is a model with one property containing a dictionary - */ -export let ModelWithDictionary; -(function (ModelWithDictionary) { - - ModelWithDictionary.schema = ( - yup.object().shape({ - prop: yup.lazy(value => { - return yup.object().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.string() - }), {}) - ).noUnknown(); - }) - }).noUnknown() - ); - - ModelWithDictionary.validate = async function(value) { - return ModelWithDictionary.schema.validate(value, { strict: true }); - }; - - ModelWithDictionary.validateSync = function(value) { - return ModelWithDictionary.schema.validateSync(value, { strict: true }); - }; - -})(ModelWithDictionary || (ModelWithDictionary = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/ModelWithDuplicateImports.js): ./test/result/v3/javascript/models/ModelWithDuplicateImports.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; - -/** - * This is a model with duplicated imports - */ -export let ModelWithDuplicateImports; -(function (ModelWithDuplicateImports) { - - ModelWithDuplicateImports.schema = ( - yup.object().shape({ - propA: ModelWithString.schema, - propB: ModelWithString.schema, - propC: ModelWithString.schema - }).noUnknown() - ); - - ModelWithDuplicateImports.validate = async function(value) { - return ModelWithDuplicateImports.schema.validate(value, { strict: true }); - }; - - ModelWithDuplicateImports.validateSync = function(value) { - return ModelWithDuplicateImports.schema.validateSync(value, { strict: true }); - }; - -})(ModelWithDuplicateImports || (ModelWithDuplicateImports = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/ModelWithDuplicateProperties.js): ./test/result/v3/javascript/models/ModelWithDuplicateProperties.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; - -/** - * This is a model with duplicated properties - */ -export let ModelWithDuplicateProperties; -(function (ModelWithDuplicateProperties) { - - ModelWithDuplicateProperties.schema = ( - yup.object().shape({ - prop: ModelWithString.schema - }).noUnknown() - ); - - ModelWithDuplicateProperties.validate = async function(value) { - return ModelWithDuplicateProperties.schema.validate(value, { strict: true }); - }; - - ModelWithDuplicateProperties.validateSync = function(value) { - return ModelWithDuplicateProperties.schema.validateSync(value, { strict: true }); - }; - -})(ModelWithDuplicateProperties || (ModelWithDuplicateProperties = {}));" -`; - exports[`generation v3 javascript file(./test/result/v3/javascript/models/ModelWithEnum.js): ./test/result/v3/javascript/models/ModelWithEnum.js 1`] = ` "/* istanbul ignore file */ /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; /** * This is a model with one enum @@ -5435,24 +2879,6 @@ export let ModelWithEnum; ERROR: 'Error' }; - ModelWithEnum.schema = ( - yup.object().shape({ - Test: yup.mixed().oneOf([ - 'Success', - 'Warning', - 'Error' - ]) - }).noUnknown() - ); - - ModelWithEnum.validate = async function(value) { - return ModelWithEnum.schema.validate(value, { strict: true }); - }; - - ModelWithEnum.validateSync = function(value) { - return ModelWithEnum.schema.validateSync(value, { strict: true }); - }; - })(ModelWithEnum || (ModelWithEnum = {}));" `; @@ -5461,7 +2887,6 @@ exports[`generation v3 javascript file(./test/result/v3/javascript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; /** * This is a model with one enum @@ -5478,427 +2903,16 @@ export let ModelWithEnumFromDescription; ERROR: 3 }; - ModelWithEnumFromDescription.schema = ( - yup.object().shape({ - Test: yup.mixed().oneOf([ - 1, - 2, - 3 - ]) - }).noUnknown() - ); - - ModelWithEnumFromDescription.validate = async function(value) { - return ModelWithEnumFromDescription.schema.validate(value, { strict: true }); - }; - - ModelWithEnumFromDescription.validateSync = function(value) { - return ModelWithEnumFromDescription.schema.validateSync(value, { strict: true }); - }; - })(ModelWithEnumFromDescription || (ModelWithEnumFromDescription = {}));" `; -exports[`generation v3 javascript file(./test/result/v3/javascript/models/ModelWithInteger.js): ./test/result/v3/javascript/models/ModelWithInteger.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a model with one number property - */ -export let ModelWithInteger; -(function (ModelWithInteger) { - - ModelWithInteger.schema = ( - yup.object().shape({ - prop: yup.number() - }).noUnknown() - ); - - ModelWithInteger.validate = async function(value) { - return ModelWithInteger.schema.validate(value, { strict: true }); - }; - - ModelWithInteger.validateSync = function(value) { - return ModelWithInteger.schema.validateSync(value, { strict: true }); - }; - -})(ModelWithInteger || (ModelWithInteger = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/ModelWithLink.js): ./test/result/v3/javascript/models/ModelWithLink.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import { ModelLink } from '../models/ModelLink'; -import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; - -/** - * This is a model that can have a template?? - */ -export let ModelWithLink; -(function (ModelWithLink) { - - ModelWithLink.schema = ( - yup.object().shape({ - prop: ModelLink.schema - }).noUnknown() - ); - - ModelWithLink.validate = async function(value) { - return ModelWithLink.schema.validate(value, { strict: true }); - }; - - ModelWithLink.validateSync = function(value) { - return ModelWithLink.schema.validateSync(value, { strict: true }); - }; - -})(ModelWithLink || (ModelWithLink = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/ModelWithNestedEnums.js): ./test/result/v3/javascript/models/ModelWithNestedEnums.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - - -import * as yup from 'yup'; - -/** - * This is a model with nested enums - */ -export let ModelWithNestedEnums; -(function (ModelWithNestedEnums) { - - ModelWithNestedEnums.schema = ( - yup.object().shape({ - arrayWithDescription: yup.array().of(yup.mixed().oneOf([ - 1, - 2, - 3 - ])), - arrayWithEnum: yup.array().of(yup.mixed().oneOf([ - 'Success', - 'Warning', - 'Error' - ])), - dictionaryWithEnum: yup.lazy(value => { - return yup.object().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.mixed().oneOf([ - 'Success', - 'Warning', - 'Error' - ]) - }), {}) - ).noUnknown(); - }), - dictionaryWithEnumFromDescription: yup.lazy(value => { - return yup.object().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.mixed().oneOf([ - 1, - 2, - 3 - ]) - }), {}) - ).noUnknown(); - }) - }).noUnknown() - ); - - ModelWithNestedEnums.validate = async function(value) { - return ModelWithNestedEnums.schema.validate(value, { strict: true }); - }; - - ModelWithNestedEnums.validateSync = function(value) { - return ModelWithNestedEnums.schema.validateSync(value, { strict: true }); - }; - -})(ModelWithNestedEnums || (ModelWithNestedEnums = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/ModelWithNestedProperties.js): ./test/result/v3/javascript/models/ModelWithNestedProperties.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a model with one nested property - */ -export let ModelWithNestedProperties; -(function (ModelWithNestedProperties) { - - ModelWithNestedProperties.schema = ( - yup.object().shape({ - first: ( - yup.object().shape({ - second: ( - yup.object().shape({ - third: yup.string().nullable().required() - }).noUnknown() - ).nullable().required() - }).noUnknown() - ).nullable().required() - }).noUnknown() - ); - - ModelWithNestedProperties.validate = async function(value) { - return ModelWithNestedProperties.schema.validate(value, { strict: true }); - }; - - ModelWithNestedProperties.validateSync = function(value) { - return ModelWithNestedProperties.schema.validateSync(value, { strict: true }); - }; - -})(ModelWithNestedProperties || (ModelWithNestedProperties = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/ModelWithProperties.js): ./test/result/v3/javascript/models/ModelWithProperties.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; - -/** - * This is a model with one nested property - */ -export let ModelWithProperties; -(function (ModelWithProperties) { - - ModelWithProperties.schema = ( - yup.object().shape({ - boolean: yup.boolean(), - number: yup.number(), - reference: ModelWithString.schema, - required: yup.string().required(), - requiredAndNullable: yup.string().nullable().required(), - requiredAndReadOnly: yup.string().required(), - string: yup.string() - }).noUnknown() - ); - - ModelWithProperties.validate = async function(value) { - return ModelWithProperties.schema.validate(value, { strict: true }); - }; - - ModelWithProperties.validateSync = function(value) { - return ModelWithProperties.schema.validateSync(value, { strict: true }); - }; - -})(ModelWithProperties || (ModelWithProperties = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/ModelWithReference.js): ./test/result/v3/javascript/models/ModelWithReference.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; - -/** - * This is a model with one property containing a reference - */ -export let ModelWithReference; -(function (ModelWithReference) { - - ModelWithReference.schema = ( - yup.object().shape({ - prop: ModelWithString.schema - }).noUnknown() - ); - - ModelWithReference.validate = async function(value) { - return ModelWithReference.schema.validate(value, { strict: true }); - }; - - ModelWithReference.validateSync = function(value) { - return ModelWithReference.schema.validateSync(value, { strict: true }); - }; - -})(ModelWithReference || (ModelWithReference = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/ModelWithString.js): ./test/result/v3/javascript/models/ModelWithString.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a model with one string property - */ -export let ModelWithString; -(function (ModelWithString) { - - ModelWithString.schema = ( - yup.object().shape({ - prop: yup.string() - }).noUnknown() - ); - - ModelWithString.validate = async function(value) { - return ModelWithString.schema.validate(value, { strict: true }); - }; - - ModelWithString.validateSync = function(value) { - return ModelWithString.schema.validateSync(value, { strict: true }); - }; - -})(ModelWithString || (ModelWithString = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/SimpleBoolean.js): ./test/result/v3/javascript/models/SimpleBoolean.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a simple boolean - */ -export let SimpleBoolean; -(function (SimpleBoolean) { - - SimpleBoolean.schema = yup.boolean(); - - SimpleBoolean.validate = async function(value) { - return SimpleBoolean.schema.validate(value, { strict: true }); - }; - - SimpleBoolean.validateSync = function(value) { - return SimpleBoolean.schema.validateSync(value, { strict: true }); - }; - -})(SimpleBoolean || (SimpleBoolean = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/SimpleFile.js): ./test/result/v3/javascript/models/SimpleFile.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a simple file - */ -export let SimpleFile; -(function (SimpleFile) { - - SimpleFile.schema = yup.mixed(); - - SimpleFile.validate = async function(value) { - return SimpleFile.schema.validate(value, { strict: true }); - }; - - SimpleFile.validateSync = function(value) { - return SimpleFile.schema.validateSync(value, { strict: true }); - }; - -})(SimpleFile || (SimpleFile = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/SimpleInteger.js): ./test/result/v3/javascript/models/SimpleInteger.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a simple number - */ -export let SimpleInteger; -(function (SimpleInteger) { - - SimpleInteger.schema = yup.number(); - - SimpleInteger.validate = async function(value) { - return SimpleInteger.schema.validate(value, { strict: true }); - }; - - SimpleInteger.validateSync = function(value) { - return SimpleInteger.schema.validateSync(value, { strict: true }); - }; - -})(SimpleInteger || (SimpleInteger = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/SimpleReference.js): ./test/result/v3/javascript/models/SimpleReference.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; - -/** - * This is a simple reference - */ -export let SimpleReference; -(function (SimpleReference) { - - SimpleReference.schema = ModelWithString.schema; - - SimpleReference.validate = async function(value) { - return SimpleReference.schema.validate(value, { strict: true }); - }; - - SimpleReference.validateSync = function(value) { - return SimpleReference.schema.validateSync(value, { strict: true }); - }; - -})(SimpleReference || (SimpleReference = {}));" -`; - -exports[`generation v3 javascript file(./test/result/v3/javascript/models/SimpleString.js): ./test/result/v3/javascript/models/SimpleString.js 1`] = ` -"/* istanbul ignore file */ -/* eslint-disable */ -/* prettier-ignore */ - -import * as yup from 'yup'; - -/** - * This is a simple string - */ -export let SimpleString; -(function (SimpleString) { - - SimpleString.schema = yup.string(); - - SimpleString.validate = async function(value) { - return SimpleString.schema.validate(value, { strict: true }); - }; - - SimpleString.validateSync = function(value) { - return SimpleString.schema.validateSync(value, { strict: true }); - }; - -})(SimpleString || (SimpleString = {}));" -`; - exports[`generation v3 javascript file(./test/result/v3/javascript/services/ComplexService.js): ./test/result/v3/javascript/services/ComplexService.js 1`] = ` "/* istanbul ignore file */ /* eslint-disable */ /* prettier-ignore */ import { ApiError, catchGenericError } from '../core/ApiError'; -import { request } from '../core/request'; +import { request as $request } from '../core/request'; import { OpenAPI } from '../core/OpenAPI'; export class ComplexService { @@ -5914,7 +2928,7 @@ export class ComplexService { parameterReference ) { - const result = await request({ + const result = await $request({ method: 'get', path: \`/api/v\${OpenAPI.VERSION}/complex\`, query: { @@ -5944,7 +2958,7 @@ exports[`generation v3 javascript file(./test/result/v3/javascript/services/Defa /* prettier-ignore */ import { ApiError, catchGenericError } from '../core/ApiError'; -import { request } from '../core/request'; +import { request as $request } from '../core/request'; import { OpenAPI } from '../core/OpenAPI'; export class DefaultsService { @@ -5967,7 +2981,7 @@ export class DefaultsService { } ) { - const result = await request({ + const result = await $request({ method: 'get', path: \`/api/v\${OpenAPI.VERSION}/defaults\`, query: { @@ -5993,7 +3007,7 @@ exports[`generation v3 javascript file(./test/result/v3/javascript/services/Para /* prettier-ignore */ import { ApiError, catchGenericError } from '../core/ApiError'; -import { request } from '../core/request'; +import { request as $request } from '../core/request'; import { OpenAPI } from '../core/OpenAPI'; export class ParametersService { @@ -6014,7 +3028,7 @@ export class ParametersService { requestBody ) { - const result = await request({ + const result = await $request({ method: 'get', path: \`/api/v\${OpenAPI.VERSION}/parameters\`, cookies: { @@ -6046,7 +3060,7 @@ exports[`generation v3 javascript file(./test/result/v3/javascript/services/Resp /* prettier-ignore */ import { ApiError, catchGenericError } from '../core/ApiError'; -import { request } from '../core/request'; +import { request as $request } from '../core/request'; import { OpenAPI } from '../core/OpenAPI'; export class ResponseService { @@ -6057,7 +3071,7 @@ export class ResponseService { */ static async callWithDuplicateResponses() { - const result = await request({ + const result = await $request({ method: 'post', path: \`/api/v\${OpenAPI.VERSION}/response\` }); @@ -6081,7 +3095,7 @@ export class ResponseService { */ static async callWithResponse() { - const result = await request({ + const result = await $request({ method: 'get', path: \`/api/v\${OpenAPI.VERSION}/response\` }); @@ -6099,7 +3113,7 @@ export class ResponseService { */ static async callWithResponses() { - const result = await request({ + const result = await $request({ method: 'put', path: \`/api/v\${OpenAPI.VERSION}/response\` }); @@ -6126,7 +3140,7 @@ exports[`generation v3 javascript file(./test/result/v3/javascript/services/Simp /* prettier-ignore */ import { ApiError, catchGenericError } from '../core/ApiError'; -import { request } from '../core/request'; +import { request as $request } from '../core/request'; import { OpenAPI } from '../core/OpenAPI'; export class SimpleService { @@ -6136,7 +3150,7 @@ export class SimpleService { */ static async deleteCallWithoutParametersAndResponse() { - const result = await request({ + const result = await $request({ method: 'delete', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -6151,7 +3165,7 @@ export class SimpleService { */ static async getCallWithoutParametersAndResponse() { - const result = await request({ + const result = await $request({ method: 'get', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -6166,7 +3180,7 @@ export class SimpleService { */ static async headCallWithoutParametersAndResponse() { - const result = await request({ + const result = await $request({ method: 'head', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -6181,7 +3195,7 @@ export class SimpleService { */ static async optionsCallWithoutParametersAndResponse() { - const result = await request({ + const result = await $request({ method: 'options', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -6196,7 +3210,7 @@ export class SimpleService { */ static async patchCallWithoutParametersAndResponse() { - const result = await request({ + const result = await $request({ method: 'patch', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -6211,7 +3225,7 @@ export class SimpleService { */ static async postCallWithoutParametersAndResponse() { - const result = await request({ + const result = await $request({ method: 'post', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -6226,7 +3240,7 @@ export class SimpleService { */ static async putCallWithoutParametersAndResponse() { - const result = await request({ + const result = await $request({ method: 'put', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -6245,7 +3259,7 @@ exports[`generation v3 javascript file(./test/result/v3/javascript/services/Type /* prettier-ignore */ import { ApiError, catchGenericError } from '../core/ApiError'; -import { request } from '../core/request'; +import { request as $request } from '../core/request'; import { OpenAPI } from '../core/OpenAPI'; export class TypesService { @@ -6276,7 +3290,7 @@ export class TypesService { id ) { - const result = await request({ + const result = await $request({ method: 'get', path: \`/api/v\${OpenAPI.VERSION}/types\`, query: { @@ -6709,51 +3723,51 @@ export { ApiError } from './core/ApiError'; export { isSuccess } from './core/isSuccess'; export { OpenAPI } from './core/OpenAPI'; -export { ArrayWithArray } from './models/ArrayWithArray'; -export { ArrayWithBooleans } from './models/ArrayWithBooleans'; -export { ArrayWithNumbers } from './models/ArrayWithNumbers'; -export { ArrayWithProperties } from './models/ArrayWithProperties'; -export { ArrayWithReferences } from './models/ArrayWithReferences'; -export { ArrayWithStrings } from './models/ArrayWithStrings'; -export { Dictionary } from './models/Dictionary'; -export { DictionaryWithArray } from './models/DictionaryWithArray'; -export { DictionaryWithDictionary } from './models/DictionaryWithDictionary'; -export { DictionaryWithProperties } from './models/DictionaryWithProperties'; -export { DictionaryWithReference } from './models/DictionaryWithReference'; -export { DictionaryWithString } from './models/DictionaryWithString'; -export { EnumFromDescription } from './models/EnumFromDescription'; -export { EnumWithNumbers } from './models/EnumWithNumbers'; -export { EnumWithStrings } from './models/EnumWithStrings'; -export { ModelLink } from './models/ModelLink'; -export { ModelThatExtends } from './models/ModelThatExtends'; -export { ModelThatExtendsExtends } from './models/ModelThatExtendsExtends'; -export { ModelWithArray } from './models/ModelWithArray'; -export { ModelWithBoolean } from './models/ModelWithBoolean'; -export { ModelWithCircularReference } from './models/ModelWithCircularReference'; -export { ModelWithDictionary } from './models/ModelWithDictionary'; -export { ModelWithDuplicateImports } from './models/ModelWithDuplicateImports'; -export { ModelWithDuplicateProperties } from './models/ModelWithDuplicateProperties'; -export { ModelWithEnum } from './models/ModelWithEnum'; -export { ModelWithEnumFromDescription } from './models/ModelWithEnumFromDescription'; -export { ModelWithInteger } from './models/ModelWithInteger'; -export { ModelWithLink } from './models/ModelWithLink'; -export { ModelWithNestedEnums } from './models/ModelWithNestedEnums'; -export { ModelWithNestedProperties } from './models/ModelWithNestedProperties'; -export { ModelWithProperties } from './models/ModelWithProperties'; -export { ModelWithReference } from './models/ModelWithReference'; -export { ModelWithString } from './models/ModelWithString'; -export { SimpleBoolean } from './models/SimpleBoolean'; -export { SimpleFile } from './models/SimpleFile'; -export { SimpleInteger } from './models/SimpleInteger'; -export { SimpleReference } from './models/SimpleReference'; -export { SimpleString } from './models/SimpleString'; +export { ArrayWithArray.ts } from './models/ArrayWithArray.ts'; +export { ArrayWithBooleans.ts } from './models/ArrayWithBooleans.ts'; +export { ArrayWithNumbers.ts } from './models/ArrayWithNumbers.ts'; +export { ArrayWithProperties.ts } from './models/ArrayWithProperties.ts'; +export { ArrayWithReferences.ts } from './models/ArrayWithReferences.ts'; +export { ArrayWithStrings.ts } from './models/ArrayWithStrings.ts'; +export { Dictionary.ts } from './models/Dictionary.ts'; +export { DictionaryWithArray.ts } from './models/DictionaryWithArray.ts'; +export { DictionaryWithDictionary.ts } from './models/DictionaryWithDictionary.ts'; +export { DictionaryWithProperties.ts } from './models/DictionaryWithProperties.ts'; +export { DictionaryWithReference.ts } from './models/DictionaryWithReference.ts'; +export { DictionaryWithString.ts } from './models/DictionaryWithString.ts'; +export { EnumFromDescription.ts } from './models/EnumFromDescription.ts'; +export { EnumWithNumbers.ts } from './models/EnumWithNumbers.ts'; +export { EnumWithStrings.ts } from './models/EnumWithStrings.ts'; +export { ModelLink.ts } from './models/ModelLink.ts'; +export { ModelThatExtends.ts } from './models/ModelThatExtends.ts'; +export { ModelThatExtendsExtends.ts } from './models/ModelThatExtendsExtends.ts'; +export { ModelWithArray.ts } from './models/ModelWithArray.ts'; +export { ModelWithBoolean.ts } from './models/ModelWithBoolean.ts'; +export { ModelWithCircularReference.ts } from './models/ModelWithCircularReference.ts'; +export { ModelWithDictionary.ts } from './models/ModelWithDictionary.ts'; +export { ModelWithDuplicateImports.ts } from './models/ModelWithDuplicateImports.ts'; +export { ModelWithDuplicateProperties.ts } from './models/ModelWithDuplicateProperties.ts'; +export { ModelWithEnum.ts } from './models/ModelWithEnum.ts'; +export { ModelWithEnumFromDescription.ts } from './models/ModelWithEnumFromDescription.ts'; +export { ModelWithInteger.ts } from './models/ModelWithInteger.ts'; +export { ModelWithLink.ts } from './models/ModelWithLink.ts'; +export { ModelWithNestedEnums.ts } from './models/ModelWithNestedEnums.ts'; +export { ModelWithNestedProperties.ts } from './models/ModelWithNestedProperties.ts'; +export { ModelWithProperties.ts } from './models/ModelWithProperties.ts'; +export { ModelWithReference.ts } from './models/ModelWithReference.ts'; +export { ModelWithString.ts } from './models/ModelWithString.ts'; +export { SimpleBoolean.ts } from './models/SimpleBoolean.ts'; +export { SimpleFile.ts } from './models/SimpleFile.ts'; +export { SimpleInteger.ts } from './models/SimpleInteger.ts'; +export { SimpleReference.ts } from './models/SimpleReference.ts'; +export { SimpleString.ts } from './models/SimpleString.ts'; -export { ComplexService } from './services/ComplexService'; -export { DefaultsService } from './services/DefaultsService'; -export { ParametersService } from './services/ParametersService'; -export { ResponseService } from './services/ResponseService'; -export { SimpleService } from './services/SimpleService'; -export { TypesService } from './services/TypesService'; +export { ComplexService.ts } from './services/ComplexService.ts'; +export { DefaultsService.ts } from './services/DefaultsService.ts'; +export { ParametersService.ts } from './services/ParametersService.ts'; +export { ResponseService.ts } from './services/ResponseService.ts'; +export { SimpleService.ts } from './services/SimpleService.ts'; +export { TypesService.ts } from './services/TypesService.ts'; " `; @@ -6764,25 +3778,11 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ArrayW /* prettier-ignore */ import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; /** * This is a simple array containing an array */ -export type ArrayWithArray = Array>; - -export namespace ArrayWithArray { - - export const schema = yup.array>().of(yup.array().of(ModelWithString.schema)); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ArrayWithArray { - return schema.validateSync(value, { strict: true }); - } -}" +export type ArrayWithArray = Array>;" `; exports[`generation v3 typescript file(./test/result/v3/typescript/models/ArrayWithBooleans.ts): ./test/result/v3/typescript/models/ArrayWithBooleans.ts 1`] = ` @@ -6791,25 +3791,10 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ArrayW /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a simple array with booleans */ -export type ArrayWithBooleans = Array; - -export namespace ArrayWithBooleans { - - export const schema = yup.array().of(yup.boolean()); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ArrayWithBooleans { - return schema.validateSync(value, { strict: true }); - } -}" +export type ArrayWithBooleans = Array;" `; exports[`generation v3 typescript file(./test/result/v3/typescript/models/ArrayWithNumbers.ts): ./test/result/v3/typescript/models/ArrayWithNumbers.ts 1`] = ` @@ -6818,25 +3803,10 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ArrayW /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a simple array with numbers */ -export type ArrayWithNumbers = Array; - -export namespace ArrayWithNumbers { - - export const schema = yup.array().of(yup.number()); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ArrayWithNumbers { - return schema.validateSync(value, { strict: true }); - } -}" +export type ArrayWithNumbers = Array;" `; exports[`generation v3 typescript file(./test/result/v3/typescript/models/ArrayWithProperties.ts): ./test/result/v3/typescript/models/ArrayWithProperties.ts 1`] = ` @@ -6845,36 +3815,13 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ArrayW /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a simple array with properties */ export type ArrayWithProperties = Array<{ foo?: string, bar?: string -}>; - -export namespace ArrayWithProperties { - - export const schema = yup.array<{ - foo?: string, - bar?: string - }>().of(( - yup.object().shape({ - foo: yup.string(), - bar: yup.string() - }).noUnknown() - )); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ArrayWithProperties { - return schema.validateSync(value, { strict: true }); - } -}" +}>;" `; exports[`generation v3 typescript file(./test/result/v3/typescript/models/ArrayWithReferences.ts): ./test/result/v3/typescript/models/ArrayWithReferences.ts 1`] = ` @@ -6884,25 +3831,11 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ArrayW /* prettier-ignore */ import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; /** * This is a simple array with references */ -export type ArrayWithReferences = Array; - -export namespace ArrayWithReferences { - - export const schema = yup.array().of(ModelWithString.schema); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ArrayWithReferences { - return schema.validateSync(value, { strict: true }); - } -}" +export type ArrayWithReferences = Array;" `; exports[`generation v3 typescript file(./test/result/v3/typescript/models/ArrayWithStrings.ts): ./test/result/v3/typescript/models/ArrayWithStrings.ts 1`] = ` @@ -6911,25 +3844,10 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ArrayW /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a simple array with strings */ -export type ArrayWithStrings = Array; - -export namespace ArrayWithStrings { - - export const schema = yup.array().of(yup.string()); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ArrayWithStrings { - return schema.validateSync(value, { strict: true }); - } -}" +export type ArrayWithStrings = Array;" `; exports[`generation v3 typescript file(./test/result/v3/typescript/models/Dictionary.ts): ./test/result/v3/typescript/models/Dictionary.ts 1`] = ` @@ -6952,32 +3870,11 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/Dictio import { Dictionary } from '../models/Dictionary'; import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; /** * This is a complex dictionary */ -export type DictionaryWithArray = Dictionary>; - -export namespace DictionaryWithArray { - - export const schema = yup.lazy>>(value => { - return yup.object>>().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.array().of(ModelWithString.schema) - }), {}) - ).noUnknown(); - }); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): DictionaryWithArray { - return schema.validateSync(value, { strict: true }); - } -}" +export type DictionaryWithArray = Dictionary>;" `; exports[`generation v3 typescript file(./test/result/v3/typescript/models/DictionaryWithDictionary.ts): ./test/result/v3/typescript/models/DictionaryWithDictionary.ts 1`] = ` @@ -6987,39 +3884,11 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/Dictio /* prettier-ignore */ import { Dictionary } from '../models/Dictionary'; -import * as yup from 'yup'; /** * This is a string dictionary */ -export type DictionaryWithDictionary = Dictionary>; - -export namespace DictionaryWithDictionary { - - export const schema = yup.lazy>>(value => { - return yup.object>>().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.lazy>(value => { - return yup.object>().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.string() - }), {}) - ).noUnknown(); - }) - }), {}) - ).noUnknown(); - }); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): DictionaryWithDictionary { - return schema.validateSync(value, { strict: true }); - } -}" +export type DictionaryWithDictionary = Dictionary>;" `; exports[`generation v3 typescript file(./test/result/v3/typescript/models/DictionaryWithProperties.ts): ./test/result/v3/typescript/models/DictionaryWithProperties.ts 1`] = ` @@ -7029,7 +3898,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/Dictio /* prettier-ignore */ import { Dictionary } from '../models/Dictionary'; -import * as yup from 'yup'; /** * This is a complex dictionary @@ -7037,38 +3905,7 @@ import * as yup from 'yup'; export type DictionaryWithProperties = Dictionary<{ foo?: string, bar?: string -}>; - -export namespace DictionaryWithProperties { - - export const schema = yup.lazy>(value => { - return yup.object>().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: ( - yup.object().shape({ - foo: yup.string(), - bar: yup.string() - }).noUnknown() - ) - }), {}) - ).noUnknown(); - }); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): DictionaryWithProperties { - return schema.validateSync(value, { strict: true }); - } -}" +}>;" `; exports[`generation v3 typescript file(./test/result/v3/typescript/models/DictionaryWithReference.ts): ./test/result/v3/typescript/models/DictionaryWithReference.ts 1`] = ` @@ -7079,32 +3916,11 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/Dictio import { Dictionary } from '../models/Dictionary'; import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; /** * This is a string reference */ -export type DictionaryWithReference = Dictionary; - -export namespace DictionaryWithReference { - - export const schema = yup.lazy>(value => { - return yup.object>().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: ModelWithString.schema - }), {}) - ).noUnknown(); - }); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): DictionaryWithReference { - return schema.validateSync(value, { strict: true }); - } -}" +export type DictionaryWithReference = Dictionary;" `; exports[`generation v3 typescript file(./test/result/v3/typescript/models/DictionaryWithString.ts): ./test/result/v3/typescript/models/DictionaryWithString.ts 1`] = ` @@ -7114,32 +3930,11 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/Dictio /* prettier-ignore */ import { Dictionary } from '../models/Dictionary'; -import * as yup from 'yup'; /** * This is a string dictionary */ -export type DictionaryWithString = Dictionary; - -export namespace DictionaryWithString { - - export const schema = yup.lazy>(value => { - return yup.object>().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.string() - }), {}) - ).noUnknown(); - }); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): DictionaryWithString { - return schema.validateSync(value, { strict: true }); - } -}" +export type DictionaryWithString = Dictionary;" `; exports[`generation v3 typescript file(./test/result/v3/typescript/models/EnumFromDescription.ts): ./test/result/v3/typescript/models/EnumFromDescription.ts 1`] = ` @@ -7148,8 +3943,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/EnumFr /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * Success=1,Warning=2,Error=3 */ @@ -7157,23 +3950,6 @@ export enum EnumFromDescription { ERROR = 3, SUCCESS = 1, WARNING = 2 -} - -export namespace EnumFromDescription { - - export const schema = yup.mixed().oneOf([ - EnumFromDescription.ERROR, - EnumFromDescription.SUCCESS, - EnumFromDescription.WARNING - ]); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): EnumFromDescription { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -7183,8 +3959,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/EnumWi /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a simple enum with numbers */ @@ -7192,23 +3966,6 @@ export enum EnumWithNumbers { NUM_1 = 1, NUM_2 = 2, NUM_3 = 3 -} - -export namespace EnumWithNumbers { - - export const schema = yup.mixed().oneOf([ - EnumWithNumbers.NUM_1, - EnumWithNumbers.NUM_2, - EnumWithNumbers.NUM_3 - ]); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): EnumWithNumbers { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -7218,8 +3975,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/EnumWi /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a simple enum with strings */ @@ -7227,23 +3982,6 @@ export enum EnumWithStrings { ERROR = 'Error', SUCCESS = 'Success', WARNING = 'Warning' -} - -export namespace EnumWithStrings { - - export const schema = yup.mixed().oneOf([ - EnumWithStrings.ERROR, - EnumWithStrings.SUCCESS, - EnumWithStrings.WARNING - ]); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): EnumWithStrings { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -7253,8 +3991,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelL /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a model that can have a template?? */ @@ -7264,19 +4000,6 @@ export interface ModelLink { export namespace ModelLink { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - id: yup.string() - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelLink { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -7287,7 +4010,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelT /* prettier-ignore */ import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; /** * This is a model that extends another model @@ -7299,22 +4021,6 @@ export interface ModelThatExtends extends ModelWithString { export namespace ModelThatExtends { - export const schema: yup.ObjectSchema = ( - ModelWithString.schema.concat( - yup.object().shape({ - propExtendsA: yup.string(), - propExtendsB: ModelWithString.schema - }).noUnknown() - ) - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelThatExtends { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -7326,7 +4032,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelT import { ModelThatExtends } from '../models/ModelThatExtends'; import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; /** * This is a model that extends another model @@ -7338,24 +4043,6 @@ export interface ModelThatExtendsExtends extends ModelWithString, ModelThatExten export namespace ModelThatExtendsExtends { - export const schema: yup.ObjectSchema = ( - ModelWithString.schema.concat( - ModelThatExtends.schema.concat( - yup.object().shape({ - propExtendsC: yup.string(), - propExtendsD: ModelWithString.schema - }).noUnknown() - ) - ) - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelThatExtendsExtends { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -7366,7 +4053,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* prettier-ignore */ import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; /** * This is a model with one property containing an array @@ -7379,21 +4065,6 @@ export interface ModelWithArray { export namespace ModelWithArray { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - prop: yup.array().of(ModelWithString.schema), - propWithFile: yup.array().of(yup.mixed()), - propWithNumber: yup.array().of(yup.number()) - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithArray { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -7403,8 +4074,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a model with one boolean property */ @@ -7417,19 +4086,6 @@ export interface ModelWithBoolean { export namespace ModelWithBoolean { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - prop: yup.boolean() - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithBoolean { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -7439,8 +4095,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a model with one property containing a circular reference */ @@ -7450,19 +4104,6 @@ export interface ModelWithCircularReference { export namespace ModelWithCircularReference { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - prop: ModelWithCircularReference.schema - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithCircularReference { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -7473,7 +4114,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* prettier-ignore */ import { Dictionary } from '../models/Dictionary'; -import * as yup from 'yup'; /** * This is a model with one property containing a dictionary @@ -7484,26 +4124,6 @@ export interface ModelWithDictionary { export namespace ModelWithDictionary { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - prop: yup.lazy>(value => { - return yup.object>().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.string() - }), {}) - ).noUnknown(); - }) - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithDictionary { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -7514,7 +4134,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* prettier-ignore */ import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; /** * This is a model with duplicated imports @@ -7527,21 +4146,6 @@ export interface ModelWithDuplicateImports { export namespace ModelWithDuplicateImports { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - propA: ModelWithString.schema, - propB: ModelWithString.schema, - propC: ModelWithString.schema - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithDuplicateImports { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -7552,7 +4156,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* prettier-ignore */ import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; /** * This is a model with duplicated properties @@ -7563,19 +4166,6 @@ export interface ModelWithDuplicateProperties { export namespace ModelWithDuplicateProperties { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - prop: ModelWithString.schema - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithDuplicateProperties { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -7585,8 +4175,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a model with one enum */ @@ -7608,23 +4196,6 @@ export namespace ModelWithEnum { ERROR = 'Error' } - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - Test: yup.mixed().oneOf([ - 'Success', - 'Warning', - 'Error' - ]) - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithEnum { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -7634,8 +4205,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a model with one enum */ @@ -7657,23 +4226,6 @@ export namespace ModelWithEnumFromDescription { ERROR = 3 } - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - Test: yup.mixed().oneOf([ - 1, - 2, - 3 - ]) - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithEnumFromDescription { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -7683,8 +4235,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a model with one number property */ @@ -7697,19 +4247,6 @@ export interface ModelWithInteger { export namespace ModelWithInteger { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - prop: yup.number() - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithInteger { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -7721,7 +4258,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW import { ModelLink } from '../models/ModelLink'; import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; /** * This is a model that can have a template?? @@ -7732,19 +4268,6 @@ export interface ModelWithLink { export namespace ModelWithLink { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - prop: ModelLink.schema - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithLink { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -7755,7 +4278,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* prettier-ignore */ import { Dictionary } from '../models/Dictionary'; -import * as yup from 'yup'; /** * This is a model with nested enums @@ -7769,52 +4291,6 @@ export interface ModelWithNestedEnums { export namespace ModelWithNestedEnums { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - arrayWithDescription: yup.array<(1 | 2 | 3)>().of(yup.mixed().oneOf([ - 1, - 2, - 3 - ])), - arrayWithEnum: yup.array<('Success' | 'Warning' | 'Error')>().of(yup.mixed().oneOf([ - 'Success', - 'Warning', - 'Error' - ])), - dictionaryWithEnum: yup.lazy>(value => { - return yup.object>().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.mixed().oneOf([ - 'Success', - 'Warning', - 'Error' - ]) - }), {}) - ).noUnknown(); - }), - dictionaryWithEnumFromDescription: yup.lazy>(value => { - return yup.object>().shape( - Object.keys(value).reduce((object, key) => ({ - ...object, - [key]: yup.mixed().oneOf([ - 1, - 2, - 3 - ]) - }), {}) - ).noUnknown(); - }) - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithNestedEnums { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -7824,8 +4300,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a model with one nested property */ @@ -7839,27 +4313,6 @@ export interface ModelWithNestedProperties { export namespace ModelWithNestedProperties { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - first: ( - yup.object().shape({ - second: ( - yup.object().shape({ - third: yup.string().nullable().required() - }).noUnknown() - ).nullable().required() - }).noUnknown() - ).nullable().required() - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithNestedProperties { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -7870,7 +4323,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* prettier-ignore */ import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; /** * This is a model with one nested property @@ -7887,25 +4339,6 @@ export interface ModelWithProperties { export namespace ModelWithProperties { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - boolean: yup.boolean(), - number: yup.number(), - reference: ModelWithString.schema, - required: yup.string().required(), - requiredAndNullable: yup.string().nullable().required(), - requiredAndReadOnly: yup.string().required(), - string: yup.string() - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithProperties { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -7916,7 +4349,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* prettier-ignore */ import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; /** * This is a model with one property containing a reference @@ -7927,19 +4359,6 @@ export interface ModelWithReference { export namespace ModelWithReference { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - prop: ModelWithString.schema - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithReference { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -7949,8 +4368,6 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelW /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a model with one string property */ @@ -7963,19 +4380,6 @@ export interface ModelWithString { export namespace ModelWithString { - export const schema: yup.ObjectSchema = ( - yup.object().shape({ - prop: yup.string() - }).noUnknown() - ); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): ModelWithString { - return schema.validateSync(value, { strict: true }); - } }" `; @@ -7985,25 +4389,10 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/Simple /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a simple boolean */ -export type SimpleBoolean = boolean; - -export namespace SimpleBoolean { - - export const schema = yup.boolean(); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): SimpleBoolean { - return schema.validateSync(value, { strict: true }); - } -}" +export type SimpleBoolean = boolean;" `; exports[`generation v3 typescript file(./test/result/v3/typescript/models/SimpleFile.ts): ./test/result/v3/typescript/models/SimpleFile.ts 1`] = ` @@ -8012,25 +4401,10 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/Simple /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a simple file */ -export type SimpleFile = File; - -export namespace SimpleFile { - - export const schema = yup.mixed(); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): SimpleFile { - return schema.validateSync(value, { strict: true }); - } -}" +export type SimpleFile = File;" `; exports[`generation v3 typescript file(./test/result/v3/typescript/models/SimpleInteger.ts): ./test/result/v3/typescript/models/SimpleInteger.ts 1`] = ` @@ -8039,25 +4413,10 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/Simple /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a simple number */ -export type SimpleInteger = number; - -export namespace SimpleInteger { - - export const schema = yup.number(); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): SimpleInteger { - return schema.validateSync(value, { strict: true }); - } -}" +export type SimpleInteger = number;" `; exports[`generation v3 typescript file(./test/result/v3/typescript/models/SimpleReference.ts): ./test/result/v3/typescript/models/SimpleReference.ts 1`] = ` @@ -8067,25 +4426,11 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/Simple /* prettier-ignore */ import { ModelWithString } from '../models/ModelWithString'; -import * as yup from 'yup'; /** * This is a simple reference */ -export type SimpleReference = ModelWithString; - -export namespace SimpleReference { - - export const schema = ModelWithString.schema; - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): SimpleReference { - return schema.validateSync(value, { strict: true }); - } -}" +export type SimpleReference = ModelWithString;" `; exports[`generation v3 typescript file(./test/result/v3/typescript/models/SimpleString.ts): ./test/result/v3/typescript/models/SimpleString.ts 1`] = ` @@ -8094,25 +4439,10 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/models/Simple /* eslint-disable */ /* prettier-ignore */ -import * as yup from 'yup'; - /** * This is a simple string */ -export type SimpleString = string; - -export namespace SimpleString { - - export const schema = yup.string(); - - export async function validate(value: any): Promise { - return schema.validate(value, { strict: true }); - } - - export function validateSync(value: any): SimpleString { - return schema.validateSync(value, { strict: true }); - } -}" +export type SimpleString = string;" `; exports[`generation v3 typescript file(./test/result/v3/typescript/services/ComplexService.ts): ./test/result/v3/typescript/services/ComplexService.ts 1`] = ` @@ -8123,7 +4453,7 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/services/Comp import { ModelWithString } from '../models/ModelWithString'; import { ApiError, catchGenericError } from '../core/ApiError'; -import { request } from '../core/request'; +import { request as $request } from '../core/request'; import { OpenAPI } from '../core/OpenAPI'; export class ComplexService { @@ -8145,7 +4475,7 @@ export class ComplexService { parameterReference: ModelWithString ): Promise> { - const result = await request({ + const result = await $request({ method: 'get', path: \`/api/v\${OpenAPI.VERSION}/complex\`, query: { @@ -8177,7 +4507,7 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/services/Defa import { ModelWithString } from '../models/ModelWithString'; import { ApiError, catchGenericError } from '../core/ApiError'; -import { request } from '../core/request'; +import { request as $request } from '../core/request'; import { OpenAPI } from '../core/OpenAPI'; export class DefaultsService { @@ -8200,7 +4530,7 @@ export class DefaultsService { } ): Promise { - const result = await request({ + const result = await $request({ method: 'get', path: \`/api/v\${OpenAPI.VERSION}/defaults\`, query: { @@ -8228,7 +4558,7 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/services/Para import { ModelWithString } from '../models/ModelWithString'; import { ApiError, catchGenericError } from '../core/ApiError'; -import { request } from '../core/request'; +import { request as $request } from '../core/request'; import { OpenAPI } from '../core/OpenAPI'; export class ParametersService { @@ -8249,7 +4579,7 @@ export class ParametersService { requestBody?: ModelWithString ): Promise { - const result = await request({ + const result = await $request({ method: 'get', path: \`/api/v\${OpenAPI.VERSION}/parameters\`, cookies: { @@ -8285,7 +4615,7 @@ import { ModelThatExtends } from '../models/ModelThatExtends'; import { ModelThatExtendsExtends } from '../models/ModelThatExtendsExtends'; import { ModelWithString } from '../models/ModelWithString'; import { ApiError, catchGenericError } from '../core/ApiError'; -import { request } from '../core/request'; +import { request as $request } from '../core/request'; import { OpenAPI } from '../core/OpenAPI'; export class ResponseService { @@ -8296,7 +4626,7 @@ export class ResponseService { */ public static async callWithDuplicateResponses(): Promise { - const result = await request({ + const result = await $request({ method: 'post', path: \`/api/v\${OpenAPI.VERSION}/response\` }); @@ -8320,7 +4650,7 @@ export class ResponseService { */ public static async callWithResponse(): Promise { - const result = await request({ + const result = await $request({ method: 'get', path: \`/api/v\${OpenAPI.VERSION}/response\` }); @@ -8338,7 +4668,7 @@ export class ResponseService { */ public static async callWithResponses(): Promise { - const result = await request({ + const result = await $request({ method: 'put', path: \`/api/v\${OpenAPI.VERSION}/response\` }); @@ -8366,7 +4696,7 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/services/Simp /* prettier-ignore */ import { ApiError, catchGenericError } from '../core/ApiError'; -import { request } from '../core/request'; +import { request as $request } from '../core/request'; import { OpenAPI } from '../core/OpenAPI'; export class SimpleService { @@ -8376,7 +4706,7 @@ export class SimpleService { */ public static async deleteCallWithoutParametersAndResponse(): Promise { - const result = await request({ + const result = await $request({ method: 'delete', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -8391,7 +4721,7 @@ export class SimpleService { */ public static async getCallWithoutParametersAndResponse(): Promise { - const result = await request({ + const result = await $request({ method: 'get', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -8406,7 +4736,7 @@ export class SimpleService { */ public static async headCallWithoutParametersAndResponse(): Promise { - const result = await request({ + const result = await $request({ method: 'head', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -8421,7 +4751,7 @@ export class SimpleService { */ public static async optionsCallWithoutParametersAndResponse(): Promise { - const result = await request({ + const result = await $request({ method: 'options', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -8436,7 +4766,7 @@ export class SimpleService { */ public static async patchCallWithoutParametersAndResponse(): Promise { - const result = await request({ + const result = await $request({ method: 'patch', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -8451,7 +4781,7 @@ export class SimpleService { */ public static async postCallWithoutParametersAndResponse(): Promise { - const result = await request({ + const result = await $request({ method: 'post', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -8466,7 +4796,7 @@ export class SimpleService { */ public static async putCallWithoutParametersAndResponse(): Promise { - const result = await request({ + const result = await $request({ method: 'put', path: \`/api/v\${OpenAPI.VERSION}/simple\` }); @@ -8486,7 +4816,7 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/services/Type /* prettier-ignore */ import { ApiError, catchGenericError } from '../core/ApiError'; -import { request } from '../core/request'; +import { request as $request } from '../core/request'; import { OpenAPI } from '../core/OpenAPI'; export class TypesService { @@ -8517,7 +4847,7 @@ export class TypesService { id?: number ): Promise { - const result = await request({ + const result = await $request({ method: 'get', path: \`/api/v\${OpenAPI.VERSION}/types\`, query: { diff --git a/yarn.lock b/yarn.lock index 2c512fd3..b6f80a19 100644 --- a/yarn.lock +++ b/yarn.lock @@ -653,13 +653,6 @@ "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-transform-typescript" "^7.7.4" -"@babel/runtime@^7.0.0": - version "7.7.4" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.7.4.tgz#b23a856751e4bf099262f867767889c0e3fe175b" - integrity sha512-r24eVUUr0QqNZa+qrImUk8fn5SPhHq+IfYvIoIMg0do3GdK9sMdiLKP3GYVVaxpPKORgm8KRKaNTEhAjgIpLMw== - dependencies: - regenerator-runtime "^0.13.2" - "@babel/template@^7.4.0", "@babel/template@^7.7.4": version "7.7.4" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.7.4.tgz#428a7d9eecffe27deac0a98e23bf8e3675d2a77b" @@ -985,11 +978,6 @@ dependencies: "@types/yargs-parser" "*" -"@types/yup@0.26.26": - version "0.26.26" - resolved "https://registry.yarnpkg.com/@types/yup/-/yup-0.26.26.tgz#2e7065384ac2b7711271d8790f26ac7d73f6a33d" - integrity sha512-5cLJLd8NIT7OfJLi7ScquRn/NWfmewBqJ92nT/FYfdpgKzyUNcR4n2BKEOQ7mOG8WuJXgomIvNl5P3sn9Akd4A== - "@typescript-eslint/eslint-plugin@2.10.0": version "2.10.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.10.0.tgz#c4cb103275e555e8a7e9b3d14c5951eb6d431e70" @@ -2091,11 +2079,6 @@ flatted@^2.0.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.1.tgz#69e57caa8f0eacbc281d2e2cb458d46fdb449e08" integrity sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg== -fn-name@~2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/fn-name/-/fn-name-2.0.1.tgz#5214d7537a4d06a4a301c0cc262feb84188002e7" - integrity sha1-UhTXU3pNBqSjAcDMJi/rhBiAAuc= - for-in@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" @@ -3208,7 +3191,7 @@ lodash.unescape@4.0.1: resolved "https://registry.yarnpkg.com/lodash.unescape/-/lodash.unescape-4.0.1.tgz#bf2249886ce514cda112fae9218cdc065211fc9c" integrity sha1-vyJJiGzlFM2hEvrpIYzcBlIR/Jw= -lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15: +lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15: version "4.17.15" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== @@ -3813,11 +3796,6 @@ prompts@^2.0.1: kleur "^3.0.3" sisteransi "^1.0.3" -property-expr@^1.5.0: - version "1.5.1" - resolved "https://registry.yarnpkg.com/property-expr/-/property-expr-1.5.1.tgz#22e8706894a0c8e28d58735804f6ba3a3673314f" - integrity sha512-CGuc0VUTGthpJXL36ydB6jnbyOf/rAHFvmVrJlH+Rg0DqqLFQGAP6hIaxD/G0OAmBJPhXDHuEJigrp0e0wFV6g== - psl@^1.1.24, psl@^1.1.28: version "1.5.0" resolved "https://registry.yarnpkg.com/psl/-/psl-1.5.0.tgz#47fd1292def7fdb1e138cd78afa8814cebcf7b13" @@ -3910,11 +3888,6 @@ regenerate@^1.4.0: resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.0.tgz#4a856ec4b56e4077c557589cae85e7a4c8869a11" integrity sha512-1G6jJVDWrt0rK99kBjvEtziZNCICAuvIPkSiUFIQxVP06RCVpq3dmDo2oi6ABpYaDYaTRr67BEhL8r1wgEZZKg== -regenerator-runtime@^0.13.2: - version "0.13.3" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz#7cf6a77d8f5c6f60eb73c5fc1955b2ceb01e6bf5" - integrity sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw== - regenerator-transform@^0.14.0: version "0.14.1" resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.14.1.tgz#3b2fce4e1ab7732c08f665dfdb314749c7ddd2fb" @@ -4501,11 +4474,6 @@ symbol-tree@^3.2.2: resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw== -synchronous-promise@^2.0.6: - version "2.0.10" - resolved "https://registry.yarnpkg.com/synchronous-promise/-/synchronous-promise-2.0.10.tgz#e64c6fd3afd25f423963353043f4a68ebd397fd8" - integrity sha512-6PC+JRGmNjiG3kJ56ZMNWDPL8hjyghF5cMXIFOKg+NiwwEZZIvxTWd0pinWKyD227odg9ygF8xVhhz7gb8Uq7A== - table@^5.2.3: version "5.4.6" resolved "https://registry.yarnpkg.com/table/-/table-5.4.6.tgz#1292d19500ce3f86053b05f0e8e7e4a3bb21079e" @@ -4596,11 +4564,6 @@ to-regex@^3.0.1, to-regex@^3.0.2: regex-not "^1.0.2" safe-regex "^1.1.0" -toposort@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/toposort/-/toposort-2.0.2.tgz#ae21768175d1559d48bef35420b2f4962f09c330" - integrity sha1-riF2gXXRVZ1IvvNUILL0li8JwzA= - tough-cookie@^2.3.3, tough-cookie@^2.3.4: version "2.5.0" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2" @@ -4931,15 +4894,3 @@ yargs@^13.3.0: which-module "^2.0.0" y18n "^4.0.0" yargs-parser "^13.1.1" - -yup@0.27.0: - version "0.27.0" - resolved "https://registry.yarnpkg.com/yup/-/yup-0.27.0.tgz#f8cb198c8e7dd2124beddc2457571329096b06e7" - integrity sha512-v1yFnE4+u9za42gG/b/081E7uNW9mUj3qtkmelLbW5YPROZzSH/KUUyJu9Wt8vxFJcT9otL/eZopS0YK1L5yPQ== - dependencies: - "@babel/runtime" "^7.0.0" - fn-name "~2.0.1" - lodash "^4.17.11" - property-expr "^1.5.0" - synchronous-promise "^2.0.6" - toposort "^2.0.2"