mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2026-01-25 16:02:59 +00:00
- Fixed nested enums
- Fixed examples of v3
This commit is contained in:
parent
fec3ca9de6
commit
4152438861
@ -6,6 +6,7 @@ export interface OperationParameters {
|
||||
parametersPath: OperationParameter[];
|
||||
parametersQuery: OperationParameter[];
|
||||
parametersForm: OperationParameter[];
|
||||
parametersCookie: OperationParameter[];
|
||||
parametersHeader: OperationParameter[];
|
||||
parametersBody: OperationParameter | null;
|
||||
}
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
import { Enum } from '../../../client/interfaces/Enum';
|
||||
import { getEnumValues } from './getEnumValues';
|
||||
|
||||
export function getEnumType(enumerators: Enum[], addParentheses: boolean = false): string {
|
||||
// Fetch values from the symbols, just to be sure we filter out
|
||||
// any double values and finally we sort them to make them easier
|
||||
// to read when we use them in our generated code.
|
||||
const values = getEnumValues(enumerators);
|
||||
|
||||
// Add grouping parentheses if needed. This can be handy if enum values
|
||||
// are used in Arrays, so that you will get the following definition:
|
||||
// const myArray: ('EnumValue1' | 'EnumValue2' | 'EnumValue3')[];
|
||||
if (values.length > 1 && addParentheses) {
|
||||
return `(${values.join(' | ')})`;
|
||||
}
|
||||
|
||||
return values.join(' | ');
|
||||
}
|
||||
@ -5,7 +5,6 @@ import { PrimaryType } from './constants';
|
||||
import { getComment } from './getComment';
|
||||
import { getEnum } from './getEnum';
|
||||
import { getEnumFromDescription } from './getEnumFromDescription';
|
||||
import { getEnumType } from './getEnumType';
|
||||
import { getModelProperties } from './getModelProperties';
|
||||
import { getType } from './getType';
|
||||
|
||||
@ -43,7 +42,7 @@ export function getModel(openApi: OpenApi, definition: OpenApiSchema, isProperty
|
||||
const enumerators = getEnum(definition.enum);
|
||||
if (enumerators.length) {
|
||||
model.export = 'enum';
|
||||
model.type = getEnumType(enumerators);
|
||||
model.type = PrimaryType.STRING;
|
||||
model.base = PrimaryType.STRING;
|
||||
model.enum.push(...enumerators);
|
||||
return model;
|
||||
@ -54,7 +53,7 @@ export function getModel(openApi: OpenApi, definition: OpenApiSchema, isProperty
|
||||
const enumerators = getEnumFromDescription(definition.description);
|
||||
if (enumerators.length) {
|
||||
model.export = 'enum';
|
||||
model.type = getEnumType(enumerators);
|
||||
model.type = PrimaryType.NUMBER;
|
||||
model.base = PrimaryType.NUMBER;
|
||||
model.enum.push(...enumerators);
|
||||
return model;
|
||||
|
||||
@ -31,6 +31,7 @@ export function getOperation(openApi: OpenApi, url: string, method: string, op:
|
||||
parametersQuery: [],
|
||||
parametersForm: [],
|
||||
parametersHeader: [],
|
||||
parametersCookie: [],
|
||||
parametersBody: null,
|
||||
imports: [],
|
||||
errors: [],
|
||||
@ -46,6 +47,7 @@ export function getOperation(openApi: OpenApi, url: string, method: string, op:
|
||||
operation.parametersQuery.push(...parameters.parametersQuery);
|
||||
operation.parametersForm.push(...parameters.parametersForm);
|
||||
operation.parametersHeader.push(...parameters.parametersHeader);
|
||||
operation.parametersCookie.push(...parameters.parametersCookie);
|
||||
operation.parametersBody = parameters.parametersBody;
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,6 @@ import { PrimaryType } from './constants';
|
||||
import { getComment } from './getComment';
|
||||
import { getEnum } from './getEnum';
|
||||
import { getEnumFromDescription } from './getEnumFromDescription';
|
||||
import { getEnumType } from './getEnumType';
|
||||
import { getModel } from './getModel';
|
||||
import { getOperationParameterDefault } from './getOperationParameterDefault';
|
||||
import { getOperationParameterName } from './getOperationParameterName';
|
||||
@ -48,7 +47,7 @@ export function getOperationParameter(openApi: OpenApi, parameter: OpenApiParame
|
||||
const enumerators = getEnum(parameter.enum);
|
||||
if (enumerators.length) {
|
||||
operationParameter.export = 'enum';
|
||||
operationParameter.type = getEnumType(enumerators);
|
||||
operationParameter.type = PrimaryType.STRING;
|
||||
operationParameter.base = PrimaryType.STRING;
|
||||
operationParameter.enum.push(...enumerators);
|
||||
return operationParameter;
|
||||
@ -59,7 +58,7 @@ export function getOperationParameter(openApi: OpenApi, parameter: OpenApiParame
|
||||
const enumerators = getEnumFromDescription(parameter.description);
|
||||
if (enumerators.length) {
|
||||
operationParameter.export = 'enum';
|
||||
operationParameter.type = getEnumType(enumerators);
|
||||
operationParameter.type = PrimaryType.NUMBER;
|
||||
operationParameter.base = PrimaryType.NUMBER;
|
||||
operationParameter.enum.push(...enumerators);
|
||||
return operationParameter;
|
||||
|
||||
@ -16,6 +16,7 @@ export function getOperationParameters(openApi: OpenApi, parameters: OpenApiPara
|
||||
parametersPath: [],
|
||||
parametersQuery: [],
|
||||
parametersForm: [],
|
||||
parametersCookie: [],
|
||||
parametersHeader: [],
|
||||
parametersBody: null,
|
||||
};
|
||||
@ -66,6 +67,7 @@ export function getOperationParameters(openApi: OpenApi, parameters: OpenApiPara
|
||||
operationParameters.parametersPath = operationParameters.parametersPath.sort(sortByRequired);
|
||||
operationParameters.parametersQuery = operationParameters.parametersQuery.sort(sortByRequired);
|
||||
operationParameters.parametersForm = operationParameters.parametersForm.sort(sortByRequired);
|
||||
operationParameters.parametersCookie = operationParameters.parametersCookie.sort(sortByRequired);
|
||||
operationParameters.parametersHeader = operationParameters.parametersHeader.sort(sortByRequired);
|
||||
return operationParameters;
|
||||
}
|
||||
|
||||
@ -8,9 +8,10 @@ import { OpenApiSchema } from './OpenApiSchema';
|
||||
*/
|
||||
export interface OpenApiParameter extends OpenApiReference {
|
||||
name: string;
|
||||
in: 'path' | 'query' | 'header' | 'cookie';
|
||||
in: 'path' | 'query' | 'header' | 'formData' | 'cookie';
|
||||
description?: string;
|
||||
required?: boolean;
|
||||
nullable?: boolean;
|
||||
deprecated?: boolean;
|
||||
allowEmptyValue?: boolean;
|
||||
style?: string;
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
import { Enum } from '../../../client/interfaces/Enum';
|
||||
import { getEnumValues } from './getEnumValues';
|
||||
|
||||
export function getEnumType(enumerators: Enum[], addParentheses: boolean = false): string {
|
||||
// Fetch values from the symbols, just to be sure we filter out
|
||||
// any double values and finally we sort them to make them easier
|
||||
// to read when we use them in our generated code.
|
||||
const values = getEnumValues(enumerators);
|
||||
|
||||
// Add grouping parentheses if needed. This can be handy if enum values
|
||||
// are used in Arrays, so that you will get the following definition:
|
||||
// const myArray: ('EnumValue1' | 'EnumValue2' | 'EnumValue3')[];
|
||||
if (values.length > 1 && addParentheses) {
|
||||
return `(${values.join(' | ')})`;
|
||||
}
|
||||
|
||||
return values.join(' | ');
|
||||
}
|
||||
@ -5,7 +5,6 @@ import { PrimaryType } from './constants';
|
||||
import { getComment } from './getComment';
|
||||
import { getEnum } from './getEnum';
|
||||
import { getEnumFromDescription } from './getEnumFromDescription';
|
||||
import { getEnumType } from './getEnumType';
|
||||
import { getModelProperties } from './getModelProperties';
|
||||
import { getType } from './getType';
|
||||
|
||||
@ -43,7 +42,7 @@ export function getModel(openApi: OpenApi, definition: OpenApiSchema, isProperty
|
||||
const enumerators = getEnum(definition.enum);
|
||||
if (enumerators.length) {
|
||||
model.export = 'enum';
|
||||
model.type = getEnumType(enumerators);
|
||||
model.type = PrimaryType.STRING;
|
||||
model.base = PrimaryType.STRING;
|
||||
model.enum.push(...enumerators);
|
||||
return model;
|
||||
@ -54,7 +53,7 @@ export function getModel(openApi: OpenApi, definition: OpenApiSchema, isProperty
|
||||
const enumerators = getEnumFromDescription(definition.description);
|
||||
if (enumerators.length) {
|
||||
model.export = 'enum';
|
||||
model.type = getEnumType(enumerators);
|
||||
model.type = PrimaryType.NUMBER;
|
||||
model.base = PrimaryType.NUMBER;
|
||||
model.enum.push(...enumerators);
|
||||
return model;
|
||||
|
||||
@ -32,6 +32,7 @@ export function getOperation(openApi: OpenApi, url: string, method: string, op:
|
||||
parametersQuery: [],
|
||||
parametersForm: [],
|
||||
parametersHeader: [],
|
||||
parametersCookie: [],
|
||||
parametersBody: null,
|
||||
imports: [],
|
||||
errors: [],
|
||||
@ -47,6 +48,7 @@ export function getOperation(openApi: OpenApi, url: string, method: string, op:
|
||||
operation.parametersQuery.push(...parameters.parametersQuery);
|
||||
operation.parametersForm.push(...parameters.parametersForm);
|
||||
operation.parametersHeader.push(...parameters.parametersHeader);
|
||||
operation.parametersCookie.push(...parameters.parametersCookie);
|
||||
operation.parametersBody = parameters.parametersBody;
|
||||
}
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ export function getOperationParameter(openApi: OpenApi, parameter: OpenApiParame
|
||||
isProperty: false,
|
||||
isReadOnly: false,
|
||||
isRequired: parameter.required === true,
|
||||
isNullable: false,
|
||||
isNullable: parameter.nullable === true,
|
||||
imports: [],
|
||||
extends: [],
|
||||
enum: [],
|
||||
|
||||
@ -16,6 +16,7 @@ export function getOperationParameters(openApi: OpenApi, parameters: OpenApiPara
|
||||
parametersPath: [],
|
||||
parametersQuery: [],
|
||||
parametersForm: [],
|
||||
parametersCookie: [],
|
||||
parametersHeader: [],
|
||||
parametersBody: null,
|
||||
};
|
||||
@ -41,6 +42,18 @@ export function getOperationParameters(openApi: OpenApi, parameters: OpenApiPara
|
||||
operationParameters.imports.push(...param.imports);
|
||||
break;
|
||||
|
||||
case 'formData':
|
||||
operationParameters.parametersForm.push(param);
|
||||
operationParameters.parameters.push(param);
|
||||
operationParameters.imports.push(...param.imports);
|
||||
break;
|
||||
|
||||
case 'cookie':
|
||||
operationParameters.parametersCookie.push(param);
|
||||
operationParameters.parameters.push(param);
|
||||
operationParameters.imports.push(...param.imports);
|
||||
break;
|
||||
|
||||
case 'header':
|
||||
operationParameters.parametersHeader.push(param);
|
||||
operationParameters.parameters.push(param);
|
||||
@ -54,6 +67,7 @@ export function getOperationParameters(openApi: OpenApi, parameters: OpenApiPara
|
||||
operationParameters.parametersPath = operationParameters.parametersPath.sort(sortByRequired);
|
||||
operationParameters.parametersQuery = operationParameters.parametersQuery.sort(sortByRequired);
|
||||
operationParameters.parametersForm = operationParameters.parametersForm.sort(sortByRequired);
|
||||
operationParameters.parametersCookie = operationParameters.parametersCookie.sort(sortByRequired);
|
||||
operationParameters.parametersHeader = operationParameters.parametersHeader.sort(sortByRequired);
|
||||
return operationParameters;
|
||||
}
|
||||
|
||||
@ -1,9 +1,13 @@
|
||||
{{~#equals parent name~}}
|
||||
yup.mixed().oneOf([
|
||||
{{#each enum}}
|
||||
{{#equals ../name name}}
|
||||
{{{value}}}{{#unless @last}},{{/unless}}
|
||||
{{else}}
|
||||
{{{../name}}}.{{{name}}}{{#unless @last}},{{/unless}}
|
||||
{{/equals}}
|
||||
{{{../parent}}}.{{{name}}}{{#unless @last}},{{/unless}}
|
||||
{{/each}}
|
||||
])
|
||||
{{~else~}}
|
||||
yup.mixed().oneOf([
|
||||
{{#each enum}}
|
||||
{{{value}}}{{#unless @last}},{{/unless}}
|
||||
{{/each}}
|
||||
])
|
||||
{{~/equals~}}
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
{{#if properties}}
|
||||
yup.object().shape({
|
||||
{{#each properties}}
|
||||
{{{name}}}: yup.lazy(() => {{>validation}}.default(undefined){{#if isNullable}}.isNullable(){{/if}}){{#if isRequired}}.isRequired(){{/if}}{{#unless @last}},{{/unless}}
|
||||
{{{name}}}: yup.lazy(() => {{>validation parent=name}}.default(undefined){{#if isNullable}}.isNullable(){{/if}}){{#if isRequired}}.isRequired(){{/if}}{{#unless @last}},{{/unless}}
|
||||
{{/each}}
|
||||
}).noUnknown()
|
||||
{{else}}
|
||||
|
||||
@ -37,7 +37,12 @@ export class {{{name}}} {
|
||||
|
||||
const result = await request({
|
||||
method: '{{{method}}}',
|
||||
path: `{{{path}}}`{{#if parametersHeader}},
|
||||
path: `{{{path}}}`{{#if parametersCookie}},
|
||||
cookies: {
|
||||
{{#each parametersCookie}}
|
||||
'{{{prop}}}': {{{name}}}{{#unless @last}},{{/unless}}
|
||||
{{/each}}
|
||||
}{{/if}}{{#if parametersCookie}},
|
||||
headers: {
|
||||
{{#each parametersHeader}}
|
||||
'{{{prop}}}': {{{name}}}{{#unless @last}},{{/unless}}
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
export interface RequestOptions {
|
||||
method: 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch';
|
||||
path: string;
|
||||
cookies?: { [key: string]: any };
|
||||
headers?: { [key: string]: any };
|
||||
query?: { [key: string]: any };
|
||||
formData?: { [key: string]: any };
|
||||
|
||||
@ -1,5 +1,9 @@
|
||||
{{~#if parent~}}
|
||||
{{{parent}}}.{{{name}}}
|
||||
{{~else~}}
|
||||
{{{type}}}
|
||||
(
|
||||
{{~#each enum~}}
|
||||
{{{value}}}{{#unless @last}} | {{/unless}}
|
||||
{{~/each~}}
|
||||
)
|
||||
{{~/if~}}
|
||||
|
||||
@ -43,7 +43,12 @@ export class {{{name}}} {
|
||||
|
||||
const result = await request({
|
||||
method: '{{{method}}}',
|
||||
path: `{{{path}}}`{{#if parametersHeader}},
|
||||
path: `{{{path}}}`{{#if parametersCookie}},
|
||||
cookies: {
|
||||
{{#each parametersCookie}}
|
||||
'{{{prop}}}': {{{name}}}{{#unless @last}},{{/unless}}
|
||||
{{/each}}
|
||||
}{{/if}}{{#if parametersCookie}},
|
||||
headers: {
|
||||
{{#each parametersHeader}}
|
||||
'{{{prop}}}': {{{name}}}{{#unless @last}},{{/unless}}
|
||||
|
||||
@ -388,6 +388,7 @@ export { ModelWithEnum } from './models/ModelWithEnum';
|
||||
export { ModelWithEnumFromDescription } from './models/ModelWithEnumFromDescription';
|
||||
export { ModelWithInteger } from './models/ModelWithInteger';
|
||||
export { ModelWithLink } from './models/ModelWithLink';
|
||||
export { ModelWithNestedEnums } from './models/ModelWithNestedEnums';
|
||||
export { ModelWithNestedProperties } from './models/ModelWithNestedProperties';
|
||||
export { ModelWithProperties } from './models/ModelWithProperties';
|
||||
export { ModelWithReference } from './models/ModelWithReference';
|
||||
@ -771,9 +772,9 @@ export let EnumFromDescription;
|
||||
EnumFromDescription.WARNING = 2;
|
||||
|
||||
EnumFromDescription.schema = yup.mixed().oneOf([
|
||||
EnumFromDescription.ERROR,
|
||||
EnumFromDescription.SUCCESS,
|
||||
EnumFromDescription.WARNING
|
||||
3,
|
||||
1,
|
||||
2
|
||||
]);
|
||||
|
||||
EnumFromDescription.validate = async function(value) {
|
||||
@ -805,9 +806,9 @@ export let EnumWithNumbers;
|
||||
EnumWithNumbers.NUM_3 = 3;
|
||||
|
||||
EnumWithNumbers.schema = yup.mixed().oneOf([
|
||||
EnumWithNumbers.NUM_1,
|
||||
EnumWithNumbers.NUM_2,
|
||||
EnumWithNumbers.NUM_3
|
||||
1,
|
||||
2,
|
||||
3
|
||||
]);
|
||||
|
||||
EnumWithNumbers.validate = async function(value) {
|
||||
@ -839,9 +840,9 @@ export let EnumWithStrings;
|
||||
EnumWithStrings.WARNING = 'Warning';
|
||||
|
||||
EnumWithStrings.schema = yup.mixed().oneOf([
|
||||
EnumWithStrings.ERROR,
|
||||
EnumWithStrings.SUCCESS,
|
||||
EnumWithStrings.WARNING
|
||||
'Error',
|
||||
'Success',
|
||||
'Warning'
|
||||
]);
|
||||
|
||||
EnumWithStrings.validate = async function(value) {
|
||||
@ -1165,7 +1166,7 @@ export let ModelWithEnum;
|
||||
/**
|
||||
* This is a simple enum with strings
|
||||
*/
|
||||
ModelWithEnum.Test = {
|
||||
ModelWithEnum.test = {
|
||||
SUCCESS: 'Success',
|
||||
WARNING: 'Warning',
|
||||
ERROR: 'Error'
|
||||
@ -1173,10 +1174,10 @@ export let ModelWithEnum;
|
||||
|
||||
ModelWithEnum.schema = (
|
||||
yup.object().shape({
|
||||
Test: yup.lazy(() => yup.mixed().oneOf([
|
||||
Test.SUCCESS,
|
||||
Test.WARNING,
|
||||
Test.ERROR
|
||||
test: yup.lazy(() => yup.mixed().oneOf([
|
||||
test.SUCCESS,
|
||||
test.WARNING,
|
||||
test.ERROR
|
||||
]).default(undefined))
|
||||
}).noUnknown()
|
||||
);
|
||||
@ -1208,7 +1209,7 @@ export let ModelWithEnumFromDescription;
|
||||
/**
|
||||
* Success=1,Warning=2,Error=3
|
||||
*/
|
||||
ModelWithEnumFromDescription.Test = {
|
||||
ModelWithEnumFromDescription.test = {
|
||||
SUCCESS: 1,
|
||||
WARNING: 2,
|
||||
ERROR: 3
|
||||
@ -1216,10 +1217,10 @@ export let ModelWithEnumFromDescription;
|
||||
|
||||
ModelWithEnumFromDescription.schema = (
|
||||
yup.object().shape({
|
||||
Test: yup.lazy(() => yup.mixed().oneOf([
|
||||
Test.SUCCESS,
|
||||
Test.WARNING,
|
||||
Test.ERROR
|
||||
test: yup.lazy(() => yup.mixed().oneOf([
|
||||
test.SUCCESS,
|
||||
test.WARNING,
|
||||
test.ERROR
|
||||
]).default(undefined))
|
||||
}).noUnknown()
|
||||
);
|
||||
@ -1297,6 +1298,63 @@ export let ModelWithLink;
|
||||
})(ModelWithLink || (ModelWithLink = {}));"
|
||||
`;
|
||||
|
||||
exports[`generation v2 javascript file(./test/result/v2/javascript/models/ModelWithNestedEnums.js): ./test/result/v2/javascript/models/ModelWithNestedEnums.js 1`] = `
|
||||
"/* istanbul ignore file */
|
||||
/* eslint-disable */
|
||||
/* prettier-ignore */
|
||||
|
||||
import { array } from '../models/array';
|
||||
|
||||
import * as yup from 'yup';
|
||||
|
||||
/**
|
||||
* This is a model with nested enums
|
||||
*/
|
||||
export let ModelWithNestedEnums;
|
||||
(function (ModelWithNestedEnums) {
|
||||
|
||||
ModelWithNestedEnums.schema = (
|
||||
yup.object().shape({
|
||||
arrayWithDescription: yup.lazy(() => yup.mixed().default(undefined)),
|
||||
arrayWithEnum: yup.lazy(() => yup.mixed().default(undefined)),
|
||||
dictionaryWithEnum: yup.lazy(() => yup.lazy(value => {
|
||||
return yup.object().shape(
|
||||
Object.entries(value).reduce((obj, item) => ({
|
||||
...obj,
|
||||
[item[0]]: yup.mixed().oneOf([
|
||||
'Success',
|
||||
'Warning',
|
||||
'Error'
|
||||
])
|
||||
}), {})
|
||||
);
|
||||
}).default(undefined)),
|
||||
dictionaryWithEnumFromDescription: yup.lazy(() => yup.lazy(value => {
|
||||
return yup.object().shape(
|
||||
Object.entries(value).reduce((obj, item) => ({
|
||||
...obj,
|
||||
[item[0]]: yup.mixed().oneOf([
|
||||
1,
|
||||
2,
|
||||
3
|
||||
])
|
||||
}), {})
|
||||
);
|
||||
}).default(undefined))
|
||||
}).noUnknown()
|
||||
);
|
||||
|
||||
ModelWithNestedEnums.validate = async function(value) {
|
||||
return ModelWithNestedEnums.schema.validate(value, { strict: true });
|
||||
};
|
||||
|
||||
ModelWithNestedEnums.validateSync = function(value) {
|
||||
return ModelWithNestedEnums.schema.validateSync(value, { strict: true });
|
||||
};
|
||||
|
||||
})(ModelWithNestedEnums || (ModelWithNestedEnums = {}));"
|
||||
`;
|
||||
|
||||
exports[`generation v2 javascript file(./test/result/v2/javascript/models/ModelWithNestedProperties.js): ./test/result/v2/javascript/models/ModelWithNestedProperties.js 1`] = `
|
||||
"/* istanbul ignore file */
|
||||
/* eslint-disable */
|
||||
@ -1637,9 +1695,6 @@ export class ParametersService {
|
||||
const result = await request({
|
||||
method: 'get',
|
||||
path: \`/api/v\${OpenAPI.VERSION}/parameters\`,
|
||||
headers: {
|
||||
'parameterHeader': parameterHeader
|
||||
},
|
||||
query: {
|
||||
'parameterQuery': parameterQuery
|
||||
},
|
||||
@ -1874,6 +1929,7 @@ export class TypesService {
|
||||
* @param parameterObject This is an object parameter
|
||||
* @param parameterArray This is an array parameter
|
||||
* @param parameterDictionary This is a dictionary parameter
|
||||
* @param parameterEnum This is an enum parameter
|
||||
* @param id This is a number parameter
|
||||
* @result number Response is a simple number
|
||||
* @result string Response is a simple string
|
||||
@ -1888,6 +1944,7 @@ export class TypesService {
|
||||
parameterObject = null,
|
||||
parameterArray,
|
||||
parameterDictionary,
|
||||
parameterEnum,
|
||||
id
|
||||
) {
|
||||
|
||||
@ -1900,7 +1957,8 @@ export class TypesService {
|
||||
'parameterBoolean': parameterBoolean,
|
||||
'parameterObject': parameterObject,
|
||||
'parameterArray': parameterArray,
|
||||
'parameterDictionary': parameterDictionary
|
||||
'parameterDictionary': parameterDictionary,
|
||||
'parameterEnum': parameterEnum
|
||||
}
|
||||
});
|
||||
|
||||
@ -1996,6 +2054,7 @@ exports[`generation v2 typescript file(./test/result/v2/typescript/core/RequestO
|
||||
export interface RequestOptions {
|
||||
method: 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch';
|
||||
path: string;
|
||||
cookies?: { [key: string]: any };
|
||||
headers?: { [key: string]: any };
|
||||
query?: { [key: string]: any };
|
||||
formData?: { [key: string]: any };
|
||||
@ -2350,6 +2409,7 @@ export { ModelWithEnum } from './models/ModelWithEnum';
|
||||
export { ModelWithEnumFromDescription } from './models/ModelWithEnumFromDescription';
|
||||
export { ModelWithInteger } from './models/ModelWithInteger';
|
||||
export { ModelWithLink } from './models/ModelWithLink';
|
||||
export { ModelWithNestedEnums } from './models/ModelWithNestedEnums';
|
||||
export { ModelWithNestedProperties } from './models/ModelWithNestedProperties';
|
||||
export { ModelWithProperties } from './models/ModelWithProperties';
|
||||
export { ModelWithReference } from './models/ModelWithReference';
|
||||
@ -3201,7 +3261,7 @@ export interface ModelWithEnum {
|
||||
/**
|
||||
* This is a simple enum with strings
|
||||
*/
|
||||
Test?: ModelWithEnum.Test;
|
||||
test?: ModelWithEnum.test;
|
||||
}
|
||||
|
||||
export namespace ModelWithEnum {
|
||||
@ -3209,7 +3269,7 @@ export namespace ModelWithEnum {
|
||||
/**
|
||||
* This is a simple enum with strings
|
||||
*/
|
||||
export enum Test {
|
||||
export enum test {
|
||||
SUCCESS = 'Success',
|
||||
WARNING = 'Warning',
|
||||
ERROR = 'Error'
|
||||
@ -3217,10 +3277,10 @@ export namespace ModelWithEnum {
|
||||
|
||||
export const schema: yup.ObjectSchema<ModelWithEnum> = (
|
||||
yup.object<ModelWithEnum>().shape({
|
||||
Test: yup.lazy(() => yup.mixed<Test>().oneOf([
|
||||
Test.SUCCESS,
|
||||
Test.WARNING,
|
||||
Test.ERROR
|
||||
test: yup.lazy(() => yup.mixed<test>().oneOf([
|
||||
test.SUCCESS,
|
||||
test.WARNING,
|
||||
test.ERROR
|
||||
]).default(undefined))
|
||||
}).noUnknown()
|
||||
);
|
||||
@ -3250,7 +3310,7 @@ export interface ModelWithEnumFromDescription {
|
||||
/**
|
||||
* Success=1,Warning=2,Error=3
|
||||
*/
|
||||
Test?: ModelWithEnumFromDescription.Test;
|
||||
test?: ModelWithEnumFromDescription.test;
|
||||
}
|
||||
|
||||
export namespace ModelWithEnumFromDescription {
|
||||
@ -3258,7 +3318,7 @@ export namespace ModelWithEnumFromDescription {
|
||||
/**
|
||||
* Success=1,Warning=2,Error=3
|
||||
*/
|
||||
export enum Test {
|
||||
export enum test {
|
||||
SUCCESS = 1,
|
||||
WARNING = 2,
|
||||
ERROR = 3
|
||||
@ -3266,10 +3326,10 @@ export namespace ModelWithEnumFromDescription {
|
||||
|
||||
export const schema: yup.ObjectSchema<ModelWithEnumFromDescription> = (
|
||||
yup.object<ModelWithEnumFromDescription>().shape({
|
||||
Test: yup.lazy(() => yup.mixed<Test>().oneOf([
|
||||
Test.SUCCESS,
|
||||
Test.WARNING,
|
||||
Test.ERROR
|
||||
test: yup.lazy(() => yup.mixed<test>().oneOf([
|
||||
test.SUCCESS,
|
||||
test.WARNING,
|
||||
test.ERROR
|
||||
]).default(undefined))
|
||||
}).noUnknown()
|
||||
);
|
||||
@ -3355,6 +3415,69 @@ export namespace ModelWithLink {
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`generation v2 typescript file(./test/result/v2/typescript/models/ModelWithNestedEnums.ts): ./test/result/v2/typescript/models/ModelWithNestedEnums.ts 1`] = `
|
||||
"/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/* prettier-ignore */
|
||||
|
||||
import { array } from '../models/array';
|
||||
import { Dictionary } from '../models/Dictionary';
|
||||
import * as yup from 'yup';
|
||||
|
||||
/**
|
||||
* This is a model with nested enums
|
||||
*/
|
||||
export interface ModelWithNestedEnums {
|
||||
arrayWithDescription?: array;
|
||||
arrayWithEnum?: array;
|
||||
dictionaryWithEnum?: Dictionary<('Success' | 'Warning' | 'Error')>;
|
||||
dictionaryWithEnumFromDescription?: Dictionary<(1 | 2 | 3)>;
|
||||
}
|
||||
|
||||
export namespace ModelWithNestedEnums {
|
||||
|
||||
export const schema: yup.ObjectSchema<ModelWithNestedEnums> = (
|
||||
yup.object<ModelWithNestedEnums>().shape({
|
||||
arrayWithDescription: yup.lazy(() => yup.mixed<array>().default(undefined)),
|
||||
arrayWithEnum: yup.lazy(() => yup.mixed<array>().default(undefined)),
|
||||
dictionaryWithEnum: yup.lazy(() => yup.lazy<Dictionary<('Success' | 'Warning' | 'Error')>>(value => {
|
||||
return yup.object<Dictionary<('Success' | 'Warning' | 'Error')>>().shape(
|
||||
Object.entries(value).reduce((obj, item) => ({
|
||||
...obj,
|
||||
[item[0]]: yup.mixed<string>().oneOf([
|
||||
'Success',
|
||||
'Warning',
|
||||
'Error'
|
||||
])
|
||||
}), {})
|
||||
);
|
||||
}).default(undefined)),
|
||||
dictionaryWithEnumFromDescription: yup.lazy(() => yup.lazy<Dictionary<(1 | 2 | 3)>>(value => {
|
||||
return yup.object<Dictionary<(1 | 2 | 3)>>().shape(
|
||||
Object.entries(value).reduce((obj, item) => ({
|
||||
...obj,
|
||||
[item[0]]: yup.mixed<number>().oneOf([
|
||||
1,
|
||||
2,
|
||||
3
|
||||
])
|
||||
}), {})
|
||||
);
|
||||
}).default(undefined))
|
||||
}).noUnknown()
|
||||
);
|
||||
|
||||
export async function validate(value: any): Promise<ModelWithNestedEnums> {
|
||||
return schema.validate(value, { strict: true });
|
||||
}
|
||||
|
||||
export function validateSync(value: any): ModelWithNestedEnums {
|
||||
return schema.validateSync(value, { strict: true });
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
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 */
|
||||
@ -3733,9 +3856,6 @@ export class ParametersService {
|
||||
const result = await request({
|
||||
method: 'get',
|
||||
path: \`/api/v\${OpenAPI.VERSION}/parameters\`,
|
||||
headers: {
|
||||
'parameterHeader': parameterHeader
|
||||
},
|
||||
query: {
|
||||
'parameterQuery': parameterQuery
|
||||
},
|
||||
@ -3977,6 +4097,7 @@ export class TypesService {
|
||||
* @param parameterObject This is an object parameter
|
||||
* @param parameterArray This is an array parameter
|
||||
* @param parameterDictionary This is a dictionary parameter
|
||||
* @param parameterEnum This is an enum parameter
|
||||
* @param id This is a number parameter
|
||||
* @result number Response is a simple number
|
||||
* @result string Response is a simple string
|
||||
@ -3991,6 +4112,7 @@ export class TypesService {
|
||||
parameterObject: any = null,
|
||||
parameterArray: Array<string>,
|
||||
parameterDictionary: Dictionary<string>,
|
||||
parameterEnum: ('Success' | 'Warning' | 'Error'),
|
||||
id?: number
|
||||
): Promise<number | string | boolean | any> {
|
||||
|
||||
@ -4003,7 +4125,8 @@ export class TypesService {
|
||||
'parameterBoolean': parameterBoolean,
|
||||
'parameterObject': parameterObject,
|
||||
'parameterArray': parameterArray,
|
||||
'parameterDictionary': parameterDictionary
|
||||
'parameterDictionary': parameterDictionary,
|
||||
'parameterEnum': parameterEnum
|
||||
}
|
||||
});
|
||||
|
||||
@ -4403,6 +4526,7 @@ export { ModelWithEnum } from './models/ModelWithEnum';
|
||||
export { ModelWithEnumFromDescription } from './models/ModelWithEnumFromDescription';
|
||||
export { ModelWithInteger } from './models/ModelWithInteger';
|
||||
export { ModelWithLink } from './models/ModelWithLink';
|
||||
export { ModelWithNestedEnums } from './models/ModelWithNestedEnums';
|
||||
export { ModelWithNestedProperties } from './models/ModelWithNestedProperties';
|
||||
export { ModelWithProperties } from './models/ModelWithProperties';
|
||||
export { ModelWithReference } from './models/ModelWithReference';
|
||||
@ -4786,9 +4910,9 @@ export let EnumFromDescription;
|
||||
EnumFromDescription.WARNING = 2;
|
||||
|
||||
EnumFromDescription.schema = yup.mixed().oneOf([
|
||||
EnumFromDescription.ERROR,
|
||||
EnumFromDescription.SUCCESS,
|
||||
EnumFromDescription.WARNING
|
||||
3,
|
||||
1,
|
||||
2
|
||||
]);
|
||||
|
||||
EnumFromDescription.validate = async function(value) {
|
||||
@ -4820,9 +4944,9 @@ export let EnumWithNumbers;
|
||||
EnumWithNumbers.NUM_3 = 3;
|
||||
|
||||
EnumWithNumbers.schema = yup.mixed().oneOf([
|
||||
EnumWithNumbers.NUM_1,
|
||||
EnumWithNumbers.NUM_2,
|
||||
EnumWithNumbers.NUM_3
|
||||
1,
|
||||
2,
|
||||
3
|
||||
]);
|
||||
|
||||
EnumWithNumbers.validate = async function(value) {
|
||||
@ -4854,9 +4978,9 @@ export let EnumWithStrings;
|
||||
EnumWithStrings.WARNING = 'Warning';
|
||||
|
||||
EnumWithStrings.schema = yup.mixed().oneOf([
|
||||
EnumWithStrings.ERROR,
|
||||
EnumWithStrings.SUCCESS,
|
||||
EnumWithStrings.WARNING
|
||||
'Error',
|
||||
'Success',
|
||||
'Warning'
|
||||
]);
|
||||
|
||||
EnumWithStrings.validate = async function(value) {
|
||||
@ -5312,6 +5436,63 @@ export let ModelWithLink;
|
||||
})(ModelWithLink || (ModelWithLink = {}));"
|
||||
`;
|
||||
|
||||
exports[`generation v3 javascript file(./test/result/v3/javascript/models/ModelWithNestedEnums.js): ./test/result/v3/javascript/models/ModelWithNestedEnums.js 1`] = `
|
||||
"/* istanbul ignore file */
|
||||
/* eslint-disable */
|
||||
/* prettier-ignore */
|
||||
|
||||
import { array } from '../models/array';
|
||||
|
||||
import * as yup from 'yup';
|
||||
|
||||
/**
|
||||
* This is a model with nested enums
|
||||
*/
|
||||
export let ModelWithNestedEnums;
|
||||
(function (ModelWithNestedEnums) {
|
||||
|
||||
ModelWithNestedEnums.schema = (
|
||||
yup.object().shape({
|
||||
arrayWithDescription: yup.lazy(() => yup.mixed().default(undefined)),
|
||||
arrayWithEnum: yup.lazy(() => yup.mixed().default(undefined)),
|
||||
dictionaryWithEnum: yup.lazy(() => yup.lazy(value => {
|
||||
return yup.object().shape(
|
||||
Object.entries(value).reduce((obj, item) => ({
|
||||
...obj,
|
||||
[item[0]]: yup.mixed().oneOf([
|
||||
'Success',
|
||||
'Warning',
|
||||
'Error'
|
||||
])
|
||||
}), {})
|
||||
);
|
||||
}).default(undefined)),
|
||||
dictionaryWithEnumFromDescription: yup.lazy(() => yup.lazy(value => {
|
||||
return yup.object().shape(
|
||||
Object.entries(value).reduce((obj, item) => ({
|
||||
...obj,
|
||||
[item[0]]: yup.mixed().oneOf([
|
||||
1,
|
||||
2,
|
||||
3
|
||||
])
|
||||
}), {})
|
||||
);
|
||||
}).default(undefined))
|
||||
}).noUnknown()
|
||||
);
|
||||
|
||||
ModelWithNestedEnums.validate = async function(value) {
|
||||
return ModelWithNestedEnums.schema.validate(value, { strict: true });
|
||||
};
|
||||
|
||||
ModelWithNestedEnums.validateSync = function(value) {
|
||||
return ModelWithNestedEnums.schema.validateSync(value, { strict: true });
|
||||
};
|
||||
|
||||
})(ModelWithNestedEnums || (ModelWithNestedEnums = {}));"
|
||||
`;
|
||||
|
||||
exports[`generation v3 javascript file(./test/result/v3/javascript/models/ModelWithNestedProperties.js): ./test/result/v3/javascript/models/ModelWithNestedProperties.js 1`] = `
|
||||
"/* istanbul ignore file */
|
||||
/* eslint-disable */
|
||||
@ -5593,7 +5774,7 @@ export class ComplexService {
|
||||
/**
|
||||
* @param parameterObject Parameter containing object
|
||||
* @param parameterReference Parameter containing reference
|
||||
* @result any Successful response
|
||||
* @result ModelWithString Successful response
|
||||
* @throws ApiError
|
||||
*/
|
||||
static async complexTypes(
|
||||
@ -5639,22 +5820,35 @@ export class ParametersService {
|
||||
/**
|
||||
* @param parameterHeader This is the parameter that goes into the request header
|
||||
* @param parameterQuery This is the parameter that goes into the request query params
|
||||
* @param parameterForm This is the parameter that goes into the request form data
|
||||
* @param parameterCookie This is the parameter that goes into the cookie
|
||||
* @param requestBody This is the parameter that goes into the body
|
||||
* @throws ApiError
|
||||
*/
|
||||
static async callWithParameters(
|
||||
parameterHeader,
|
||||
parameterQuery
|
||||
parameterQuery,
|
||||
parameterForm,
|
||||
parameterCookie,
|
||||
requestBody
|
||||
) {
|
||||
|
||||
const result = await request({
|
||||
method: 'get',
|
||||
path: \`/api/v\${OpenAPI.VERSION}/parameters\`,
|
||||
cookies: {
|
||||
'parameterCookie': parameterCookie
|
||||
},
|
||||
headers: {
|
||||
'parameterHeader': parameterHeader
|
||||
},
|
||||
query: {
|
||||
'parameterQuery': parameterQuery
|
||||
}
|
||||
},
|
||||
formData: {
|
||||
'parameterForm': parameterForm
|
||||
},
|
||||
body: requestBody
|
||||
});
|
||||
|
||||
catchGenericError(result);
|
||||
@ -5677,7 +5871,7 @@ import { OpenAPI } from '../core/OpenAPI';
|
||||
export class ResponseService {
|
||||
|
||||
/**
|
||||
* @result any Message for default response
|
||||
* @result ModelWithString Message for default response
|
||||
* @throws ApiError
|
||||
*/
|
||||
static async callWithDuplicateResponses() {
|
||||
@ -5701,7 +5895,7 @@ export class ResponseService {
|
||||
}
|
||||
|
||||
/**
|
||||
* @result any Message for default response
|
||||
* @result ModelWithString
|
||||
* @throws ApiError
|
||||
*/
|
||||
static async callWithResponse() {
|
||||
@ -5717,7 +5911,9 @@ export class ResponseService {
|
||||
}
|
||||
|
||||
/**
|
||||
* @result any Message for default response
|
||||
* @result ModelWithString Message for default response
|
||||
* @result ModelThatExtends Message for 201 response
|
||||
* @result ModelThatExtendsExtends Message for 202 response
|
||||
* @throws ApiError
|
||||
*/
|
||||
static async callWithResponses() {
|
||||
@ -5880,8 +6076,12 @@ export class TypesService {
|
||||
* @param parameterObject This is an object parameter
|
||||
* @param parameterArray This is an array parameter
|
||||
* @param parameterDictionary This is a dictionary parameter
|
||||
* @param parameterEnum This is an enum parameter
|
||||
* @param id This is a number parameter
|
||||
* @result any Response is a simple number
|
||||
* @result number Response is a simple number
|
||||
* @result string Response is a simple string
|
||||
* @result boolean Response is a simple boolean
|
||||
* @result any Response is a simple object
|
||||
* @throws ApiError
|
||||
*/
|
||||
static async types(
|
||||
@ -5891,6 +6091,7 @@ export class TypesService {
|
||||
parameterObject,
|
||||
parameterArray,
|
||||
parameterDictionary,
|
||||
parameterEnum,
|
||||
id
|
||||
) {
|
||||
|
||||
@ -5903,7 +6104,8 @@ export class TypesService {
|
||||
'parameterBoolean': parameterBoolean,
|
||||
'parameterObject': parameterObject,
|
||||
'parameterArray': parameterArray,
|
||||
'parameterDictionary': parameterDictionary
|
||||
'parameterDictionary': parameterDictionary,
|
||||
'parameterEnum': parameterEnum
|
||||
}
|
||||
});
|
||||
|
||||
@ -5999,6 +6201,7 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/core/RequestO
|
||||
export interface RequestOptions {
|
||||
method: 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch';
|
||||
path: string;
|
||||
cookies?: { [key: string]: any };
|
||||
headers?: { [key: string]: any };
|
||||
query?: { [key: string]: any };
|
||||
formData?: { [key: string]: any };
|
||||
@ -6353,6 +6556,7 @@ export { ModelWithEnum } from './models/ModelWithEnum';
|
||||
export { ModelWithEnumFromDescription } from './models/ModelWithEnumFromDescription';
|
||||
export { ModelWithInteger } from './models/ModelWithInteger';
|
||||
export { ModelWithLink } from './models/ModelWithLink';
|
||||
export { ModelWithNestedEnums } from './models/ModelWithNestedEnums';
|
||||
export { ModelWithNestedProperties } from './models/ModelWithNestedProperties';
|
||||
export { ModelWithProperties } from './models/ModelWithProperties';
|
||||
export { ModelWithReference } from './models/ModelWithReference';
|
||||
@ -7358,6 +7562,69 @@ export namespace ModelWithLink {
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelWithNestedEnums.ts): ./test/result/v3/typescript/models/ModelWithNestedEnums.ts 1`] = `
|
||||
"/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/* prettier-ignore */
|
||||
|
||||
import { array } from '../models/array';
|
||||
import { Dictionary } from '../models/Dictionary';
|
||||
import * as yup from 'yup';
|
||||
|
||||
/**
|
||||
* This is a model with nested enums
|
||||
*/
|
||||
export interface ModelWithNestedEnums {
|
||||
arrayWithDescription?: array;
|
||||
arrayWithEnum?: array;
|
||||
dictionaryWithEnum?: Dictionary<('Success' | 'Warning' | 'Error')>;
|
||||
dictionaryWithEnumFromDescription?: Dictionary<(1 | 2 | 3)>;
|
||||
}
|
||||
|
||||
export namespace ModelWithNestedEnums {
|
||||
|
||||
export const schema: yup.ObjectSchema<ModelWithNestedEnums> = (
|
||||
yup.object<ModelWithNestedEnums>().shape({
|
||||
arrayWithDescription: yup.lazy(() => yup.mixed<array>().default(undefined)),
|
||||
arrayWithEnum: yup.lazy(() => yup.mixed<array>().default(undefined)),
|
||||
dictionaryWithEnum: yup.lazy(() => yup.lazy<Dictionary<('Success' | 'Warning' | 'Error')>>(value => {
|
||||
return yup.object<Dictionary<('Success' | 'Warning' | 'Error')>>().shape(
|
||||
Object.entries(value).reduce((obj, item) => ({
|
||||
...obj,
|
||||
[item[0]]: yup.mixed<string>().oneOf([
|
||||
'Success',
|
||||
'Warning',
|
||||
'Error'
|
||||
])
|
||||
}), {})
|
||||
);
|
||||
}).default(undefined)),
|
||||
dictionaryWithEnumFromDescription: yup.lazy(() => yup.lazy<Dictionary<(1 | 2 | 3)>>(value => {
|
||||
return yup.object<Dictionary<(1 | 2 | 3)>>().shape(
|
||||
Object.entries(value).reduce((obj, item) => ({
|
||||
...obj,
|
||||
[item[0]]: yup.mixed<number>().oneOf([
|
||||
1,
|
||||
2,
|
||||
3
|
||||
])
|
||||
}), {})
|
||||
);
|
||||
}).default(undefined))
|
||||
}).noUnknown()
|
||||
);
|
||||
|
||||
export async function validate(value: any): Promise<ModelWithNestedEnums> {
|
||||
return schema.validate(value, { strict: true });
|
||||
}
|
||||
|
||||
export function validateSync(value: any): ModelWithNestedEnums {
|
||||
return schema.validateSync(value, { strict: true });
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`generation v3 typescript file(./test/result/v3/typescript/models/ModelWithNestedProperties.ts): ./test/result/v3/typescript/models/ModelWithNestedProperties.ts 1`] = `
|
||||
"/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
@ -7671,7 +7938,7 @@ export class ComplexService {
|
||||
/**
|
||||
* @param parameterObject Parameter containing object
|
||||
* @param parameterReference Parameter containing reference
|
||||
* @result any Successful response
|
||||
* @result ModelWithString Successful response
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static async complexTypes(
|
||||
@ -7683,7 +7950,7 @@ export class ComplexService {
|
||||
}
|
||||
},
|
||||
parameterReference: ModelWithString
|
||||
): Promise<any> {
|
||||
): Promise<Array<ModelWithString>> {
|
||||
|
||||
const result = await request({
|
||||
method: 'get',
|
||||
@ -7715,6 +7982,7 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/services/Para
|
||||
/* eslint-disable */
|
||||
/* prettier-ignore */
|
||||
|
||||
import { ModelWithString } from '../models/ModelWithString';
|
||||
import { ApiError, catchGenericError } from '../core/ApiError';
|
||||
import { request } from '../core/request';
|
||||
import { OpenAPI } from '../core/OpenAPI';
|
||||
@ -7724,22 +7992,35 @@ export class ParametersService {
|
||||
/**
|
||||
* @param parameterHeader This is the parameter that goes into the request header
|
||||
* @param parameterQuery This is the parameter that goes into the request query params
|
||||
* @param parameterForm This is the parameter that goes into the request form data
|
||||
* @param parameterCookie This is the parameter that goes into the cookie
|
||||
* @param requestBody This is the parameter that goes into the body
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static async callWithParameters(
|
||||
parameterHeader: any,
|
||||
parameterQuery: any
|
||||
parameterHeader: string | null,
|
||||
parameterQuery: string | null,
|
||||
parameterForm: string | null,
|
||||
parameterCookie: string | null,
|
||||
requestBody?: ModelWithString
|
||||
): Promise<void> {
|
||||
|
||||
const result = await request({
|
||||
method: 'get',
|
||||
path: \`/api/v\${OpenAPI.VERSION}/parameters\`,
|
||||
cookies: {
|
||||
'parameterCookie': parameterCookie
|
||||
},
|
||||
headers: {
|
||||
'parameterHeader': parameterHeader
|
||||
},
|
||||
query: {
|
||||
'parameterQuery': parameterQuery
|
||||
}
|
||||
},
|
||||
formData: {
|
||||
'parameterForm': parameterForm
|
||||
},
|
||||
body: requestBody
|
||||
});
|
||||
|
||||
catchGenericError(result);
|
||||
@ -7756,6 +8037,9 @@ exports[`generation v3 typescript file(./test/result/v3/typescript/services/Resp
|
||||
/* eslint-disable */
|
||||
/* prettier-ignore */
|
||||
|
||||
import { ModelThatExtends } from '../models/ModelThatExtends';
|
||||
import { ModelThatExtendsExtends } from '../models/ModelThatExtendsExtends';
|
||||
import { ModelWithString } from '../models/ModelWithString';
|
||||
import { ApiError, catchGenericError } from '../core/ApiError';
|
||||
import { request } from '../core/request';
|
||||
import { OpenAPI } from '../core/OpenAPI';
|
||||
@ -7763,10 +8047,10 @@ import { OpenAPI } from '../core/OpenAPI';
|
||||
export class ResponseService {
|
||||
|
||||
/**
|
||||
* @result any Message for default response
|
||||
* @result ModelWithString Message for default response
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static async callWithDuplicateResponses(): Promise<any> {
|
||||
public static async callWithDuplicateResponses(): Promise<ModelWithString> {
|
||||
|
||||
const result = await request({
|
||||
method: 'post',
|
||||
@ -7787,10 +8071,10 @@ export class ResponseService {
|
||||
}
|
||||
|
||||
/**
|
||||
* @result any Message for default response
|
||||
* @result ModelWithString
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static async callWithResponse(): Promise<any> {
|
||||
public static async callWithResponse(): Promise<ModelWithString> {
|
||||
|
||||
const result = await request({
|
||||
method: 'get',
|
||||
@ -7803,10 +8087,12 @@ export class ResponseService {
|
||||
}
|
||||
|
||||
/**
|
||||
* @result any Message for default response
|
||||
* @result ModelWithString Message for default response
|
||||
* @result ModelThatExtends Message for 201 response
|
||||
* @result ModelThatExtendsExtends Message for 202 response
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static async callWithResponses(): Promise<any> {
|
||||
public static async callWithResponses(): Promise<ModelWithString | ModelThatExtends | ModelThatExtendsExtends> {
|
||||
|
||||
const result = await request({
|
||||
method: 'put',
|
||||
@ -7968,19 +8254,24 @@ export class TypesService {
|
||||
* @param parameterObject This is an object parameter
|
||||
* @param parameterArray This is an array parameter
|
||||
* @param parameterDictionary This is a dictionary parameter
|
||||
* @param parameterEnum This is an enum parameter
|
||||
* @param id This is a number parameter
|
||||
* @result any Response is a simple number
|
||||
* @result number Response is a simple number
|
||||
* @result string Response is a simple string
|
||||
* @result boolean Response is a simple boolean
|
||||
* @result any Response is a simple object
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static async types(
|
||||
parameterNumber: any,
|
||||
parameterString: any,
|
||||
parameterBoolean: any,
|
||||
parameterObject: any,
|
||||
parameterArray: any,
|
||||
parameterDictionary: any,
|
||||
parameterNumber: number,
|
||||
parameterString: string | null,
|
||||
parameterBoolean: boolean | null,
|
||||
parameterObject: any | null,
|
||||
parameterArray: Array<string> | null,
|
||||
parameterDictionary: any | null,
|
||||
parameterEnum: ('Success' | 'Warning' | 'Error') | null,
|
||||
id?: number
|
||||
): Promise<any> {
|
||||
): Promise<number | string | boolean | any> {
|
||||
|
||||
const result = await request({
|
||||
method: 'get',
|
||||
@ -7991,7 +8282,8 @@ export class TypesService {
|
||||
'parameterBoolean': parameterBoolean,
|
||||
'parameterObject': parameterObject,
|
||||
'parameterArray': parameterArray,
|
||||
'parameterDictionary': parameterDictionary
|
||||
'parameterDictionary': parameterDictionary,
|
||||
'parameterEnum': parameterEnum
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -261,6 +261,19 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "This is an enum parameter",
|
||||
"name": "parameterEnum",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"enum": [
|
||||
"Success",
|
||||
"Warning",
|
||||
"Error"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "This is a number parameter",
|
||||
"name": "id",
|
||||
@ -538,7 +551,7 @@
|
||||
"description": "This is a model with one enum",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"Test": {
|
||||
"test": {
|
||||
"description": "This is a simple enum with strings",
|
||||
"enum": [
|
||||
"Success",
|
||||
@ -552,12 +565,52 @@
|
||||
"description": "This is a model with one enum",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"Test": {
|
||||
"test": {
|
||||
"type": "integer",
|
||||
"description": "Success=1,Warning=2,Error=3"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ModelWithNestedEnums": {
|
||||
"description": "This is a model with nested enums",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"dictionaryWithEnum": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"enum": [
|
||||
"Success",
|
||||
"Warning",
|
||||
"Error"
|
||||
]
|
||||
}
|
||||
},
|
||||
"dictionaryWithEnumFromDescription": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "integer",
|
||||
"description": "Success=1,Warning=2,Error=3"
|
||||
}
|
||||
},
|
||||
"arrayWithEnum": {
|
||||
"type": "array",
|
||||
"additionalProperties": {
|
||||
"enum": [
|
||||
"Success",
|
||||
"Warning",
|
||||
"Error"
|
||||
]
|
||||
}
|
||||
},
|
||||
"arrayWithDescription": {
|
||||
"type": "array",
|
||||
"additionalProperties": {
|
||||
"type": "integer",
|
||||
"description": "Success=1,Warning=2,Error=3"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ModelWithReference": {
|
||||
"description": "This is a model with one property containing a reference",
|
||||
"type": "object",
|
||||
|
||||
@ -65,42 +65,63 @@
|
||||
"description": "This is the parameter that goes into the request header",
|
||||
"name": "parameterHeader",
|
||||
"in": "header",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"nullable": true
|
||||
"nullable": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "This is the parameter that goes into the request query params",
|
||||
"name": "parameterQuery",
|
||||
"in": "query",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"nullable": true
|
||||
"nullable": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "This is the parameter that goes into the request form data",
|
||||
"name": "parameterForm",
|
||||
"in": "formData",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"nullable": true
|
||||
"nullable": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "This is the parameter that is send as request body",
|
||||
"name": "parameterBody",
|
||||
"in": "body",
|
||||
"type": "string",
|
||||
"description": "This is the parameter that goes into the cookie",
|
||||
"name": "parameterCookie",
|
||||
"in": "cookie",
|
||||
"required": true,
|
||||
"nullable": true
|
||||
"nullable": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "api-version",
|
||||
"in": "path",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"nullable": true
|
||||
"nullable": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
"requestBody": {
|
||||
"description": "This is the parameter that goes into the body",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"description": "Message for default response",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v{api-version}/response": {
|
||||
@ -111,9 +132,13 @@
|
||||
"operationId": "CallWithResponse",
|
||||
"responses": {
|
||||
"default": {
|
||||
"description": "Message for default response",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
"content": {
|
||||
"application/json": {
|
||||
"description": "Message for default response",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -126,38 +151,62 @@
|
||||
"responses": {
|
||||
"default": {
|
||||
"description": "Message for default response",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"201": {
|
||||
"description": "Message for 201 response",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"202": {
|
||||
"description": "Message for 202 response",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Message for 500 error",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"501": {
|
||||
"description": "Message for 501 error",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"502": {
|
||||
"description": "Message for 502 error",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -170,38 +219,62 @@
|
||||
"responses": {
|
||||
"default": {
|
||||
"description": "Message for default response",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"201": {
|
||||
"description": "Message for 201 response",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelThatExtends"
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelThatExtends"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"202": {
|
||||
"description": "Message for 202 response",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelThatExtendsExtends"
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelThatExtendsExtends"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Message for 500 error",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"501": {
|
||||
"description": "Message for 501 error",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"502": {
|
||||
"description": "Message for 502 error",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -220,7 +293,9 @@
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"default": 123,
|
||||
"type": "int"
|
||||
"schema": {
|
||||
"type": "int"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "This is a string parameter",
|
||||
@ -229,7 +304,9 @@
|
||||
"required": true,
|
||||
"nullable": true,
|
||||
"default": "default",
|
||||
"type": "string"
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "This is a boolean parameter",
|
||||
@ -238,7 +315,9 @@
|
||||
"required": true,
|
||||
"nullable": true,
|
||||
"default": true,
|
||||
"type": "boolean"
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "This is an object parameter",
|
||||
@ -247,7 +326,9 @@
|
||||
"required": true,
|
||||
"nullable": true,
|
||||
"default": null,
|
||||
"type": "object"
|
||||
"schema": {
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "This is an array parameter",
|
||||
@ -255,9 +336,11 @@
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"nullable": true,
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -266,9 +349,25 @@
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"nullable": true,
|
||||
"type": "object",
|
||||
"items": {
|
||||
"type": "string"
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "This is an enum parameter",
|
||||
"name": "parameterEnum",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"nullable": true,
|
||||
"schema": {
|
||||
"enum": [
|
||||
"Success",
|
||||
"Warning",
|
||||
"Error"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -284,27 +383,42 @@
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Response is a simple number",
|
||||
"schema": {
|
||||
"type": "number"
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"201": {
|
||||
"description": "Response is a simple string",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"202": {
|
||||
"description": "Response is a simple boolean",
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"203": {
|
||||
"description": "Response is a simple object",
|
||||
"default": null,
|
||||
"schema": {
|
||||
"type": "object"
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -354,10 +468,14 @@
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful response",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/ModelWithString"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -569,6 +687,46 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"ModelWithNestedEnums": {
|
||||
"description": "This is a model with nested enums",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"dictionaryWithEnum": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"enum": [
|
||||
"Success",
|
||||
"Warning",
|
||||
"Error"
|
||||
]
|
||||
}
|
||||
},
|
||||
"dictionaryWithEnumFromDescription": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "integer",
|
||||
"description": "Success=1,Warning=2,Error=3"
|
||||
}
|
||||
},
|
||||
"arrayWithEnum": {
|
||||
"type": "array",
|
||||
"additionalProperties": {
|
||||
"enum": [
|
||||
"Success",
|
||||
"Warning",
|
||||
"Error"
|
||||
]
|
||||
}
|
||||
},
|
||||
"arrayWithDescription": {
|
||||
"type": "array",
|
||||
"additionalProperties": {
|
||||
"type": "integer",
|
||||
"description": "Success=1,Warning=2,Error=3"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ModelWithReference": {
|
||||
"description": "This is a model with one property containing a reference",
|
||||
"type": "object",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user