From 00158b4af7c2e49051d5313f867fa98c30a2315d Mon Sep 17 00:00:00 2001 From: Ferdi Koomen Date: Sat, 23 Nov 2019 20:01:29 +0100 Subject: [PATCH] - Added tests --- .eslintrc.json | 12 +- package.json | 1 + src/index.ts | 6 +- src/openApi/v2/index.ts | 6 +- .../v2/interfaces/OpenApiParameter.d.ts | 2 +- .../v2/interfaces/OpenApiResponse.d.ts | 2 +- src/openApi/v2/interfaces/OpenApiSchema.d.ts | 2 +- src/openApi/v2/parser/getModel.ts | 10 +- src/openApi/v2/parser/getModelProperties.ts | 4 +- src/openApi/v2/parser/getOperation.ts | 13 +- src/openApi/v2/parser/getOperationErrors.ts | 2 +- .../v2/parser/getOperationParameter.ts | 10 +- .../v2/parser/getOperationParameters.ts | 12 +- src/openApi/v2/parser/getOperationResponse.ts | 58 + .../v2/parser/getOperationResponses.ts | 65 +- src/openApi/v2/parser/getOperationResults.ts | 4 +- src/openApi/v2/parser/getServices.ts | 4 +- src/openApi/v2/parser/getType.ts | 4 +- src/openApi/v3/index.ts | 6 +- src/openApi/v3/interfaces/OpenApiLink.d.ts | 2 +- src/openApi/v3/parser/getModel.ts | 10 +- src/openApi/v3/parser/getModelProperties.ts | 9 +- src/openApi/v3/parser/getModels.ts | 8 +- src/openApi/v3/parser/getOperation.ts | 13 +- src/openApi/v3/parser/getOperationErrors.ts | 2 +- .../v3/parser/getOperationParameter.ts | 18 +- .../v3/parser/getOperationParameters.ts | 12 +- src/openApi/v3/parser/getOperationResponse.ts | 57 + .../v3/parser/getOperationResponses.ts | 68 +- src/openApi/v3/parser/getOperationResults.ts | 4 +- src/openApi/v3/parser/getServices.ts | 4 +- src/openApi/v3/parser/getType.spec.ts | 8 +- src/openApi/v3/parser/getType.ts | 8 +- src/utils/getFileName.spec.ts | 2 +- src/utils/getModelNames.spec.ts | 2 +- src/utils/getOpenApiSpec.spec.ts | 2 +- src/utils/getServiceNames.spec.ts | 2 +- src/utils/readHandlebarsTemplate.spec.ts | 2 +- src/utils/readHandlebarsTemplate.ts | 2 +- src/utils/readHandlebarsTemplates.spec.ts | 4 +- src/utils/readHandlebarsTemplates.ts | 8 +- src/utils/writeClient.spec.ts | 8 +- src/utils/writeClient.ts | 18 +- src/utils/writeClientIndex.spec.ts | 2 +- src/utils/writeClientIndex.ts | 8 +- src/utils/writeClientModels.spec.ts | 4 +- src/utils/writeClientModels.ts | 6 +- src/utils/writeClientServices.spec.ts | 4 +- src/utils/writeClientServices.ts | 6 +- src/utils/writeClientSettings.ts | 4 +- test/__snapshots__/index.spec.js.snap | 4608 ++++++++++++++++- test/index.spec.js | 95 +- yarn.lock | 81 +- 53 files changed, 4931 insertions(+), 383 deletions(-) create mode 100644 src/openApi/v2/parser/getOperationResponse.ts create mode 100644 src/openApi/v3/parser/getOperationResponse.ts diff --git a/.eslintrc.json b/.eslintrc.json index bd4d9ab0..61304779 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -10,14 +10,20 @@ "node": true, "jest": true }, + "plugins": [ + "sort-imports-es6-autofix" + ], "rules": { "@typescript-eslint/no-explicit-any": 0, "@typescript-eslint/no-inferrable-types": 0, "@typescript-eslint/no-non-null-assertion": 0, "@typescript-eslint/ban-ts-ignore": 0, "@typescript-eslint/explicit-function-return-type": 0, - "prettier/prettier": [ - "error" - ] + "sort-imports-es6-autofix/sort-imports-es6": [2, { + "ignoreCase": false, + "ignoreMemberSort": false, + "memberSyntaxSortOrder": ["none", "all", "multiple", "single"] + }], + "prettier/prettier": ["error"] } } diff --git a/package.json b/package.json index fa0aa4ee..94ddde6b 100644 --- a/package.json +++ b/package.json @@ -79,6 +79,7 @@ "eslint": "6.6.0", "eslint-config-prettier": "6.7.0", "eslint-plugin-prettier": "3.1.1", + "eslint-plugin-sort-imports-es6-autofix": "0.5.0", "glob": "7.1.6", "handlebars": "4.5.3", "jest": "24.9.0", diff --git a/src/index.ts b/src/index.ts index 0f1e32e0..392d1227 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,11 +1,11 @@ import * as path from 'path'; +import * as ts from 'typescript'; +import { OpenApiVersion, getOpenApiVersion } from './utils/getOpenApiVersion'; +import { getOpenApiSpec } from './utils/getOpenApiSpec'; import { parse as parseV2 } from './openApi/v2'; import { parse as parseV3 } from './openApi/v3'; import { readHandlebarsTemplates } from './utils/readHandlebarsTemplates'; -import { getOpenApiSpec } from './utils/getOpenApiSpec'; import { writeClient } from './utils/writeClient'; -import * as ts from 'typescript'; -import { getOpenApiVersion, OpenApiVersion } from './utils/getOpenApiVersion'; export enum Language { TYPESCRIPT = 'typescript', diff --git a/src/openApi/v2/index.ts b/src/openApi/v2/index.ts index dbfb034b..734b80d4 100644 --- a/src/openApi/v2/index.ts +++ b/src/openApi/v2/index.ts @@ -1,9 +1,9 @@ -import { OpenApi } from './interfaces/OpenApi'; import { Client } from '../../client/interfaces/Client'; -import { getServer } from './parser/getServer'; -import { getServices } from './parser/getServices'; +import { OpenApi } from './interfaces/OpenApi'; import { getModels } from './parser/getModels'; +import { getServer } from './parser/getServer'; import { getServiceVersion } from './parser/getServiceVersion'; +import { getServices } from './parser/getServices'; /** * Parse the OpenAPI specification to a Client model that contains diff --git a/src/openApi/v2/interfaces/OpenApiParameter.d.ts b/src/openApi/v2/interfaces/OpenApiParameter.d.ts index cffa15c5..d6b56960 100644 --- a/src/openApi/v2/interfaces/OpenApiParameter.d.ts +++ b/src/openApi/v2/interfaces/OpenApiParameter.d.ts @@ -1,6 +1,6 @@ import { OpenApiItems } from './OpenApiItems'; -import { OpenApiSchema } from './OpenApiSchema'; import { OpenApiReference } from './OpenApiReference'; +import { OpenApiSchema } from './OpenApiSchema'; /** * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#parameterObject diff --git a/src/openApi/v2/interfaces/OpenApiResponse.d.ts b/src/openApi/v2/interfaces/OpenApiResponse.d.ts index 28d88129..6b42777c 100644 --- a/src/openApi/v2/interfaces/OpenApiResponse.d.ts +++ b/src/openApi/v2/interfaces/OpenApiResponse.d.ts @@ -1,8 +1,8 @@ import { Dictionary } from '../../../utils/types'; import { OpenApiExample } from './OpenApiExample'; import { OpenApiHeader } from './OpenApiHeader'; -import { OpenApiSchema } from './OpenApiSchema'; import { OpenApiReference } from './OpenApiReference'; +import { OpenApiSchema } from './OpenApiSchema'; /** * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#responseObject diff --git a/src/openApi/v2/interfaces/OpenApiSchema.d.ts b/src/openApi/v2/interfaces/OpenApiSchema.d.ts index 7b64637a..7f36b6fa 100644 --- a/src/openApi/v2/interfaces/OpenApiSchema.d.ts +++ b/src/openApi/v2/interfaces/OpenApiSchema.d.ts @@ -1,7 +1,7 @@ import { Dictionary } from '../../../utils/types'; import { OpenApiExternalDocs } from './OpenApiExternalDocs'; -import { OpenApiXml } from './OpenApiXml'; import { OpenApiReference } from './OpenApiReference'; +import { OpenApiXml } from './OpenApiXml'; /** * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#schemaObject diff --git a/src/openApi/v2/parser/getModel.ts b/src/openApi/v2/parser/getModel.ts index f69ea813..898524c6 100644 --- a/src/openApi/v2/parser/getModel.ts +++ b/src/openApi/v2/parser/getModel.ts @@ -1,13 +1,13 @@ +import { Model } from '../../../client/interfaces/Model'; import { OpenApi } from '../interfaces/OpenApi'; import { OpenApiSchema } from '../interfaces/OpenApiSchema'; -import { getComment } from './getComment'; -import { getType } from './getType'; -import { Model } from '../../../client/interfaces/Model'; import { PrimaryType } from './constants'; -import { getEnumType } from './getEnumType'; +import { getComment } from './getComment'; import { getEnum } from './getEnum'; import { getEnumFromDescription } from './getEnumFromDescription'; +import { getEnumType } from './getEnumType'; import { getModelProperties } from './getModelProperties'; +import { getType } from './getType'; export function getModel(openApi: OpenApi, definition: OpenApiSchema, isProperty: boolean = false, name: string = ''): Model { const model: Model = { @@ -20,8 +20,8 @@ export function getModel(openApi: OpenApi, definition: OpenApiSchema, isProperty description: getComment(definition.description), isProperty: isProperty, isReadOnly: definition.readOnly || false, - isRequired: false, isNullable: false, + isRequired: false, imports: [], extends: [], enum: [], diff --git a/src/openApi/v2/parser/getModelProperties.ts b/src/openApi/v2/parser/getModelProperties.ts index 07edbd65..bae1e9dc 100644 --- a/src/openApi/v2/parser/getModelProperties.ts +++ b/src/openApi/v2/parser/getModelProperties.ts @@ -1,9 +1,9 @@ +import { Model } from '../../../client/interfaces/Model'; import { OpenApi } from '../interfaces/OpenApi'; import { OpenApiSchema } from '../interfaces/OpenApiSchema'; import { getComment } from './getComment'; -import { getType } from './getType'; -import { Model } from '../../../client/interfaces/Model'; import { getModel } from './getModel'; +import { getType } from './getType'; export function getModelProperties(openApi: OpenApi, definition: OpenApiSchema): Model[] { const models: Model[] = []; diff --git a/src/openApi/v2/parser/getOperation.ts b/src/openApi/v2/parser/getOperation.ts index 23007b82..b3828457 100644 --- a/src/openApi/v2/parser/getOperation.ts +++ b/src/openApi/v2/parser/getOperation.ts @@ -1,15 +1,14 @@ -import { Service } from '../../../client/interfaces/Service'; -import { getServiceClassName } from './getServiceClassName'; -import { OpenApiOperation } from '../interfaces/OpenApiOperation'; -import { getOperationName } from './getOperationName'; -import { getOperationPath } from './getOperationPath'; import { OpenApi } from '../interfaces/OpenApi'; -import { getComment } from './getComment'; +import { OpenApiOperation } from '../interfaces/OpenApiOperation'; import { Operation } from '../../../client/interfaces/Operation'; +import { getComment } from './getComment'; +import { getOperationErrors } from './getOperationErrors'; +import { getOperationName } from './getOperationName'; import { getOperationParameters } from './getOperationParameters'; +import { getOperationPath } from './getOperationPath'; import { getOperationResponses } from './getOperationResponses'; import { getOperationResults } from './getOperationResults'; -import { getOperationErrors } from './getOperationErrors'; +import { getServiceClassName } from './getServiceClassName'; export function getOperation(openApi: OpenApi, url: string, method: string, op: OpenApiOperation): Operation { const serviceName = (op.tags && op.tags[0]) || 'Service'; diff --git a/src/openApi/v2/parser/getOperationErrors.ts b/src/openApi/v2/parser/getOperationErrors.ts index 2615e074..ab6edbb6 100644 --- a/src/openApi/v2/parser/getOperationErrors.ts +++ b/src/openApi/v2/parser/getOperationErrors.ts @@ -1,5 +1,5 @@ -import { OperationResponse } from '../../../client/interfaces/OperationResponse'; import { OperationError } from '../../../client/interfaces/OperationError'; +import { OperationResponse } from '../../../client/interfaces/OperationResponse'; export function getOperationErrors(operationResponses: OperationResponse[]): OperationError[] { return operationResponses diff --git a/src/openApi/v2/parser/getOperationParameter.ts b/src/openApi/v2/parser/getOperationParameter.ts index 9040ce2d..eef5fbc5 100644 --- a/src/openApi/v2/parser/getOperationParameter.ts +++ b/src/openApi/v2/parser/getOperationParameter.ts @@ -1,15 +1,15 @@ -import { OpenApiParameter } from '../interfaces/OpenApiParameter'; import { OpenApi } from '../interfaces/OpenApi'; -import { getComment } from './getComment'; -import { getOperationParameterName } from './getOperationParameterName'; +import { OpenApiParameter } from '../interfaces/OpenApiParameter'; import { OperationParameter } from '../../../client/interfaces/OperationParameter'; import { PrimaryType } from './constants'; -import { getType } from './getType'; +import { getComment } from './getComment'; import { getEnum } from './getEnum'; -import { getEnumType } from './getEnumType'; import { getEnumFromDescription } from './getEnumFromDescription'; +import { getEnumType } from './getEnumType'; import { getModel } from './getModel'; import { getOperationParameterDefault } from './getOperationParameterDefault'; +import { getOperationParameterName } from './getOperationParameterName'; +import { getType } from './getType'; export function getOperationParameter(openApi: OpenApi, parameter: OpenApiParameter): OperationParameter { const operationParameter: OperationParameter = { diff --git a/src/openApi/v2/parser/getOperationParameters.ts b/src/openApi/v2/parser/getOperationParameters.ts index eff8b29f..7faea9d4 100644 --- a/src/openApi/v2/parser/getOperationParameters.ts +++ b/src/openApi/v2/parser/getOperationParameters.ts @@ -1,9 +1,9 @@ -import { OpenApiParameter } from '../interfaces/OpenApiParameter'; import { OpenApi } from '../interfaces/OpenApi'; -import { getRef } from './getRef'; -import { OperationParameters } from '../../../client/interfaces/OperationParameters'; +import { OpenApiParameter } from '../interfaces/OpenApiParameter'; import { OperationParameter } from '../../../client/interfaces/OperationParameter'; +import { OperationParameters } from '../../../client/interfaces/OperationParameters'; import { getOperationParameter } from './getOperationParameter'; +import { getRef } from './getRef'; function sortByRequired(a: OperationParameter, b: OperationParameter): number { return a.isRequired && !b.isRequired ? -1 : !a.isRequired && b.isRequired ? 1 : 0; @@ -21,9 +21,9 @@ export function getOperationParameters(openApi: OpenApi, parameters: OpenApiPara }; // Iterate over the parameters - parameters.forEach(parameter => { - const paramRef = getRef(openApi, parameter); - const param = getOperationParameter(openApi, paramRef); + parameters.forEach(parameterOrReference => { + const parameter = getRef(openApi, parameterOrReference); + const param = getOperationParameter(openApi, parameter); // We ignore the "api-version" param, since we do not want to add this // as the first / default parameter for each of the service calls. diff --git a/src/openApi/v2/parser/getOperationResponse.ts b/src/openApi/v2/parser/getOperationResponse.ts new file mode 100644 index 00000000..200e5700 --- /dev/null +++ b/src/openApi/v2/parser/getOperationResponse.ts @@ -0,0 +1,58 @@ +import { OpenApi } from '../interfaces/OpenApi'; +import { OpenApiResponse } from '../interfaces/OpenApiResponse'; +import { OperationResponse } from '../../../client/interfaces/OperationResponse'; +import { PrimaryType } from './constants'; +import { getComment } from './getComment'; +import { getModel } from './getModel'; +import { getType } from './getType'; + +export function getOperationResponse(openApi: OpenApi, response: OpenApiResponse, responseCode: number): OperationResponse { + const operationResponse: OperationResponse = { + name: '', + code: responseCode, + description: getComment(response.description)!, + export: 'generic', + type: PrimaryType.OBJECT, + base: PrimaryType.OBJECT, + template: null, + link: null, + isProperty: false, + isReadOnly: false, + isRequired: false, + isNullable: false, + imports: [], + extends: [], + enum: [], + enums: [], + properties: [], + }; + + // If this response has a schema, then we need to check two things: + // if this is a reference then the parameter is just the 'name' of + // this reference type. Otherwise it might be a complex schema and + // then we need to parse the schema! + if (response.schema) { + if (response.schema.$ref) { + const model = getType(response.schema.$ref); + operationResponse.export = 'reference'; + operationResponse.type = model.type; + operationResponse.base = model.base; + operationResponse.template = model.template; + operationResponse.imports.push(...model.imports); + } else { + const model = getModel(openApi, response.schema); + operationResponse.export = model.export; + operationResponse.type = model.type; + operationResponse.base = model.base; + operationResponse.template = model.template; + operationResponse.link = model.link; + operationResponse.imports.push(...model.imports); + operationResponse.extends.push(...model.extends); + operationResponse.enum.push(...model.enum); + operationResponse.enums.push(...model.enums); + operationResponse.properties.push(...model.properties); + } + } + + return operationResponse; +} diff --git a/src/openApi/v2/parser/getOperationResponses.ts b/src/openApi/v2/parser/getOperationResponses.ts index 96533044..87621291 100644 --- a/src/openApi/v2/parser/getOperationResponses.ts +++ b/src/openApi/v2/parser/getOperationResponses.ts @@ -1,13 +1,10 @@ -import { OpenApiResponses } from '../interfaces/OpenApiResponses'; -import { getOperationResponseCode } from './getOperationResponseCode'; -import { OpenApiResponse } from '../interfaces/OpenApiResponse'; -import { getRef } from './getRef'; import { OpenApi } from '../interfaces/OpenApi'; +import { OpenApiResponse } from '../interfaces/OpenApiResponse'; +import { OpenApiResponses } from '../interfaces/OpenApiResponses'; import { OperationResponse } from '../../../client/interfaces/OperationResponse'; -import { getType } from './getType'; -import { getModel } from './getModel'; -import { getComment } from './getComment'; -import { PrimaryType } from './constants'; +import { getOperationResponse } from './getOperationResponse'; +import { getOperationResponseCode } from './getOperationResponseCode'; +import { getRef } from './getRef'; export function getOperationResponses(openApi: OpenApi, responses: OpenApiResponses): OperationResponse[] { const operationResponses: OperationResponse[] = []; @@ -20,58 +17,8 @@ export function getOperationResponses(openApi: OpenApi, responses: OpenApiRespon const response = getRef(openApi, responseOrReference); const responseCode = getOperationResponseCode(code); - // If there is a response code then we check what data we get back, - // if there is no typed data, we just return so the user is still - // free to do their own casting if needed. if (responseCode) { - const operationResponse: OperationResponse = { - name: '', - code: responseCode, - description: getComment(response.description)!, - export: 'generic', - type: PrimaryType.OBJECT, - base: PrimaryType.OBJECT, - template: null, - link: null, - isProperty: false, - isReadOnly: false, - isRequired: false, - isNullable: false, - imports: [], - extends: [], - enum: [], - enums: [], - properties: [], - }; - - // If this response has a schema, then we need to check two things: - // if this is a reference then the parameter is just the 'name' of - // this reference type. Otherwise it might be a complex schema and - // then we need to parse the schema! - if (response.schema) { - if (response.schema.$ref) { - const model = getType(response.schema.$ref); - operationResponse.export = 'reference'; - operationResponse.type = model.type; - operationResponse.base = model.base; - operationResponse.template = model.template; - operationResponse.imports.push(...model.imports); - } else { - const model = getModel(openApi, response.schema); - operationResponse.export = model.export; - operationResponse.type = model.type; - operationResponse.base = model.base; - operationResponse.template = model.template; - operationResponse.link = model.link; - operationResponse.imports.push(...model.imports); - operationResponse.extends.push(...model.extends); - operationResponse.enum.push(...model.enum); - operationResponse.enums.push(...model.enums); - operationResponse.properties.push(...model.properties); - } - } - - operationResponses.push(operationResponse); + operationResponses.push(getOperationResponse(openApi, response, responseCode)); } } } diff --git a/src/openApi/v2/parser/getOperationResults.ts b/src/openApi/v2/parser/getOperationResults.ts index 57456799..fdb76359 100644 --- a/src/openApi/v2/parser/getOperationResults.ts +++ b/src/openApi/v2/parser/getOperationResults.ts @@ -1,6 +1,6 @@ -import { PrimaryType } from './constants'; -import { OperationResponse } from '../../../client/interfaces/OperationResponse'; import { Model } from '../../../client/interfaces/Model'; +import { OperationResponse } from '../../../client/interfaces/OperationResponse'; +import { PrimaryType } from './constants'; function areEqual(a: Model, b: Model): boolean { const equal = a.type === b.type && a.base === b.base && a.template === b.template; diff --git a/src/openApi/v2/parser/getServices.ts b/src/openApi/v2/parser/getServices.ts index e9905a5e..ed18b28b 100644 --- a/src/openApi/v2/parser/getServices.ts +++ b/src/openApi/v2/parser/getServices.ts @@ -1,6 +1,6 @@ -import { Service } from '../../../client/interfaces/Service'; -import { OpenApi } from '../interfaces/OpenApi'; import { Method } from './constants'; +import { OpenApi } from '../interfaces/OpenApi'; +import { Service } from '../../../client/interfaces/Service'; import { getOperation } from './getOperation'; /** diff --git a/src/openApi/v2/parser/getType.ts b/src/openApi/v2/parser/getType.ts index 7ab373f4..3c12cc67 100644 --- a/src/openApi/v2/parser/getType.ts +++ b/src/openApi/v2/parser/getType.ts @@ -1,7 +1,7 @@ -import { stripNamespace } from './stripNamespace'; +import { PrimaryType } from './constants'; import { Type } from '../../../client/interfaces/Type'; import { getMappedType, hasMappedType } from './getMappedType'; -import { PrimaryType } from './constants'; +import { stripNamespace } from './stripNamespace'; /** * Parse any string value into a type object. diff --git a/src/openApi/v3/index.ts b/src/openApi/v3/index.ts index 39d5033b..734b80d4 100644 --- a/src/openApi/v3/index.ts +++ b/src/openApi/v3/index.ts @@ -1,9 +1,9 @@ -import { OpenApi } from './interfaces/OpenApi'; import { Client } from '../../client/interfaces/Client'; -import { getServer } from './parser/getServer'; +import { OpenApi } from './interfaces/OpenApi'; import { getModels } from './parser/getModels'; -import { getServices } from './parser/getServices'; +import { getServer } from './parser/getServer'; import { getServiceVersion } from './parser/getServiceVersion'; +import { getServices } from './parser/getServices'; /** * Parse the OpenAPI specification to a Client model that contains diff --git a/src/openApi/v3/interfaces/OpenApiLink.d.ts b/src/openApi/v3/interfaces/OpenApiLink.d.ts index 7b8dae67..9797217e 100644 --- a/src/openApi/v3/interfaces/OpenApiLink.d.ts +++ b/src/openApi/v3/interfaces/OpenApiLink.d.ts @@ -1,6 +1,6 @@ import { Dictionary } from '../../../utils/types'; -import { OpenApiServer } from './OpenApiServer'; import { OpenApiReference } from './OpenApiReference'; +import { OpenApiServer } from './OpenApiServer'; /** * https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#linkObject diff --git a/src/openApi/v3/parser/getModel.ts b/src/openApi/v3/parser/getModel.ts index f69ea813..bcc606c4 100644 --- a/src/openApi/v3/parser/getModel.ts +++ b/src/openApi/v3/parser/getModel.ts @@ -1,13 +1,13 @@ +import { Model } from '../../../client/interfaces/Model'; import { OpenApi } from '../interfaces/OpenApi'; import { OpenApiSchema } from '../interfaces/OpenApiSchema'; -import { getComment } from './getComment'; -import { getType } from './getType'; -import { Model } from '../../../client/interfaces/Model'; import { PrimaryType } from './constants'; -import { getEnumType } from './getEnumType'; +import { getComment } from './getComment'; import { getEnum } from './getEnum'; import { getEnumFromDescription } from './getEnumFromDescription'; +import { getEnumType } from './getEnumType'; import { getModelProperties } from './getModelProperties'; +import { getType } from './getType'; export function getModel(openApi: OpenApi, definition: OpenApiSchema, isProperty: boolean = false, name: string = ''): Model { const model: Model = { @@ -20,8 +20,8 @@ export function getModel(openApi: OpenApi, definition: OpenApiSchema, isProperty description: getComment(definition.description), isProperty: isProperty, isReadOnly: definition.readOnly || false, + isNullable: definition.nullable || false, isRequired: false, - isNullable: false, imports: [], extends: [], enum: [], diff --git a/src/openApi/v3/parser/getModelProperties.ts b/src/openApi/v3/parser/getModelProperties.ts index 07edbd65..22fd92a1 100644 --- a/src/openApi/v3/parser/getModelProperties.ts +++ b/src/openApi/v3/parser/getModelProperties.ts @@ -1,9 +1,9 @@ +import { Model } from '../../../client/interfaces/Model'; import { OpenApi } from '../interfaces/OpenApi'; import { OpenApiSchema } from '../interfaces/OpenApiSchema'; import { getComment } from './getComment'; -import { getType } from './getType'; -import { Model } from '../../../client/interfaces/Model'; import { getModel } from './getModel'; +import { getType } from './getType'; export function getModelProperties(openApi: OpenApi, definition: OpenApiSchema): Model[] { const models: Model[] = []; @@ -12,6 +12,7 @@ export function getModelProperties(openApi: OpenApi, definition: OpenApiSchema): const property = definition.properties[propertyName]; const propertyRequired = !!(definition.required && definition.required.includes(propertyName)); const propertyReadOnly = !!property.readOnly; + const propertyNullable = !!property.nullable; if (property.$ref) { const model = getType(property.$ref); models.push({ @@ -25,7 +26,7 @@ export function getModelProperties(openApi: OpenApi, definition: OpenApiSchema): isProperty: true, isReadOnly: propertyReadOnly, isRequired: propertyRequired, - isNullable: false, + isNullable: propertyNullable, imports: model.imports, extends: [], enum: [], @@ -45,7 +46,7 @@ export function getModelProperties(openApi: OpenApi, definition: OpenApiSchema): isProperty: true, isReadOnly: propertyReadOnly, isRequired: propertyRequired, - isNullable: false, + isNullable: propertyNullable, imports: model.imports, extends: model.extends, enum: model.enum, diff --git a/src/openApi/v3/parser/getModels.ts b/src/openApi/v3/parser/getModels.ts index daf488a5..16204236 100644 --- a/src/openApi/v3/parser/getModels.ts +++ b/src/openApi/v3/parser/getModels.ts @@ -1,7 +1,7 @@ -import {Model} from '../../../client/interfaces/Model'; -import {OpenApi} from '../interfaces/OpenApi'; -import {getModel} from './getModel'; -import {getType} from './getType'; +import { Model } from '../../../client/interfaces/Model'; +import { OpenApi } from '../interfaces/OpenApi'; +import { getModel } from './getModel'; +import { getType } from './getType'; export function getModels(openApi: OpenApi): Map { const models = new Map(); diff --git a/src/openApi/v3/parser/getOperation.ts b/src/openApi/v3/parser/getOperation.ts index 23007b82..b3828457 100644 --- a/src/openApi/v3/parser/getOperation.ts +++ b/src/openApi/v3/parser/getOperation.ts @@ -1,15 +1,14 @@ -import { Service } from '../../../client/interfaces/Service'; -import { getServiceClassName } from './getServiceClassName'; -import { OpenApiOperation } from '../interfaces/OpenApiOperation'; -import { getOperationName } from './getOperationName'; -import { getOperationPath } from './getOperationPath'; import { OpenApi } from '../interfaces/OpenApi'; -import { getComment } from './getComment'; +import { OpenApiOperation } from '../interfaces/OpenApiOperation'; import { Operation } from '../../../client/interfaces/Operation'; +import { getComment } from './getComment'; +import { getOperationErrors } from './getOperationErrors'; +import { getOperationName } from './getOperationName'; import { getOperationParameters } from './getOperationParameters'; +import { getOperationPath } from './getOperationPath'; import { getOperationResponses } from './getOperationResponses'; import { getOperationResults } from './getOperationResults'; -import { getOperationErrors } from './getOperationErrors'; +import { getServiceClassName } from './getServiceClassName'; export function getOperation(openApi: OpenApi, url: string, method: string, op: OpenApiOperation): Operation { const serviceName = (op.tags && op.tags[0]) || 'Service'; diff --git a/src/openApi/v3/parser/getOperationErrors.ts b/src/openApi/v3/parser/getOperationErrors.ts index 2615e074..ab6edbb6 100644 --- a/src/openApi/v3/parser/getOperationErrors.ts +++ b/src/openApi/v3/parser/getOperationErrors.ts @@ -1,5 +1,5 @@ -import { OperationResponse } from '../../../client/interfaces/OperationResponse'; import { OperationError } from '../../../client/interfaces/OperationError'; +import { OperationResponse } from '../../../client/interfaces/OperationResponse'; export function getOperationErrors(operationResponses: OperationResponse[]): OperationError[] { return operationResponses diff --git a/src/openApi/v3/parser/getOperationParameter.ts b/src/openApi/v3/parser/getOperationParameter.ts index 8acfab6a..b52dd582 100644 --- a/src/openApi/v3/parser/getOperationParameter.ts +++ b/src/openApi/v3/parser/getOperationParameter.ts @@ -1,11 +1,11 @@ -import { OpenApiParameter } from '../interfaces/OpenApiParameter'; import { OpenApi } from '../interfaces/OpenApi'; -import { getComment } from './getComment'; -import { getOperationParameterName } from './getOperationParameterName'; +import { OpenApiParameter } from '../interfaces/OpenApiParameter'; import { OperationParameter } from '../../../client/interfaces/OperationParameter'; import { PrimaryType } from './constants'; -import { getType } from './getType'; +import { getComment } from './getComment'; import { getModel } from './getModel'; +import { getOperationParameterName } from './getOperationParameterName'; +import { getType } from './getType'; export function getOperationParameter(openApi: OpenApi, parameter: OpenApiParameter): OperationParameter { const operationParameter: OperationParameter = { @@ -30,6 +30,16 @@ export function getOperationParameter(openApi: OpenApi, parameter: OpenApiParame properties: [], }; + if (parameter.$ref) { + const definitionRef = getType(parameter.$ref); + operationParameter.export = 'reference'; + operationParameter.type = definitionRef.type; + operationParameter.base = definitionRef.base; + operationParameter.template = definitionRef.template; + operationParameter.imports.push(...definitionRef.imports); + return operationParameter; + } + if (parameter.schema) { if (parameter.schema.$ref) { const model = getType(parameter.schema.$ref); diff --git a/src/openApi/v3/parser/getOperationParameters.ts b/src/openApi/v3/parser/getOperationParameters.ts index c4af435f..ff27d159 100644 --- a/src/openApi/v3/parser/getOperationParameters.ts +++ b/src/openApi/v3/parser/getOperationParameters.ts @@ -1,9 +1,9 @@ -import { OpenApiParameter } from '../interfaces/OpenApiParameter'; import { OpenApi } from '../interfaces/OpenApi'; -import { getRef } from './getRef'; -import { OperationParameters } from '../../../client/interfaces/OperationParameters'; +import { OpenApiParameter } from '../interfaces/OpenApiParameter'; import { OperationParameter } from '../../../client/interfaces/OperationParameter'; +import { OperationParameters } from '../../../client/interfaces/OperationParameters'; import { getOperationParameter } from './getOperationParameter'; +import { getRef } from './getRef'; function sortByRequired(a: OperationParameter, b: OperationParameter): number { return a.isRequired && !b.isRequired ? -1 : !a.isRequired && b.isRequired ? 1 : 0; @@ -21,9 +21,9 @@ export function getOperationParameters(openApi: OpenApi, parameters: OpenApiPara }; // Iterate over the parameters - parameters.forEach(parameter => { - const paramRef = getRef(openApi, parameter); - const param = getOperationParameter(openApi, paramRef); + parameters.forEach(parameterOrReference => { + const parameter = getRef(openApi, parameterOrReference); + const param = getOperationParameter(openApi, parameter); // We ignore the "api-version" param, since we do not want to add this // as the first / default parameter for each of the service calls. diff --git a/src/openApi/v3/parser/getOperationResponse.ts b/src/openApi/v3/parser/getOperationResponse.ts new file mode 100644 index 00000000..cb04bb1d --- /dev/null +++ b/src/openApi/v3/parser/getOperationResponse.ts @@ -0,0 +1,57 @@ +import { OpenApi } from '../interfaces/OpenApi'; +import { OpenApiResponse } from '../interfaces/OpenApiResponse'; +import { OperationResponse } from '../../../client/interfaces/OperationResponse'; +import { PrimaryType } from './constants'; +import { getComment } from './getComment'; + +export function getOperationResponse(openApi: OpenApi, response: OpenApiResponse, responseCode: number): OperationResponse { + const operationResponse: OperationResponse = { + name: '', + code: responseCode, + description: getComment(response.description)!, + export: 'generic', + type: PrimaryType.OBJECT, + base: PrimaryType.OBJECT, + template: null, + link: null, + isProperty: false, + isReadOnly: false, + isRequired: false, + isNullable: false, + imports: [], + extends: [], + enum: [], + enums: [], + properties: [], + }; + + // If this response has a schema, then we need to check two things: + // if this is a reference then the parameter is just the 'name' of + // this reference type. Otherwise it might be a complex schema and + // then we need to parse the schema! + + // if (response.schema) { + // if (response.schema.$ref) { + // const model = getType(response.schema.$ref); + // operationResponse.export = 'reference'; + // operationResponse.type = model.type; + // operationResponse.base = model.base; + // operationResponse.template = model.template; + // operationResponse.imports.push(...model.imports); + // } else { + // const model = getModel(openApi, response.schema); + // operationResponse.export = model.export; + // operationResponse.type = model.type; + // operationResponse.base = model.base; + // operationResponse.template = model.template; + // operationResponse.link = model.link; + // operationResponse.imports.push(...model.imports); + // operationResponse.extends.push(...model.extends); + // operationResponse.enum.push(...model.enum); + // operationResponse.enums.push(...model.enums); + // operationResponse.properties.push(...model.properties); + // } + // } + + return operationResponse; +} diff --git a/src/openApi/v3/parser/getOperationResponses.ts b/src/openApi/v3/parser/getOperationResponses.ts index 98b16434..87621291 100644 --- a/src/openApi/v3/parser/getOperationResponses.ts +++ b/src/openApi/v3/parser/getOperationResponses.ts @@ -1,13 +1,10 @@ -import { OpenApiResponses } from '../interfaces/OpenApiResponses'; -import { getOperationResponseCode } from './getOperationResponseCode'; -import { OpenApiResponse } from '../interfaces/OpenApiResponse'; -import { getRef } from './getRef'; import { OpenApi } from '../interfaces/OpenApi'; +import { OpenApiResponse } from '../interfaces/OpenApiResponse'; +import { OpenApiResponses } from '../interfaces/OpenApiResponses'; import { OperationResponse } from '../../../client/interfaces/OperationResponse'; -import { getType } from './getType'; -import { getModel } from './getModel'; -import { getComment } from './getComment'; -import { PrimaryType } from './constants'; +import { getOperationResponse } from './getOperationResponse'; +import { getOperationResponseCode } from './getOperationResponseCode'; +import { getRef } from './getRef'; export function getOperationResponses(openApi: OpenApi, responses: OpenApiResponses): OperationResponse[] { const operationResponses: OperationResponse[] = []; @@ -20,61 +17,8 @@ export function getOperationResponses(openApi: OpenApi, responses: OpenApiRespon const response = getRef(openApi, responseOrReference); const responseCode = getOperationResponseCode(code); - // If there is a response code then we check what data we get back, - // if there is no typed data, we just return so the user is still - // free to do their own casting if needed. if (responseCode) { - const operationResponse: OperationResponse = { - name: '', - code: responseCode, - description: getComment(response.description)!, - export: 'generic', - type: PrimaryType.OBJECT, - base: PrimaryType.OBJECT, - template: null, - link: null, - isProperty: false, - isReadOnly: false, - isRequired: false, - isNullable: false, - imports: [], - extends: [], - enum: [], - enums: [], - properties: [], - }; - - // If this response has a schema, then we need to check two things: - // if this is a reference then the parameter is just the 'name' of - // this reference type. Otherwise it might be a complex schema and - // then we need to parse the schema! - - // TODO: Needs content! - - // if (response.schema) { - // if (response.schema.$ref) { - // const model = getType(response.schema.$ref); - // operationResponse.export = 'reference'; - // operationResponse.type = model.type; - // operationResponse.base = model.base; - // operationResponse.template = model.template; - // operationResponse.imports.push(...model.imports); - // } else { - // const model = getModel(openApi, response.schema); - // operationResponse.export = model.export; - // operationResponse.type = model.type; - // operationResponse.base = model.base; - // operationResponse.template = model.template; - // operationResponse.link = model.link; - // operationResponse.imports.push(...model.imports); - // operationResponse.extends.push(...model.extends); - // operationResponse.enum.push(...model.enum); - // operationResponse.enums.push(...model.enums); - // operationResponse.properties.push(...model.properties); - // } - // } - - operationResponses.push(operationResponse); + operationResponses.push(getOperationResponse(openApi, response, responseCode)); } } } diff --git a/src/openApi/v3/parser/getOperationResults.ts b/src/openApi/v3/parser/getOperationResults.ts index 57456799..fdb76359 100644 --- a/src/openApi/v3/parser/getOperationResults.ts +++ b/src/openApi/v3/parser/getOperationResults.ts @@ -1,6 +1,6 @@ -import { PrimaryType } from './constants'; -import { OperationResponse } from '../../../client/interfaces/OperationResponse'; import { Model } from '../../../client/interfaces/Model'; +import { OperationResponse } from '../../../client/interfaces/OperationResponse'; +import { PrimaryType } from './constants'; function areEqual(a: Model, b: Model): boolean { const equal = a.type === b.type && a.base === b.base && a.template === b.template; diff --git a/src/openApi/v3/parser/getServices.ts b/src/openApi/v3/parser/getServices.ts index e9905a5e..ed18b28b 100644 --- a/src/openApi/v3/parser/getServices.ts +++ b/src/openApi/v3/parser/getServices.ts @@ -1,6 +1,6 @@ -import { Service } from '../../../client/interfaces/Service'; -import { OpenApi } from '../interfaces/OpenApi'; import { Method } from './constants'; +import { OpenApi } from '../interfaces/OpenApi'; +import { Service } from '../../../client/interfaces/Service'; import { getOperation } from './getOperation'; /** diff --git a/src/openApi/v3/parser/getType.spec.ts b/src/openApi/v3/parser/getType.spec.ts index a3e7e422..70c061e3 100644 --- a/src/openApi/v3/parser/getType.spec.ts +++ b/src/openApi/v3/parser/getType.spec.ts @@ -26,7 +26,7 @@ describe('getType', () => { }); it('should convert template with primary', () => { - const type = getType('#/definitions/Link[String]'); + const type = getType('#/components/schemas/Link[String]'); expect(type.type).toEqual('Link'); expect(type.base).toEqual('Link'); expect(type.template).toEqual('string'); @@ -34,7 +34,7 @@ describe('getType', () => { }); it('should convert template with model', () => { - const type = getType('#/definitions/Link[Model]'); + const type = getType('#/components/schemas/Link[Model]'); expect(type.type).toEqual('Link'); expect(type.base).toEqual('Link'); expect(type.template).toEqual('Model'); @@ -42,7 +42,7 @@ describe('getType', () => { }); it('should have double imports', () => { - const type = getType('#/definitions/Link[Link]'); + const type = getType('#/components/schemas/Link[Link]'); expect(type.type).toEqual('Link'); expect(type.base).toEqual('Link'); expect(type.template).toEqual('Link'); @@ -50,7 +50,7 @@ describe('getType', () => { }); it('should convert generic', () => { - const type = getType('#/definitions/Link', 'Link'); + const type = getType('#/components/schemas/Link', 'Link'); expect(type.type).toEqual('T'); expect(type.base).toEqual('T'); expect(type.template).toEqual(null); diff --git a/src/openApi/v3/parser/getType.ts b/src/openApi/v3/parser/getType.ts index 7ab373f4..21df6122 100644 --- a/src/openApi/v3/parser/getType.ts +++ b/src/openApi/v3/parser/getType.ts @@ -1,7 +1,7 @@ -import { stripNamespace } from './stripNamespace'; -import { Type } from '../../../client/interfaces/Type'; -import { getMappedType, hasMappedType } from './getMappedType'; -import { PrimaryType } from './constants'; +import {PrimaryType} from './constants'; +import {Type} from '../../../client/interfaces/Type'; +import {getMappedType, hasMappedType} from './getMappedType'; +import {stripNamespace} from './stripNamespace'; /** * Parse any string value into a type object. diff --git a/src/utils/getFileName.spec.ts b/src/utils/getFileName.spec.ts index 5da3db33..3f3e8b04 100644 --- a/src/utils/getFileName.spec.ts +++ b/src/utils/getFileName.spec.ts @@ -1,5 +1,5 @@ -import { getFileName } from './getFileName'; import { Language } from '../index'; +import { getFileName } from './getFileName'; describe('getFileName', () => { it('should convert to correct file name', () => { diff --git a/src/utils/getModelNames.spec.ts b/src/utils/getModelNames.spec.ts index 24d16b4c..38ea1b8a 100644 --- a/src/utils/getModelNames.spec.ts +++ b/src/utils/getModelNames.spec.ts @@ -1,5 +1,5 @@ -import { getModelNames } from './getModelNames'; import { Model } from '../client/interfaces/Model'; +import { getModelNames } from './getModelNames'; describe('getModelNames', () => { it('should return sorted list', () => { diff --git a/src/utils/getOpenApiSpec.spec.ts b/src/utils/getOpenApiSpec.spec.ts index 2629d4cc..22735d1a 100644 --- a/src/utils/getOpenApiSpec.spec.ts +++ b/src/utils/getOpenApiSpec.spec.ts @@ -1,5 +1,5 @@ -import { getOpenApiSpec } from './getOpenApiSpec'; import * as fs from 'fs'; +import { getOpenApiSpec } from './getOpenApiSpec'; jest.mock('fs'); diff --git a/src/utils/getServiceNames.spec.ts b/src/utils/getServiceNames.spec.ts index be24dbc8..c41a5150 100644 --- a/src/utils/getServiceNames.spec.ts +++ b/src/utils/getServiceNames.spec.ts @@ -1,5 +1,5 @@ -import { getServiceNames } from './getServiceNames'; import { Service } from '../client/interfaces/Service'; +import { getServiceNames } from './getServiceNames'; describe('getServiceNames', () => { it('should return sorted list', () => { diff --git a/src/utils/readHandlebarsTemplate.spec.ts b/src/utils/readHandlebarsTemplate.spec.ts index 84897603..7ec2d254 100644 --- a/src/utils/readHandlebarsTemplate.spec.ts +++ b/src/utils/readHandlebarsTemplate.spec.ts @@ -1,5 +1,5 @@ -import { readHandlebarsTemplate } from './readHandlebarsTemplate'; import * as fs from 'fs'; +import { readHandlebarsTemplate } from './readHandlebarsTemplate'; jest.mock('fs'); diff --git a/src/utils/readHandlebarsTemplate.ts b/src/utils/readHandlebarsTemplate.ts index 65d01713..e721f2f2 100644 --- a/src/utils/readHandlebarsTemplate.ts +++ b/src/utils/readHandlebarsTemplate.ts @@ -1,5 +1,5 @@ -import * as fs from 'fs'; import * as Handlebars from 'handlebars'; +import * as fs from 'fs'; /** * Read and compile the Handlebars template. diff --git a/src/utils/readHandlebarsTemplates.spec.ts b/src/utils/readHandlebarsTemplates.spec.ts index d9ae13ee..9e034723 100644 --- a/src/utils/readHandlebarsTemplates.spec.ts +++ b/src/utils/readHandlebarsTemplates.spec.ts @@ -1,7 +1,7 @@ -import { readHandlebarsTemplates } from './readHandlebarsTemplates'; import * as fs from 'fs'; -import { Language } from '../index'; import * as glob from 'glob'; +import { Language } from '../index'; +import { readHandlebarsTemplates } from './readHandlebarsTemplates'; jest.mock('fs'); jest.mock('glob'); diff --git a/src/utils/readHandlebarsTemplates.ts b/src/utils/readHandlebarsTemplates.ts index 3be404ea..69868094 100644 --- a/src/utils/readHandlebarsTemplates.ts +++ b/src/utils/readHandlebarsTemplates.ts @@ -1,9 +1,9 @@ import * as Handlebars from 'handlebars'; -import { readHandlebarsTemplate } from './readHandlebarsTemplate'; -import { Language } from '../index'; -import * as path from 'path'; -import { registerHandlebarHelpers } from './registerHandlebarHelpers'; import * as glob from 'glob'; +import * as path from 'path'; +import { Language } from '../index'; +import { readHandlebarsTemplate } from './readHandlebarsTemplate'; +import { registerHandlebarHelpers } from './registerHandlebarHelpers'; export interface Templates { index: Handlebars.TemplateDelegate; diff --git a/src/utils/writeClient.spec.ts b/src/utils/writeClient.spec.ts index d8d045ae..b616b1bc 100644 --- a/src/utils/writeClient.spec.ts +++ b/src/utils/writeClient.spec.ts @@ -1,13 +1,13 @@ -import { writeClient } from './writeClient'; +import * as fs from 'fs'; +import * as glob from 'glob'; import * as mkdirp from 'mkdirp'; import * as rimraf from 'rimraf'; -import * as fs from 'fs'; import { Client } from '../client/interfaces/Client'; -import { Templates } from './readHandlebarsTemplates'; import { HttpClient, Language } from '../index'; -import * as glob from 'glob'; import { Model } from '../client/interfaces/Model'; import { Service } from '../client/interfaces/Service'; +import { Templates } from './readHandlebarsTemplates'; +import { writeClient } from './writeClient'; jest.mock('rimraf'); jest.mock('mkdirp'); diff --git a/src/utils/writeClient.ts b/src/utils/writeClient.ts index 29769cb3..351f8ac5 100644 --- a/src/utils/writeClient.ts +++ b/src/utils/writeClient.ts @@ -1,14 +1,14 @@ -import { writeClientModels } from './writeClientModels'; -import { writeClientServices } from './writeClientServices'; -import { Client } from '../client/interfaces/Client'; -import * as path from 'path'; -import * as mkdirp from 'mkdirp'; -import * as rimraf from 'rimraf'; -import { Templates } from './readHandlebarsTemplates'; -import { writeClientIndex } from './writeClientIndex'; -import { HttpClient, Language } from '../index'; import * as fs from 'fs'; import * as glob from 'glob'; +import * as mkdirp from 'mkdirp'; +import * as path from 'path'; +import * as rimraf from 'rimraf'; +import { Client } from '../client/interfaces/Client'; +import { HttpClient, Language } from '../index'; +import { Templates } from './readHandlebarsTemplates'; +import { writeClientIndex } from './writeClientIndex'; +import { writeClientModels } from './writeClientModels'; +import { writeClientServices } from './writeClientServices'; import { writeClientSettings } from './writeClientSettings'; /** diff --git a/src/utils/writeClientIndex.spec.ts b/src/utils/writeClientIndex.spec.ts index 104b2b6b..cb72a728 100644 --- a/src/utils/writeClientIndex.spec.ts +++ b/src/utils/writeClientIndex.spec.ts @@ -1,10 +1,10 @@ -import { writeClientIndex } from './writeClientIndex'; import * as fs from 'fs'; import { Client } from '../client/interfaces/Client'; import { Language } from '../index'; import { Model } from '../client/interfaces/Model'; import { Service } from '../client/interfaces/Service'; import { Templates } from './readHandlebarsTemplates'; +import { writeClientIndex } from './writeClientIndex'; jest.mock('fs'); diff --git a/src/utils/writeClientIndex.ts b/src/utils/writeClientIndex.ts index 902c52a4..8c25e60b 100644 --- a/src/utils/writeClientIndex.ts +++ b/src/utils/writeClientIndex.ts @@ -1,11 +1,11 @@ -import { Client } from '../client/interfaces/Client'; import * as fs from 'fs'; import * as path from 'path'; +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 { Language } from '../index'; -import { getFileName } from './getFileName'; -import { Templates } from './readHandlebarsTemplates'; /** * Generate the OpenAPI client index file using the Handlebar template and write it to disk. diff --git a/src/utils/writeClientModels.spec.ts b/src/utils/writeClientModels.spec.ts index b55604d6..3628c2e3 100644 --- a/src/utils/writeClientModels.spec.ts +++ b/src/utils/writeClientModels.spec.ts @@ -1,8 +1,8 @@ -import { writeClientModels } from './writeClientModels'; import * as fs from 'fs'; -import { Model } from '../client/interfaces/Model'; import { Language } from '../index'; +import { Model } from '../client/interfaces/Model'; import { Templates } from './readHandlebarsTemplates'; +import { writeClientModels } from './writeClientModels'; jest.mock('fs'); diff --git a/src/utils/writeClientModels.ts b/src/utils/writeClientModels.ts index cf7d29f6..440ba3a2 100644 --- a/src/utils/writeClientModels.ts +++ b/src/utils/writeClientModels.ts @@ -1,11 +1,11 @@ import * as fs from 'fs'; -import { Model } from '../client/interfaces/Model'; import * as path from 'path'; import { Language } from '../index'; -import { getFileName } from './getFileName'; -import { exportModel } from './exportModel'; +import { Model } from '../client/interfaces/Model'; import { Templates } from './readHandlebarsTemplates'; +import { exportModel } from './exportModel'; import { format } from './format'; +import { getFileName } from './getFileName'; /** * Generate Models using the Handlebar template and write to disk. diff --git a/src/utils/writeClientServices.spec.ts b/src/utils/writeClientServices.spec.ts index de7adcb7..c191d76a 100644 --- a/src/utils/writeClientServices.spec.ts +++ b/src/utils/writeClientServices.spec.ts @@ -1,8 +1,8 @@ -import { writeClientServices } from './writeClientServices'; import * as fs from 'fs'; -import { Service } from '../client/interfaces/Service'; import { Language } from '../index'; +import { Service } from '../client/interfaces/Service'; import { Templates } from './readHandlebarsTemplates'; +import { writeClientServices } from './writeClientServices'; jest.mock('fs'); diff --git a/src/utils/writeClientServices.ts b/src/utils/writeClientServices.ts index d7559d3b..88aea452 100644 --- a/src/utils/writeClientServices.ts +++ b/src/utils/writeClientServices.ts @@ -1,11 +1,11 @@ import * as fs from 'fs'; import * as path from 'path'; -import { Service } from '../client/interfaces/Service'; import { Language } from '../index'; -import { getFileName } from './getFileName'; -import { exportService } from './exportService'; +import { Service } from '../client/interfaces/Service'; import { Templates } from './readHandlebarsTemplates'; +import { exportService } from './exportService'; import { format } from './format'; +import { getFileName } from './getFileName'; /** * Generate Services using the Handlebar template and write to disk. diff --git a/src/utils/writeClientSettings.ts b/src/utils/writeClientSettings.ts index b75e82a4..dc37ae56 100644 --- a/src/utils/writeClientSettings.ts +++ b/src/utils/writeClientSettings.ts @@ -1,9 +1,9 @@ -import { Client } from '../client/interfaces/Client'; import * as fs from 'fs'; import * as path from 'path'; +import { Client } from '../client/interfaces/Client'; import { HttpClient, Language } from '../index'; -import { getFileName } from './getFileName'; import { Templates } from './readHandlebarsTemplates'; +import { getFileName } from './getFileName'; export function writeClientSettings(client: Client, language: Language, httpClient: HttpClient, templates: Templates, outputPath: string): void { const fileName = getFileName('OpenAPI', language); diff --git a/test/__snapshots__/index.spec.js.snap b/test/__snapshots__/index.spec.js.snap index 16b3faef..48cfb75f 100644 --- a/test/__snapshots__/index.spec.js.snap +++ b/test/__snapshots__/index.spec.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`generation javascript file(./test/result/v2/javascript/core/ApiError.js): ./test/result/v2/javascript/core/ApiError.js 1`] = ` +exports[`generation v2 javascript file(./test/result/v2/javascript/core/ApiError.js): ./test/result/v2/javascript/core/ApiError.js 1`] = ` "/* istanbul ignore file */ /* eslint-disable */ /* prettier-ignore */ @@ -56,7 +56,7 @@ export function catchGenericError(result) { " `; -exports[`generation javascript file(./test/result/v2/javascript/core/OpenAPI.js): ./test/result/v2/javascript/core/OpenAPI.js 1`] = ` +exports[`generation v2 javascript file(./test/result/v2/javascript/core/OpenAPI.js): ./test/result/v2/javascript/core/OpenAPI.js 1`] = ` "/* istanbul ignore file */ /* eslint-disable */ /* prettier-ignore */ @@ -70,7 +70,7 @@ export let OpenAPI; })(OpenAPI || (OpenAPI = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/core/getFormData.js): ./test/result/v2/javascript/core/getFormData.js 1`] = ` +exports[`generation v2 javascript file(./test/result/v2/javascript/core/getFormData.js): ./test/result/v2/javascript/core/getFormData.js 1`] = ` "/* istanbul ignore file */ /* eslint-disable */ /* prettier-ignore */ @@ -95,7 +95,7 @@ export function getFormData(params) { " `; -exports[`generation javascript file(./test/result/v2/javascript/core/getQueryString.js): ./test/result/v2/javascript/core/getQueryString.js 1`] = ` +exports[`generation v2 javascript file(./test/result/v2/javascript/core/getQueryString.js): ./test/result/v2/javascript/core/getQueryString.js 1`] = ` "/* istanbul ignore file */ /* eslint-disable */ /* prettier-ignore */ @@ -129,7 +129,7 @@ export function getQueryString(params) { " `; -exports[`generation javascript file(./test/result/v2/javascript/core/isSuccess.js): ./test/result/v2/javascript/core/isSuccess.js 1`] = ` +exports[`generation v2 javascript file(./test/result/v2/javascript/core/isSuccess.js): ./test/result/v2/javascript/core/isSuccess.js 1`] = ` "/* istanbul ignore file */ /* eslint-disable */ /* prettier-ignore */ @@ -144,7 +144,7 @@ export function isSuccess(status) { " `; -exports[`generation javascript file(./test/result/v2/javascript/core/request.js): ./test/result/v2/javascript/core/request.js 1`] = ` +exports[`generation v2 javascript file(./test/result/v2/javascript/core/request.js): ./test/result/v2/javascript/core/request.js 1`] = ` "/* istanbul ignore file */ /* eslint-disable */ /* prettier-ignore */ @@ -226,7 +226,7 @@ export async function request(options) { " `; -exports[`generation javascript file(./test/result/v2/javascript/core/requestUsingFetch.js): ./test/result/v2/javascript/core/requestUsingFetch.js 1`] = ` +exports[`generation v2 javascript file(./test/result/v2/javascript/core/requestUsingFetch.js): ./test/result/v2/javascript/core/requestUsingFetch.js 1`] = ` "/* istanbul ignore file */ /* eslint-disable */ /* prettier-ignore */ @@ -277,7 +277,7 @@ export async function requestUsingFetch(url, request) { " `; -exports[`generation javascript file(./test/result/v2/javascript/core/requestUsingXHR.js): ./test/result/v2/javascript/core/requestUsingXHR.js 1`] = ` +exports[`generation v2 javascript file(./test/result/v2/javascript/core/requestUsingXHR.js): ./test/result/v2/javascript/core/requestUsingXHR.js 1`] = ` "/* istanbul ignore file */ /* eslint-disable */ /* prettier-ignore */ @@ -351,7 +351,7 @@ export async function requestUsingXHR(url, request) { " `; -exports[`generation javascript file(./test/result/v2/javascript/index.js): ./test/result/v2/javascript/index.js 1`] = ` +exports[`generation v2 javascript file(./test/result/v2/javascript/index.js): ./test/result/v2/javascript/index.js 1`] = ` "/* istanbul ignore file */ /* eslint-disable */ /* prettier-ignore */ @@ -405,7 +405,7 @@ export { TypesService } from './services/TypesService'; " `; -exports[`generation javascript file(./test/result/v2/javascript/models/ArrayWithArray.js): ./test/result/v2/javascript/models/ArrayWithArray.js 1`] = ` +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 */ @@ -432,7 +432,7 @@ export let ArrayWithArray; })(ArrayWithArray || (ArrayWithArray = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/ArrayWithBooleans.js): ./test/result/v2/javascript/models/ArrayWithBooleans.js 1`] = ` +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 */ @@ -458,7 +458,7 @@ export let ArrayWithBooleans; })(ArrayWithBooleans || (ArrayWithBooleans = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/ArrayWithNumbers.js): ./test/result/v2/javascript/models/ArrayWithNumbers.js 1`] = ` +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 */ @@ -484,7 +484,7 @@ export let ArrayWithNumbers; })(ArrayWithNumbers || (ArrayWithNumbers = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/ArrayWithProperties.js): ./test/result/v2/javascript/models/ArrayWithProperties.js 1`] = ` +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 */ @@ -515,7 +515,7 @@ export let ArrayWithProperties; })(ArrayWithProperties || (ArrayWithProperties = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/ArrayWithReferences.js): ./test/result/v2/javascript/models/ArrayWithReferences.js 1`] = ` +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 */ @@ -542,7 +542,7 @@ export let ArrayWithReferences; })(ArrayWithReferences || (ArrayWithReferences = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/ArrayWithStrings.js): ./test/result/v2/javascript/models/ArrayWithStrings.js 1`] = ` +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 */ @@ -568,7 +568,7 @@ export let ArrayWithStrings; })(ArrayWithStrings || (ArrayWithStrings = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/DictionaryWithArray.js): ./test/result/v2/javascript/models/DictionaryWithArray.js 1`] = ` +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 */ @@ -603,7 +603,7 @@ export let DictionaryWithArray; })(DictionaryWithArray || (DictionaryWithArray = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/DictionaryWithDictionary.js): ./test/result/v2/javascript/models/DictionaryWithDictionary.js 1`] = ` +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 */ @@ -644,7 +644,7 @@ export let DictionaryWithDictionary; })(DictionaryWithDictionary || (DictionaryWithDictionary = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/DictionaryWithProperties.js): ./test/result/v2/javascript/models/DictionaryWithProperties.js 1`] = ` +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 */ @@ -683,7 +683,7 @@ export let DictionaryWithProperties; })(DictionaryWithProperties || (DictionaryWithProperties = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/DictionaryWithReference.js): ./test/result/v2/javascript/models/DictionaryWithReference.js 1`] = ` +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 */ @@ -718,7 +718,7 @@ export let DictionaryWithReference; })(DictionaryWithReference || (DictionaryWithReference = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/DictionaryWithString.js): ./test/result/v2/javascript/models/DictionaryWithString.js 1`] = ` +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 */ @@ -752,7 +752,7 @@ export let DictionaryWithString; })(DictionaryWithString || (DictionaryWithString = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/EnumFromDescription.js): ./test/result/v2/javascript/models/EnumFromDescription.js 1`] = ` +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 */ @@ -786,7 +786,7 @@ export let EnumFromDescription; })(EnumFromDescription || (EnumFromDescription = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/EnumWithNumbers.js): ./test/result/v2/javascript/models/EnumWithNumbers.js 1`] = ` +exports[`generation v2 javascript file(./test/result/v2/javascript/models/EnumWithNumbers.js): ./test/result/v2/javascript/models/EnumWithNumbers.js 1`] = ` "/* istanbul ignore file */ /* eslint-disable */ /* prettier-ignore */ @@ -820,7 +820,7 @@ export let EnumWithNumbers; })(EnumWithNumbers || (EnumWithNumbers = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/EnumWithStrings.js): ./test/result/v2/javascript/models/EnumWithStrings.js 1`] = ` +exports[`generation v2 javascript file(./test/result/v2/javascript/models/EnumWithStrings.js): ./test/result/v2/javascript/models/EnumWithStrings.js 1`] = ` "/* istanbul ignore file */ /* eslint-disable */ /* prettier-ignore */ @@ -854,7 +854,7 @@ export let EnumWithStrings; })(EnumWithStrings || (EnumWithStrings = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/ModelLink.js): ./test/result/v2/javascript/models/ModelLink.js 1`] = ` +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 */ @@ -884,7 +884,7 @@ export let ModelLink; })(ModelLink || (ModelLink = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/ModelThatExtends.js): ./test/result/v2/javascript/models/ModelThatExtends.js 1`] = ` +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 */ @@ -918,7 +918,7 @@ export let ModelThatExtends; })(ModelThatExtends || (ModelThatExtends = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/ModelThatExtendsExtends.js): ./test/result/v2/javascript/models/ModelThatExtendsExtends.js 1`] = ` +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 */ @@ -955,7 +955,7 @@ export let ModelThatExtendsExtends; })(ModelThatExtendsExtends || (ModelThatExtendsExtends = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/ModelWithArray.js): ./test/result/v2/javascript/models/ModelWithArray.js 1`] = ` +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 */ @@ -986,7 +986,7 @@ export let ModelWithArray; })(ModelWithArray || (ModelWithArray = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/ModelWithBoolean.js): ./test/result/v2/javascript/models/ModelWithBoolean.js 1`] = ` +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 */ @@ -1016,7 +1016,7 @@ export let ModelWithBoolean; })(ModelWithBoolean || (ModelWithBoolean = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/ModelWithCircularReference.js): ./test/result/v2/javascript/models/ModelWithCircularReference.js 1`] = ` +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 */ @@ -1046,7 +1046,7 @@ export let ModelWithCircularReference; })(ModelWithCircularReference || (ModelWithCircularReference = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/ModelWithDictionary.js): ./test/result/v2/javascript/models/ModelWithDictionary.js 1`] = ` +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 */ @@ -1084,7 +1084,7 @@ export let ModelWithDictionary; })(ModelWithDictionary || (ModelWithDictionary = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/ModelWithDuplicateImports.js): ./test/result/v2/javascript/models/ModelWithDuplicateImports.js 1`] = ` +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 */ @@ -1117,7 +1117,7 @@ export let ModelWithDuplicateImports; })(ModelWithDuplicateImports || (ModelWithDuplicateImports = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/ModelWithDuplicateProperties.js): ./test/result/v2/javascript/models/ModelWithDuplicateProperties.js 1`] = ` +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 */ @@ -1148,7 +1148,7 @@ export let ModelWithDuplicateProperties; })(ModelWithDuplicateProperties || (ModelWithDuplicateProperties = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/ModelWithEnum.js): ./test/result/v2/javascript/models/ModelWithEnum.js 1`] = ` +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 */ @@ -1191,7 +1191,7 @@ export let ModelWithEnum; })(ModelWithEnum || (ModelWithEnum = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/ModelWithEnumFromDescription.js): ./test/result/v2/javascript/models/ModelWithEnumFromDescription.js 1`] = ` +exports[`generation v2 javascript file(./test/result/v2/javascript/models/ModelWithEnumFromDescription.js): ./test/result/v2/javascript/models/ModelWithEnumFromDescription.js 1`] = ` "/* istanbul ignore file */ /* eslint-disable */ /* prettier-ignore */ @@ -1234,7 +1234,7 @@ export let ModelWithEnumFromDescription; })(ModelWithEnumFromDescription || (ModelWithEnumFromDescription = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/ModelWithInteger.js): ./test/result/v2/javascript/models/ModelWithInteger.js 1`] = ` +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 */ @@ -1264,7 +1264,7 @@ export let ModelWithInteger; })(ModelWithInteger || (ModelWithInteger = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/ModelWithLink.js): ./test/result/v2/javascript/models/ModelWithLink.js 1`] = ` +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 */ @@ -1296,7 +1296,7 @@ export let ModelWithLink; })(ModelWithLink || (ModelWithLink = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/ModelWithNestedProperties.js): ./test/result/v2/javascript/models/ModelWithNestedProperties.js 1`] = ` +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 */ @@ -1334,7 +1334,7 @@ export let ModelWithNestedProperties; })(ModelWithNestedProperties || (ModelWithNestedProperties = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/ModelWithReference.js): ./test/result/v2/javascript/models/ModelWithReference.js 1`] = ` +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 */ @@ -1365,7 +1365,7 @@ export let ModelWithReference; })(ModelWithReference || (ModelWithReference = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/ModelWithString.js): ./test/result/v2/javascript/models/ModelWithString.js 1`] = ` +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 */ @@ -1395,7 +1395,7 @@ export let ModelWithString; })(ModelWithString || (ModelWithString = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/SimpleBoolean.js): ./test/result/v2/javascript/models/SimpleBoolean.js 1`] = ` +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 */ @@ -1421,7 +1421,7 @@ export let SimpleBoolean; })(SimpleBoolean || (SimpleBoolean = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/SimpleFile.js): ./test/result/v2/javascript/models/SimpleFile.js 1`] = ` +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 */ @@ -1447,7 +1447,7 @@ export let SimpleFile; })(SimpleFile || (SimpleFile = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/SimpleInteger.js): ./test/result/v2/javascript/models/SimpleInteger.js 1`] = ` +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 */ @@ -1473,7 +1473,7 @@ export let SimpleInteger; })(SimpleInteger || (SimpleInteger = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/SimpleReference.js): ./test/result/v2/javascript/models/SimpleReference.js 1`] = ` +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 */ @@ -1500,7 +1500,7 @@ export let SimpleReference; })(SimpleReference || (SimpleReference = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/models/SimpleString.js): ./test/result/v2/javascript/models/SimpleString.js 1`] = ` +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 */ @@ -1526,7 +1526,7 @@ export let SimpleString; })(SimpleString || (SimpleString = {}));" `; -exports[`generation javascript file(./test/result/v2/javascript/services/ComplexService.js): ./test/result/v2/javascript/services/ComplexService.js 1`] = ` +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 */ @@ -1572,7 +1572,7 @@ export class ComplexService { }" `; -exports[`generation javascript file(./test/result/v2/javascript/services/ParametersService.js): ./test/result/v2/javascript/services/ParametersService.js 1`] = ` +exports[`generation v2 javascript file(./test/result/v2/javascript/services/ParametersService.js): ./test/result/v2/javascript/services/ParametersService.js 1`] = ` "/* istanbul ignore file */ /* eslint-disable */ /* prettier-ignore */ @@ -1620,7 +1620,7 @@ export class ParametersService { }" `; -exports[`generation javascript file(./test/result/v2/javascript/services/ResponseService.js): ./test/result/v2/javascript/services/ResponseService.js 1`] = ` +exports[`generation v2 javascript file(./test/result/v2/javascript/services/ResponseService.js): ./test/result/v2/javascript/services/ResponseService.js 1`] = ` "/* istanbul ignore file */ /* eslint-disable */ /* prettier-ignore */ @@ -1700,7 +1700,7 @@ export class ResponseService { }" `; -exports[`generation javascript file(./test/result/v2/javascript/services/SimpleService.js): ./test/result/v2/javascript/services/SimpleService.js 1`] = ` +exports[`generation v2 javascript file(./test/result/v2/javascript/services/SimpleService.js): ./test/result/v2/javascript/services/SimpleService.js 1`] = ` "/* istanbul ignore file */ /* eslint-disable */ /* prettier-ignore */ @@ -1819,7 +1819,7 @@ export class SimpleService { }" `; -exports[`generation javascript file(./test/result/v2/javascript/services/TypesService.js): ./test/result/v2/javascript/services/TypesService.js 1`] = ` +exports[`generation v2 javascript file(./test/result/v2/javascript/services/TypesService.js): ./test/result/v2/javascript/services/TypesService.js 1`] = ` "/* istanbul ignore file */ /* eslint-disable */ /* prettier-ignore */ @@ -1875,7 +1875,7 @@ export class TypesService { }" `; -exports[`generation typescript file(./test/result/v2/typescript/core/ApiError.ts): ./test/result/v2/typescript/core/ApiError.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/core/ApiError.ts): ./test/result/v2/typescript/core/ApiError.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1936,7 +1936,7 @@ export function catchGenericError(result: Result): void { " `; -exports[`generation typescript file(./test/result/v2/typescript/core/OpenAPI.ts): ./test/result/v2/typescript/core/OpenAPI.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/core/OpenAPI.ts): ./test/result/v2/typescript/core/OpenAPI.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1950,7 +1950,7 @@ export namespace OpenAPI { }" `; -exports[`generation typescript file(./test/result/v2/typescript/core/RequestOptions.ts): ./test/result/v2/typescript/core/RequestOptions.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/core/RequestOptions.ts): ./test/result/v2/typescript/core/RequestOptions.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1967,7 +1967,7 @@ export interface RequestOptions { " `; -exports[`generation typescript file(./test/result/v2/typescript/core/Result.ts): ./test/result/v2/typescript/core/Result.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/core/Result.ts): ./test/result/v2/typescript/core/Result.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -1983,7 +1983,7 @@ export interface Result { " `; -exports[`generation typescript file(./test/result/v2/typescript/core/getFormData.ts): ./test/result/v2/typescript/core/getFormData.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/core/getFormData.ts): ./test/result/v2/typescript/core/getFormData.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2009,7 +2009,7 @@ export function getFormData(params: { [key: string]: any }): FormData { " `; -exports[`generation typescript file(./test/result/v2/typescript/core/getQueryString.ts): ./test/result/v2/typescript/core/getQueryString.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/core/getQueryString.ts): ./test/result/v2/typescript/core/getQueryString.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2044,7 +2044,7 @@ export function getQueryString(params: { [key: string]: any }): string { " `; -exports[`generation typescript file(./test/result/v2/typescript/core/isSuccess.ts): ./test/result/v2/typescript/core/isSuccess.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/core/isSuccess.ts): ./test/result/v2/typescript/core/isSuccess.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2060,7 +2060,7 @@ export function isSuccess(status: number): boolean { " `; -exports[`generation typescript file(./test/result/v2/typescript/core/request.ts): ./test/result/v2/typescript/core/request.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/core/request.ts): ./test/result/v2/typescript/core/request.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2145,7 +2145,7 @@ export async function request(options: Readonly): Promise { " `; -exports[`generation typescript file(./test/result/v2/typescript/models/DictionaryWithArray.ts): ./test/result/v2/typescript/models/DictionaryWithArray.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/DictionaryWithArray.ts): ./test/result/v2/typescript/models/DictionaryWithArray.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2553,7 +2553,7 @@ export namespace DictionaryWithArray { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/DictionaryWithDictionary.ts): ./test/result/v2/typescript/models/DictionaryWithDictionary.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/DictionaryWithDictionary.ts): ./test/result/v2/typescript/models/DictionaryWithDictionary.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2595,7 +2595,7 @@ export namespace DictionaryWithDictionary { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/DictionaryWithProperties.ts): ./test/result/v2/typescript/models/DictionaryWithProperties.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/DictionaryWithProperties.ts): ./test/result/v2/typescript/models/DictionaryWithProperties.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2644,7 +2644,7 @@ export namespace DictionaryWithProperties { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/DictionaryWithReference.ts): ./test/result/v2/typescript/models/DictionaryWithReference.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/DictionaryWithReference.ts): ./test/result/v2/typescript/models/DictionaryWithReference.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2680,7 +2680,7 @@ export namespace DictionaryWithReference { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/DictionaryWithString.ts): ./test/result/v2/typescript/models/DictionaryWithString.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/DictionaryWithString.ts): ./test/result/v2/typescript/models/DictionaryWithString.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2715,7 +2715,7 @@ export namespace DictionaryWithString { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/EnumFromDescription.ts): ./test/result/v2/typescript/models/EnumFromDescription.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/EnumFromDescription.ts): ./test/result/v2/typescript/models/EnumFromDescription.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2750,7 +2750,7 @@ export namespace EnumFromDescription { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/EnumWithNumbers.ts): ./test/result/v2/typescript/models/EnumWithNumbers.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/EnumWithNumbers.ts): ./test/result/v2/typescript/models/EnumWithNumbers.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2785,7 +2785,7 @@ export namespace EnumWithNumbers { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/EnumWithStrings.ts): ./test/result/v2/typescript/models/EnumWithStrings.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/EnumWithStrings.ts): ./test/result/v2/typescript/models/EnumWithStrings.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2820,7 +2820,7 @@ export namespace EnumWithStrings { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/ModelLink.ts): ./test/result/v2/typescript/models/ModelLink.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelLink.ts): ./test/result/v2/typescript/models/ModelLink.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2853,7 +2853,7 @@ export namespace ModelLink { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/ModelThatExtends.ts): ./test/result/v2/typescript/models/ModelThatExtends.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelThatExtends.ts): ./test/result/v2/typescript/models/ModelThatExtends.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2891,7 +2891,7 @@ export namespace ModelThatExtends { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/ModelThatExtendsExtends.ts): ./test/result/v2/typescript/models/ModelThatExtendsExtends.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelThatExtendsExtends.ts): ./test/result/v2/typescript/models/ModelThatExtendsExtends.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2932,7 +2932,7 @@ export namespace ModelThatExtendsExtends { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/ModelWithArray.ts): ./test/result/v2/typescript/models/ModelWithArray.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelWithArray.ts): ./test/result/v2/typescript/models/ModelWithArray.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -2966,7 +2966,7 @@ export namespace ModelWithArray { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/ModelWithBoolean.ts): ./test/result/v2/typescript/models/ModelWithBoolean.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelWithBoolean.ts): ./test/result/v2/typescript/models/ModelWithBoolean.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3002,7 +3002,7 @@ export namespace ModelWithBoolean { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/ModelWithCircularReference.ts): ./test/result/v2/typescript/models/ModelWithCircularReference.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelWithCircularReference.ts): ./test/result/v2/typescript/models/ModelWithCircularReference.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3035,7 +3035,7 @@ export namespace ModelWithCircularReference { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/ModelWithDictionary.ts): ./test/result/v2/typescript/models/ModelWithDictionary.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelWithDictionary.ts): ./test/result/v2/typescript/models/ModelWithDictionary.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3076,7 +3076,7 @@ export namespace ModelWithDictionary { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/ModelWithDuplicateImports.ts): ./test/result/v2/typescript/models/ModelWithDuplicateImports.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelWithDuplicateImports.ts): ./test/result/v2/typescript/models/ModelWithDuplicateImports.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3114,7 +3114,7 @@ export namespace ModelWithDuplicateImports { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/ModelWithDuplicateProperties.ts): ./test/result/v2/typescript/models/ModelWithDuplicateProperties.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelWithDuplicateProperties.ts): ./test/result/v2/typescript/models/ModelWithDuplicateProperties.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3148,7 +3148,7 @@ export namespace ModelWithDuplicateProperties { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/ModelWithEnum.ts): ./test/result/v2/typescript/models/ModelWithEnum.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelWithEnum.ts): ./test/result/v2/typescript/models/ModelWithEnum.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3197,7 +3197,7 @@ export namespace ModelWithEnum { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/ModelWithEnumFromDescription.ts): ./test/result/v2/typescript/models/ModelWithEnumFromDescription.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelWithEnumFromDescription.ts): ./test/result/v2/typescript/models/ModelWithEnumFromDescription.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3246,7 +3246,7 @@ export namespace ModelWithEnumFromDescription { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/ModelWithInteger.ts): ./test/result/v2/typescript/models/ModelWithInteger.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelWithInteger.ts): ./test/result/v2/typescript/models/ModelWithInteger.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3282,7 +3282,7 @@ export namespace ModelWithInteger { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/ModelWithLink.ts): ./test/result/v2/typescript/models/ModelWithLink.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelWithLink.ts): ./test/result/v2/typescript/models/ModelWithLink.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3317,7 +3317,7 @@ export namespace ModelWithLink { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/ModelWithNestedProperties.ts): ./test/result/v2/typescript/models/ModelWithNestedProperties.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelWithNestedProperties.ts): ./test/result/v2/typescript/models/ModelWithNestedProperties.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3362,7 +3362,7 @@ export namespace ModelWithNestedProperties { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/ModelWithReference.ts): ./test/result/v2/typescript/models/ModelWithReference.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelWithReference.ts): ./test/result/v2/typescript/models/ModelWithReference.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3396,7 +3396,7 @@ export namespace ModelWithReference { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/ModelWithString.ts): ./test/result/v2/typescript/models/ModelWithString.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelWithString.ts): ./test/result/v2/typescript/models/ModelWithString.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3432,7 +3432,7 @@ export namespace ModelWithString { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/SimpleBoolean.ts): ./test/result/v2/typescript/models/SimpleBoolean.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/SimpleBoolean.ts): ./test/result/v2/typescript/models/SimpleBoolean.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3459,7 +3459,7 @@ export namespace SimpleBoolean { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/SimpleFile.ts): ./test/result/v2/typescript/models/SimpleFile.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/SimpleFile.ts): ./test/result/v2/typescript/models/SimpleFile.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3486,7 +3486,7 @@ export namespace SimpleFile { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/SimpleInteger.ts): ./test/result/v2/typescript/models/SimpleInteger.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/SimpleInteger.ts): ./test/result/v2/typescript/models/SimpleInteger.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3513,7 +3513,7 @@ export namespace SimpleInteger { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/SimpleReference.ts): ./test/result/v2/typescript/models/SimpleReference.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/SimpleReference.ts): ./test/result/v2/typescript/models/SimpleReference.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3541,7 +3541,7 @@ export namespace SimpleReference { }" `; -exports[`generation typescript file(./test/result/v2/typescript/models/SimpleString.ts): ./test/result/v2/typescript/models/SimpleString.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/models/SimpleString.ts): ./test/result/v2/typescript/models/SimpleString.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3568,7 +3568,7 @@ export namespace SimpleString { }" `; -exports[`generation typescript file(./test/result/v2/typescript/services/ComplexService.ts): ./test/result/v2/typescript/services/ComplexService.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/services/ComplexService.ts): ./test/result/v2/typescript/services/ComplexService.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3622,7 +3622,7 @@ export class ComplexService { }" `; -exports[`generation typescript file(./test/result/v2/typescript/services/ParametersService.ts): ./test/result/v2/typescript/services/ParametersService.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/services/ParametersService.ts): ./test/result/v2/typescript/services/ParametersService.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3671,7 +3671,7 @@ export class ParametersService { }" `; -exports[`generation typescript file(./test/result/v2/typescript/services/ResponseService.ts): ./test/result/v2/typescript/services/ResponseService.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/services/ResponseService.ts): ./test/result/v2/typescript/services/ResponseService.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3755,7 +3755,7 @@ export class ResponseService { }" `; -exports[`generation typescript file(./test/result/v2/typescript/services/SimpleService.ts): ./test/result/v2/typescript/services/SimpleService.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/services/SimpleService.ts): ./test/result/v2/typescript/services/SimpleService.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3875,7 +3875,7 @@ export class SimpleService { }" `; -exports[`generation typescript file(./test/result/v2/typescript/services/TypesService.ts): ./test/result/v2/typescript/services/TypesService.ts 1`] = ` +exports[`generation v2 typescript file(./test/result/v2/typescript/services/TypesService.ts): ./test/result/v2/typescript/services/TypesService.ts 1`] = ` "/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -3932,3 +3932,4409 @@ export class TypesService { }" `; + +exports[`generation v3 javascript file(./test/result/v3/javascript/core/ApiError.js): ./test/result/v3/javascript/core/ApiError.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import { isSuccess } from \\"./isSuccess\\"; + +export class ApiError extends Error { + + constructor(result, message) { + super(message); + + this.url = result.url; + this.status = result.status; + this.statusText = result.statusText; + this.body = result.body; + } +} + +(function (ApiError) { + let Message; + (function (Message) { + Message.BAD_REQUEST = 'Bad Request'; + Message.UNAUTHORIZED = 'Unauthorized'; + Message.FORBIDDEN = 'Forbidden'; + Message.NOT_FOUND = 'Not Found'; + Message.INTERNAL_SERVER_ERROR = 'Internal Server Error'; + Message.BAD_GATEWAY = 'Bad Gateway'; + Message.SERVICE_UNAVAILABLE = 'Service Unavailable'; + Message.GENERIC_ERROR = 'Generic Error'; + })(Message = ApiError.Message || (ApiError.Message = {})); +})(ApiError || (ApiError = {})); + +/** + * Catch common errors (based on status code). + * @param result + */ +export function catchGenericError(result) { + + switch (result.status) { + case 400: throw new ApiError(result, ApiError.Message.BAD_REQUEST); + case 401: throw new ApiError(result, ApiError.Message.UNAUTHORIZED); + case 403: throw new ApiError(result, ApiError.Message.FORBIDDEN); + case 404: throw new ApiError(result, ApiError.Message.NOT_FOUND); + case 500: throw new ApiError(result, ApiError.Message.INTERNAL_SERVER_ERROR); + case 502: throw new ApiError(result, ApiError.Message.BAD_GATEWAY); + case 503: throw new ApiError(result, ApiError.Message.SERVICE_UNAVAILABLE); + } + + if (!isSuccess(result.status)) { + throw new ApiError(result, ApiError.Message.GENERIC_ERROR); + } +} +" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/core/OpenAPI.js): ./test/result/v3/javascript/core/OpenAPI.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +export let OpenAPI; +(function (OpenAPI) { + OpenAPI.BASE = '/access-manager'; + OpenAPI.VERSION = '1'; + OpenAPI.CLIENT = 'xhr'; + OpenAPI.TOKEN = ''; +})(OpenAPI || (OpenAPI = {}));" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/core/getFormData.js): ./test/result/v3/javascript/core/getFormData.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +/** + * Get FormData from object. This method is needed to upload + * multipart form data to the REST API. + * @param params Key value based object. + */ +export function getFormData(params) { + const formData = new FormData(); + for (const key in params) { + if (typeof params[key] !== 'undefined') { + const value = params[key]; + if (value !== undefined && value !== null) { + formData.append(key, value); + } + } + } + return formData; +} +" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/core/getQueryString.js): ./test/result/v3/javascript/core/getQueryString.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +/** + * Get query string from query parameters object. This method also + * supports multi-value items by creating a key for each item. + * @param params Key value based object. + */ +export function getQueryString(params) { + const qs = []; + for (const key in params) { + if (typeof params[key] !== 'undefined') { + const value = params[key]; + if (value !== undefined && value !== null) { + if (Array.isArray(value)) { + value.forEach(value => { + qs.push(\`\${encodeURIComponent(key)}=\${encodeURIComponent(String(value))}\`); + }); + } else { + qs.push(\`\${encodeURIComponent(key)}=\${encodeURIComponent(String(value))}\`); + } + } + } + } + if (qs.length > 0) { + return \`?\${qs.join('&')}\`; + } + return ''; +} +" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/core/isSuccess.js): ./test/result/v3/javascript/core/isSuccess.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +/** + * Check success response code. + * @param status Status code + */ +export function isSuccess(status) { + return status >= 200 && status < 300; +} +" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/core/request.js): ./test/result/v3/javascript/core/request.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import {getFormData} from './getFormData'; +import {getQueryString} from './getQueryString'; +import {OpenAPI} from './OpenAPI'; +import {requestUsingFetch} from './requestUsingFetch'; +import {requestUsingXHR} from './requestUsingXHR'; + +/** + * Create the request. + * @param options Request method options. + * @returns Result object (see above) + */ +export async function request(options) { + + // Create the request URL + let url = \`\${OpenAPI.BASE}\${options.path}\`; + + // Create request headers + const headers = new Headers({ + ...options.headers, + Accept: 'application/json' + }); + + // Create request settings + const request = { + headers, + method: options.method, + credentials: 'same-origin' + }; + + // If we have a bearer token then we set the authentication header. + if (OpenAPI.TOKEN !== null && OpenAPI.TOKEN !== '') { + headers.append('Authorization', \`Bearer \${OpenAPI.TOKEN}\`); + } + + // Add the query parameters (if defined). + if (options.query) { + url += getQueryString(options.query); + } + + // Append formData as body + if (options.formData) { + request.body = getFormData(options.formData); + } else if (options.body) { + + // If this is blob data, then pass it directly to the body and set content type. + // Otherwise we just convert request data to JSON string (needed for fetch api) + if (options.body instanceof Blob) { + request.body = options.body; + if (options.body.type) { + headers.append('Content-Type', options.body.type); + } + } else { + request.body = JSON.stringify(options.body); + headers.append('Content-Type', 'application/json'); + } + } + + try { + switch (OpenAPI.CLIENT) { + case 'xhr': + return await requestUsingXHR(url, request); + default: + return await requestUsingFetch(url, request); + } + } catch (error) { + return { + url, + ok: false, + status: 0, + statusText: '', + body: error + }; + } +} +" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/core/requestUsingFetch.js): ./test/result/v3/javascript/core/requestUsingFetch.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +/** + * Request content using the new Fetch API. This is the default API that is used and + * is create for all JSON, XML and text objects. However it is limited to UTF-8. + * This is a problem for some of the Docs content, since that requires UTF-16! + * @param url The url to request. + * @param request The request object, containing method, headers, body, etc. + */ +export async function requestUsingFetch(url, request) { + + // Fetch response using fetch API. + const response = await fetch(url, request); + + // Create result object. + const result = { + url, + ok: response.ok, + status: response.status, + statusText: response.statusText, + body: null + }; + + // Try to parse the content for any response status code. + // We check the \\"Content-Type\\" header to see if we need to parse the + // content as json or as plain text. + const contentType = response.headers.get('Content-Type'); + if (contentType) { + switch (contentType.toLowerCase()) { + case 'application/json': + case 'application/json; charset=utf-8': + result.body = await response.json(); + break; + + case 'text/plain': + case 'text/xml': + case 'text/xml; charset=utf-8': + case 'text/xml; charset=utf-16': + result.body = await response.text(); + break; + } + } + + return result; +} +" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/core/requestUsingXHR.js): ./test/result/v3/javascript/core/requestUsingXHR.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import { isSuccess } from './isSuccess'; + +/** + * Request content using the new legacy XMLHttpRequest API. This method is useful + * when we want to request UTF-16 content, since it natively supports loading UTF-16. + * We could do the same with the Fetch API, but then we will need to convert the + * content using JavaScript... And that is very very slow. + * @param url The url to request. + * @param request The request object, containing method, headers, body, etc. + */ +export async function requestUsingXHR(url, request) { + return new Promise(resolve => { + const xhr = new XMLHttpRequest(); + + // Open the request, remember to do this before adding any headers, + // because the request needs to be initialized! + xhr.open(request.method, url, true); + + // Add the headers (required when dealing with JSON) + const headers = request.headers as Headers; + headers.forEach((value, key) => { + xhr.setRequestHeader(key, value); + }); + + // Register the readystate handler, this will fire when the request is done. + xhr.onreadystatechange = () => { + if (xhr.readyState === XMLHttpRequest.DONE) { + + // Create result object. + const result = { + url, + ok: isSuccess(xhr.status), + status: xhr.status, + statusText: xhr.statusText, + body: null + }; + + // Try to parse the content for any response status code. + // We check the \\"Content-Type\\" header to see if we need to parse the + // content as json or as plain text. + const contentType = xhr.getResponseHeader('Content-Type'); + if (contentType) { + switch (contentType.toLowerCase()) { + case 'application/json': + case 'application/json; charset=utf-8': + result.body = JSON.parse(xhr.responseText); + break; + + case 'text/plain': + case 'text/xml': + case 'text/xml; charset=utf-8': + case 'text/xml; charset=utf-16': + result.body = xhr.responseText; + break; + } + } + + // Done! + resolve(result); + } + }; + + // Start the request! + xhr.send(request.body); + }); +} +" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/index.js): ./test/result/v3/javascript/index.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +export { ApiError } from './core/ApiError'; +export { isSuccess } from './core/isSuccess'; +export { OpenAPI } from './core/OpenAPI'; + +export { ApiResource } from './models/ApiResource'; +export { ApiResourceLink } from './models/ApiResourceLink'; +export { ApiResourceRole } from './models/ApiResourceRole'; +export { ApiResourceRoleLink } from './models/ApiResourceRoleLink'; +export { Application } from './models/Application'; +export { ApplicationLink } from './models/ApplicationLink'; +export { ClaimBasedAccessControlEntry } from './models/ClaimBasedAccessControlEntry'; + +export { ErrorMessage } from './models/ErrorMessage'; +export { ErrorResponse } from './models/ErrorResponse'; +export { IdentityProvider } from './models/IdentityProvider'; +export { IdentityProviderParameters } from './models/IdentityProviderParameters'; +export { IdentityProviderType } from './models/IdentityProviderType'; +export { IInnerError } from './models/IInnerError'; +export { LdapParameters } from './models/LdapParameters'; +export { LoginOption } from './models/LoginOption'; +export { OpenIdParameters } from './models/OpenIdParameters'; +export { ProblemDetails } from './models/ProblemDetails'; +export { SamlParameters } from './models/SamlParameters'; +export { ServiceAccount } from './models/ServiceAccount'; +export { ServiceAccountBasedAccessControlEntry } from './models/ServiceAccountBasedAccessControlEntry'; +export { User } from './models/User'; +export { UserBasedAccessControlEntry } from './models/UserBasedAccessControlEntry'; +export { UserClientSecret } from './models/UserClientSecret'; +export { WindowsParameters } from './models/WindowsParameters'; + +export { ApiResourcesService } from './services/ApiResourcesService'; +export { ApplicationsService } from './services/ApplicationsService'; +export { ClaimsService } from './services/ClaimsService'; +export { IdentityProvidersService } from './services/IdentityProvidersService'; +export { ServiceAccountsService } from './services/ServiceAccountsService'; +export { SuggestionsService } from './services/SuggestionsService'; +export { UsersService } from './services/UsersService'; +" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/models/ApiResource.js): ./test/result/v3/javascript/models/ApiResource.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ApiResourceRole } from '../models/ApiResourceRole'; +import * as yup from 'yup'; + +export let ApiResource; +(function (ApiResource) { + + ApiResource.schema = ( + yup.object().shape({ + id: yup.lazy(() => yup.number().default(undefined)), + key: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired(), + name: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired(), + roles: yup.lazy(() => yup.array().of(ApiResourceRole.schema).default(undefined).isNullable()) + }).noUnknown() + ); + + ApiResource.validate = async function(value) { + return ApiResource.schema.validate(value, { strict: true }); + }; + + ApiResource.validateSync = function(value) { + return ApiResource.schema.validateSync(value, { strict: true }); + }; + +})(ApiResource || (ApiResource = {}));" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/models/ApiResourceLink.js): ./test/result/v3/javascript/models/ApiResourceLink.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import * as yup from 'yup'; + +export let ApiResourceLink; +(function (ApiResourceLink) { + + ApiResourceLink.schema = ( + yup.object().shape({ + id: yup.lazy(() => yup.number().default(undefined)), + name: yup.lazy(() => yup.string().default(undefined).isNullable()) + }).noUnknown() + ); + + ApiResourceLink.validate = async function(value) { + return ApiResourceLink.schema.validate(value, { strict: true }); + }; + + ApiResourceLink.validateSync = function(value) { + return ApiResourceLink.schema.validateSync(value, { strict: true }); + }; + +})(ApiResourceLink || (ApiResourceLink = {}));" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/models/ApiResourceRole.js): ./test/result/v3/javascript/models/ApiResourceRole.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ApiResource } from '../models/ApiResource'; +import * as yup from 'yup'; + +export let ApiResourceRole; +(function (ApiResourceRole) { + + ApiResourceRole.schema = ( + yup.object().shape({ + apiResource: yup.lazy(() => ApiResource.schema.default(undefined)), + id: yup.lazy(() => yup.number().default(undefined)), + key: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired(), + name: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired() + }).noUnknown() + ); + + ApiResourceRole.validate = async function(value) { + return ApiResourceRole.schema.validate(value, { strict: true }); + }; + + ApiResourceRole.validateSync = function(value) { + return ApiResourceRole.schema.validateSync(value, { strict: true }); + }; + +})(ApiResourceRole || (ApiResourceRole = {}));" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/models/ApiResourceRoleLink.js): ./test/result/v3/javascript/models/ApiResourceRoleLink.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import * as yup from 'yup'; + +export let ApiResourceRoleLink; +(function (ApiResourceRoleLink) { + + ApiResourceRoleLink.schema = ( + yup.object().shape({ + id: yup.lazy(() => yup.number().default(undefined)), + name: yup.lazy(() => yup.string().default(undefined).isNullable()) + }).noUnknown() + ); + + ApiResourceRoleLink.validate = async function(value) { + return ApiResourceRoleLink.schema.validate(value, { strict: true }); + }; + + ApiResourceRoleLink.validateSync = function(value) { + return ApiResourceRoleLink.schema.validateSync(value, { strict: true }); + }; + +})(ApiResourceRoleLink || (ApiResourceRoleLink = {}));" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/models/Application.js): ./test/result/v3/javascript/models/Application.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import * as yup from 'yup'; + +export let Application; +(function (Application) { + + Application.schema = ( + yup.object().shape({ + clientId: yup.lazy(() => yup.string().default(undefined).isNullable()), + createdAt: yup.lazy(() => yup.string().default(undefined)), + createdBy: yup.lazy(() => yup.number().default(undefined).isNullable()), + id: yup.lazy(() => yup.number().default(undefined)), + modifiedAt: yup.lazy(() => yup.string().default(undefined)), + modifiedBy: yup.lazy(() => yup.number().default(undefined).isNullable()), + name: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired(), + redirectUrls: yup.lazy(() => yup.array().of(yup.string()).default(undefined).isNullable()).isRequired() + }).noUnknown() + ); + + Application.validate = async function(value) { + return Application.schema.validate(value, { strict: true }); + }; + + Application.validateSync = function(value) { + return Application.schema.validateSync(value, { strict: true }); + }; + +})(Application || (Application = {}));" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/models/ApplicationLink.js): ./test/result/v3/javascript/models/ApplicationLink.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import * as yup from 'yup'; + +export let ApplicationLink; +(function (ApplicationLink) { + + ApplicationLink.schema = ( + yup.object().shape({ + id: yup.lazy(() => yup.number().default(undefined)), + name: yup.lazy(() => yup.string().default(undefined).isNullable()) + }).noUnknown() + ); + + ApplicationLink.validate = async function(value) { + return ApplicationLink.schema.validate(value, { strict: true }); + }; + + ApplicationLink.validateSync = function(value) { + return ApplicationLink.schema.validateSync(value, { strict: true }); + }; + +})(ApplicationLink || (ApplicationLink = {}));" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/models/ClaimBasedAccessControlEntry.js): ./test/result/v3/javascript/models/ClaimBasedAccessControlEntry.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ApiResourceLink } from '../models/ApiResourceLink'; +import { ApiResourceRoleLink } from '../models/ApiResourceRoleLink'; +import { ApplicationLink } from '../models/ApplicationLink'; +import * as yup from 'yup'; + +export let ClaimBasedAccessControlEntry; +(function (ClaimBasedAccessControlEntry) { + + ClaimBasedAccessControlEntry.schema = ( + yup.object().shape({ + apiResourceRoles: yup.lazy(() => yup.array().of(ApiResourceRoleLink.schema).default(undefined).isNullable()), + apiResources: yup.lazy(() => yup.array().of(ApiResourceLink.schema).default(undefined).isNullable()), + applications: yup.lazy(() => yup.array().of(ApplicationLink.schema).default(undefined).isNullable()), + claimType: yup.lazy(() => yup.string().default(undefined).isNullable()), + claimValue: yup.lazy(() => yup.string().default(undefined).isNullable()) + }).noUnknown() + ); + + ClaimBasedAccessControlEntry.validate = async function(value) { + return ClaimBasedAccessControlEntry.schema.validate(value, { strict: true }); + }; + + ClaimBasedAccessControlEntry.validateSync = function(value) { + return ClaimBasedAccessControlEntry.schema.validateSync(value, { strict: true }); + }; + +})(ClaimBasedAccessControlEntry || (ClaimBasedAccessControlEntry = {}));" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/models/ErrorMessage.js): ./test/result/v3/javascript/models/ErrorMessage.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import { IInnerError } from '../models/IInnerError'; +import * as yup from 'yup'; + +export let ErrorMessage; +(function (ErrorMessage) { + + ErrorMessage.schema = ( + yup.object().shape({ + code: yup.lazy(() => yup.string().default(undefined).isNullable()), + details: yup.lazy(() => yup.array().of(ErrorMessage.schema).default(undefined).isNullable()), + innerError: yup.lazy(() => IInnerError.schema.default(undefined)), + innerException: yup.lazy(() => ErrorMessage.schema.default(undefined)), + localizedMessage: yup.lazy(() => yup.string().default(undefined).isNullable()), + message: yup.lazy(() => yup.string().default(undefined).isNullable()), + stackTrace: yup.lazy(() => yup.string().default(undefined).isNullable()), + target: yup.lazy(() => yup.string().default(undefined).isNullable()) + }).noUnknown() + ); + + ErrorMessage.validate = async function(value) { + return ErrorMessage.schema.validate(value, { strict: true }); + }; + + ErrorMessage.validateSync = function(value) { + return ErrorMessage.schema.validateSync(value, { strict: true }); + }; + +})(ErrorMessage || (ErrorMessage = {}));" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/models/ErrorResponse.js): ./test/result/v3/javascript/models/ErrorResponse.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ErrorMessage } from '../models/ErrorMessage'; +import * as yup from 'yup'; + +export let ErrorResponse; +(function (ErrorResponse) { + + ErrorResponse.schema = ( + yup.object().shape({ + errorMessage: yup.lazy(() => ErrorMessage.schema.default(undefined)) + }).noUnknown() + ); + + ErrorResponse.validate = async function(value) { + return ErrorResponse.schema.validate(value, { strict: true }); + }; + + ErrorResponse.validateSync = function(value) { + return ErrorResponse.schema.validateSync(value, { strict: true }); + }; + +})(ErrorResponse || (ErrorResponse = {}));" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/models/IInnerError.js): ./test/result/v3/javascript/models/IInnerError.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import * as yup from 'yup'; + +export let IInnerError; +(function (IInnerError) { + + IInnerError.schema = ( + yup.object().shape({ + code: yup.lazy(() => yup.string().default(undefined).isNullable()), + innerError: yup.lazy(() => IInnerError.schema.default(undefined)) + }).noUnknown() + ); + + IInnerError.validate = async function(value) { + return IInnerError.schema.validate(value, { strict: true }); + }; + + IInnerError.validateSync = function(value) { + return IInnerError.schema.validateSync(value, { strict: true }); + }; + +})(IInnerError || (IInnerError = {}));" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/models/IdentityProvider.js): ./test/result/v3/javascript/models/IdentityProvider.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ClaimBasedAccessControlEntry } from '../models/ClaimBasedAccessControlEntry'; +import { IdentityProviderParameters } from '../models/IdentityProviderParameters'; +import { IdentityProviderType } from '../models/IdentityProviderType'; +import * as yup from 'yup'; + +export let IdentityProvider; +(function (IdentityProvider) { + + IdentityProvider.schema = ( + yup.object().shape({ + accessControlList: yup.lazy(() => yup.array().of(ClaimBasedAccessControlEntry.schema).default(undefined).isNullable()), + createdAt: yup.lazy(() => yup.string().default(undefined)), + createdBy: yup.lazy(() => yup.number().default(undefined).isNullable()), + description: yup.lazy(() => yup.string().default(undefined).isNullable()), + forwardedClaims: yup.lazy(() => yup.array().of(yup.string()).default(undefined).isNullable()), + iconUrl: yup.lazy(() => yup.string().default(undefined).isNullable()), + iconViewUrl: yup.lazy(() => yup.string().default(undefined).isNullable()), + id: yup.lazy(() => yup.number().default(undefined)), + isEnabled: yup.lazy(() => yup.boolean().default(undefined)), + key: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired(), + modifiedAt: yup.lazy(() => yup.string().default(undefined)), + modifiedBy: yup.lazy(() => yup.number().default(undefined).isNullable()), + name: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired(), + parameters: yup.lazy(() => IdentityProviderParameters.schema.default(undefined)).isRequired(), + postLogoutRedirectUrl: yup.lazy(() => yup.string().default(undefined).isNullable()), + redirectUrl: yup.lazy(() => yup.string().default(undefined).isNullable()), + type: yup.lazy(() => IdentityProviderType.schema.default(undefined)).isRequired(), + validateUrl: yup.lazy(() => yup.string().default(undefined).isNullable()) + }).noUnknown() + ); + + IdentityProvider.validate = async function(value) { + return IdentityProvider.schema.validate(value, { strict: true }); + }; + + IdentityProvider.validateSync = function(value) { + return IdentityProvider.schema.validateSync(value, { strict: true }); + }; + +})(IdentityProvider || (IdentityProvider = {}));" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/models/IdentityProviderParameters.js): ./test/result/v3/javascript/models/IdentityProviderParameters.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import * as yup from 'yup'; + +export let IdentityProviderParameters; +(function (IdentityProviderParameters) { + + IdentityProviderParameters.schema = ( + yup.object() + ); + + IdentityProviderParameters.validate = async function(value) { + return IdentityProviderParameters.schema.validate(value, { strict: true }); + }; + + IdentityProviderParameters.validateSync = function(value) { + return IdentityProviderParameters.schema.validateSync(value, { strict: true }); + }; + +})(IdentityProviderParameters || (IdentityProviderParameters = {}));" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/models/IdentityProviderType.js): ./test/result/v3/javascript/models/IdentityProviderType.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import * as yup from 'yup'; + +export let IdentityProviderType; +(function (IdentityProviderType) { + + IdentityProviderType.LDAP = 'LDAP'; + IdentityProviderType.OPEN_ID_CONNECT = 'OpenIdConnect'; + IdentityProviderType.SAML2P = 'SAML2P'; + IdentityProviderType.WINDOWS = 'Windows'; + + IdentityProviderType.schema = yup.mixed().oneOf([ + IdentityProviderType.LDAP, + IdentityProviderType.OPEN_ID_CONNECT, + IdentityProviderType.SAML2P, + IdentityProviderType.WINDOWS + ]); + + IdentityProviderType.validate = async function(value) { + return IdentityProviderType.schema.validate(value, { strict: true }); + }; + + IdentityProviderType.validateSync = function(value) { + return IdentityProviderType.schema.validateSync(value, { strict: true }); + }; + +})(IdentityProviderType || (IdentityProviderType = {}));" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/models/LdapParameters.js): ./test/result/v3/javascript/models/LdapParameters.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import * as yup from 'yup'; + +export let LdapParameters; +(function (LdapParameters) { + + LdapParameters.schema = ( + yup.object().shape({ + additionalAttributes: yup.lazy(() => yup.string().default(undefined).isNullable()), + fullNameClaim: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired(), + groupBaseDn: yup.lazy(() => yup.string().default(undefined).isNullable()), + groupMemberAttribute: yup.lazy(() => yup.string().default(undefined).isNullable()), + port: yup.lazy(() => yup.number().default(undefined)).isRequired(), + searchAccount: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired(), + searchAccountPassword: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired(), + separator: yup.lazy(() => yup.string().default(undefined).isNullable()), + serverAddress: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired(), + userBaseDn: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired(), + usernameClaim: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired(), + useSsl: yup.lazy(() => yup.boolean().default(undefined)).isRequired() + }).noUnknown() + ); + + LdapParameters.validate = async function(value) { + return LdapParameters.schema.validate(value, { strict: true }); + }; + + LdapParameters.validateSync = function(value) { + return LdapParameters.schema.validateSync(value, { strict: true }); + }; + +})(LdapParameters || (LdapParameters = {}));" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/models/LoginOption.js): ./test/result/v3/javascript/models/LoginOption.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import * as yup from 'yup'; + +export let LoginOption; +(function (LoginOption) { + + LoginOption.schema = ( + yup.object().shape({ + iconUrl: yup.lazy(() => yup.string().default(undefined).isNullable()), + loginTriggerUrl: yup.lazy(() => yup.string().default(undefined).isNullable()), + name: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired() + }).noUnknown() + ); + + LoginOption.validate = async function(value) { + return LoginOption.schema.validate(value, { strict: true }); + }; + + LoginOption.validateSync = function(value) { + return LoginOption.schema.validateSync(value, { strict: true }); + }; + +})(LoginOption || (LoginOption = {}));" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/models/OpenIdParameters.js): ./test/result/v3/javascript/models/OpenIdParameters.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import * as yup from 'yup'; + +export let OpenIdParameters; +(function (OpenIdParameters) { + + OpenIdParameters.schema = ( + yup.object().shape({ + authority: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired(), + clientId: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired(), + clientSecret: yup.lazy(() => yup.string().default(undefined).isNullable()), + endSessionEndpoint: yup.lazy(() => yup.string().default(undefined).isNullable()), + fullNameClaim: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired(), + sendIdTokenHintDuringLogout: yup.lazy(() => yup.boolean().default(undefined)), + separator: yup.lazy(() => yup.string().default(undefined).isNullable()), + usernameClaim: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired() + }).noUnknown() + ); + + OpenIdParameters.validate = async function(value) { + return OpenIdParameters.schema.validate(value, { strict: true }); + }; + + OpenIdParameters.validateSync = function(value) { + return OpenIdParameters.schema.validateSync(value, { strict: true }); + }; + +})(OpenIdParameters || (OpenIdParameters = {}));" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/models/ProblemDetails.js): ./test/result/v3/javascript/models/ProblemDetails.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + + +import * as yup from 'yup'; + +export let ProblemDetails; +(function (ProblemDetails) { + + ProblemDetails.schema = ( + yup.object().shape({ + detail: yup.lazy(() => yup.string().default(undefined).isNullable()), + extensions: yup.lazy(() => yup.lazy(value => { + return yup.object().shape( + Object.entries(value).reduce((obj, item) => ({ + ...obj, + [item[0]]: ( + yup.object() + ) + }), {}) + ); + }).default(undefined).isNullable()), + instance: yup.lazy(() => yup.string().default(undefined).isNullable()), + status: yup.lazy(() => yup.number().default(undefined).isNullable()), + title: yup.lazy(() => yup.string().default(undefined).isNullable()), + type: yup.lazy(() => yup.string().default(undefined).isNullable()) + }).noUnknown() + ); + + ProblemDetails.validate = async function(value) { + return ProblemDetails.schema.validate(value, { strict: true }); + }; + + ProblemDetails.validateSync = function(value) { + return ProblemDetails.schema.validateSync(value, { strict: true }); + }; + +})(ProblemDetails || (ProblemDetails = {}));" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/models/SamlParameters.js): ./test/result/v3/javascript/models/SamlParameters.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import * as yup from 'yup'; + +export let SamlParameters; +(function (SamlParameters) { + + SamlParameters.schema = ( + yup.object().shape({ + certificates: yup.lazy(() => yup.array().of(yup.string()).default(undefined).isNullable()).isRequired(), + fullNameClaim: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired(), + issuerName: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired(), + separator: yup.lazy(() => yup.string().default(undefined).isNullable()), + serviceProviderName: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired(), + singleLogoutServiceUrl: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired(), + singleSignOnServiceUrl: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired(), + usernameClaim: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired() + }).noUnknown() + ); + + SamlParameters.validate = async function(value) { + return SamlParameters.schema.validate(value, { strict: true }); + }; + + SamlParameters.validateSync = function(value) { + return SamlParameters.schema.validateSync(value, { strict: true }); + }; + +})(SamlParameters || (SamlParameters = {}));" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/models/ServiceAccount.js): ./test/result/v3/javascript/models/ServiceAccount.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ServiceAccountBasedAccessControlEntry } from '../models/ServiceAccountBasedAccessControlEntry'; +import { UserClientSecret } from '../models/UserClientSecret'; +import * as yup from 'yup'; + +export let ServiceAccount; +(function (ServiceAccount) { + + ServiceAccount.schema = ( + yup.object().shape({ + accessControlEntry: yup.lazy(() => ServiceAccountBasedAccessControlEntry.schema.default(undefined)), + clientId: yup.lazy(() => yup.string().default(undefined).isNullable()), + clientSecrets: yup.lazy(() => yup.array().of(UserClientSecret.schema).default(undefined).isNullable()), + createdAt: yup.lazy(() => yup.string().default(undefined)), + createdBy: yup.lazy(() => yup.number().default(undefined).isNullable()), + id: yup.lazy(() => yup.number().default(undefined)), + lastLoginAt: yup.lazy(() => yup.string().default(undefined).isNullable()), + modifiedAt: yup.lazy(() => yup.string().default(undefined)), + modifiedBy: yup.lazy(() => yup.number().default(undefined).isNullable()), + name: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired() + }).noUnknown() + ); + + ServiceAccount.validate = async function(value) { + return ServiceAccount.schema.validate(value, { strict: true }); + }; + + ServiceAccount.validateSync = function(value) { + return ServiceAccount.schema.validateSync(value, { strict: true }); + }; + +})(ServiceAccount || (ServiceAccount = {}));" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/models/ServiceAccountBasedAccessControlEntry.js): ./test/result/v3/javascript/models/ServiceAccountBasedAccessControlEntry.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ApiResourceLink } from '../models/ApiResourceLink'; +import { ApiResourceRoleLink } from '../models/ApiResourceRoleLink'; +import * as yup from 'yup'; + +export let ServiceAccountBasedAccessControlEntry; +(function (ServiceAccountBasedAccessControlEntry) { + + ServiceAccountBasedAccessControlEntry.schema = ( + yup.object().shape({ + apiResourceRoles: yup.lazy(() => yup.array().of(ApiResourceRoleLink.schema).default(undefined).isNullable()), + apiResources: yup.lazy(() => yup.array().of(ApiResourceLink.schema).default(undefined).isNullable()) + }).noUnknown() + ); + + ServiceAccountBasedAccessControlEntry.validate = async function(value) { + return ServiceAccountBasedAccessControlEntry.schema.validate(value, { strict: true }); + }; + + ServiceAccountBasedAccessControlEntry.validateSync = function(value) { + return ServiceAccountBasedAccessControlEntry.schema.validateSync(value, { strict: true }); + }; + +})(ServiceAccountBasedAccessControlEntry || (ServiceAccountBasedAccessControlEntry = {}));" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/models/User.js): ./test/result/v3/javascript/models/User.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import { UserBasedAccessControlEntry } from '../models/UserBasedAccessControlEntry'; +import { UserClientSecret } from '../models/UserClientSecret'; +import * as yup from 'yup'; + +export let User; +(function (User) { + + User.schema = ( + yup.object().shape({ + accessControlEntry: yup.lazy(() => UserBasedAccessControlEntry.schema.default(undefined)), + clientId: yup.lazy(() => yup.string().default(undefined).isNullable()), + clientSecrets: yup.lazy(() => yup.array().of(UserClientSecret.schema).default(undefined).isNullable()), + createdAt: yup.lazy(() => yup.string().default(undefined)), + createdBy: yup.lazy(() => yup.number().default(undefined).isNullable()), + email: yup.lazy(() => yup.string().default(undefined).isNullable()), + id: yup.lazy(() => yup.number().default(undefined)), + identityProviderId: yup.lazy(() => yup.number().default(undefined)).isRequired(), + identityProviderKey: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired(), + lastLoginAt: yup.lazy(() => yup.string().default(undefined).isNullable()), + modifiedAt: yup.lazy(() => yup.string().default(undefined)), + modifiedBy: yup.lazy(() => yup.number().default(undefined).isNullable()), + name: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired(), + subject: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired() + }).noUnknown() + ); + + User.validate = async function(value) { + return User.schema.validate(value, { strict: true }); + }; + + User.validateSync = function(value) { + return User.schema.validateSync(value, { strict: true }); + }; + +})(User || (User = {}));" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/models/UserBasedAccessControlEntry.js): ./test/result/v3/javascript/models/UserBasedAccessControlEntry.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ApiResourceLink } from '../models/ApiResourceLink'; +import { ApiResourceRoleLink } from '../models/ApiResourceRoleLink'; +import { ApplicationLink } from '../models/ApplicationLink'; +import * as yup from 'yup'; + +export let UserBasedAccessControlEntry; +(function (UserBasedAccessControlEntry) { + + UserBasedAccessControlEntry.schema = ( + yup.object().shape({ + apiResourceRoles: yup.lazy(() => yup.array().of(ApiResourceRoleLink.schema).default(undefined).isNullable()), + apiResources: yup.lazy(() => yup.array().of(ApiResourceLink.schema).default(undefined).isNullable()), + applications: yup.lazy(() => yup.array().of(ApplicationLink.schema).default(undefined).isNullable()) + }).noUnknown() + ); + + UserBasedAccessControlEntry.validate = async function(value) { + return UserBasedAccessControlEntry.schema.validate(value, { strict: true }); + }; + + UserBasedAccessControlEntry.validateSync = function(value) { + return UserBasedAccessControlEntry.schema.validateSync(value, { strict: true }); + }; + +})(UserBasedAccessControlEntry || (UserBasedAccessControlEntry = {}));" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/models/UserClientSecret.js): ./test/result/v3/javascript/models/UserClientSecret.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import * as yup from 'yup'; + +export let UserClientSecret; +(function (UserClientSecret) { + + UserClientSecret.schema = ( + yup.object().shape({ + clientSecret: yup.lazy(() => yup.string().default(undefined).isNullable()).isRequired(), + clientSecretUnHashed: yup.lazy(() => yup.string().default(undefined).isNullable()), + expiresAt: yup.lazy(() => yup.string().default(undefined)).isRequired(), + id: yup.lazy(() => yup.number().default(undefined)), + lastLoginAt: yup.lazy(() => yup.string().default(undefined).isNullable()) + }).noUnknown() + ); + + UserClientSecret.validate = async function(value) { + return UserClientSecret.schema.validate(value, { strict: true }); + }; + + UserClientSecret.validateSync = function(value) { + return UserClientSecret.schema.validateSync(value, { strict: true }); + }; + +})(UserClientSecret || (UserClientSecret = {}));" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/models/WindowsParameters.js): ./test/result/v3/javascript/models/WindowsParameters.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import * as yup from 'yup'; + +export let WindowsParameters; +(function (WindowsParameters) { + + WindowsParameters.schema = ( + yup.object() + ); + + WindowsParameters.validate = async function(value) { + return WindowsParameters.schema.validate(value, { strict: true }); + }; + + WindowsParameters.validateSync = function(value) { + return WindowsParameters.schema.validateSync(value, { strict: true }); + }; + +})(WindowsParameters || (WindowsParameters = {}));" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/services/ApiResourcesService.js): ./test/result/v3/javascript/services/ApiResourcesService.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ApiError, catchGenericError } from '../core/ApiError'; +import { request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class ApiResourcesService { + + /** + * @result any Success + * @throws ApiError + */ + static async get() { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/ApiResources\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param id + * @result any Success + * @throws ApiError + */ + static async get1( + id + ) { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/ApiResources/\${id}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param name + * @result any Success + * @throws ApiError + */ + static async getByName( + name + ) { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/ApiResources/getByName/\${name}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/services/ApplicationsService.js): ./test/result/v3/javascript/services/ApplicationsService.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ApiError, catchGenericError } from '../core/ApiError'; +import { request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class ApplicationsService { + + /** + * @param id + * @result any Success + * @throws ApiError + */ + static async get( + id + ) { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/Applications/\${id}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @result any Success + * @throws ApiError + */ + static async get1() { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/Applications\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param clientId + * @result any Success + * @throws ApiError + */ + static async getByClientId( + clientId + ) { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/Applications/getByClientId/\${clientId}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param name + * @result any Success + * @throws ApiError + */ + static async getByName( + name + ) { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/Applications/getByName/\${name}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param id + * @result any Success + * @throws ApiError + */ + static async update( + id + ) { + + const result = await request({ + method: 'put', + path: \`/api/v\${OpenAPI.VERSION}/Applications/\${id}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/services/ClaimsService.js): ./test/result/v3/javascript/services/ClaimsService.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ApiError, catchGenericError } from '../core/ApiError'; +import { request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class ClaimsService { + + /** + * @result any Success + * @throws ApiError + */ + static async get() { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/Claims\` + }); + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/services/IdentityProvidersService.js): ./test/result/v3/javascript/services/IdentityProvidersService.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ApiError, catchGenericError } from '../core/ApiError'; +import { request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class IdentityProvidersService { + + /** + * @result any Success + * @throws ApiError + */ + static async create() { + + const result = await request({ + method: 'post', + path: \`/api/v\${OpenAPI.VERSION}/IdentityProviders\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param id + * @result any Success + * @throws ApiError + */ + static async delete( + id + ) { + + const result = await request({ + method: 'delete', + path: \`/api/v\${OpenAPI.VERSION}/IdentityProviders/\${id}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @result any Success + * @throws ApiError + */ + static async get() { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/IdentityProviders\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param id + * @result any Success + * @throws ApiError + */ + static async get1( + id + ) { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/IdentityProviders/\${id}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param name + * @result any Success + * @throws ApiError + */ + static async getIcon( + name + ) { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/IdentityProviders/icon/\${name}\` + }); + + if (!result.ok) { + switch (result.status) { + case 416: throw new ApiError(result, \`Client Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @result any Success + * @throws ApiError + */ + static async getLoginOptions() { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/IdentityProviders/loginOptions\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param providerType + * @result any Success + * @throws ApiError + */ + static async getParametersForIdentityProviderType( + providerType + ) { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/IdentityProviders/getParametersForIdentityProviderType/\${providerType}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param id + * @result any Success + * @throws ApiError + */ + static async update( + id + ) { + + const result = await request({ + method: 'put', + path: \`/api/v\${OpenAPI.VERSION}/IdentityProviders/\${id}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/services/ServiceAccountsService.js): ./test/result/v3/javascript/services/ServiceAccountsService.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ApiError, catchGenericError } from '../core/ApiError'; +import { request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class ServiceAccountsService { + + /** + * @param serviceAccountId + * @param secretId + * @result any Success + * @throws ApiError + */ + static async deleteClientSecret( + serviceAccountId, + secretId + ) { + + const result = await request({ + method: 'delete', + path: \`/api/v\${OpenAPI.VERSION}/ServiceAccounts/\${serviceAccountId}/clientSecrets/\${secretId}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param serviceAccountId + * @result any Success + * @throws ApiError + */ + static async generateClientSecret( + serviceAccountId + ) { + + const result = await request({ + method: 'post', + path: \`/api/v\${OpenAPI.VERSION}/ServiceAccounts/\${serviceAccountId}/generateClientSecret\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @result any Success + * @throws ApiError + */ + static async get() { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/ServiceAccounts\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param id + * @result any Success + * @throws ApiError + */ + static async get1( + id + ) { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/ServiceAccounts/\${id}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param secretId + * @param serviceAccountId + * @result any Success + * @throws ApiError + */ + static async updateClientSecret( + secretId, + serviceAccountId + ) { + + const result = await request({ + method: 'put', + path: \`/api/v\${OpenAPI.VERSION}/ServiceAccounts/\${serviceAccountId}/clientSecrets/\${secretId}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/services/SuggestionsService.js): ./test/result/v3/javascript/services/SuggestionsService.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ApiError, catchGenericError } from '../core/ApiError'; +import { request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class SuggestionsService { + + /** + * @param searchText + * @result any Success + * @throws ApiError + */ + static async getClaimTypes( + searchText + ) { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/Suggestions/claimTypes\`, + query: { + 'searchText': searchText + } + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`generation v3 javascript file(./test/result/v3/javascript/services/UsersService.js): ./test/result/v3/javascript/services/UsersService.js 1`] = ` +"/* istanbul ignore file */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ApiError, catchGenericError } from '../core/ApiError'; +import { request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class UsersService { + + /** + * @result any Success + * @throws ApiError + */ + static async create() { + + const result = await request({ + method: 'post', + path: \`/api/v\${OpenAPI.VERSION}/Users\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param id + * @result any Success + * @throws ApiError + */ + static async delete( + id + ) { + + const result = await request({ + method: 'delete', + path: \`/api/v\${OpenAPI.VERSION}/Users/\${id}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param userId + * @param secretId + * @result any Success + * @throws ApiError + */ + static async deleteClientSecret( + userId, + secretId + ) { + + const result = await request({ + method: 'delete', + path: \`/api/v\${OpenAPI.VERSION}/Users/\${userId}/clientSecrets/\${secretId}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param userId + * @result any Success + * @throws ApiError + */ + static async generateClientSecret( + userId + ) { + + const result = await request({ + method: 'post', + path: \`/api/v\${OpenAPI.VERSION}/Users/\${userId}/generateClientSecret\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param id + * @result any Success + * @throws ApiError + */ + static async get( + id + ) { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/Users/\${id}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @result any Success + * @throws ApiError + */ + static async get1() { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/Users\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param id + * @result any Success + * @throws ApiError + */ + static async update( + id + ) { + + const result = await request({ + method: 'put', + path: \`/api/v\${OpenAPI.VERSION}/Users/\${id}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param secretId + * @param userId + * @result any Success + * @throws ApiError + */ + static async updateClientSecret( + secretId, + userId + ) { + + const result = await request({ + method: 'put', + path: \`/api/v\${OpenAPI.VERSION}/Users/\${userId}/clientSecrets/\${secretId}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/core/ApiError.ts): ./test/result/v3/typescript/core/ApiError.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import { isSuccess } from './isSuccess'; +import { Result } from './Result'; + +export class ApiError extends Error { + + public readonly url: string; + public readonly status: number; + public readonly statusText: string; + public readonly body: any; + + constructor(result: Readonly, message: string) { + super(message); + + this.url = result.url; + this.status = result.status; + this.statusText = result.statusText; + this.body = result.body; + } +} + +export namespace ApiError { + export enum Message { + BAD_REQUEST = 'Bad Request', + UNAUTHORIZED = 'Unauthorized', + FORBIDDEN = 'Forbidden', + NOT_FOUND = 'Not Found', + INTERNAL_SERVER_ERROR = 'Internal Server Error', + BAD_GATEWAY = 'Bad Gateway', + SERVICE_UNAVAILABLE = 'Service Unavailable', + GENERIC_ERROR = 'Generic Error', + } +} + +/** + * Catch common errors (based on status code). + * @param result + */ +export function catchGenericError(result: Result): void { + switch (result.status) { + case 400: throw new ApiError(result, ApiError.Message.BAD_REQUEST); + case 401: throw new ApiError(result, ApiError.Message.UNAUTHORIZED); + case 403: throw new ApiError(result, ApiError.Message.FORBIDDEN); + case 404: throw new ApiError(result, ApiError.Message.NOT_FOUND); + case 500: throw new ApiError(result, ApiError.Message.INTERNAL_SERVER_ERROR); + case 502: throw new ApiError(result, ApiError.Message.BAD_GATEWAY); + case 503: throw new ApiError(result, ApiError.Message.SERVICE_UNAVAILABLE); + } + + if (!isSuccess(result.status)) { + throw new ApiError(result, ApiError.Message.GENERIC_ERROR); + } +} +" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/core/OpenAPI.ts): ./test/result/v3/typescript/core/OpenAPI.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +export namespace OpenAPI { + export let BASE = '/access-manager'; + export let VERSION = '1'; + export let CLIENT = 'fetch'; + export let TOKEN = ''; +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/core/RequestOptions.ts): ./test/result/v3/typescript/core/RequestOptions.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +export interface RequestOptions { + method: 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch'; + path: string; + headers?: { [key: string]: any }; + query?: { [key: string]: any }; + formData?: { [key: string]: any }; + body?: any; +} +" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/core/Result.ts): ./test/result/v3/typescript/core/Result.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +export interface Result { + url: string; + ok: boolean; + status: number; + statusText: string; + body: any; +} +" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/core/getFormData.ts): ./test/result/v3/typescript/core/getFormData.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +/** + * Get FormData from object. This method is needed to upload + * multipart form data to the REST API. + * @param params Key value based object. + */ +export function getFormData(params: { [key: string]: any }): FormData { + const formData = new FormData(); + for (const key in params) { + if (typeof params[key] !== 'undefined') { + const value: any = params[key]; + if (value !== undefined && value !== null) { + formData.append(key, value); + } + } + } + return formData; +} +" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/core/getQueryString.ts): ./test/result/v3/typescript/core/getQueryString.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +/** + * Get query string from query parameters object. This method also + * supports multi-value items by creating a key for each item. + * @param params Key value based object. + */ +export function getQueryString(params: { [key: string]: any }): string { + const qs: string[] = []; + for (const key in params) { + if (typeof params[key] !== 'undefined') { + const value: any = params[key]; + if (value !== undefined && value !== null) { + if (Array.isArray(value)) { + value.forEach(value => { + qs.push(\`\${encodeURIComponent(key)}=\${encodeURIComponent(String(value))}\`); + }); + } else { + qs.push(\`\${encodeURIComponent(key)}=\${encodeURIComponent(String(value))}\`); + } + } + } + } + if (qs.length > 0) { + return \`?\${qs.join('&')}\`; + } + return ''; +} +" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/core/isSuccess.ts): ./test/result/v3/typescript/core/isSuccess.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +/** + * Check success response code. + * @param status Status code + */ +export function isSuccess(status: number): boolean { + return status >= 200 && status < 300; +} +" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/core/request.ts): ./test/result/v3/typescript/core/request.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import {getFormData} from './getFormData'; +import {getQueryString} from './getQueryString'; +import {OpenAPI} from './OpenAPI'; +import {RequestOptions} from './RequestOptions'; +import {requestUsingFetch} from './requestUsingFetch'; +import {requestUsingXHR} from './requestUsingXHR'; +import {Result} from './Result'; + +/** + * Create the request. + * @param options Request method options. + * @returns Result object (see above) + */ +export async function request(options: Readonly): Promise { + + // Create the request URL + let url = \`\${OpenAPI.BASE}\${options.path}\`; + + // Create request headers + const headers = new Headers({ + ...options.headers, + Accept: 'application/json' + }); + + // Create request settings + const request: RequestInit = { + headers, + method: options.method, + credentials: 'same-origin' + }; + + // If we have a bearer token then we set the authentication header. + if (OpenAPI.TOKEN !== null && OpenAPI.TOKEN !== '') { + headers.append('Authorization', \`Bearer \${OpenAPI.TOKEN}\`); + } + + // Add the query parameters (if defined). + if (options.query) { + url += getQueryString(options.query); + } + + // Append formData as body + if (options.formData) { + request.body = getFormData(options.formData); + } else if (options.body) { + + // If this is blob data, then pass it directly to the body and set content type. + // Otherwise we just convert request data to JSON string (needed for fetch api) + if (options.body instanceof Blob) { + request.body = options.body; + if (options.body.type) { + headers.append('Content-Type', options.body.type); + } + } else { + request.body = JSON.stringify(options.body); + headers.append('Content-Type', 'application/json'); + } + } + + try { + switch (OpenAPI.CLIENT) { + case 'xhr': + return await requestUsingXHR(url, request); + default: + return await requestUsingFetch(url, request); + } + } catch (error) { + return { + url, + ok: false, + status: 0, + statusText: '', + body: error + }; + } +} +" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/core/requestUsingFetch.ts): ./test/result/v3/typescript/core/requestUsingFetch.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import { Result } from './Result'; + +/** + * Request content using the new Fetch API. This is the default API that is used and + * is create for all JSON, XML and text objects. However it is limited to UTF-8. + * This is a problem for some of the Docs content, since that requires UTF-16! + * @param url The url to request. + * @param request The request object, containing method, headers, body, etc. + */ +export async function requestUsingFetch(url: string, request: Readonly): Promise { + + // Fetch response using fetch API. + const response = await fetch(url, request); + + // Create result object. + const result: Result = { + url, + ok: response.ok, + status: response.status, + statusText: response.statusText, + body: null + }; + + // Try to parse the content for any response status code. + // We check the \\"Content-Type\\" header to see if we need to parse the + // content as json or as plain text. + const contentType = response.headers.get('Content-Type'); + if (contentType) { + switch (contentType.toLowerCase()) { + case 'application/json': + case 'application/json; charset=utf-8': + result.body = await response.json(); + break; + + case 'text/plain': + case 'text/xml': + case 'text/xml; charset=utf-8': + case 'text/xml; charset=utf-16': + result.body = await response.text(); + break; + } + } + + return result; +} +" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/core/requestUsingXHR.ts): ./test/result/v3/typescript/core/requestUsingXHR.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import { Result } from './Result'; +import { isSuccess } from './isSuccess'; + +/** + * Request content using the new legacy XMLHttpRequest API. This method is useful + * when we want to request UTF-16 content, since it natively supports loading UTF-16. + * We could do the same with the Fetch API, but then we will need to convert the + * content using JavaScript... And that is very very slow. + * @param url The url to request. + * @param request The request object, containing method, headers, body, etc. + */ +export async function requestUsingXHR(url: string, request: Readonly): Promise { + return new Promise(resolve => { + const xhr = new XMLHttpRequest(); + + // Open the request, remember to do this before adding any headers, + // because the request needs to be initialized! + xhr.open(request.method!, url, true); + + // Add the headers (required when dealing with JSON) + const headers = request.headers as Headers; + headers.forEach((value: string, key: string): void => { + xhr.setRequestHeader(key, value); + }); + + // Register the readystate handler, this will fire when the request is done. + xhr.onreadystatechange = () => { + if (xhr.readyState === XMLHttpRequest.DONE) { + + // Create result object. + const result: Result = { + url, + ok: isSuccess(xhr.status), + status: xhr.status, + statusText: xhr.statusText, + body: null + }; + + // Try to parse the content for any response status code. + // We check the \\"Content-Type\\" header to see if we need to parse the + // content as json or as plain text. + const contentType = xhr.getResponseHeader('Content-Type'); + if (contentType) { + switch (contentType.toLowerCase()) { + case 'application/json': + case 'application/json; charset=utf-8': + result.body = JSON.parse(xhr.responseText); + break; + + case 'text/plain': + case 'text/xml': + case 'text/xml; charset=utf-8': + case 'text/xml; charset=utf-16': + result.body = xhr.responseText; + break; + } + } + + // Done! + resolve(result); + } + }; + + // Start the request! + xhr.send(request.body); + }); +} +" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/index.ts): ./test/result/v3/typescript/index.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +export { ApiError } from './core/ApiError'; +export { isSuccess } from './core/isSuccess'; +export { OpenAPI } from './core/OpenAPI'; + +export { ApiResource } from './models/ApiResource'; +export { ApiResourceLink } from './models/ApiResourceLink'; +export { ApiResourceRole } from './models/ApiResourceRole'; +export { ApiResourceRoleLink } from './models/ApiResourceRoleLink'; +export { Application } from './models/Application'; +export { ApplicationLink } from './models/ApplicationLink'; +export { ClaimBasedAccessControlEntry } from './models/ClaimBasedAccessControlEntry'; +export { Dictionary } from './models/Dictionary'; +export { ErrorMessage } from './models/ErrorMessage'; +export { ErrorResponse } from './models/ErrorResponse'; +export { IdentityProvider } from './models/IdentityProvider'; +export { IdentityProviderParameters } from './models/IdentityProviderParameters'; +export { IdentityProviderType } from './models/IdentityProviderType'; +export { IInnerError } from './models/IInnerError'; +export { LdapParameters } from './models/LdapParameters'; +export { LoginOption } from './models/LoginOption'; +export { OpenIdParameters } from './models/OpenIdParameters'; +export { ProblemDetails } from './models/ProblemDetails'; +export { SamlParameters } from './models/SamlParameters'; +export { ServiceAccount } from './models/ServiceAccount'; +export { ServiceAccountBasedAccessControlEntry } from './models/ServiceAccountBasedAccessControlEntry'; +export { User } from './models/User'; +export { UserBasedAccessControlEntry } from './models/UserBasedAccessControlEntry'; +export { UserClientSecret } from './models/UserClientSecret'; +export { WindowsParameters } from './models/WindowsParameters'; + +export { ApiResourcesService } from './services/ApiResourcesService'; +export { ApplicationsService } from './services/ApplicationsService'; +export { ClaimsService } from './services/ClaimsService'; +export { IdentityProvidersService } from './services/IdentityProvidersService'; +export { ServiceAccountsService } from './services/ServiceAccountsService'; +export { SuggestionsService } from './services/SuggestionsService'; +export { UsersService } from './services/UsersService'; +" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/models/ApiResource.ts): ./test/result/v3/typescript/models/ApiResource.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ApiResourceRole } from '../models/ApiResourceRole'; +import * as yup from 'yup'; + +export interface ApiResource { + id?: number; + key: string | null; + name: string | null; + roles?: Array | null; +} + +export namespace ApiResource { + + export const schema: yup.ObjectSchema = ( + yup.object().shape({ + id: yup.lazy(() => yup.number().default(undefined)), + key: yup.lazy(() => yup.string().default(undefined).nullable().required()), + name: yup.lazy(() => yup.string().default(undefined).nullable().required()), + roles: yup.lazy(() => yup.array().of(ApiResourceRole.schema).default(undefined).nullable()) + }).noUnknown() + ); + + export async function validate(value: any): Promise { + return schema.validate(value, { strict: true }); + } + + export function validateSync(value: any): ApiResource { + return schema.validateSync(value, { strict: true }); + } +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/models/ApiResourceLink.ts): ./test/result/v3/typescript/models/ApiResourceLink.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import * as yup from 'yup'; + +export interface ApiResourceLink { + id?: number; + name?: string | null; +} + +export namespace ApiResourceLink { + + export const schema: yup.ObjectSchema = ( + yup.object().shape({ + id: yup.lazy(() => yup.number().default(undefined)), + name: yup.lazy(() => yup.string().default(undefined).nullable()) + }).noUnknown() + ); + + export async function validate(value: any): Promise { + return schema.validate(value, { strict: true }); + } + + export function validateSync(value: any): ApiResourceLink { + return schema.validateSync(value, { strict: true }); + } +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/models/ApiResourceRole.ts): ./test/result/v3/typescript/models/ApiResourceRole.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ApiResource } from '../models/ApiResource'; +import * as yup from 'yup'; + +export interface ApiResourceRole { + apiResource?: ApiResource; + id?: number; + key: string | null; + name: string | null; +} + +export namespace ApiResourceRole { + + export const schema: yup.ObjectSchema = ( + yup.object().shape({ + apiResource: yup.lazy(() => ApiResource.schema.default(undefined)), + id: yup.lazy(() => yup.number().default(undefined)), + key: yup.lazy(() => yup.string().default(undefined).nullable().required()), + name: yup.lazy(() => yup.string().default(undefined).nullable().required()) + }).noUnknown() + ); + + export async function validate(value: any): Promise { + return schema.validate(value, { strict: true }); + } + + export function validateSync(value: any): ApiResourceRole { + return schema.validateSync(value, { strict: true }); + } +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/models/ApiResourceRoleLink.ts): ./test/result/v3/typescript/models/ApiResourceRoleLink.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import * as yup from 'yup'; + +export interface ApiResourceRoleLink { + id?: number; + name?: string | null; +} + +export namespace ApiResourceRoleLink { + + export const schema: yup.ObjectSchema = ( + yup.object().shape({ + id: yup.lazy(() => yup.number().default(undefined)), + name: yup.lazy(() => yup.string().default(undefined).nullable()) + }).noUnknown() + ); + + export async function validate(value: any): Promise { + return schema.validate(value, { strict: true }); + } + + export function validateSync(value: any): ApiResourceRoleLink { + return schema.validateSync(value, { strict: true }); + } +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/models/Application.ts): ./test/result/v3/typescript/models/Application.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import * as yup from 'yup'; + +export interface Application { + clientId?: string | null; + createdAt?: string; + createdBy?: number | null; + id?: number; + modifiedAt?: string; + modifiedBy?: number | null; + name: string | null; + redirectUrls: Array | null; +} + +export namespace Application { + + export const schema: yup.ObjectSchema = ( + yup.object().shape({ + clientId: yup.lazy(() => yup.string().default(undefined).nullable()), + createdAt: yup.lazy(() => yup.string().default(undefined)), + createdBy: yup.lazy(() => yup.number().default(undefined).nullable()), + id: yup.lazy(() => yup.number().default(undefined)), + modifiedAt: yup.lazy(() => yup.string().default(undefined)), + modifiedBy: yup.lazy(() => yup.number().default(undefined).nullable()), + name: yup.lazy(() => yup.string().default(undefined).nullable().required()), + redirectUrls: yup.lazy(() => yup.array().of(yup.string()).default(undefined).nullable().required()) + }).noUnknown() + ); + + export async function validate(value: any): Promise { + return schema.validate(value, { strict: true }); + } + + export function validateSync(value: any): Application { + return schema.validateSync(value, { strict: true }); + } +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/models/ApplicationLink.ts): ./test/result/v3/typescript/models/ApplicationLink.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import * as yup from 'yup'; + +export interface ApplicationLink { + id?: number; + name?: string | null; +} + +export namespace ApplicationLink { + + export const schema: yup.ObjectSchema = ( + yup.object().shape({ + id: yup.lazy(() => yup.number().default(undefined)), + name: yup.lazy(() => yup.string().default(undefined).nullable()) + }).noUnknown() + ); + + export async function validate(value: any): Promise { + return schema.validate(value, { strict: true }); + } + + export function validateSync(value: any): ApplicationLink { + return schema.validateSync(value, { strict: true }); + } +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/models/ClaimBasedAccessControlEntry.ts): ./test/result/v3/typescript/models/ClaimBasedAccessControlEntry.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ApiResourceLink } from '../models/ApiResourceLink'; +import { ApiResourceRoleLink } from '../models/ApiResourceRoleLink'; +import { ApplicationLink } from '../models/ApplicationLink'; +import * as yup from 'yup'; + +export interface ClaimBasedAccessControlEntry { + apiResourceRoles?: Array | null; + apiResources?: Array | null; + applications?: Array | null; + claimType?: string | null; + claimValue?: string | null; +} + +export namespace ClaimBasedAccessControlEntry { + + export const schema: yup.ObjectSchema = ( + yup.object().shape({ + apiResourceRoles: yup.lazy(() => yup.array().of(ApiResourceRoleLink.schema).default(undefined).nullable()), + apiResources: yup.lazy(() => yup.array().of(ApiResourceLink.schema).default(undefined).nullable()), + applications: yup.lazy(() => yup.array().of(ApplicationLink.schema).default(undefined).nullable()), + claimType: yup.lazy(() => yup.string().default(undefined).nullable()), + claimValue: yup.lazy(() => yup.string().default(undefined).nullable()) + }).noUnknown() + ); + + export async function validate(value: any): Promise { + return schema.validate(value, { strict: true }); + } + + export function validateSync(value: any): ClaimBasedAccessControlEntry { + return schema.validateSync(value, { strict: true }); + } +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/models/Dictionary.ts): ./test/result/v3/typescript/models/Dictionary.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +export interface Dictionary { + [key: string]: T; +} +" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/models/ErrorMessage.ts): ./test/result/v3/typescript/models/ErrorMessage.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import { IInnerError } from '../models/IInnerError'; +import * as yup from 'yup'; + +export interface ErrorMessage { + code?: string | null; + details?: Array | null; + innerError?: IInnerError; + innerException?: ErrorMessage; + localizedMessage?: string | null; + message?: string | null; + stackTrace?: string | null; + target?: string | null; +} + +export namespace ErrorMessage { + + export const schema: yup.ObjectSchema = ( + yup.object().shape({ + code: yup.lazy(() => yup.string().default(undefined).nullable()), + details: yup.lazy(() => yup.array().of(ErrorMessage.schema).default(undefined).nullable()), + innerError: yup.lazy(() => IInnerError.schema.default(undefined)), + innerException: yup.lazy(() => ErrorMessage.schema.default(undefined)), + localizedMessage: yup.lazy(() => yup.string().default(undefined).nullable()), + message: yup.lazy(() => yup.string().default(undefined).nullable()), + stackTrace: yup.lazy(() => yup.string().default(undefined).nullable()), + target: yup.lazy(() => yup.string().default(undefined).nullable()) + }).noUnknown() + ); + + export async function validate(value: any): Promise { + return schema.validate(value, { strict: true }); + } + + export function validateSync(value: any): ErrorMessage { + return schema.validateSync(value, { strict: true }); + } +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/models/ErrorResponse.ts): ./test/result/v3/typescript/models/ErrorResponse.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ErrorMessage } from '../models/ErrorMessage'; +import * as yup from 'yup'; + +export interface ErrorResponse { + errorMessage?: ErrorMessage; +} + +export namespace ErrorResponse { + + export const schema: yup.ObjectSchema = ( + yup.object().shape({ + errorMessage: yup.lazy(() => ErrorMessage.schema.default(undefined)) + }).noUnknown() + ); + + export async function validate(value: any): Promise { + return schema.validate(value, { strict: true }); + } + + export function validateSync(value: any): ErrorResponse { + return schema.validateSync(value, { strict: true }); + } +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/models/IInnerError.ts): ./test/result/v3/typescript/models/IInnerError.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import * as yup from 'yup'; + +export interface IInnerError { + code?: string | null; + innerError?: IInnerError; +} + +export namespace IInnerError { + + export const schema: yup.ObjectSchema = ( + yup.object().shape({ + code: yup.lazy(() => yup.string().default(undefined).nullable()), + innerError: yup.lazy(() => IInnerError.schema.default(undefined)) + }).noUnknown() + ); + + export async function validate(value: any): Promise { + return schema.validate(value, { strict: true }); + } + + export function validateSync(value: any): IInnerError { + return schema.validateSync(value, { strict: true }); + } +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/models/IdentityProvider.ts): ./test/result/v3/typescript/models/IdentityProvider.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ClaimBasedAccessControlEntry } from '../models/ClaimBasedAccessControlEntry'; +import { IdentityProviderParameters } from '../models/IdentityProviderParameters'; +import { IdentityProviderType } from '../models/IdentityProviderType'; +import * as yup from 'yup'; + +export interface IdentityProvider { + accessControlList?: Array | null; + createdAt?: string; + createdBy?: number | null; + description?: string | null; + forwardedClaims?: Array | null; + iconUrl?: string | null; + iconViewUrl?: string | null; + id?: number; + isEnabled?: boolean; + key: string | null; + modifiedAt?: string; + modifiedBy?: number | null; + name: string | null; + parameters: IdentityProviderParameters; + postLogoutRedirectUrl?: string | null; + redirectUrl?: string | null; + type: IdentityProviderType; + validateUrl?: string | null; +} + +export namespace IdentityProvider { + + export const schema: yup.ObjectSchema = ( + yup.object().shape({ + accessControlList: yup.lazy(() => yup.array().of(ClaimBasedAccessControlEntry.schema).default(undefined).nullable()), + createdAt: yup.lazy(() => yup.string().default(undefined)), + createdBy: yup.lazy(() => yup.number().default(undefined).nullable()), + description: yup.lazy(() => yup.string().default(undefined).nullable()), + forwardedClaims: yup.lazy(() => yup.array().of(yup.string()).default(undefined).nullable()), + iconUrl: yup.lazy(() => yup.string().default(undefined).nullable()), + iconViewUrl: yup.lazy(() => yup.string().default(undefined).nullable()), + id: yup.lazy(() => yup.number().default(undefined)), + isEnabled: yup.lazy(() => yup.boolean().default(undefined)), + key: yup.lazy(() => yup.string().default(undefined).nullable().required()), + modifiedAt: yup.lazy(() => yup.string().default(undefined)), + modifiedBy: yup.lazy(() => yup.number().default(undefined).nullable()), + name: yup.lazy(() => yup.string().default(undefined).nullable().required()), + parameters: yup.lazy(() => IdentityProviderParameters.schema.default(undefined).required()), + postLogoutRedirectUrl: yup.lazy(() => yup.string().default(undefined).nullable()), + redirectUrl: yup.lazy(() => yup.string().default(undefined).nullable()), + type: yup.lazy(() => IdentityProviderType.schema.default(undefined).required()), + validateUrl: yup.lazy(() => yup.string().default(undefined).nullable()) + }).noUnknown() + ); + + export async function validate(value: any): Promise { + return schema.validate(value, { strict: true }); + } + + export function validateSync(value: any): IdentityProvider { + return schema.validateSync(value, { strict: true }); + } +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/models/IdentityProviderParameters.ts): ./test/result/v3/typescript/models/IdentityProviderParameters.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import * as yup from 'yup'; + +export interface IdentityProviderParameters { +} + +export namespace IdentityProviderParameters { + + export const schema: yup.ObjectSchema = ( + yup.object() + ); + + export async function validate(value: any): Promise { + return schema.validate(value, { strict: true }); + } + + export function validateSync(value: any): IdentityProviderParameters { + return schema.validateSync(value, { strict: true }); + } +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/models/IdentityProviderType.ts): ./test/result/v3/typescript/models/IdentityProviderType.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import * as yup from 'yup'; + +export enum IdentityProviderType { + LDAP = 'LDAP', + OPEN_ID_CONNECT = 'OpenIdConnect', + SAML2P = 'SAML2P', + WINDOWS = 'Windows' +} + +export namespace IdentityProviderType { + + export const schema = yup.mixed().oneOf([ + IdentityProviderType.LDAP, + IdentityProviderType.OPEN_ID_CONNECT, + IdentityProviderType.SAML2P, + IdentityProviderType.WINDOWS + ]); + + export async function validate(value: any): Promise { + return schema.validate(value, { strict: true }); + } + + export function validateSync(value: any): IdentityProviderType { + return schema.validateSync(value, { strict: true }); + } +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/models/LdapParameters.ts): ./test/result/v3/typescript/models/LdapParameters.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import * as yup from 'yup'; + +export interface LdapParameters { + additionalAttributes?: string | null; + fullNameClaim: string | null; + groupBaseDn?: string | null; + groupMemberAttribute?: string | null; + port: number; + searchAccount: string | null; + searchAccountPassword: string | null; + separator?: string | null; + serverAddress: string | null; + userBaseDn: string | null; + usernameClaim: string | null; + useSsl: boolean; +} + +export namespace LdapParameters { + + export const schema: yup.ObjectSchema = ( + yup.object().shape({ + additionalAttributes: yup.lazy(() => yup.string().default(undefined).nullable()), + fullNameClaim: yup.lazy(() => yup.string().default(undefined).nullable().required()), + groupBaseDn: yup.lazy(() => yup.string().default(undefined).nullable()), + groupMemberAttribute: yup.lazy(() => yup.string().default(undefined).nullable()), + port: yup.lazy(() => yup.number().default(undefined).required()), + searchAccount: yup.lazy(() => yup.string().default(undefined).nullable().required()), + searchAccountPassword: yup.lazy(() => yup.string().default(undefined).nullable().required()), + separator: yup.lazy(() => yup.string().default(undefined).nullable()), + serverAddress: yup.lazy(() => yup.string().default(undefined).nullable().required()), + userBaseDn: yup.lazy(() => yup.string().default(undefined).nullable().required()), + usernameClaim: yup.lazy(() => yup.string().default(undefined).nullable().required()), + useSsl: yup.lazy(() => yup.boolean().default(undefined).required()) + }).noUnknown() + ); + + export async function validate(value: any): Promise { + return schema.validate(value, { strict: true }); + } + + export function validateSync(value: any): LdapParameters { + return schema.validateSync(value, { strict: true }); + } +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/models/LoginOption.ts): ./test/result/v3/typescript/models/LoginOption.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import * as yup from 'yup'; + +export interface LoginOption { + iconUrl?: string | null; + loginTriggerUrl?: string | null; + name: string | null; +} + +export namespace LoginOption { + + export const schema: yup.ObjectSchema = ( + yup.object().shape({ + iconUrl: yup.lazy(() => yup.string().default(undefined).nullable()), + loginTriggerUrl: yup.lazy(() => yup.string().default(undefined).nullable()), + name: yup.lazy(() => yup.string().default(undefined).nullable().required()) + }).noUnknown() + ); + + export async function validate(value: any): Promise { + return schema.validate(value, { strict: true }); + } + + export function validateSync(value: any): LoginOption { + return schema.validateSync(value, { strict: true }); + } +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/models/OpenIdParameters.ts): ./test/result/v3/typescript/models/OpenIdParameters.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import * as yup from 'yup'; + +export interface OpenIdParameters { + authority: string | null; + clientId: string | null; + clientSecret?: string | null; + endSessionEndpoint?: string | null; + fullNameClaim: string | null; + sendIdTokenHintDuringLogout?: boolean; + separator?: string | null; + usernameClaim: string | null; +} + +export namespace OpenIdParameters { + + export const schema: yup.ObjectSchema = ( + yup.object().shape({ + authority: yup.lazy(() => yup.string().default(undefined).nullable().required()), + clientId: yup.lazy(() => yup.string().default(undefined).nullable().required()), + clientSecret: yup.lazy(() => yup.string().default(undefined).nullable()), + endSessionEndpoint: yup.lazy(() => yup.string().default(undefined).nullable()), + fullNameClaim: yup.lazy(() => yup.string().default(undefined).nullable().required()), + sendIdTokenHintDuringLogout: yup.lazy(() => yup.boolean().default(undefined)), + separator: yup.lazy(() => yup.string().default(undefined).nullable()), + usernameClaim: yup.lazy(() => yup.string().default(undefined).nullable().required()) + }).noUnknown() + ); + + export async function validate(value: any): Promise { + return schema.validate(value, { strict: true }); + } + + export function validateSync(value: any): OpenIdParameters { + return schema.validateSync(value, { strict: true }); + } +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/models/ProblemDetails.ts): ./test/result/v3/typescript/models/ProblemDetails.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import { Dictionary } from '../models/Dictionary'; +import * as yup from 'yup'; + +export interface ProblemDetails { + detail?: string | null; + extensions?: Dictionary | null; + instance?: string | null; + status?: number | null; + title?: string | null; + type?: string | null; +} + +export namespace ProblemDetails { + + export const schema: yup.ObjectSchema = ( + yup.object().shape({ + detail: yup.lazy(() => yup.string().default(undefined).nullable()), + extensions: yup.lazy(() => yup.lazy>(value => { + return yup.object>().shape( + Object.entries(value).reduce((obj, item) => ({ + ...obj, + [item[0]]: ( + yup.object() + ) + }), {}) + ); + }).default(undefined).nullable()), + instance: yup.lazy(() => yup.string().default(undefined).nullable()), + status: yup.lazy(() => yup.number().default(undefined).nullable()), + title: yup.lazy(() => yup.string().default(undefined).nullable()), + type: yup.lazy(() => yup.string().default(undefined).nullable()) + }).noUnknown() + ); + + export async function validate(value: any): Promise { + return schema.validate(value, { strict: true }); + } + + export function validateSync(value: any): ProblemDetails { + return schema.validateSync(value, { strict: true }); + } +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/models/SamlParameters.ts): ./test/result/v3/typescript/models/SamlParameters.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import * as yup from 'yup'; + +export interface SamlParameters { + certificates: Array | null; + fullNameClaim: string | null; + issuerName: string | null; + separator?: string | null; + serviceProviderName: string | null; + singleLogoutServiceUrl: string | null; + singleSignOnServiceUrl: string | null; + usernameClaim: string | null; +} + +export namespace SamlParameters { + + export const schema: yup.ObjectSchema = ( + yup.object().shape({ + certificates: yup.lazy(() => yup.array().of(yup.string()).default(undefined).nullable().required()), + fullNameClaim: yup.lazy(() => yup.string().default(undefined).nullable().required()), + issuerName: yup.lazy(() => yup.string().default(undefined).nullable().required()), + separator: yup.lazy(() => yup.string().default(undefined).nullable()), + serviceProviderName: yup.lazy(() => yup.string().default(undefined).nullable().required()), + singleLogoutServiceUrl: yup.lazy(() => yup.string().default(undefined).nullable().required()), + singleSignOnServiceUrl: yup.lazy(() => yup.string().default(undefined).nullable().required()), + usernameClaim: yup.lazy(() => yup.string().default(undefined).nullable().required()) + }).noUnknown() + ); + + export async function validate(value: any): Promise { + return schema.validate(value, { strict: true }); + } + + export function validateSync(value: any): SamlParameters { + return schema.validateSync(value, { strict: true }); + } +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/models/ServiceAccount.ts): ./test/result/v3/typescript/models/ServiceAccount.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ServiceAccountBasedAccessControlEntry } from '../models/ServiceAccountBasedAccessControlEntry'; +import { UserClientSecret } from '../models/UserClientSecret'; +import * as yup from 'yup'; + +export interface ServiceAccount { + accessControlEntry?: ServiceAccountBasedAccessControlEntry; + clientId?: string | null; + clientSecrets?: Array | null; + createdAt?: string; + createdBy?: number | null; + id?: number; + lastLoginAt?: string | null; + modifiedAt?: string; + modifiedBy?: number | null; + name: string | null; +} + +export namespace ServiceAccount { + + export const schema: yup.ObjectSchema = ( + yup.object().shape({ + accessControlEntry: yup.lazy(() => ServiceAccountBasedAccessControlEntry.schema.default(undefined)), + clientId: yup.lazy(() => yup.string().default(undefined).nullable()), + clientSecrets: yup.lazy(() => yup.array().of(UserClientSecret.schema).default(undefined).nullable()), + createdAt: yup.lazy(() => yup.string().default(undefined)), + createdBy: yup.lazy(() => yup.number().default(undefined).nullable()), + id: yup.lazy(() => yup.number().default(undefined)), + lastLoginAt: yup.lazy(() => yup.string().default(undefined).nullable()), + modifiedAt: yup.lazy(() => yup.string().default(undefined)), + modifiedBy: yup.lazy(() => yup.number().default(undefined).nullable()), + name: yup.lazy(() => yup.string().default(undefined).nullable().required()) + }).noUnknown() + ); + + export async function validate(value: any): Promise { + return schema.validate(value, { strict: true }); + } + + export function validateSync(value: any): ServiceAccount { + return schema.validateSync(value, { strict: true }); + } +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/models/ServiceAccountBasedAccessControlEntry.ts): ./test/result/v3/typescript/models/ServiceAccountBasedAccessControlEntry.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ApiResourceLink } from '../models/ApiResourceLink'; +import { ApiResourceRoleLink } from '../models/ApiResourceRoleLink'; +import * as yup from 'yup'; + +export interface ServiceAccountBasedAccessControlEntry { + apiResourceRoles?: Array | null; + apiResources?: Array | null; +} + +export namespace ServiceAccountBasedAccessControlEntry { + + export const schema: yup.ObjectSchema = ( + yup.object().shape({ + apiResourceRoles: yup.lazy(() => yup.array().of(ApiResourceRoleLink.schema).default(undefined).nullable()), + apiResources: yup.lazy(() => yup.array().of(ApiResourceLink.schema).default(undefined).nullable()) + }).noUnknown() + ); + + export async function validate(value: any): Promise { + return schema.validate(value, { strict: true }); + } + + export function validateSync(value: any): ServiceAccountBasedAccessControlEntry { + return schema.validateSync(value, { strict: true }); + } +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/models/User.ts): ./test/result/v3/typescript/models/User.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import { UserBasedAccessControlEntry } from '../models/UserBasedAccessControlEntry'; +import { UserClientSecret } from '../models/UserClientSecret'; +import * as yup from 'yup'; + +export interface User { + accessControlEntry?: UserBasedAccessControlEntry; + clientId?: string | null; + clientSecrets?: Array | null; + createdAt?: string; + createdBy?: number | null; + email?: string | null; + id?: number; + identityProviderId: number; + identityProviderKey: string | null; + lastLoginAt?: string | null; + modifiedAt?: string; + modifiedBy?: number | null; + name: string | null; + subject: string | null; +} + +export namespace User { + + export const schema: yup.ObjectSchema = ( + yup.object().shape({ + accessControlEntry: yup.lazy(() => UserBasedAccessControlEntry.schema.default(undefined)), + clientId: yup.lazy(() => yup.string().default(undefined).nullable()), + clientSecrets: yup.lazy(() => yup.array().of(UserClientSecret.schema).default(undefined).nullable()), + createdAt: yup.lazy(() => yup.string().default(undefined)), + createdBy: yup.lazy(() => yup.number().default(undefined).nullable()), + email: yup.lazy(() => yup.string().default(undefined).nullable()), + id: yup.lazy(() => yup.number().default(undefined)), + identityProviderId: yup.lazy(() => yup.number().default(undefined).required()), + identityProviderKey: yup.lazy(() => yup.string().default(undefined).nullable().required()), + lastLoginAt: yup.lazy(() => yup.string().default(undefined).nullable()), + modifiedAt: yup.lazy(() => yup.string().default(undefined)), + modifiedBy: yup.lazy(() => yup.number().default(undefined).nullable()), + name: yup.lazy(() => yup.string().default(undefined).nullable().required()), + subject: yup.lazy(() => yup.string().default(undefined).nullable().required()) + }).noUnknown() + ); + + export async function validate(value: any): Promise { + return schema.validate(value, { strict: true }); + } + + export function validateSync(value: any): User { + return schema.validateSync(value, { strict: true }); + } +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/models/UserBasedAccessControlEntry.ts): ./test/result/v3/typescript/models/UserBasedAccessControlEntry.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ApiResourceLink } from '../models/ApiResourceLink'; +import { ApiResourceRoleLink } from '../models/ApiResourceRoleLink'; +import { ApplicationLink } from '../models/ApplicationLink'; +import * as yup from 'yup'; + +export interface UserBasedAccessControlEntry { + apiResourceRoles?: Array | null; + apiResources?: Array | null; + applications?: Array | null; +} + +export namespace UserBasedAccessControlEntry { + + export const schema: yup.ObjectSchema = ( + yup.object().shape({ + apiResourceRoles: yup.lazy(() => yup.array().of(ApiResourceRoleLink.schema).default(undefined).nullable()), + apiResources: yup.lazy(() => yup.array().of(ApiResourceLink.schema).default(undefined).nullable()), + applications: yup.lazy(() => yup.array().of(ApplicationLink.schema).default(undefined).nullable()) + }).noUnknown() + ); + + export async function validate(value: any): Promise { + return schema.validate(value, { strict: true }); + } + + export function validateSync(value: any): UserBasedAccessControlEntry { + return schema.validateSync(value, { strict: true }); + } +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/models/UserClientSecret.ts): ./test/result/v3/typescript/models/UserClientSecret.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import * as yup from 'yup'; + +export interface UserClientSecret { + clientSecret: string | null; + clientSecretUnHashed?: string | null; + expiresAt: string; + id?: number; + lastLoginAt?: string | null; +} + +export namespace UserClientSecret { + + export const schema: yup.ObjectSchema = ( + yup.object().shape({ + clientSecret: yup.lazy(() => yup.string().default(undefined).nullable().required()), + clientSecretUnHashed: yup.lazy(() => yup.string().default(undefined).nullable()), + expiresAt: yup.lazy(() => yup.string().default(undefined).required()), + id: yup.lazy(() => yup.number().default(undefined)), + lastLoginAt: yup.lazy(() => yup.string().default(undefined).nullable()) + }).noUnknown() + ); + + export async function validate(value: any): Promise { + return schema.validate(value, { strict: true }); + } + + export function validateSync(value: any): UserClientSecret { + return schema.validateSync(value, { strict: true }); + } +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/models/WindowsParameters.ts): ./test/result/v3/typescript/models/WindowsParameters.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import * as yup from 'yup'; + +export interface WindowsParameters { +} + +export namespace WindowsParameters { + + export const schema: yup.ObjectSchema = ( + yup.object() + ); + + export async function validate(value: any): Promise { + return schema.validate(value, { strict: true }); + } + + export function validateSync(value: any): WindowsParameters { + return schema.validateSync(value, { strict: true }); + } +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/services/ApiResourcesService.ts): ./test/result/v3/typescript/services/ApiResourcesService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ApiError, catchGenericError } from '../core/ApiError'; +import { request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class ApiResourcesService { + + /** + * @result any Success + * @throws ApiError + */ + public static async get(): Promise { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/ApiResources\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param id + * @result any Success + * @throws ApiError + */ + public static async get1( + id: number + ): Promise { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/ApiResources/\${id}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param name + * @result any Success + * @throws ApiError + */ + public static async getByName( + name: string + ): Promise { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/ApiResources/getByName/\${name}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/services/ApplicationsService.ts): ./test/result/v3/typescript/services/ApplicationsService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ApiError, catchGenericError } from '../core/ApiError'; +import { request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class ApplicationsService { + + /** + * @param id + * @result any Success + * @throws ApiError + */ + public static async get( + id: number + ): Promise { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/Applications/\${id}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @result any Success + * @throws ApiError + */ + public static async get1(): Promise { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/Applications\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param clientId + * @result any Success + * @throws ApiError + */ + public static async getByClientId( + clientId: string + ): Promise { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/Applications/getByClientId/\${clientId}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param name + * @result any Success + * @throws ApiError + */ + public static async getByName( + name: string + ): Promise { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/Applications/getByName/\${name}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param id + * @result any Success + * @throws ApiError + */ + public static async update( + id: number + ): Promise { + + const result = await request({ + method: 'put', + path: \`/api/v\${OpenAPI.VERSION}/Applications/\${id}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/services/ClaimsService.ts): ./test/result/v3/typescript/services/ClaimsService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ApiError, catchGenericError } from '../core/ApiError'; +import { request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class ClaimsService { + + /** + * @result any Success + * @throws ApiError + */ + public static async get(): Promise { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/Claims\` + }); + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/services/IdentityProvidersService.ts): ./test/result/v3/typescript/services/IdentityProvidersService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import { IdentityProviderType } from '../models/IdentityProviderType'; +import { ApiError, catchGenericError } from '../core/ApiError'; +import { request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class IdentityProvidersService { + + /** + * @result any Success + * @throws ApiError + */ + public static async create(): Promise { + + const result = await request({ + method: 'post', + path: \`/api/v\${OpenAPI.VERSION}/IdentityProviders\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param id + * @result any Success + * @throws ApiError + */ + public static async delete( + id: number + ): Promise { + + const result = await request({ + method: 'delete', + path: \`/api/v\${OpenAPI.VERSION}/IdentityProviders/\${id}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @result any Success + * @throws ApiError + */ + public static async get(): Promise { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/IdentityProviders\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param id + * @result any Success + * @throws ApiError + */ + public static async get1( + id: number + ): Promise { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/IdentityProviders/\${id}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param name + * @result any Success + * @throws ApiError + */ + public static async getIcon( + name: string + ): Promise { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/IdentityProviders/icon/\${name}\` + }); + + if (!result.ok) { + switch (result.status) { + case 416: throw new ApiError(result, \`Client Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @result any Success + * @throws ApiError + */ + public static async getLoginOptions(): Promise { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/IdentityProviders/loginOptions\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param providerType + * @result any Success + * @throws ApiError + */ + public static async getParametersForIdentityProviderType( + providerType: IdentityProviderType + ): Promise { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/IdentityProviders/getParametersForIdentityProviderType/\${providerType}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param id + * @result any Success + * @throws ApiError + */ + public static async update( + id: number + ): Promise { + + const result = await request({ + method: 'put', + path: \`/api/v\${OpenAPI.VERSION}/IdentityProviders/\${id}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/services/ServiceAccountsService.ts): ./test/result/v3/typescript/services/ServiceAccountsService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ApiError, catchGenericError } from '../core/ApiError'; +import { request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class ServiceAccountsService { + + /** + * @param serviceAccountId + * @param secretId + * @result any Success + * @throws ApiError + */ + public static async deleteClientSecret( + serviceAccountId: number, + secretId: number + ): Promise { + + const result = await request({ + method: 'delete', + path: \`/api/v\${OpenAPI.VERSION}/ServiceAccounts/\${serviceAccountId}/clientSecrets/\${secretId}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param serviceAccountId + * @result any Success + * @throws ApiError + */ + public static async generateClientSecret( + serviceAccountId: number + ): Promise { + + const result = await request({ + method: 'post', + path: \`/api/v\${OpenAPI.VERSION}/ServiceAccounts/\${serviceAccountId}/generateClientSecret\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @result any Success + * @throws ApiError + */ + public static async get(): Promise { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/ServiceAccounts\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param id + * @result any Success + * @throws ApiError + */ + public static async get1( + id: number + ): Promise { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/ServiceAccounts/\${id}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param secretId + * @param serviceAccountId + * @result any Success + * @throws ApiError + */ + public static async updateClientSecret( + secretId: number, + serviceAccountId: number + ): Promise { + + const result = await request({ + method: 'put', + path: \`/api/v\${OpenAPI.VERSION}/ServiceAccounts/\${serviceAccountId}/clientSecrets/\${secretId}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/services/SuggestionsService.ts): ./test/result/v3/typescript/services/SuggestionsService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ApiError, catchGenericError } from '../core/ApiError'; +import { request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class SuggestionsService { + + /** + * @param searchText + * @result any Success + * @throws ApiError + */ + public static async getClaimTypes( + searchText?: string + ): Promise { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/Suggestions/claimTypes\`, + query: { + 'searchText': searchText + } + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + +}" +`; + +exports[`generation v3 typescript file(./test/result/v3/typescript/services/UsersService.ts): ./test/result/v3/typescript/services/UsersService.ts 1`] = ` +"/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +import { ApiError, catchGenericError } from '../core/ApiError'; +import { request } from '../core/request'; +import { OpenAPI } from '../core/OpenAPI'; + +export class UsersService { + + /** + * @result any Success + * @throws ApiError + */ + public static async create(): Promise { + + const result = await request({ + method: 'post', + path: \`/api/v\${OpenAPI.VERSION}/Users\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param id + * @result any Success + * @throws ApiError + */ + public static async delete( + id: number + ): Promise { + + const result = await request({ + method: 'delete', + path: \`/api/v\${OpenAPI.VERSION}/Users/\${id}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param userId + * @param secretId + * @result any Success + * @throws ApiError + */ + public static async deleteClientSecret( + userId: number, + secretId: number + ): Promise { + + const result = await request({ + method: 'delete', + path: \`/api/v\${OpenAPI.VERSION}/Users/\${userId}/clientSecrets/\${secretId}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param userId + * @result any Success + * @throws ApiError + */ + public static async generateClientSecret( + userId: number + ): Promise { + + const result = await request({ + method: 'post', + path: \`/api/v\${OpenAPI.VERSION}/Users/\${userId}/generateClientSecret\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param id + * @result any Success + * @throws ApiError + */ + public static async get( + id: number + ): Promise { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/Users/\${id}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @result any Success + * @throws ApiError + */ + public static async get1(): Promise { + + const result = await request({ + method: 'get', + path: \`/api/v\${OpenAPI.VERSION}/Users\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param id + * @result any Success + * @throws ApiError + */ + public static async update( + id: number + ): Promise { + + const result = await request({ + method: 'put', + path: \`/api/v\${OpenAPI.VERSION}/Users/\${id}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + + /** + * @param secretId + * @param userId + * @result any Success + * @throws ApiError + */ + public static async updateClientSecret( + secretId: number, + userId: number + ): Promise { + + const result = await request({ + method: 'put', + path: \`/api/v\${OpenAPI.VERSION}/Users/\${userId}/clientSecrets/\${secretId}\` + }); + + if (!result.ok) { + switch (result.status) { + case 400: throw new ApiError(result, \`Bad Request\`); + case 404: throw new ApiError(result, \`Not Found\`); + case 500: throw new ApiError(result, \`Server Error\`); + } + } + + catchGenericError(result); + + return result.body; + } + +}" +`; diff --git a/test/index.spec.js b/test/index.spec.js index a570f560..f715293b 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -4,42 +4,83 @@ const fs = require('fs'); describe('generation', () => { - describe('typescript', () => { + describe('v2', () => { - OpenAPI.generate( - './test/mock/spec-v2.json', - './test/result/v2/typescript/', - OpenAPI.Language.TYPESCRIPT, - OpenAPI.HttpClient.FETCH, - ); + describe('typescript', () => { - test.each(glob - .sync('./test/result/v2/typescript/**/*.ts') - .map(file => [file]) - )('file(%s)', file => { - const content = fs.readFileSync(file, 'utf8').toString(); - expect(content).toMatchSnapshot(file); + OpenAPI.generate( + './test/mock/spec-v2.json', + './test/result/v2/typescript/', + OpenAPI.Language.TYPESCRIPT, + OpenAPI.HttpClient.FETCH, + ); + + test.each(glob + .sync('./test/result/v2/typescript/**/*.ts') + .map(file => [file]) + )('file(%s)', file => { + const content = fs.readFileSync(file, 'utf8').toString(); + expect(content).toMatchSnapshot(file); + }); + }); + + describe('javascript', () => { + + OpenAPI.generate( + './test/mock/spec-v2.json', + './test/result/v2/javascript/', + OpenAPI.Language.JAVASCRIPT, + OpenAPI.HttpClient.XHR, + ); + + test.each(glob + .sync('./test/result/v2/javascript/**/*.js') + .map(file => [file]) + )('file(%s)', file => { + const content = fs.readFileSync(file, 'utf8').toString(); + expect(content).toMatchSnapshot(file); + }); }); }); - describe('javascript', () => { + describe('v3', () => { - OpenAPI.generate( - './test/mock/spec-v2.json', - './test/result/v2/javascript/', - OpenAPI.Language.JAVASCRIPT, - OpenAPI.HttpClient.XHR, - ); + describe('typescript', () => { - test.each(glob - .sync('./test/result/v2/javascript/**/*.js') - .map(file => [file]) - )('file(%s)', file => { - const content = fs.readFileSync(file, 'utf8').toString(); - expect(content).toMatchSnapshot(file); + OpenAPI.generate( + './test/mock/spec-v3.json', + './test/result/v3/typescript/', + OpenAPI.Language.TYPESCRIPT, + OpenAPI.HttpClient.FETCH, + ); + + test.each(glob + .sync('./test/result/v3/typescript/**/*.ts') + .map(file => [file]) + )('file(%s)', file => { + const content = fs.readFileSync(file, 'utf8').toString(); + expect(content).toMatchSnapshot(file); + }); + }); + + describe('javascript', () => { + + OpenAPI.generate( + './test/mock/spec-v3.json', + './test/result/v3/javascript/', + OpenAPI.Language.JAVASCRIPT, + OpenAPI.HttpClient.XHR, + ); + + test.each(glob + .sync('./test/result/v3/javascript/**/*.js') + .map(file => [file]) + )('file(%s)', file => { + const content = fs.readFileSync(file, 'utf8').toString(); + expect(content).toMatchSnapshot(file); + }); }); }); - }); diff --git a/yarn.lock b/yarn.lock index 37deca4a..039fa41a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1800,6 +1800,13 @@ eslint-plugin-prettier@3.1.1: dependencies: prettier-linter-helpers "^1.0.0" +eslint-plugin-sort-imports-es6-autofix@0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-sort-imports-es6-autofix/-/eslint-plugin-sort-imports-es6-autofix-0.5.0.tgz#dabae09a457eac6e95c52d8edd7855f576d014b6" + integrity sha512-KEX2Uz6bAs67jDYiH/OT1xz1E7AzIJJOIRg1F7OnFAfUVlpws3ldSZj5oZySRHfoVkWqDX9GGExYxckdLrWhwg== + dependencies: + eslint "^6.2.2" + eslint-scope@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.0.0.tgz#e87c8887c73e8d1ec84f1ca591645c358bfc8fb9" @@ -1863,6 +1870,49 @@ eslint@6.6.0: text-table "^0.2.0" v8-compile-cache "^2.0.3" +eslint@^6.2.2: + version "6.7.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-6.7.0.tgz#766162e383b236e61d873697f82c3a3e41392020" + integrity sha512-dQpj+PaHKHfXHQ2Imcw5d853PTvkUGbHk/MR68KQUl98EgKDCdh4vLRH1ZxhqeQjQFJeg8fgN0UwmNhN3l8dDQ== + dependencies: + "@babel/code-frame" "^7.0.0" + ajv "^6.10.0" + chalk "^2.1.0" + cross-spawn "^6.0.5" + debug "^4.0.1" + doctrine "^3.0.0" + eslint-scope "^5.0.0" + eslint-utils "^1.4.3" + eslint-visitor-keys "^1.1.0" + espree "^6.1.2" + esquery "^1.0.1" + esutils "^2.0.2" + file-entry-cache "^5.0.1" + functional-red-black-tree "^1.0.1" + glob-parent "^5.0.0" + globals "^12.1.0" + ignore "^4.0.6" + import-fresh "^3.0.0" + imurmurhash "^0.1.4" + inquirer "^7.0.0" + is-glob "^4.0.0" + js-yaml "^3.13.1" + json-stable-stringify-without-jsonify "^1.0.1" + levn "^0.3.0" + lodash "^4.17.14" + minimatch "^3.0.4" + mkdirp "^0.5.1" + natural-compare "^1.4.0" + optionator "^0.8.3" + progress "^2.0.0" + regexpp "^2.0.1" + semver "^6.1.2" + strip-ansi "^5.2.0" + strip-json-comments "^3.0.1" + table "^5.2.3" + text-table "^0.2.0" + v8-compile-cache "^2.0.3" + espree@^6.1.2: version "6.1.2" resolved "https://registry.yarnpkg.com/espree/-/espree-6.1.2.tgz#6c272650932b4f91c3714e5e7b5f5e2ecf47262d" @@ -2022,7 +2072,7 @@ fast-json-stable-stringify@^2.0.0: resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" integrity sha1-1RQsDK7msRifh9OnYREGT4bIu/I= -fast-levenshtein@~2.0.4: +fast-levenshtein@~2.0.4, fast-levenshtein@~2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= @@ -2219,6 +2269,13 @@ globals@^11.1.0, globals@^11.7.0: resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== +globals@^12.1.0: + version "12.3.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-12.3.0.tgz#1e564ee5c4dded2ab098b0f88f24702a3c56be13" + integrity sha512-wAfjdLgFsPZsklLJvOBUBmzYE8/CwhEqSBEMRXA3qxIiNtyqvjYurAtIfDh6chlEPUfmTY3MnZh5Hfh4q0UlIw== + dependencies: + type-fest "^0.8.1" + graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2: version "4.2.3" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.3.tgz#4a12ff1b60376ef09862c2093edd908328be8423" @@ -3598,6 +3655,18 @@ optionator@^0.8.1, optionator@^0.8.2: type-check "~0.3.2" wordwrap "~1.0.0" +optionator@^0.8.3: + version "0.8.3" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495" + integrity sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA== + dependencies: + deep-is "~0.1.3" + fast-levenshtein "~2.0.6" + levn "~0.3.0" + prelude-ls "~1.1.2" + type-check "~0.3.2" + word-wrap "~1.2.3" + os-homedir@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" @@ -4646,6 +4715,11 @@ type-fest@^0.5.2: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.5.2.tgz#d6ef42a0356c6cd45f49485c3b6281fc148e48a2" integrity sha512-DWkS49EQKVX//Tbupb9TFa19c7+MK1XmzkrZUR8TAktmE/DizXoaoJV6TZ/tSIPXipqNiRI6CyAe7x69Jb6RSw== +type-fest@^0.8.1: + version "0.8.1" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d" + integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA== + typescript@3.7.2: version "3.7.2" resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.2.tgz#27e489b95fa5909445e9fef5ee48d81697ad18fb" @@ -4832,6 +4906,11 @@ wide-align@^1.1.0: dependencies: string-width "^1.0.2 || 2" +word-wrap@~1.2.3: + version "1.2.3" + resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" + integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ== + wordwrap@~0.0.2: version "0.0.3" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107"