diff --git a/src/openApi/v2/parser/getOperationName.spec.ts b/src/openApi/v2/parser/getOperationName.spec.ts index 8773b5f0..24332ab3 100644 --- a/src/openApi/v2/parser/getOperationName.spec.ts +++ b/src/openApi/v2/parser/getOperationName.spec.ts @@ -9,5 +9,10 @@ describe('getOperationName', () => { expect(getOperationName('foo-bar')).toEqual('fooBar'); expect(getOperationName('foo_bar')).toEqual('fooBar'); expect(getOperationName('foo.bar')).toEqual('fooBar'); + expect(getOperationName('@foo.bar')).toEqual('fooBar'); + expect(getOperationName('$foo.bar')).toEqual('fooBar'); + expect(getOperationName('_foo.bar')).toEqual('fooBar'); + expect(getOperationName('-foo.bar')).toEqual('fooBar'); + expect(getOperationName('123.foo.bar')).toEqual('fooBar'); }); }); diff --git a/src/openApi/v2/parser/getOperationName.ts b/src/openApi/v2/parser/getOperationName.ts index 78a045ca..9a993d8d 100644 --- a/src/openApi/v2/parser/getOperationName.ts +++ b/src/openApi/v2/parser/getOperationName.ts @@ -6,6 +6,9 @@ import camelCase from 'camelcase'; * the most popular Javascript and Typescript writing style. */ export function getOperationName(value: string): string { - const clean = value.replace(/[^\w\s\-]+/g, '-').trim(); + const clean = value + .replace(/^[^a-zA-Z]+/g, '') + .replace(/[^\w\-]+/g, '-') + .trim(); return camelCase(clean); } diff --git a/src/openApi/v2/parser/getOperationParameterName.spec.ts b/src/openApi/v2/parser/getOperationParameterName.spec.ts index ef7f2ddc..72501153 100644 --- a/src/openApi/v2/parser/getOperationParameterName.spec.ts +++ b/src/openApi/v2/parser/getOperationParameterName.spec.ts @@ -5,9 +5,12 @@ describe('getOperationParameterName', () => { expect(getOperationParameterName('')).toEqual(''); expect(getOperationParameterName('foobar')).toEqual('foobar'); expect(getOperationParameterName('fooBar')).toEqual('fooBar'); - expect(getOperationParameterName('foo-bar')).toEqual('fooBar'); expect(getOperationParameterName('foo_bar')).toEqual('fooBar'); + expect(getOperationParameterName('foo-bar')).toEqual('fooBar'); expect(getOperationParameterName('foo.bar')).toEqual('fooBar'); + expect(getOperationParameterName('@foo.bar')).toEqual('fooBar'); + expect(getOperationParameterName('$foo.bar')).toEqual('fooBar'); + expect(getOperationParameterName('123.foo.bar')).toEqual('fooBar'); expect(getOperationParameterName('Foo-Bar')).toEqual('fooBar'); expect(getOperationParameterName('FOO-BAR')).toEqual('fooBar'); }); diff --git a/src/openApi/v2/parser/getOperationParameterName.ts b/src/openApi/v2/parser/getOperationParameterName.ts index 5eb6c6a4..e84069d8 100644 --- a/src/openApi/v2/parser/getOperationParameterName.ts +++ b/src/openApi/v2/parser/getOperationParameterName.ts @@ -5,6 +5,9 @@ import camelCase from 'camelcase'; * For example: 'filter.someProperty' becomes 'filterSomeProperty'. */ export function getOperationParameterName(value: string): string { - const clean = value.replace(/[^\w\s\-]+/g, '-').trim(); + const clean = value + .replace(/^[^a-zA-Z]+/g, '') + .replace(/[^\w\-]+/g, '-') + .trim(); return camelCase(clean); } diff --git a/src/openApi/v2/parser/getServiceClassName.spec.ts b/src/openApi/v2/parser/getServiceClassName.spec.ts index 9bcf6e15..41d5808d 100644 --- a/src/openApi/v2/parser/getServiceClassName.spec.ts +++ b/src/openApi/v2/parser/getServiceClassName.spec.ts @@ -9,5 +9,8 @@ describe('getServiceClassName', () => { expect(getServiceClassName('FooBarService')).toEqual('FooBarService'); expect(getServiceClassName('Foo Bar Service')).toEqual('FooBarService'); expect(getServiceClassName('foo bar service')).toEqual('FooBarService'); + expect(getServiceClassName('@fooBar')).toEqual('FooBarService'); + expect(getServiceClassName('$fooBar')).toEqual('FooBarService'); + expect(getServiceClassName('123fooBar')).toEqual('FooBarService'); }); }); diff --git a/src/openApi/v2/parser/getServiceClassName.ts b/src/openApi/v2/parser/getServiceClassName.ts index 4f116a5a..05435abc 100644 --- a/src/openApi/v2/parser/getServiceClassName.ts +++ b/src/openApi/v2/parser/getServiceClassName.ts @@ -5,7 +5,10 @@ import camelCase from 'camelcase'; * the input string to PascalCase and appends the "Service" prefix if needed. */ export function getServiceClassName(value: string): string { - const clean = value.replace(/[^\w\s\-]+/g, '-').trim(); + const clean = value + .replace(/^[^a-zA-Z]+/g, '') + .replace(/[^\w\-]+/g, '-') + .trim(); const name = camelCase(clean, { pascalCase: true }); if (name && !name.endsWith('Service')) { return `${name}Service`; diff --git a/src/openApi/v3/parser/getOperationName.spec.ts b/src/openApi/v3/parser/getOperationName.spec.ts index 8773b5f0..24332ab3 100644 --- a/src/openApi/v3/parser/getOperationName.spec.ts +++ b/src/openApi/v3/parser/getOperationName.spec.ts @@ -9,5 +9,10 @@ describe('getOperationName', () => { expect(getOperationName('foo-bar')).toEqual('fooBar'); expect(getOperationName('foo_bar')).toEqual('fooBar'); expect(getOperationName('foo.bar')).toEqual('fooBar'); + expect(getOperationName('@foo.bar')).toEqual('fooBar'); + expect(getOperationName('$foo.bar')).toEqual('fooBar'); + expect(getOperationName('_foo.bar')).toEqual('fooBar'); + expect(getOperationName('-foo.bar')).toEqual('fooBar'); + expect(getOperationName('123.foo.bar')).toEqual('fooBar'); }); }); diff --git a/src/openApi/v3/parser/getOperationName.ts b/src/openApi/v3/parser/getOperationName.ts index 78a045ca..9a993d8d 100644 --- a/src/openApi/v3/parser/getOperationName.ts +++ b/src/openApi/v3/parser/getOperationName.ts @@ -6,6 +6,9 @@ import camelCase from 'camelcase'; * the most popular Javascript and Typescript writing style. */ export function getOperationName(value: string): string { - const clean = value.replace(/[^\w\s\-]+/g, '-').trim(); + const clean = value + .replace(/^[^a-zA-Z]+/g, '') + .replace(/[^\w\-]+/g, '-') + .trim(); return camelCase(clean); } diff --git a/src/openApi/v3/parser/getOperationParameterName.spec.ts b/src/openApi/v3/parser/getOperationParameterName.spec.ts index ef7f2ddc..72501153 100644 --- a/src/openApi/v3/parser/getOperationParameterName.spec.ts +++ b/src/openApi/v3/parser/getOperationParameterName.spec.ts @@ -5,9 +5,12 @@ describe('getOperationParameterName', () => { expect(getOperationParameterName('')).toEqual(''); expect(getOperationParameterName('foobar')).toEqual('foobar'); expect(getOperationParameterName('fooBar')).toEqual('fooBar'); - expect(getOperationParameterName('foo-bar')).toEqual('fooBar'); expect(getOperationParameterName('foo_bar')).toEqual('fooBar'); + expect(getOperationParameterName('foo-bar')).toEqual('fooBar'); expect(getOperationParameterName('foo.bar')).toEqual('fooBar'); + expect(getOperationParameterName('@foo.bar')).toEqual('fooBar'); + expect(getOperationParameterName('$foo.bar')).toEqual('fooBar'); + expect(getOperationParameterName('123.foo.bar')).toEqual('fooBar'); expect(getOperationParameterName('Foo-Bar')).toEqual('fooBar'); expect(getOperationParameterName('FOO-BAR')).toEqual('fooBar'); }); diff --git a/src/openApi/v3/parser/getOperationParameterName.ts b/src/openApi/v3/parser/getOperationParameterName.ts index 5eb6c6a4..e84069d8 100644 --- a/src/openApi/v3/parser/getOperationParameterName.ts +++ b/src/openApi/v3/parser/getOperationParameterName.ts @@ -5,6 +5,9 @@ import camelCase from 'camelcase'; * For example: 'filter.someProperty' becomes 'filterSomeProperty'. */ export function getOperationParameterName(value: string): string { - const clean = value.replace(/[^\w\s\-]+/g, '-').trim(); + const clean = value + .replace(/^[^a-zA-Z]+/g, '') + .replace(/[^\w\-]+/g, '-') + .trim(); return camelCase(clean); } diff --git a/src/openApi/v3/parser/getServiceClassName.spec.ts b/src/openApi/v3/parser/getServiceClassName.spec.ts index 9bcf6e15..41d5808d 100644 --- a/src/openApi/v3/parser/getServiceClassName.spec.ts +++ b/src/openApi/v3/parser/getServiceClassName.spec.ts @@ -9,5 +9,8 @@ describe('getServiceClassName', () => { expect(getServiceClassName('FooBarService')).toEqual('FooBarService'); expect(getServiceClassName('Foo Bar Service')).toEqual('FooBarService'); expect(getServiceClassName('foo bar service')).toEqual('FooBarService'); + expect(getServiceClassName('@fooBar')).toEqual('FooBarService'); + expect(getServiceClassName('$fooBar')).toEqual('FooBarService'); + expect(getServiceClassName('123fooBar')).toEqual('FooBarService'); }); }); diff --git a/src/openApi/v3/parser/getServiceClassName.ts b/src/openApi/v3/parser/getServiceClassName.ts index 4f116a5a..05435abc 100644 --- a/src/openApi/v3/parser/getServiceClassName.ts +++ b/src/openApi/v3/parser/getServiceClassName.ts @@ -5,7 +5,10 @@ import camelCase from 'camelcase'; * the input string to PascalCase and appends the "Service" prefix if needed. */ export function getServiceClassName(value: string): string { - const clean = value.replace(/[^\w\s\-]+/g, '-').trim(); + const clean = value + .replace(/^[^a-zA-Z]+/g, '') + .replace(/[^\w\-]+/g, '-') + .trim(); const name = camelCase(clean, { pascalCase: true }); if (name && !name.endsWith('Service')) { return `${name}Service`; diff --git a/test/__snapshots__/index.spec.js.snap b/test/__snapshots__/index.spec.js.snap index c12e9b75..db1782ca 100644 --- a/test/__snapshots__/index.spec.js.snap +++ b/test/__snapshots__/index.spec.js.snap @@ -902,6 +902,8 @@ export interface ModelWithProperties { number?: number; boolean?: boolean; reference?: ModelWithString; + readonly @namespace.string?: string; + readonly @namespace.integer?: number; } " `; @@ -1479,6 +1481,14 @@ export const $ModelWithProperties = { reference: { type: 'ModelWithString', }, + @namespace.string: { + type: 'string', + isReadOnly: true, + }, + @namespace.integer: { + type: 'number', + isReadOnly: true, + }, }, };" `; @@ -1569,32 +1579,31 @@ exports[`v2 should generate: ./test/generated/v2/services/ComplexService.ts 1`] /* eslint-disable */ import type { ModelWithString } from '../models/ModelWithString'; import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; export class ComplexService { /** - * @param parameterObject Parameter containing object - * @param parameterReference Parameter containing reference + * @param 'parameterObject' Parameter containing object + * @param 'parameterReference' Parameter containing reference * @result ModelWithString Successful response * @throws ApiError */ public static async complexTypes( - parameterObject: { + 'parameterObject': { first?: { second?: { third?: string, }, }, }, - parameterReference: ModelWithString, + 'parameterReference': ModelWithString, ): Promise> { const result = await __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/complex\`, + path: \`/api/v\${api-version}/complex\`, query: { - 'parameterObject': parameterObject, - 'parameterReference': parameterReference, + 'parameterObject': 'parameterObject', + 'parameterReference': 'parameterReference', }, errors: { 400: \`400 server error\`, @@ -1613,99 +1622,98 @@ exports[`v2 should generate: ./test/generated/v2/services/DefaultsService.ts 1`] /* eslint-disable */ import type { ModelWithString } from '../models/ModelWithString'; import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; export class DefaultsService { /** - * @param parameterString This is a simple string with default value - * @param parameterNumber This is a simple number with default value - * @param parameterBoolean This is a simple boolean with default value - * @param parameterEnum This is a simple enum with default value - * @param parameterModel This is a simple model with default value + * @param 'parameterString' This is a simple string with default value + * @param 'parameterNumber' This is a simple number with default value + * @param 'parameterBoolean' This is a simple boolean with default value + * @param 'parameterEnum' This is a simple enum with default value + * @param 'parameterModel' This is a simple model with default value * @throws ApiError */ public static async callWithDefaultParameters( - parameterString: string = 'Hello World!', - parameterNumber: number = 123, - parameterBoolean: boolean = true, - parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', - parameterModel: ModelWithString = { + 'parameterString': string = 'Hello World!', + 'parameterNumber': number = 123, + 'parameterBoolean': boolean = true, + 'parameterEnum': 'Success' | 'Warning' | 'Error' = 'Success', + 'parameterModel': ModelWithString = { \\"prop\\": \\"Hello World!\\" }, ): Promise { const result = await __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/defaults\`, + path: \`/api/v\${api-version}/defaults\`, query: { - 'parameterString': parameterString, - 'parameterNumber': parameterNumber, - 'parameterBoolean': parameterBoolean, - 'parameterEnum': parameterEnum, - 'parameterModel': parameterModel, + 'parameterString': 'parameterString', + 'parameterNumber': 'parameterNumber', + 'parameterBoolean': 'parameterBoolean', + 'parameterEnum': 'parameterEnum', + 'parameterModel': 'parameterModel', }, }); return result.body; } /** - * @param parameterString This is a simple string that is optional with default value - * @param parameterNumber This is a simple number that is optional with default value - * @param parameterBoolean This is a simple boolean that is optional with default value - * @param parameterEnum This is a simple enum that is optional with default value - * @param parameterModel This is a simple model that is optional with default value + * @param 'parameterString' This is a simple string that is optional with default value + * @param 'parameterNumber' This is a simple number that is optional with default value + * @param 'parameterBoolean' This is a simple boolean that is optional with default value + * @param 'parameterEnum' This is a simple enum that is optional with default value + * @param 'parameterModel' This is a simple model that is optional with default value * @throws ApiError */ public static async callWithDefaultOptionalParameters( - parameterString: string = 'Hello World!', - parameterNumber: number = 123, - parameterBoolean: boolean = true, - parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', - parameterModel: ModelWithString = { + 'parameterString': string = 'Hello World!', + 'parameterNumber': number = 123, + 'parameterBoolean': boolean = true, + 'parameterEnum': 'Success' | 'Warning' | 'Error' = 'Success', + 'parameterModel': ModelWithString = { \\"prop\\": \\"Hello World!\\" }, ): Promise { const result = await __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/defaults\`, + path: \`/api/v\${api-version}/defaults\`, query: { - 'parameterString': parameterString, - 'parameterNumber': parameterNumber, - 'parameterBoolean': parameterBoolean, - 'parameterEnum': parameterEnum, - 'parameterModel': parameterModel, + 'parameterString': 'parameterString', + 'parameterNumber': 'parameterNumber', + 'parameterBoolean': 'parameterBoolean', + 'parameterEnum': 'parameterEnum', + 'parameterModel': 'parameterModel', }, }); return result.body; } /** - * @param parameterStringWithNoDefault This is a string with no default - * @param parameterOptionalStringWithDefault This is a optional string with default - * @param parameterOptionalStringWithEmptyDefault This is a optional string with empty default - * @param parameterOptionalStringWithNoDefault This is a optional string with no default - * @param parameterStringWithDefault This is a string with default - * @param parameterStringWithEmptyDefault This is a string with empty default + * @param 'parameterStringWithNoDefault' This is a string with no default + * @param 'parameterOptionalStringWithDefault' This is a optional string with default + * @param 'parameterOptionalStringWithEmptyDefault' This is a optional string with empty default + * @param 'parameterOptionalStringWithNoDefault' This is a optional string with no default + * @param 'parameterStringWithDefault' This is a string with default + * @param 'parameterStringWithEmptyDefault' This is a string with empty default * @throws ApiError */ public static async callToTestOrderOfParams( - parameterStringWithNoDefault: string, - parameterOptionalStringWithDefault: string = 'Hello World!', - parameterOptionalStringWithEmptyDefault: string = '', - parameterOptionalStringWithNoDefault?: string, - parameterStringWithDefault: string = 'Hello World!', - parameterStringWithEmptyDefault: string = '', + 'parameterStringWithNoDefault': string, + 'parameterOptionalStringWithDefault': string = 'Hello World!', + 'parameterOptionalStringWithEmptyDefault': string = '', + 'parameterOptionalStringWithNoDefault'?: string, + 'parameterStringWithDefault': string = 'Hello World!', + 'parameterStringWithEmptyDefault': string = '', ): Promise { const result = await __request({ method: 'PUT', - path: \`/api/v\${OpenAPI.VERSION}/defaults\`, + path: \`/api/v\${api-version}/defaults\`, query: { - 'parameterStringWithNoDefault': parameterStringWithNoDefault, - 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, - 'parameterOptionalStringWithEmptyDefault': parameterOptionalStringWithEmptyDefault, - 'parameterOptionalStringWithNoDefault': parameterOptionalStringWithNoDefault, - 'parameterStringWithDefault': parameterStringWithDefault, - 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, + 'parameterStringWithNoDefault': 'parameterStringWithNoDefault', + 'parameterOptionalStringWithDefault': 'parameterOptionalStringWithDefault', + 'parameterOptionalStringWithEmptyDefault': 'parameterOptionalStringWithEmptyDefault', + 'parameterOptionalStringWithNoDefault': 'parameterOptionalStringWithNoDefault', + 'parameterStringWithDefault': 'parameterStringWithDefault', + 'parameterStringWithEmptyDefault': 'parameterStringWithEmptyDefault', }, }); return result.body; @@ -1719,7 +1727,6 @@ exports[`v2 should generate: ./test/generated/v2/services/DuplicateService.ts 1` /* tslint:disable */ /* eslint-disable */ import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; export class DuplicateService { @@ -1729,7 +1736,7 @@ export class DuplicateService { public static async duplicateName(): Promise { const result = await __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + path: \`/api/v\${api-version}/duplicate\`, }); return result.body; } @@ -1740,7 +1747,7 @@ export class DuplicateService { public static async duplicateName1(): Promise { const result = await __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + path: \`/api/v\${api-version}/duplicate\`, }); return result.body; } @@ -1751,7 +1758,7 @@ export class DuplicateService { public static async duplicateName2(): Promise { const result = await __request({ method: 'PUT', - path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + path: \`/api/v\${api-version}/duplicate\`, }); return result.body; } @@ -1762,7 +1769,7 @@ export class DuplicateService { public static async duplicateName3(): Promise { const result = await __request({ method: 'DELETE', - path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + path: \`/api/v\${api-version}/duplicate\`, }); return result.body; } @@ -1775,7 +1782,6 @@ exports[`v2 should generate: ./test/generated/v2/services/HeaderService.ts 1`] = /* tslint:disable */ /* eslint-disable */ import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; export class HeaderService { @@ -1786,7 +1792,7 @@ export class HeaderService { public static async callWithResultFromHeader(): Promise { const result = await __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/header\`, + path: \`/api/v\${api-version}/header\`, responseHeader: 'operation-location', errors: { 400: \`400 server error\`, @@ -1804,74 +1810,73 @@ exports[`v2 should generate: ./test/generated/v2/services/ParametersService.ts 1 /* tslint:disable */ /* eslint-disable */ import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; export class ParametersService { /** - * @param parameterHeader This is the parameter that goes into the header - * @param parameterQuery This is the parameter that goes into the query params - * @param parameterForm This is the parameter that goes into the form data - * @param parameterBody This is the parameter that is send as request body - * @param parameterPath This is the parameter that goes into the path + * @param 'parameterHeader' This is the parameter that goes into the header + * @param 'parameterQuery' This is the parameter that goes into the query params + * @param 'parameterForm' This is the parameter that goes into the form data + * @param 'parameterBody' This is the parameter that is send as request body + * @param 'parameterPath' This is the parameter that goes into the path * @throws ApiError */ public static async callWithParameters( - parameterHeader: string, - parameterQuery: string, - parameterForm: string, - parameterBody: string, - parameterPath: string, + 'parameterHeader': string, + 'parameterQuery': string, + 'parameterForm': string, + 'parameterBody': string, + 'parameterPath': string, ): Promise { const result = await __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/parameters/\${parameterPath}\`, + path: \`/api/v\${api-version}/parameters/\${'parameterPath'}\`, headers: { - 'parameterHeader': parameterHeader, + 'parameterHeader': 'parameterHeader', }, query: { - 'parameterQuery': parameterQuery, + 'parameterQuery': 'parameterQuery', }, formData: { - 'parameterForm': parameterForm, + 'parameterForm': 'parameterForm', }, - body: parameterBody, + body: 'parameterBody', }); return result.body; } /** - * @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 parameterBody This is the parameter that is send as request body - * @param parameterPath1 This is the parameter that goes into the path - * @param parameterPath2 This is the parameter that goes into the path - * @param parameterPath3 This is the parameter that goes into the path + * @param parameter.header This is the parameter that goes into the request header + * @param parameter-query This is the parameter that goes into the request query params + * @param 'parameter_form' This is the parameter that goes into the request form data + * @param PARAMETER-BODY This is the parameter that is send as request body + * @param parameter.path.1 This is the parameter that goes into the path + * @param parameter-path-2 This is the parameter that goes into the path + * @param PARAMETER-PATH-3 This is the parameter that goes into the path * @throws ApiError */ public static async callWithWeirdParameterNames( - parameterHeader: string, - parameterQuery: string, - parameterForm: string, - parameterBody: string, - parameterPath1?: string, - parameterPath2?: string, - parameterPath3?: string, + parameter.header: string, + parameter-query: string, + 'parameter_form': string, + PARAMETER-BODY: string, + parameter.path.1?: string, + parameter-path-2?: string, + PARAMETER-PATH-3?: string, ): Promise { const result = await __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, + path: \`/api/v\${api-version}/parameters/\${parameter.path.1}/\${parameter-path-2}/\${PARAMETER-PATH-3}\`, headers: { - 'parameter.header': parameterHeader, + 'parameter.header': parameter.header, }, query: { - 'parameter-query': parameterQuery, + 'parameter-query': parameter-query, }, formData: { - 'parameter_form': parameterForm, + 'parameter_form': 'parameter_form', }, - body: parameterBody, + body: PARAMETER-BODY, }); return result.body; } @@ -1887,7 +1892,6 @@ import type { ModelThatExtends } from '../models/ModelThatExtends'; import type { ModelThatExtendsExtends } from '../models/ModelThatExtendsExtends'; import type { ModelWithString } from '../models/ModelWithString'; import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; export class ResponseService { @@ -1898,7 +1902,7 @@ export class ResponseService { public static async callWithResponse(): Promise { const result = await __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/response\`, + path: \`/api/v\${api-version}/response\`, }); return result.body; } @@ -1910,7 +1914,7 @@ export class ResponseService { public static async callWithDuplicateResponses(): Promise { const result = await __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/response\`, + path: \`/api/v\${api-version}/response\`, errors: { 500: \`Message for 500 error\`, 501: \`Message for 501 error\`, @@ -1921,15 +1925,20 @@ export class ResponseService { } /** + * @result any Message for 200 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 { + public static async callWithResponses(): Promise<{ + readonly @namespace.string?: string, + readonly @namespace.integer?: number, + readonly value?: Array, + } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends> { const result = await __request({ method: 'PUT', - path: \`/api/v\${OpenAPI.VERSION}/response\`, + path: \`/api/v\${api-version}/response\`, errors: { 500: \`Message for 500 error\`, 501: \`Message for 501 error\`, @@ -1947,7 +1956,6 @@ exports[`v2 should generate: ./test/generated/v2/services/SimpleService.ts 1`] = /* tslint:disable */ /* eslint-disable */ import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; export class SimpleService { @@ -1957,7 +1965,7 @@ export class SimpleService { public static async getCallWithoutParametersAndResponse(): Promise { const result = await __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${api-version}/simple\`, }); return result.body; } @@ -1968,7 +1976,7 @@ export class SimpleService { public static async putCallWithoutParametersAndResponse(): Promise { const result = await __request({ method: 'PUT', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${api-version}/simple\`, }); return result.body; } @@ -1979,7 +1987,7 @@ export class SimpleService { public static async postCallWithoutParametersAndResponse(): Promise { const result = await __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${api-version}/simple\`, }); return result.body; } @@ -1990,7 +1998,7 @@ export class SimpleService { public static async deleteCallWithoutParametersAndResponse(): Promise { const result = await __request({ method: 'DELETE', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${api-version}/simple\`, }); return result.body; } @@ -2001,7 +2009,7 @@ export class SimpleService { public static async optionsCallWithoutParametersAndResponse(): Promise { const result = await __request({ method: 'OPTIONS', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${api-version}/simple\`, }); return result.body; } @@ -2012,7 +2020,7 @@ export class SimpleService { public static async headCallWithoutParametersAndResponse(): Promise { const result = await __request({ method: 'HEAD', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${api-version}/simple\`, }); return result.body; } @@ -2023,7 +2031,7 @@ export class SimpleService { public static async patchCallWithoutParametersAndResponse(): Promise { const result = await __request({ method: 'PATCH', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${api-version}/simple\`, }); return result.body; } @@ -2036,19 +2044,18 @@ exports[`v2 should generate: ./test/generated/v2/services/TypesService.ts 1`] = /* tslint:disable */ /* eslint-disable */ import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; export class TypesService { /** - * @param parameterArray This is an array parameter - * @param parameterDictionary This is a dictionary parameter - * @param parameterEnum This is an enum parameter - * @param parameterNumber This is a number parameter - * @param parameterString This is a string parameter - * @param parameterBoolean This is a boolean parameter - * @param parameterObject This is an object parameter - * @param id This is a number parameter + * @param 'parameterArray' This is an array parameter + * @param 'parameterDictionary' This is a dictionary parameter + * @param 'parameterEnum' This is an enum parameter + * @param 'parameterNumber' This is a number parameter + * @param 'parameterString' This is a string parameter + * @param 'parameterBoolean' This is a boolean parameter + * @param 'parameterObject' This is an object parameter + * @param 'id' This is a number parameter * @result number Response is a simple number * @result string Response is a simple string * @result boolean Response is a simple boolean @@ -2056,26 +2063,26 @@ export class TypesService { * @throws ApiError */ public static async types( - parameterArray: Array, - parameterDictionary: Record, - parameterEnum: 'Success' | 'Warning' | 'Error', - parameterNumber: number = 123, - parameterString: string = 'default', - parameterBoolean: boolean = true, - parameterObject: any = null, - id?: number, + 'parameterArray': Array, + 'parameterDictionary': Record, + 'parameterEnum': 'Success' | 'Warning' | 'Error', + 'parameterNumber': number = 123, + 'parameterString': string = 'default', + 'parameterBoolean': boolean = true, + 'parameterObject': any = null, + 'id'?: number, ): Promise { const result = await __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/types\`, + path: \`/api/v\${api-version}/types\`, query: { - 'parameterArray': parameterArray, - 'parameterDictionary': parameterDictionary, - 'parameterEnum': parameterEnum, - 'parameterNumber': parameterNumber, - 'parameterString': parameterString, - 'parameterBoolean': parameterBoolean, - 'parameterObject': parameterObject, + 'parameterArray': 'parameterArray', + 'parameterDictionary': 'parameterDictionary', + 'parameterEnum': 'parameterEnum', + 'parameterNumber': 'parameterNumber', + 'parameterString': 'parameterString', + 'parameterBoolean': 'parameterBoolean', + 'parameterObject': 'parameterObject', }, }); return result.body; @@ -3008,6 +3015,8 @@ export interface ModelWithProperties { number?: number; boolean?: boolean; reference?: ModelWithString; + readonly @namespace.string?: string; + readonly @namespace.integer?: number; } " `; @@ -3600,6 +3609,14 @@ export const $ModelWithProperties = { reference: { type: 'ModelWithString', }, + @namespace.string: { + type: 'string', + isReadOnly: true, + }, + @namespace.integer: { + type: 'number', + isReadOnly: true, + }, }, };" `; @@ -3693,32 +3710,31 @@ import type { ModelWithDictionary } from '../models/ModelWithDictionary'; import type { ModelWithEnum } from '../models/ModelWithEnum'; import type { ModelWithString } from '../models/ModelWithString'; import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; export class ComplexService { /** - * @param parameterObject Parameter containing object - * @param parameterReference Parameter containing reference + * @param 'parameterObject' Parameter containing object + * @param 'parameterReference' Parameter containing reference * @result ModelWithString Successful response * @throws ApiError */ public static async complexTypes( - parameterObject: { + 'parameterObject': { first?: { second?: { third?: string, }, }, }, - parameterReference: ModelWithString, + 'parameterReference': ModelWithString, ): Promise> { const result = await __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/complex\`, + path: \`/api/v\${api-version}/complex\`, query: { - 'parameterObject': parameterObject, - 'parameterReference': parameterReference, + 'parameterObject': 'parameterObject', + 'parameterReference': 'parameterReference', }, errors: { 400: \`400 server error\`, @@ -3729,13 +3745,13 @@ export class ComplexService { } /** - * @param id + * @param 'id' * @param requestBody * @result ModelWithString Success * @throws ApiError */ public static async complexParams( - id: number, + 'id': number, requestBody?: { readonly key: string | null, name: string | null, @@ -3752,7 +3768,7 @@ export class ComplexService { ): Promise { const result = await __request({ method: 'PUT', - path: \`/api/v\${OpenAPI.VERSION}/complex/\${id}\`, + path: \`/api/v\${api-version}/complex/\${'id'}\`, body: requestBody, }); return result.body; @@ -3767,99 +3783,98 @@ exports[`v3 should generate: ./test/generated/v3/services/DefaultsService.ts 1`] /* eslint-disable */ import type { ModelWithString } from '../models/ModelWithString'; import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; export class DefaultsService { /** - * @param parameterString This is a simple string with default value - * @param parameterNumber This is a simple number with default value - * @param parameterBoolean This is a simple boolean with default value - * @param parameterEnum This is a simple enum with default value - * @param parameterModel This is a simple model with default value + * @param 'parameterString' This is a simple string with default value + * @param 'parameterNumber' This is a simple number with default value + * @param 'parameterBoolean' This is a simple boolean with default value + * @param 'parameterEnum' This is a simple enum with default value + * @param 'parameterModel' This is a simple model with default value * @throws ApiError */ public static async callWithDefaultParameters( - parameterString: string | null = 'Hello World!', - parameterNumber: number | null = 123, - parameterBoolean: boolean | null = true, - parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', - parameterModel: ModelWithString | null = { + 'parameterString': string | null = 'Hello World!', + 'parameterNumber': number | null = 123, + 'parameterBoolean': boolean | null = true, + 'parameterEnum': 'Success' | 'Warning' | 'Error' = 'Success', + 'parameterModel': ModelWithString | null = { \\"prop\\": \\"Hello World!\\" }, ): Promise { const result = await __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/defaults\`, + path: \`/api/v\${api-version}/defaults\`, query: { - 'parameterString': parameterString, - 'parameterNumber': parameterNumber, - 'parameterBoolean': parameterBoolean, - 'parameterEnum': parameterEnum, - 'parameterModel': parameterModel, + 'parameterString': 'parameterString', + 'parameterNumber': 'parameterNumber', + 'parameterBoolean': 'parameterBoolean', + 'parameterEnum': 'parameterEnum', + 'parameterModel': 'parameterModel', }, }); return result.body; } /** - * @param parameterString This is a simple string that is optional with default value - * @param parameterNumber This is a simple number that is optional with default value - * @param parameterBoolean This is a simple boolean that is optional with default value - * @param parameterEnum This is a simple enum that is optional with default value - * @param parameterModel This is a simple model that is optional with default value + * @param 'parameterString' This is a simple string that is optional with default value + * @param 'parameterNumber' This is a simple number that is optional with default value + * @param 'parameterBoolean' This is a simple boolean that is optional with default value + * @param 'parameterEnum' This is a simple enum that is optional with default value + * @param 'parameterModel' This is a simple model that is optional with default value * @throws ApiError */ public static async callWithDefaultOptionalParameters( - parameterString: string = 'Hello World!', - parameterNumber: number = 123, - parameterBoolean: boolean = true, - parameterEnum: 'Success' | 'Warning' | 'Error' = 'Success', - parameterModel: ModelWithString = { + 'parameterString': string = 'Hello World!', + 'parameterNumber': number = 123, + 'parameterBoolean': boolean = true, + 'parameterEnum': 'Success' | 'Warning' | 'Error' = 'Success', + 'parameterModel': ModelWithString = { \\"prop\\": \\"Hello World!\\" }, ): Promise { const result = await __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/defaults\`, + path: \`/api/v\${api-version}/defaults\`, query: { - 'parameterString': parameterString, - 'parameterNumber': parameterNumber, - 'parameterBoolean': parameterBoolean, - 'parameterEnum': parameterEnum, - 'parameterModel': parameterModel, + 'parameterString': 'parameterString', + 'parameterNumber': 'parameterNumber', + 'parameterBoolean': 'parameterBoolean', + 'parameterEnum': 'parameterEnum', + 'parameterModel': 'parameterModel', }, }); return result.body; } /** - * @param parameterStringWithNoDefault This is a string with no default - * @param parameterOptionalStringWithDefault This is a optional string with default - * @param parameterOptionalStringWithEmptyDefault This is a optional string with empty default - * @param parameterOptionalStringWithNoDefault This is a optional string with no default - * @param parameterStringWithDefault This is a string with default - * @param parameterStringWithEmptyDefault This is a string with empty default + * @param 'parameterStringWithNoDefault' This is a string with no default + * @param 'parameterOptionalStringWithDefault' This is a optional string with default + * @param 'parameterOptionalStringWithEmptyDefault' This is a optional string with empty default + * @param 'parameterOptionalStringWithNoDefault' This is a optional string with no default + * @param 'parameterStringWithDefault' This is a string with default + * @param 'parameterStringWithEmptyDefault' This is a string with empty default * @throws ApiError */ public static async callToTestOrderOfParams( - parameterStringWithNoDefault: string, - parameterOptionalStringWithDefault: string = 'Hello World!', - parameterOptionalStringWithEmptyDefault: string = '', - parameterOptionalStringWithNoDefault?: string, - parameterStringWithDefault: string = 'Hello World!', - parameterStringWithEmptyDefault: string = '', + 'parameterStringWithNoDefault': string, + 'parameterOptionalStringWithDefault': string = 'Hello World!', + 'parameterOptionalStringWithEmptyDefault': string = '', + 'parameterOptionalStringWithNoDefault'?: string, + 'parameterStringWithDefault': string = 'Hello World!', + 'parameterStringWithEmptyDefault': string = '', ): Promise { const result = await __request({ method: 'PUT', - path: \`/api/v\${OpenAPI.VERSION}/defaults\`, + path: \`/api/v\${api-version}/defaults\`, query: { - 'parameterStringWithNoDefault': parameterStringWithNoDefault, - 'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault, - 'parameterOptionalStringWithEmptyDefault': parameterOptionalStringWithEmptyDefault, - 'parameterOptionalStringWithNoDefault': parameterOptionalStringWithNoDefault, - 'parameterStringWithDefault': parameterStringWithDefault, - 'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault, + 'parameterStringWithNoDefault': 'parameterStringWithNoDefault', + 'parameterOptionalStringWithDefault': 'parameterOptionalStringWithDefault', + 'parameterOptionalStringWithEmptyDefault': 'parameterOptionalStringWithEmptyDefault', + 'parameterOptionalStringWithNoDefault': 'parameterOptionalStringWithNoDefault', + 'parameterStringWithDefault': 'parameterStringWithDefault', + 'parameterStringWithEmptyDefault': 'parameterStringWithEmptyDefault', }, }); return result.body; @@ -3873,7 +3888,6 @@ exports[`v3 should generate: ./test/generated/v3/services/DuplicateService.ts 1` /* tslint:disable */ /* eslint-disable */ import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; export class DuplicateService { @@ -3883,7 +3897,7 @@ export class DuplicateService { public static async duplicateName(): Promise { const result = await __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + path: \`/api/v\${api-version}/duplicate\`, }); return result.body; } @@ -3894,7 +3908,7 @@ export class DuplicateService { public static async duplicateName1(): Promise { const result = await __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + path: \`/api/v\${api-version}/duplicate\`, }); return result.body; } @@ -3905,7 +3919,7 @@ export class DuplicateService { public static async duplicateName2(): Promise { const result = await __request({ method: 'PUT', - path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + path: \`/api/v\${api-version}/duplicate\`, }); return result.body; } @@ -3916,7 +3930,7 @@ export class DuplicateService { public static async duplicateName3(): Promise { const result = await __request({ method: 'DELETE', - path: \`/api/v\${OpenAPI.VERSION}/duplicate\`, + path: \`/api/v\${api-version}/duplicate\`, }); return result.body; } @@ -3929,7 +3943,6 @@ exports[`v3 should generate: ./test/generated/v3/services/HeaderService.ts 1`] = /* tslint:disable */ /* eslint-disable */ import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; export class HeaderService { @@ -3940,7 +3953,7 @@ export class HeaderService { public static async callWithResultFromHeader(): Promise { const result = await __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/header\`, + path: \`/api/v\${api-version}/header\`, responseHeader: 'operation-location', errors: { 400: \`400 server error\`, @@ -3958,7 +3971,6 @@ exports[`v3 should generate: ./test/generated/v3/services/MultipartService.ts 1` /* tslint:disable */ /* eslint-disable */ import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; export class MultipartService { @@ -3975,7 +3987,7 @@ export class MultipartService { }> { const result = await __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/multipart\`, + path: \`/api/v\${api-version}/multipart\`, }); return result.body; } @@ -3989,41 +4001,40 @@ exports[`v3 should generate: ./test/generated/v3/services/ParametersService.ts 1 /* eslint-disable */ import type { ModelWithString } from '../models/ModelWithString'; import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; export class ParametersService { /** - * @param parameterHeader This is the parameter that goes into the header - * @param parameterQuery This is the parameter that goes into the query params - * @param parameterForm This is the parameter that goes into the form data - * @param parameterCookie This is the parameter that goes into the cookie - * @param parameterPath This is the parameter that goes into the path + * @param 'parameterHeader' This is the parameter that goes into the header + * @param 'parameterQuery' This is the parameter that goes into the query params + * @param 'parameterForm' This is the parameter that goes into the form data + * @param 'parameterCookie' This is the parameter that goes into the cookie + * @param 'parameterPath' This is the parameter that goes into the path * @param requestBody This is the parameter that goes into the body * @throws ApiError */ public static async callWithParameters( - parameterHeader: string | null, - parameterQuery: string | null, - parameterForm: string | null, - parameterCookie: string | null, - parameterPath: string | null, + 'parameterHeader': string | null, + 'parameterQuery': string | null, + 'parameterForm': string | null, + 'parameterCookie': string | null, + 'parameterPath': string | null, requestBody: ModelWithString | null, ): Promise { const result = await __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/parameters/\${parameterPath}\`, + path: \`/api/v\${api-version}/parameters/\${'parameterPath'}\`, cookies: { - 'parameterCookie': parameterCookie, + 'parameterCookie': 'parameterCookie', }, headers: { - 'parameterHeader': parameterHeader, + 'parameterHeader': 'parameterHeader', }, query: { - 'parameterQuery': parameterQuery, + 'parameterQuery': 'parameterQuery', }, formData: { - 'parameterForm': parameterForm, + 'parameterForm': 'parameterForm', }, body: requestBody, }); @@ -4031,40 +4042,40 @@ 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 parameter.header This is the parameter that goes into the request header + * @param parameter-query This is the parameter that goes into the request query params + * @param 'parameter_form' This is the parameter that goes into the request form data + * @param PARAMETER-COOKIE This is the parameter that goes into the cookie * @param requestBody This is the parameter that goes into the body - * @param parameterPath1 This is the parameter that goes into the path - * @param parameterPath2 This is the parameter that goes into the path - * @param parameterPath3 This is the parameter that goes into the path + * @param parameter.path.1 This is the parameter that goes into the path + * @param parameter-path-2 This is the parameter that goes into the path + * @param PARAMETER-PATH-3 This is the parameter that goes into the path * @throws ApiError */ public static async callWithWeirdParameterNames( - parameterHeader: string | null, - parameterQuery: string | null, - parameterForm: string | null, - parameterCookie: string | null, + parameter.header: string | null, + parameter-query: string | null, + 'parameter_form': string | null, + PARAMETER-COOKIE: string | null, requestBody: ModelWithString | null, - parameterPath1?: string, - parameterPath2?: string, - parameterPath3?: string, + parameter.path.1?: string, + parameter-path-2?: string, + PARAMETER-PATH-3?: string, ): Promise { const result = await __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/parameters/\${parameterPath1}/\${parameterPath2}/\${parameterPath3}\`, + path: \`/api/v\${api-version}/parameters/\${parameter.path.1}/\${parameter-path-2}/\${PARAMETER-PATH-3}\`, cookies: { - 'PARAMETER-COOKIE': parameterCookie, + 'PARAMETER-COOKIE': PARAMETER-COOKIE, }, headers: { - 'parameter.header': parameterHeader, + 'parameter.header': parameter.header, }, query: { - 'parameter-query': parameterQuery, + 'parameter-query': parameter-query, }, formData: { - 'parameter_form': parameterForm, + 'parameter_form': 'parameter_form', }, body: requestBody, }); @@ -4073,18 +4084,18 @@ export class ParametersService { /** * @param requestBody This is a required parameter - * @param parameter This is an optional parameter + * @param 'parameter' This is an optional parameter * @throws ApiError */ public static async getCallWithOptionalParam( requestBody: ModelWithString, - parameter?: string, + 'parameter'?: string, ): Promise { const result = await __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/parameters/\`, + path: \`/api/v\${api-version}/parameters/\`, query: { - 'parameter': parameter, + 'parameter': 'parameter', }, body: requestBody, }); @@ -4092,19 +4103,19 @@ export class ParametersService { } /** - * @param parameter This is a required parameter + * @param 'parameter' This is a required parameter * @param requestBody This is an optional parameter * @throws ApiError */ public static async postCallWithOptionalParam( - parameter: string, + 'parameter': string, requestBody?: ModelWithString, ): Promise { const result = await __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/parameters/\`, + path: \`/api/v\${api-version}/parameters/\`, query: { - 'parameter': parameter, + 'parameter': 'parameter', }, body: requestBody, }); @@ -4120,7 +4131,6 @@ exports[`v3 should generate: ./test/generated/v3/services/RequestBodyService.ts /* eslint-disable */ import type { ModelWithString } from '../models/ModelWithString'; import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; export class RequestBodyService { @@ -4133,7 +4143,7 @@ export class RequestBodyService { ): Promise { const result = await __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/requestBody/\`, + path: \`/api/v\${api-version}/requestBody/\`, body: requestBody, }); return result.body; @@ -4150,7 +4160,6 @@ import type { ModelThatExtends } from '../models/ModelThatExtends'; import type { ModelThatExtendsExtends } from '../models/ModelThatExtendsExtends'; import type { ModelWithString } from '../models/ModelWithString'; import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; export class ResponseService { @@ -4161,7 +4170,7 @@ export class ResponseService { public static async callWithResponse(): Promise { const result = await __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/response\`, + path: \`/api/v\${api-version}/response\`, }); return result.body; } @@ -4173,7 +4182,7 @@ export class ResponseService { public static async callWithDuplicateResponses(): Promise { const result = await __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/response\`, + path: \`/api/v\${api-version}/response\`, errors: { 500: \`Message for 500 error\`, 501: \`Message for 501 error\`, @@ -4184,15 +4193,20 @@ export class ResponseService { } /** + * @result any Message for 200 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 { + public static async callWithResponses(): Promise<{ + readonly @namespace.string?: string, + readonly @namespace.integer?: number, + readonly value?: Array, + } | ModelWithString | ModelThatExtends | ModelThatExtendsExtends> { const result = await __request({ method: 'PUT', - path: \`/api/v\${OpenAPI.VERSION}/response\`, + path: \`/api/v\${api-version}/response\`, errors: { 500: \`Message for 500 error\`, 501: \`Message for 501 error\`, @@ -4210,7 +4224,6 @@ exports[`v3 should generate: ./test/generated/v3/services/SimpleService.ts 1`] = /* tslint:disable */ /* eslint-disable */ import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; export class SimpleService { @@ -4220,7 +4233,7 @@ export class SimpleService { public static async getCallWithoutParametersAndResponse(): Promise { const result = await __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${api-version}/simple\`, }); return result.body; } @@ -4231,7 +4244,7 @@ export class SimpleService { public static async putCallWithoutParametersAndResponse(): Promise { const result = await __request({ method: 'PUT', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${api-version}/simple\`, }); return result.body; } @@ -4242,7 +4255,7 @@ export class SimpleService { public static async postCallWithoutParametersAndResponse(): Promise { const result = await __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${api-version}/simple\`, }); return result.body; } @@ -4253,7 +4266,7 @@ export class SimpleService { public static async deleteCallWithoutParametersAndResponse(): Promise { const result = await __request({ method: 'DELETE', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${api-version}/simple\`, }); return result.body; } @@ -4264,7 +4277,7 @@ export class SimpleService { public static async optionsCallWithoutParametersAndResponse(): Promise { const result = await __request({ method: 'OPTIONS', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${api-version}/simple\`, }); return result.body; } @@ -4275,7 +4288,7 @@ export class SimpleService { public static async headCallWithoutParametersAndResponse(): Promise { const result = await __request({ method: 'HEAD', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${api-version}/simple\`, }); return result.body; } @@ -4286,7 +4299,7 @@ export class SimpleService { public static async patchCallWithoutParametersAndResponse(): Promise { const result = await __request({ method: 'PATCH', - path: \`/api/v\${OpenAPI.VERSION}/simple\`, + path: \`/api/v\${api-version}/simple\`, }); return result.body; } @@ -4299,19 +4312,18 @@ exports[`v3 should generate: ./test/generated/v3/services/TypesService.ts 1`] = /* tslint:disable */ /* eslint-disable */ import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; export class TypesService { /** - * @param parameterArray This is an array parameter - * @param parameterDictionary This is a dictionary parameter - * @param parameterEnum This is an enum parameter - * @param parameterNumber This is a number parameter - * @param parameterString This is a string parameter - * @param parameterBoolean This is a boolean parameter - * @param parameterObject This is an object parameter - * @param id This is a number parameter + * @param 'parameterArray' This is an array parameter + * @param 'parameterDictionary' This is a dictionary parameter + * @param 'parameterEnum' This is an enum parameter + * @param 'parameterNumber' This is a number parameter + * @param 'parameterString' This is a string parameter + * @param 'parameterBoolean' This is a boolean parameter + * @param 'parameterObject' This is an object parameter + * @param 'id' This is a number parameter * @result number Response is a simple number * @result string Response is a simple string * @result boolean Response is a simple boolean @@ -4319,26 +4331,26 @@ export class TypesService { * @throws ApiError */ public static async types( - parameterArray: Array | null, - parameterDictionary: any, - parameterEnum: 'Success' | 'Warning' | 'Error' | null, - parameterNumber: number = 123, - parameterString: string | null = 'default', - parameterBoolean: boolean | null = true, - parameterObject: any = null, - id?: number, + 'parameterArray': Array | null, + 'parameterDictionary': any, + 'parameterEnum': 'Success' | 'Warning' | 'Error' | null, + 'parameterNumber': number = 123, + 'parameterString': string | null = 'default', + 'parameterBoolean': boolean | null = true, + 'parameterObject': any = null, + 'id'?: number, ): Promise { const result = await __request({ method: 'GET', - path: \`/api/v\${OpenAPI.VERSION}/types\`, + path: \`/api/v\${api-version}/types\`, query: { - 'parameterArray': parameterArray, - 'parameterDictionary': parameterDictionary, - 'parameterEnum': parameterEnum, - 'parameterNumber': parameterNumber, - 'parameterString': parameterString, - 'parameterBoolean': parameterBoolean, - 'parameterObject': parameterObject, + 'parameterArray': 'parameterArray', + 'parameterDictionary': 'parameterDictionary', + 'parameterEnum': 'parameterEnum', + 'parameterNumber': 'parameterNumber', + 'parameterString': 'parameterString', + 'parameterBoolean': 'parameterBoolean', + 'parameterObject': 'parameterObject', }, }); return result.body; @@ -4352,23 +4364,22 @@ exports[`v3 should generate: ./test/generated/v3/services/UploadService.ts 1`] = /* tslint:disable */ /* eslint-disable */ import { request as __request } from '../core/request'; -import { OpenAPI } from '../core/OpenAPI'; export class UploadService { /** - * @param file Supply a file reference for upload + * @param 'file' Supply a file reference for upload * @result boolean * @throws ApiError */ public static async uploadFile( - file: Blob, + 'file': Blob, ): Promise { const result = await __request({ method: 'POST', - path: \`/api/v\${OpenAPI.VERSION}/upload\`, + path: \`/api/v\${api-version}/upload\`, formData: { - 'file': file, + 'file': 'file', }, }); return result.body; diff --git a/test/spec/v2.json b/test/spec/v2.json index ccd3d6a0..da86c684 100644 --- a/test/spec/v2.json +++ b/test/spec/v2.json @@ -434,6 +434,29 @@ "$ref": "#/definitions/ModelWithString" } }, + "200": { + "description": "Message for 200 response", + "schema": { + "type": "object", + "properties": { + "@namespace.string": { + "type": "string", + "readOnly": true + }, + "@namespace.integer": { + "type": "integer", + "readOnly": true + }, + "value": { + "type": "array", + "items": { + "$ref": "#/definitions/ModelWithString" + }, + "readOnly": true + } + } + } + }, "201": { "description": "Message for 201 response", "schema": { @@ -1050,6 +1073,14 @@ }, "reference": { "$ref": "#/definitions/ModelWithString" + }, + "@namespace.string": { + "type": "string", + "readOnly": true + }, + "@namespace.integer": { + "type": "integer", + "readOnly": true } } }, diff --git a/test/spec/v3.json b/test/spec/v3.json index b3368809..6ae5f82c 100644 --- a/test/spec/v3.json +++ b/test/spec/v3.json @@ -632,6 +632,33 @@ } } }, + "200": { + "description": "Message for 200 response", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "@namespace.string": { + "type": "string", + "readOnly": true + }, + "@namespace.integer": { + "type": "integer", + "readOnly": true + }, + "value": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ModelWithString" + }, + "readOnly": true + } + } + } + } + } + }, "201": { "description": "Message for 201 response", "content": { @@ -1558,6 +1585,14 @@ }, "reference": { "$ref": "#/components/schemas/ModelWithString" + }, + "@namespace.string": { + "type": "string", + "readOnly": true + }, + "@namespace.integer": { + "type": "integer", + "readOnly": true } } },