From ecd60167e95267f79ab755308d993390f3ca29f5 Mon Sep 17 00:00:00 2001 From: Dirk Niemeier Date: Tue, 18 Nov 2025 15:25:12 +0100 Subject: [PATCH 1/2] feat(typescript-rxjs): Add @deprecated tag to generated API operations This commit introduces the JSDoc @deprecated tag to API operations in the typescript-rxjs generator when the operation is marked as deprecated in the OpenAPI specification. This ensures that IDEs (like VS Code or WebStorm) correctly flag the method as deprecated, providing better developer experience and warning consumers about upcoming removals or changes. --- bin/configs/typescript-rxjs-3.0.yaml | 4 + .../resources/typescript-rxjs/apis.mustache | 5 +- .../typescript-rxjs/modelEnum.mustache | 3 + .../typescript-rxjs/modelGeneric.mustache | 9 + .../codegen/ruby/RubyClientCodegenTest.java | 60 ++-- .../test/resources/3_0/allOf_composition.yaml | 6 +- .../allOf-composition/models/Human.ts | 7 + .../typescript-rxjs/builds/3.0/.gitignore | 4 + .../builds/3.0/.openapi-generator-ignore | 23 ++ .../builds/3.0/.openapi-generator/FILES | 17 + .../builds/3.0/.openapi-generator/VERSION | 1 + .../typescript-rxjs/builds/3.0/apis/PetApi.ts | 303 ++++++++++++++++++ .../builds/3.0/apis/StoreApi.ts | 108 +++++++ .../builds/3.0/apis/UserApi.ts | 221 +++++++++++++ .../typescript-rxjs/builds/3.0/apis/index.ts | 3 + .../typescript-rxjs/builds/3.0/index.ts | 4 + .../builds/3.0/models/ApiResponse.ts | 35 ++ .../builds/3.0/models/Category.ts | 30 ++ .../builds/3.0/models/Order.ts | 62 ++++ .../typescript-rxjs/builds/3.0/models/Pet.ts | 69 ++++ .../typescript-rxjs/builds/3.0/models/Tag.ts | 30 ++ .../typescript-rxjs/builds/3.0/models/User.ts | 61 ++++ .../builds/3.0/models/index.ts | 6 + .../typescript-rxjs/builds/3.0/runtime.ts | 193 +++++++++++ .../typescript-rxjs/builds/3.0/servers.ts | 45 +++ .../typescript-rxjs/builds/3.0/tsconfig.json | 22 ++ .../builds/default/apis/PetApi.ts | 1 + .../builds/es6-target/apis/PetApi.ts | 1 + .../builds/with-npm-version/apis/PetApi.ts | 1 + .../with-progress-subscriber/apis/PetApi.ts | 1 + 30 files changed, 1308 insertions(+), 27 deletions(-) create mode 100644 bin/configs/typescript-rxjs-3.0.yaml create mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/.gitignore create mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/.openapi-generator-ignore create mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/.openapi-generator/FILES create mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/.openapi-generator/VERSION create mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/apis/PetApi.ts create mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/apis/StoreApi.ts create mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/apis/UserApi.ts create mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/apis/index.ts create mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/index.ts create mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/models/ApiResponse.ts create mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/models/Category.ts create mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/models/Order.ts create mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/models/Pet.ts create mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/models/Tag.ts create mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/models/User.ts create mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/models/index.ts create mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/runtime.ts create mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/servers.ts create mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/tsconfig.json diff --git a/bin/configs/typescript-rxjs-3.0.yaml b/bin/configs/typescript-rxjs-3.0.yaml new file mode 100644 index 000000000000..0a0b14b36817 --- /dev/null +++ b/bin/configs/typescript-rxjs-3.0.yaml @@ -0,0 +1,4 @@ +generatorName: typescript-rxjs +outputDir: samples/client/petstore/typescript-rxjs/builds/3.0 +inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/typescript-rxjs diff --git a/modules/openapi-generator/src/main/resources/typescript-rxjs/apis.mustache b/modules/openapi-generator/src/main/resources/typescript-rxjs/apis.mustache index e0ca79a7946f..640a4a8b6410 100644 --- a/modules/openapi-generator/src/main/resources/typescript-rxjs/apis.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-rxjs/apis.mustache @@ -39,6 +39,9 @@ export class {{classname}} extends BaseAPI { {{#summary}} * {{&summary}} {{/summary}} + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} */ {{nickname}}({{#allParams.0}}{ {{#allParams}}{{paramName}}{{#vendorExtensions.x-param-name-alternative}}: {{vendorExtensions.x-param-name-alternative}}{{/vendorExtensions.x-param-name-alternative}}{{^-last}}, {{/-last}}{{/allParams}} }: {{operationIdCamelCase}}Request{{/allParams.0}}): Observable<{{{returnType}}}{{^returnType}}void{{/returnType}}> {{#withProgressSubscriber}} @@ -244,4 +247,4 @@ export enum {{operationIdCamelCase}}{{enumName}} { {{/allParams}} {{/operation}} {{/operations}} -{{/hasEnums}} +{{/hasEnums}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript-rxjs/modelEnum.mustache b/modules/openapi-generator/src/main/resources/typescript-rxjs/modelEnum.mustache index dc04cb0bd63d..3516dcd60387 100644 --- a/modules/openapi-generator/src/main/resources/typescript-rxjs/modelEnum.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-rxjs/modelEnum.mustache @@ -2,6 +2,9 @@ * {{{description}}} * @export * @enum {string} +{{#deprecated}} + * @deprecated +{{/deprecated}} */ export enum {{classname}} { {{#allowableValues}} diff --git a/modules/openapi-generator/src/main/resources/typescript-rxjs/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/typescript-rxjs/modelGeneric.mustache index a12ceb35c3dc..854d4de53c9a 100644 --- a/modules/openapi-generator/src/main/resources/typescript-rxjs/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-rxjs/modelGeneric.mustache @@ -10,6 +10,9 @@ import type { * {{{.}}}{{/description}} * @export * @interface {{classname}} +{{#deprecated}} + * @deprecated +{{/deprecated}} */ export interface {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{ {{#additionalPropertiesType}} @@ -18,6 +21,9 @@ export interface {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{ {{#vars}} /**{{#description}} * {{{.}}}{{/description}} + {{#deprecated}} + * @deprecated + {{/deprecated}} * @type {{=<% %>=}}{<%&datatype%>}<%={{ }}=%> * @memberof {{classname}} */ @@ -30,6 +36,9 @@ export interface {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{ /** * @export * @enum {string} +{{#deprecated}} + * @deprecated +{{/deprecated}} */ export enum {{classname}}{{enumName}} { {{#allowableValues}} diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java index dc1db42fae02..e6f66ad8f10d 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java @@ -564,8 +564,8 @@ public void allOfCompositionTest() { Assert.assertNotNull(superMan); // to test all properties - Assert.assertEquals(superMan.getVars().size(), 6); - Assert.assertEquals(superMan.getAllVars().size(), 6); + Assert.assertEquals(superMan.getVars().size(), 7); + Assert.assertEquals(superMan.getAllVars().size(), 7); Assert.assertEquals(superMan.getMandatory().size(), 3); Assert.assertEquals(superMan.getAllMandatory().size(), 3); @@ -577,46 +577,56 @@ public void allOfCompositionTest() { Assert.assertEquals(cp1.name, "name"); Assert.assertFalse(cp1.required); - CodegenProperty cp2 = superMan.getVars().get(2); - Assert.assertEquals(cp2.name, "reward"); - Assert.assertFalse(cp2.required); + CodegenProperty cp2 = superMan.getVars().get(2); + Assert.assertEquals(cp2.name, "nickname"); + Assert.assertFalse(cp2.required); + Assert.assertTrue(cp2.deprecated); CodegenProperty cp3 = superMan.getVars().get(3); - Assert.assertEquals(cp3.name, "origin"); - Assert.assertTrue(cp3.required); + Assert.assertEquals(cp3.name, "reward"); + Assert.assertFalse(cp3.required); CodegenProperty cp4 = superMan.getVars().get(4); - Assert.assertEquals(cp4.name, "category"); - Assert.assertFalse(cp4.required); + Assert.assertEquals(cp4.name, "origin"); + Assert.assertTrue(cp4.required); CodegenProperty cp5 = superMan.getVars().get(5); - Assert.assertEquals(cp5.name, "level"); - Assert.assertTrue(cp5.required); + Assert.assertEquals(cp5.name, "category"); + Assert.assertFalse(cp5.required); - CodegenProperty cp6 = superMan.getAllVars().get(0); - Assert.assertEquals(cp6.name, "id"); + CodegenProperty cp6 = superMan.getVars().get(6); + Assert.assertEquals(cp6.name, "level"); Assert.assertTrue(cp6.required); - CodegenProperty cp7 = superMan.getAllVars().get(1); - Assert.assertEquals(cp7.name, "name"); - Assert.assertFalse(cp7.required); + CodegenProperty cp7 = superMan.getAllVars().get(0); + Assert.assertEquals(cp7.name, "id"); + Assert.assertTrue(cp7.required); - CodegenProperty cp8 = superMan.getAllVars().get(2); - Assert.assertEquals(cp8.name, "reward"); + CodegenProperty cp8 = superMan.getAllVars().get(1); + Assert.assertEquals(cp8.name, "name"); Assert.assertFalse(cp8.required); - CodegenProperty cp9 = superMan.getAllVars().get(3); - Assert.assertEquals(cp9.name, "origin"); - Assert.assertTrue(cp9.required); + CodegenProperty cp9 = superMan.getAllVars().get(2); + Assert.assertEquals(cp9.name, "nickname"); + Assert.assertFalse(cp9.required); + Assert.assertTrue(cp9.deprecated); - CodegenProperty cp10 = superMan.getAllVars().get(4); - Assert.assertEquals(cp10.name, "category"); + CodegenProperty cp10 = superMan.getAllVars().get(3); + Assert.assertEquals(cp10.name, "reward"); Assert.assertFalse(cp10.required); - CodegenProperty cp11 = superMan.getAllVars().get(5); - Assert.assertEquals(cp11.name, "level"); + CodegenProperty cp11 = superMan.getAllVars().get(4); + Assert.assertEquals(cp11.name, "origin"); Assert.assertTrue(cp11.required); + CodegenProperty cp12 = superMan.getAllVars().get(5); + Assert.assertEquals(cp12.name, "category"); + Assert.assertFalse(cp12.required); + + CodegenProperty cp13 = superMan.getAllVars().get(6); + Assert.assertEquals(cp13.name, "level"); + Assert.assertTrue(cp13.required); + } diff --git a/modules/openapi-generator/src/test/resources/3_0/allOf_composition.yaml b/modules/openapi-generator/src/test/resources/3_0/allOf_composition.yaml index 3b2c6a1be5d6..75205af519e3 100644 --- a/modules/openapi-generator/src/test/resources/3_0/allOf_composition.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/allOf_composition.yaml @@ -81,4 +81,8 @@ components: format: int64 name: type: string - example: Tom + example: Tom + nickname: + type: string + description: Previous short name for the human, replaced by `name` + deprecated: true diff --git a/samples/client/others/typescript-rxjs/allOf-composition/models/Human.ts b/samples/client/others/typescript-rxjs/allOf-composition/models/Human.ts index 2122f4c7a134..9cf274075e8e 100644 --- a/samples/client/others/typescript-rxjs/allOf-composition/models/Human.ts +++ b/samples/client/others/typescript-rxjs/allOf-composition/models/Human.ts @@ -27,4 +27,11 @@ export interface Human { * @memberof Human */ name?: string; + /** + * Previous short name for the human, replaced by `name` + * @deprecated + * @type {string} + * @memberof Human + */ + nickname?: string; } diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/.gitignore b/samples/client/petstore/typescript-rxjs/builds/3.0/.gitignore new file mode 100644 index 000000000000..149b57654723 --- /dev/null +++ b/samples/client/petstore/typescript-rxjs/builds/3.0/.gitignore @@ -0,0 +1,4 @@ +wwwroot/*.js +node_modules +typings +dist diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/.openapi-generator-ignore b/samples/client/petstore/typescript-rxjs/builds/3.0/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/typescript-rxjs/builds/3.0/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/.openapi-generator/FILES b/samples/client/petstore/typescript-rxjs/builds/3.0/.openapi-generator/FILES new file mode 100644 index 000000000000..e5826f31b67f --- /dev/null +++ b/samples/client/petstore/typescript-rxjs/builds/3.0/.openapi-generator/FILES @@ -0,0 +1,17 @@ +.gitignore +.openapi-generator-ignore +apis/PetApi.ts +apis/StoreApi.ts +apis/UserApi.ts +apis/index.ts +index.ts +models/ApiResponse.ts +models/Category.ts +models/Order.ts +models/Pet.ts +models/Tag.ts +models/User.ts +models/index.ts +runtime.ts +servers.ts +tsconfig.json diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/.openapi-generator/VERSION b/samples/client/petstore/typescript-rxjs/builds/3.0/.openapi-generator/VERSION new file mode 100644 index 000000000000..2fb556b60635 --- /dev/null +++ b/samples/client/petstore/typescript-rxjs/builds/3.0/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.18.0-SNAPSHOT diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/apis/PetApi.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/apis/PetApi.ts new file mode 100644 index 000000000000..e22240ade71b --- /dev/null +++ b/samples/client/petstore/typescript-rxjs/builds/3.0/apis/PetApi.ts @@ -0,0 +1,303 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import type { Observable } from 'rxjs'; +import type { AjaxResponse } from 'rxjs/ajax'; +import { BaseAPI, throwIfNullOrUndefined, encodeURI, COLLECTION_FORMATS } from '../runtime'; +import type { OperationOpts, HttpHeaders, HttpQuery } from '../runtime'; +import type { + ApiResponse, + Pet, +} from '../models'; + +export interface AddPetRequest { + pet: Pet; +} + +export interface DeletePetRequest { + petId: number; + apiKey?: string; +} + +export interface FindPetsByStatusRequest { + status: Array; +} + +export interface FindPetsByTagsRequest { + tags: Array; +} + +export interface GetPetByIdRequest { + petId: number; +} + +export interface UpdatePetRequest { + pet: Pet; +} + +export interface UpdatePetWithFormRequest { + petId: number; + name?: string; + status?: string; +} + +export interface UploadFileRequest { + petId: number; + additionalMetadata?: string; + file?: Blob; +} + +/** + * no description + */ +export class PetApi extends BaseAPI { + + /** + * + * Add a new pet to the store + */ + addPet({ pet }: AddPetRequest): Observable + addPet({ pet }: AddPetRequest, opts?: OperationOpts): Observable> + addPet({ pet }: AddPetRequest, opts?: OperationOpts): Observable> { + throwIfNullOrUndefined(pet, 'pet', 'addPet'); + + const headers: HttpHeaders = { + 'Content-Type': 'application/json', + // oauth required + ...(this.configuration.accessToken != null + ? { Authorization: typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken('petstore_auth', ['write:pets', 'read:pets']) + : this.configuration.accessToken } + : undefined + ), + }; + + return this.request({ + url: '/pet', + method: 'POST', + headers, + body: pet, + }, opts?.responseOpts); + }; + + /** + * + * Deletes a pet + */ + deletePet({ petId, apiKey }: DeletePetRequest): Observable + deletePet({ petId, apiKey }: DeletePetRequest, opts?: OperationOpts): Observable> + deletePet({ petId, apiKey }: DeletePetRequest, opts?: OperationOpts): Observable> { + throwIfNullOrUndefined(petId, 'petId', 'deletePet'); + + const headers: HttpHeaders = { + ...(apiKey != null ? { 'api_key': String(apiKey) } : undefined), + // oauth required + ...(this.configuration.accessToken != null + ? { Authorization: typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken('petstore_auth', ['write:pets', 'read:pets']) + : this.configuration.accessToken } + : undefined + ), + }; + + return this.request({ + url: '/pet/{petId}'.replace('{petId}', encodeURI(petId)), + method: 'DELETE', + headers, + }, opts?.responseOpts); + }; + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + */ + findPetsByStatus({ status }: FindPetsByStatusRequest): Observable> + findPetsByStatus({ status }: FindPetsByStatusRequest, opts?: OperationOpts): Observable>> + findPetsByStatus({ status }: FindPetsByStatusRequest, opts?: OperationOpts): Observable | AjaxResponse>> { + throwIfNullOrUndefined(status, 'status', 'findPetsByStatus'); + + const headers: HttpHeaders = { + // oauth required + ...(this.configuration.accessToken != null + ? { Authorization: typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken('petstore_auth', ['read:pets']) + : this.configuration.accessToken } + : undefined + ), + }; + + const query: HttpQuery = { // required parameters are used directly since they are already checked by throwIfNullOrUndefined + 'status': status.join(COLLECTION_FORMATS['csv']), + }; + + return this.request>({ + url: '/pet/findByStatus', + method: 'GET', + headers, + query, + }, opts?.responseOpts); + }; + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + * @deprecated + */ + findPetsByTags({ tags }: FindPetsByTagsRequest): Observable> + findPetsByTags({ tags }: FindPetsByTagsRequest, opts?: OperationOpts): Observable>> + findPetsByTags({ tags }: FindPetsByTagsRequest, opts?: OperationOpts): Observable | AjaxResponse>> { + throwIfNullOrUndefined(tags, 'tags', 'findPetsByTags'); + + const headers: HttpHeaders = { + // oauth required + ...(this.configuration.accessToken != null + ? { Authorization: typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken('petstore_auth', ['read:pets']) + : this.configuration.accessToken } + : undefined + ), + }; + + const query: HttpQuery = { // required parameters are used directly since they are already checked by throwIfNullOrUndefined + 'tags': tags.join(COLLECTION_FORMATS['csv']), + }; + + return this.request>({ + url: '/pet/findByTags', + method: 'GET', + headers, + query, + }, opts?.responseOpts); + }; + + /** + * Returns a single pet + * Find pet by ID + */ + getPetById({ petId }: GetPetByIdRequest): Observable + getPetById({ petId }: GetPetByIdRequest, opts?: OperationOpts): Observable> + getPetById({ petId }: GetPetByIdRequest, opts?: OperationOpts): Observable> { + throwIfNullOrUndefined(petId, 'petId', 'getPetById'); + + const headers: HttpHeaders = { + ...(this.configuration.apiKey && { 'api_key': this.configuration.apiKey('api_key') }), // api_key authentication + }; + + return this.request({ + url: '/pet/{petId}'.replace('{petId}', encodeURI(petId)), + method: 'GET', + headers, + }, opts?.responseOpts); + }; + + /** + * + * Update an existing pet + */ + updatePet({ pet }: UpdatePetRequest): Observable + updatePet({ pet }: UpdatePetRequest, opts?: OperationOpts): Observable> + updatePet({ pet }: UpdatePetRequest, opts?: OperationOpts): Observable> { + throwIfNullOrUndefined(pet, 'pet', 'updatePet'); + + const headers: HttpHeaders = { + 'Content-Type': 'application/json', + // oauth required + ...(this.configuration.accessToken != null + ? { Authorization: typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken('petstore_auth', ['write:pets', 'read:pets']) + : this.configuration.accessToken } + : undefined + ), + }; + + return this.request({ + url: '/pet', + method: 'PUT', + headers, + body: pet, + }, opts?.responseOpts); + }; + + /** + * + * Updates a pet in the store with form data + */ + updatePetWithForm({ petId, name, status }: UpdatePetWithFormRequest): Observable + updatePetWithForm({ petId, name, status }: UpdatePetWithFormRequest, opts?: OperationOpts): Observable> + updatePetWithForm({ petId, name, status }: UpdatePetWithFormRequest, opts?: OperationOpts): Observable> { + throwIfNullOrUndefined(petId, 'petId', 'updatePetWithForm'); + + const headers: HttpHeaders = { + // oauth required + ...(this.configuration.accessToken != null + ? { Authorization: typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken('petstore_auth', ['write:pets', 'read:pets']) + : this.configuration.accessToken } + : undefined + ), + }; + + const formData = new FormData(); + if (name !== undefined) { formData.append('name', name as any); } + if (status !== undefined) { formData.append('status', status as any); } + + return this.request({ + url: '/pet/{petId}'.replace('{petId}', encodeURI(petId)), + method: 'POST', + headers, + body: formData, + }, opts?.responseOpts); + }; + + /** + * + * uploads an image + */ + uploadFile({ petId, additionalMetadata, file }: UploadFileRequest): Observable + uploadFile({ petId, additionalMetadata, file }: UploadFileRequest, opts?: OperationOpts): Observable> + uploadFile({ petId, additionalMetadata, file }: UploadFileRequest, opts?: OperationOpts): Observable> { + throwIfNullOrUndefined(petId, 'petId', 'uploadFile'); + + const headers: HttpHeaders = { + // oauth required + ...(this.configuration.accessToken != null + ? { Authorization: typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken('petstore_auth', ['write:pets', 'read:pets']) + : this.configuration.accessToken } + : undefined + ), + }; + + const formData = new FormData(); + if (additionalMetadata !== undefined) { formData.append('additionalMetadata', additionalMetadata as any); } + if (file !== undefined) { formData.append('file', file as any); } + + return this.request({ + url: '/pet/{petId}/uploadImage'.replace('{petId}', encodeURI(petId)), + method: 'POST', + headers, + body: formData, + }, opts?.responseOpts); + }; + +} + +/** + * @export + * @enum {string} + */ +export enum FindPetsByStatusStatusEnum { + Available = 'available', + Pending = 'pending', + Sold = 'sold' +} diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/apis/StoreApi.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/apis/StoreApi.ts new file mode 100644 index 000000000000..102c54d299b2 --- /dev/null +++ b/samples/client/petstore/typescript-rxjs/builds/3.0/apis/StoreApi.ts @@ -0,0 +1,108 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import type { Observable } from 'rxjs'; +import type { AjaxResponse } from 'rxjs/ajax'; +import { BaseAPI, throwIfNullOrUndefined, encodeURI } from '../runtime'; +import type { OperationOpts, HttpHeaders } from '../runtime'; +import type { + Order, +} from '../models'; + +export interface DeleteOrderRequest { + orderId: string; +} + +export interface GetOrderByIdRequest { + orderId: number; +} + +export interface PlaceOrderRequest { + order: Order; +} + +/** + * no description + */ +export class StoreApi extends BaseAPI { + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + */ + deleteOrder({ orderId }: DeleteOrderRequest): Observable + deleteOrder({ orderId }: DeleteOrderRequest, opts?: OperationOpts): Observable> + deleteOrder({ orderId }: DeleteOrderRequest, opts?: OperationOpts): Observable> { + throwIfNullOrUndefined(orderId, 'orderId', 'deleteOrder'); + + return this.request({ + url: '/store/order/{orderId}'.replace('{orderId}', encodeURI(orderId)), + method: 'DELETE', + }, opts?.responseOpts); + }; + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + */ + getInventory(): Observable<{ [key: string]: number; }> + getInventory(opts?: OperationOpts): Observable> + getInventory(opts?: OperationOpts): Observable<{ [key: string]: number; } | AjaxResponse<{ [key: string]: number; }>> { + const headers: HttpHeaders = { + ...(this.configuration.apiKey && { 'api_key': this.configuration.apiKey('api_key') }), // api_key authentication + }; + + return this.request<{ [key: string]: number; }>({ + url: '/store/inventory', + method: 'GET', + headers, + }, opts?.responseOpts); + }; + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * Find purchase order by ID + */ + getOrderById({ orderId }: GetOrderByIdRequest): Observable + getOrderById({ orderId }: GetOrderByIdRequest, opts?: OperationOpts): Observable> + getOrderById({ orderId }: GetOrderByIdRequest, opts?: OperationOpts): Observable> { + throwIfNullOrUndefined(orderId, 'orderId', 'getOrderById'); + + return this.request({ + url: '/store/order/{orderId}'.replace('{orderId}', encodeURI(orderId)), + method: 'GET', + }, opts?.responseOpts); + }; + + /** + * + * Place an order for a pet + */ + placeOrder({ order }: PlaceOrderRequest): Observable + placeOrder({ order }: PlaceOrderRequest, opts?: OperationOpts): Observable> + placeOrder({ order }: PlaceOrderRequest, opts?: OperationOpts): Observable> { + throwIfNullOrUndefined(order, 'order', 'placeOrder'); + + const headers: HttpHeaders = { + 'Content-Type': 'application/json', + }; + + return this.request({ + url: '/store/order', + method: 'POST', + headers, + body: order, + }, opts?.responseOpts); + }; + +} diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/apis/UserApi.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/apis/UserApi.ts new file mode 100644 index 000000000000..68cd486e0567 --- /dev/null +++ b/samples/client/petstore/typescript-rxjs/builds/3.0/apis/UserApi.ts @@ -0,0 +1,221 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import type { Observable } from 'rxjs'; +import type { AjaxResponse } from 'rxjs/ajax'; +import { BaseAPI, throwIfNullOrUndefined, encodeURI } from '../runtime'; +import type { OperationOpts, HttpHeaders, HttpQuery } from '../runtime'; +import type { + User, +} from '../models'; + +export interface CreateUserRequest { + user: User; +} + +export interface CreateUsersWithArrayInputRequest { + user: Array; +} + +export interface CreateUsersWithListInputRequest { + user: Array; +} + +export interface DeleteUserRequest { + username: string; +} + +export interface GetUserByNameRequest { + username: string; +} + +export interface LoginUserRequest { + username: string; + password: string; +} + +export interface UpdateUserRequest { + username: string; + user: User; +} + +/** + * no description + */ +export class UserApi extends BaseAPI { + + /** + * This can only be done by the logged in user. + * Create user + */ + createUser({ user }: CreateUserRequest): Observable + createUser({ user }: CreateUserRequest, opts?: OperationOpts): Observable> + createUser({ user }: CreateUserRequest, opts?: OperationOpts): Observable> { + throwIfNullOrUndefined(user, 'user', 'createUser'); + + const headers: HttpHeaders = { + 'Content-Type': 'application/json', + ...(this.configuration.apiKey && { 'api_key': this.configuration.apiKey('api_key') }), // api_key authentication + }; + + return this.request({ + url: '/user', + method: 'POST', + headers, + body: user, + }, opts?.responseOpts); + }; + + /** + * + * Creates list of users with given input array + */ + createUsersWithArrayInput({ user }: CreateUsersWithArrayInputRequest): Observable + createUsersWithArrayInput({ user }: CreateUsersWithArrayInputRequest, opts?: OperationOpts): Observable> + createUsersWithArrayInput({ user }: CreateUsersWithArrayInputRequest, opts?: OperationOpts): Observable> { + throwIfNullOrUndefined(user, 'user', 'createUsersWithArrayInput'); + + const headers: HttpHeaders = { + 'Content-Type': 'application/json', + ...(this.configuration.apiKey && { 'api_key': this.configuration.apiKey('api_key') }), // api_key authentication + }; + + return this.request({ + url: '/user/createWithArray', + method: 'POST', + headers, + body: user, + }, opts?.responseOpts); + }; + + /** + * + * Creates list of users with given input array + */ + createUsersWithListInput({ user }: CreateUsersWithListInputRequest): Observable + createUsersWithListInput({ user }: CreateUsersWithListInputRequest, opts?: OperationOpts): Observable> + createUsersWithListInput({ user }: CreateUsersWithListInputRequest, opts?: OperationOpts): Observable> { + throwIfNullOrUndefined(user, 'user', 'createUsersWithListInput'); + + const headers: HttpHeaders = { + 'Content-Type': 'application/json', + ...(this.configuration.apiKey && { 'api_key': this.configuration.apiKey('api_key') }), // api_key authentication + }; + + return this.request({ + url: '/user/createWithList', + method: 'POST', + headers, + body: user, + }, opts?.responseOpts); + }; + + /** + * This can only be done by the logged in user. + * Delete user + */ + deleteUser({ username }: DeleteUserRequest): Observable + deleteUser({ username }: DeleteUserRequest, opts?: OperationOpts): Observable> + deleteUser({ username }: DeleteUserRequest, opts?: OperationOpts): Observable> { + throwIfNullOrUndefined(username, 'username', 'deleteUser'); + + const headers: HttpHeaders = { + ...(this.configuration.apiKey && { 'api_key': this.configuration.apiKey('api_key') }), // api_key authentication + }; + + return this.request({ + url: '/user/{username}'.replace('{username}', encodeURI(username)), + method: 'DELETE', + headers, + }, opts?.responseOpts); + }; + + /** + * + * Get user by user name + */ + getUserByName({ username }: GetUserByNameRequest): Observable + getUserByName({ username }: GetUserByNameRequest, opts?: OperationOpts): Observable> + getUserByName({ username }: GetUserByNameRequest, opts?: OperationOpts): Observable> { + throwIfNullOrUndefined(username, 'username', 'getUserByName'); + + return this.request({ + url: '/user/{username}'.replace('{username}', encodeURI(username)), + method: 'GET', + }, opts?.responseOpts); + }; + + /** + * + * Logs user into the system + */ + loginUser({ username, password }: LoginUserRequest): Observable + loginUser({ username, password }: LoginUserRequest, opts?: OperationOpts): Observable> + loginUser({ username, password }: LoginUserRequest, opts?: OperationOpts): Observable> { + throwIfNullOrUndefined(username, 'username', 'loginUser'); + throwIfNullOrUndefined(password, 'password', 'loginUser'); + + const query: HttpQuery = { // required parameters are used directly since they are already checked by throwIfNullOrUndefined + 'username': username, + 'password': password, + }; + + return this.request({ + url: '/user/login', + method: 'GET', + query, + }, opts?.responseOpts); + }; + + /** + * + * Logs out current logged in user session + */ + logoutUser(): Observable + logoutUser(opts?: OperationOpts): Observable> + logoutUser(opts?: OperationOpts): Observable> { + const headers: HttpHeaders = { + ...(this.configuration.apiKey && { 'api_key': this.configuration.apiKey('api_key') }), // api_key authentication + }; + + return this.request({ + url: '/user/logout', + method: 'GET', + headers, + }, opts?.responseOpts); + }; + + /** + * This can only be done by the logged in user. + * Updated user + */ + updateUser({ username, user }: UpdateUserRequest): Observable + updateUser({ username, user }: UpdateUserRequest, opts?: OperationOpts): Observable> + updateUser({ username, user }: UpdateUserRequest, opts?: OperationOpts): Observable> { + throwIfNullOrUndefined(username, 'username', 'updateUser'); + throwIfNullOrUndefined(user, 'user', 'updateUser'); + + const headers: HttpHeaders = { + 'Content-Type': 'application/json', + ...(this.configuration.apiKey && { 'api_key': this.configuration.apiKey('api_key') }), // api_key authentication + }; + + return this.request({ + url: '/user/{username}'.replace('{username}', encodeURI(username)), + method: 'PUT', + headers, + body: user, + }, opts?.responseOpts); + }; + +} diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/apis/index.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/apis/index.ts new file mode 100644 index 000000000000..056206bfaca3 --- /dev/null +++ b/samples/client/petstore/typescript-rxjs/builds/3.0/apis/index.ts @@ -0,0 +1,3 @@ +export * from './PetApi'; +export * from './StoreApi'; +export * from './UserApi'; diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/index.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/index.ts new file mode 100644 index 000000000000..b9e2f3ca3b7e --- /dev/null +++ b/samples/client/petstore/typescript-rxjs/builds/3.0/index.ts @@ -0,0 +1,4 @@ +export * from './runtime'; +export * from './servers'; +export * from './apis'; +export * from './models'; diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/models/ApiResponse.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/models/ApiResponse.ts new file mode 100644 index 000000000000..942e4b992bf0 --- /dev/null +++ b/samples/client/petstore/typescript-rxjs/builds/3.0/models/ApiResponse.ts @@ -0,0 +1,35 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * Describes the result of uploading an image resource + * @export + * @interface ApiResponse + */ +export interface ApiResponse { + /** + * @type {number} + * @memberof ApiResponse + */ + code?: number; + /** + * @type {string} + * @memberof ApiResponse + */ + type?: string; + /** + * @type {string} + * @memberof ApiResponse + */ + message?: string; +} diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/models/Category.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/models/Category.ts new file mode 100644 index 000000000000..4e1d3e51e2e3 --- /dev/null +++ b/samples/client/petstore/typescript-rxjs/builds/3.0/models/Category.ts @@ -0,0 +1,30 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * A category for a pet + * @export + * @interface Category + */ +export interface Category { + /** + * @type {number} + * @memberof Category + */ + id?: number; + /** + * @type {string} + * @memberof Category + */ + name?: string; +} diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/models/Order.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/models/Order.ts new file mode 100644 index 000000000000..c6b7790d7024 --- /dev/null +++ b/samples/client/petstore/typescript-rxjs/builds/3.0/models/Order.ts @@ -0,0 +1,62 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * An order for a pets from the pet store + * @export + * @interface Order + */ +export interface Order { + /** + * @type {number} + * @memberof Order + */ + id?: number; + /** + * @type {number} + * @memberof Order + */ + petId?: number; + /** + * @type {number} + * @memberof Order + */ + quantity?: number; + /** + * @type {string} + * @memberof Order + */ + shipDate?: string; + /** + * Order Status + * @type {string} + * @memberof Order + */ + status?: OrderStatusEnum; + /** + * @type {boolean} + * @memberof Order + */ + complete?: boolean; +} + +/** + * @export + * @enum {string} + */ +export enum OrderStatusEnum { + Placed = 'placed', + Approved = 'approved', + Delivered = 'delivered' +} + diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/models/Pet.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/models/Pet.ts new file mode 100644 index 000000000000..1c62cd065bf2 --- /dev/null +++ b/samples/client/petstore/typescript-rxjs/builds/3.0/models/Pet.ts @@ -0,0 +1,69 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import type { + Category, + Tag, +} from './'; + +/** + * A pet for sale in the pet store + * @export + * @interface Pet + */ +export interface Pet { + /** + * @type {number} + * @memberof Pet + */ + id?: number; + /** + * @type {Category} + * @memberof Pet + */ + category?: Category; + /** + * @type {string} + * @memberof Pet + */ + name: string; + /** + * @type {Array} + * @memberof Pet + */ + photoUrls: Array; + /** + * @type {Array} + * @memberof Pet + */ + tags?: Array; + /** + * pet status in the store + * @deprecated + * @type {string} + * @memberof Pet + */ + status?: PetStatusEnum; +} + +/** + * @export + * @enum {string} + * @deprecated + */ +export enum PetStatusEnum { + Available = 'available', + Pending = 'pending', + Sold = 'sold' +} + diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/models/Tag.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/models/Tag.ts new file mode 100644 index 000000000000..58792b18e6b8 --- /dev/null +++ b/samples/client/petstore/typescript-rxjs/builds/3.0/models/Tag.ts @@ -0,0 +1,30 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * A tag for a pet + * @export + * @interface Tag + */ +export interface Tag { + /** + * @type {number} + * @memberof Tag + */ + id?: number; + /** + * @type {string} + * @memberof Tag + */ + name?: string; +} diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/models/User.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/models/User.ts new file mode 100644 index 000000000000..a642d97bf8cd --- /dev/null +++ b/samples/client/petstore/typescript-rxjs/builds/3.0/models/User.ts @@ -0,0 +1,61 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +/** + * A User who is purchasing from the pet store + * @export + * @interface User + */ +export interface User { + /** + * @type {number} + * @memberof User + */ + id?: number; + /** + * @type {string} + * @memberof User + */ + username?: string; + /** + * @type {string} + * @memberof User + */ + firstName?: string; + /** + * @type {string} + * @memberof User + */ + lastName?: string; + /** + * @type {string} + * @memberof User + */ + email?: string; + /** + * @type {string} + * @memberof User + */ + password?: string; + /** + * @type {string} + * @memberof User + */ + phone?: string; + /** + * User Status + * @type {number} + * @memberof User + */ + userStatus?: number; +} diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/models/index.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/models/index.ts new file mode 100644 index 000000000000..f53c1dd42bdd --- /dev/null +++ b/samples/client/petstore/typescript-rxjs/builds/3.0/models/index.ts @@ -0,0 +1,6 @@ +export * from './ApiResponse'; +export * from './Category'; +export * from './Order'; +export * from './Pet'; +export * from './Tag'; +export * from './User'; diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/runtime.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/runtime.ts new file mode 100644 index 000000000000..d3934f08cc75 --- /dev/null +++ b/samples/client/petstore/typescript-rxjs/builds/3.0/runtime.ts @@ -0,0 +1,193 @@ +// tslint:disable +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { of } from 'rxjs'; +import type { Observable } from 'rxjs'; +import { ajax } from 'rxjs/ajax'; +import type { AjaxConfig, AjaxResponse } from 'rxjs/ajax'; +import { map, concatMap } from 'rxjs/operators'; +import { servers } from './servers'; + +export const BASE_PATH = servers[0].getUrl(); + +export interface ConfigurationParameters { + basePath?: string; // override base path + middleware?: Middleware[]; // middleware to apply before/after rxjs requests + username?: string; // parameter for basic security + password?: string; // parameter for basic security + apiKey?: string | ((name: string) => string); // parameter for apiKey security + accessToken?: string | ((name?: string, scopes?: string[]) => string); // parameter for oauth2 security +} + +export class Configuration { + constructor(private configuration: ConfigurationParameters = {}) {} + + get basePath(): string { + return this.configuration.basePath ?? BASE_PATH; + } + + get middleware(): Middleware[] { + return this.configuration.middleware ?? []; + } + + get username(): string | undefined { + return this.configuration.username; + } + + get password(): string | undefined { + return this.configuration.password; + } + + get apiKey(): ((name: string) => string) | undefined { + const { apiKey } = this.configuration; + return apiKey ? (typeof apiKey === 'string' ? () => apiKey : apiKey) : undefined; + } + + get accessToken(): ((name: string, scopes?: string[]) => string) | undefined { + const { accessToken } = this.configuration; + return accessToken ? (typeof accessToken === 'string' ? () => accessToken : accessToken) : undefined; + } +} + +/** + * This is the base class for all generated API classes. + */ +export class BaseAPI { + private middleware: Middleware[] = []; + + constructor(protected configuration = new Configuration()) { + this.middleware = configuration.middleware; + } + + withMiddleware = (middlewares: Middleware[]): this => { + const next = this.clone(); + next.middleware = next.middleware.concat(middlewares); + return next; + }; + + withPreMiddleware = (preMiddlewares: Array) => + this.withMiddleware(preMiddlewares.map((pre) => ({ pre }))); + + withPostMiddleware = (postMiddlewares: Array) => + this.withMiddleware(postMiddlewares.map((post) => ({ post }))); + + protected request(requestOpts: RequestOpts): Observable + protected request(requestOpts: RequestOpts, responseOpts?: ResponseOpts): Observable> + protected request(requestOpts: RequestOpts, responseOpts?: ResponseOpts): Observable> { + return this.rxjsRequest(this.createRequestArgs(requestOpts)).pipe( + map((res) => { + const { status, response } = res; + if (status >= 200 && status < 300) { + return responseOpts?.response === 'raw' ? res : response; + } + throw res; + }) + ); + } + + private createRequestArgs = ({ url: baseUrl, query, method, headers, body, responseType }: RequestOpts): AjaxConfig => { + // only add the queryString to the URL if there are query parameters. + // this is done to avoid urls ending with a '?' character which buggy webservers + // do not handle correctly sometimes. + const url = `${this.configuration.basePath}${baseUrl}${query && Object.keys(query).length ? `?${queryString(query)}`: ''}`; + + return { + url, + method, + headers, + body: body instanceof FormData ? body : JSON.stringify(body), + responseType: responseType ?? 'json', + }; + } + + private rxjsRequest = (params: AjaxConfig): Observable> => + of(params).pipe( + map((request) => { + this.middleware.filter((item) => item.pre).forEach((mw) => (request = mw.pre!(request))); + return request; + }), + concatMap((args) => + ajax(args).pipe( + map((response) => { + this.middleware.filter((item) => item.post).forEach((mw) => (response = mw.post!(response))); + return response; + }) + ) + ) + ); + + /** + * Create a shallow clone of `this` by constructing a new instance + * and then shallow cloning data members. + */ + private clone = (): this => + Object.assign(Object.create(Object.getPrototypeOf(this)), this); +} + +/** + * @deprecated + * export for not being a breaking change + */ +export class RequiredError extends Error { + override name: 'RequiredError' = 'RequiredError'; +} + +export const COLLECTION_FORMATS = { + csv: ',', + ssv: ' ', + tsv: '\t', + pipes: '|', +}; + +export type Json = any; +export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD'; +export type HttpHeaders = { [key: string]: string }; +export type HttpQuery = Partial<{ [key: string]: string | number | null | boolean | Array }>; // partial is needed for strict mode +export type HttpBody = Json | FormData; + +export interface RequestOpts extends AjaxConfig { + // TODO: replace custom 'query' prop with 'queryParams' + query?: HttpQuery; // additional prop + // the following props have improved types over AjaxRequest + method: HttpMethod; + headers?: HttpHeaders; + body?: HttpBody; +} + +export interface ResponseOpts { + response?: 'raw'; +} + +export interface OperationOpts { + responseOpts?: ResponseOpts; +} + +export const encodeURI = (value: any) => encodeURIComponent(`${value}`); + +const queryString = (params: HttpQuery): string => Object.entries(params) + .map(([key, value]) => value instanceof Array + ? value.map((val) => `${encodeURI(key)}=${encodeURI(val)}`).join('&') + : `${encodeURI(key)}=${encodeURI(value)}` + ) + .join('&'); + +export const throwIfNullOrUndefined = (value: any, paramName: string, nickname: string) => { + if (value == null) { + throw new Error(`Parameter "${paramName}" was null or undefined when calling "${nickname}".`); + } +}; + +export interface Middleware { + pre?(request: AjaxConfig): AjaxConfig; + post?(response: AjaxResponse): AjaxResponse; +} diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/servers.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/servers.ts new file mode 100644 index 000000000000..c7f87796bc4b --- /dev/null +++ b/samples/client/petstore/typescript-rxjs/builds/3.0/servers.ts @@ -0,0 +1,45 @@ +/** + * + * Represents the configuration of a server including its + * url template and variable configuration based on the url. + * + */ +export class ServerConfiguration { + public constructor(private url: string, private variableConfiguration: T, private description: string) {} + + /** + * Sets the value of the variables of this server. + * + * @param variableConfiguration a partial variable configuration for the variables contained in the url + */ + public setVariables(variableConfiguration: Partial) { + Object.assign(this.variableConfiguration, variableConfiguration); + } + + public getConfiguration(): T { + return this.variableConfiguration; + } + + public getDescription(): string { + return this.description; + } + + /** + * Constructs the URL for this server using the url with variables + * replaced with their respective values. + */ + public getUrl(): string { + let replacedUrl = this.url; + for (const key in this.variableConfiguration) { + if (this.variableConfiguration.hasOwnProperty(key)) { + const re = new RegExp("{" + key + "}", "g"); + replacedUrl = replacedUrl.replace(re, this.variableConfiguration[key]); + } + } + return replacedUrl; + } +} + +const server1 = new ServerConfiguration<{ }>("http://petstore.swagger.io/v2", { }, ""); + +export const servers = [server1]; diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/tsconfig.json b/samples/client/petstore/typescript-rxjs/builds/3.0/tsconfig.json new file mode 100644 index 000000000000..59a60838a05c --- /dev/null +++ b/samples/client/petstore/typescript-rxjs/builds/3.0/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "declaration": true, + "target": "es5", + "module": "commonjs", + "moduleResolution": "node", + "outDir": "dist", + "rootDir": ".", + "lib": [ + "es6", + "dom", + "es2017" + ], + "typeRoots": [ + "node_modules/@types" + ] + }, + "exclude": [ + "dist", + "node_modules" + ] +} diff --git a/samples/client/petstore/typescript-rxjs/builds/default/apis/PetApi.ts b/samples/client/petstore/typescript-rxjs/builds/default/apis/PetApi.ts index 7745f081c8bb..5629cf25de2c 100644 --- a/samples/client/petstore/typescript-rxjs/builds/default/apis/PetApi.ts +++ b/samples/client/petstore/typescript-rxjs/builds/default/apis/PetApi.ts @@ -149,6 +149,7 @@ export class PetApi extends BaseAPI { /** * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * Finds Pets by tags + * @deprecated */ findPetsByTags({ tags }: FindPetsByTagsRequest): Observable> findPetsByTags({ tags }: FindPetsByTagsRequest, opts?: OperationOpts): Observable>> diff --git a/samples/client/petstore/typescript-rxjs/builds/es6-target/apis/PetApi.ts b/samples/client/petstore/typescript-rxjs/builds/es6-target/apis/PetApi.ts index 7745f081c8bb..5629cf25de2c 100644 --- a/samples/client/petstore/typescript-rxjs/builds/es6-target/apis/PetApi.ts +++ b/samples/client/petstore/typescript-rxjs/builds/es6-target/apis/PetApi.ts @@ -149,6 +149,7 @@ export class PetApi extends BaseAPI { /** * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * Finds Pets by tags + * @deprecated */ findPetsByTags({ tags }: FindPetsByTagsRequest): Observable> findPetsByTags({ tags }: FindPetsByTagsRequest, opts?: OperationOpts): Observable>> diff --git a/samples/client/petstore/typescript-rxjs/builds/with-npm-version/apis/PetApi.ts b/samples/client/petstore/typescript-rxjs/builds/with-npm-version/apis/PetApi.ts index 7745f081c8bb..5629cf25de2c 100644 --- a/samples/client/petstore/typescript-rxjs/builds/with-npm-version/apis/PetApi.ts +++ b/samples/client/petstore/typescript-rxjs/builds/with-npm-version/apis/PetApi.ts @@ -149,6 +149,7 @@ export class PetApi extends BaseAPI { /** * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * Finds Pets by tags + * @deprecated */ findPetsByTags({ tags }: FindPetsByTagsRequest): Observable> findPetsByTags({ tags }: FindPetsByTagsRequest, opts?: OperationOpts): Observable>> diff --git a/samples/client/petstore/typescript-rxjs/builds/with-progress-subscriber/apis/PetApi.ts b/samples/client/petstore/typescript-rxjs/builds/with-progress-subscriber/apis/PetApi.ts index 1fd55eca4bcf..2313c4beb053 100644 --- a/samples/client/petstore/typescript-rxjs/builds/with-progress-subscriber/apis/PetApi.ts +++ b/samples/client/petstore/typescript-rxjs/builds/with-progress-subscriber/apis/PetApi.ts @@ -155,6 +155,7 @@ export class PetApi extends BaseAPI { /** * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * Finds Pets by tags + * @deprecated */ findPetsByTags({ tags }: FindPetsByTagsRequest): Observable> findPetsByTags({ tags }: FindPetsByTagsRequest, opts?: Pick): Observable> From d18304094054bce1f9027e9a226c88a0f89251a8 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sun, 23 Nov 2025 15:48:08 +0800 Subject: [PATCH 2/2] minor updates --- bin/configs/typescript-rxjs-3.0.yaml | 4 - .../codegen/ruby/RubyClientCodegenTest.java | 16 +- .../typescript-rxjs/builds/3.0/.gitignore | 4 - .../builds/3.0/.openapi-generator-ignore | 23 -- .../builds/3.0/.openapi-generator/FILES | 17 - .../builds/3.0/.openapi-generator/VERSION | 1 - .../typescript-rxjs/builds/3.0/apis/PetApi.ts | 303 ------------------ .../builds/3.0/apis/StoreApi.ts | 108 ------- .../builds/3.0/apis/UserApi.ts | 221 ------------- .../typescript-rxjs/builds/3.0/apis/index.ts | 3 - .../typescript-rxjs/builds/3.0/index.ts | 4 - .../builds/3.0/models/ApiResponse.ts | 35 -- .../builds/3.0/models/Category.ts | 30 -- .../builds/3.0/models/Order.ts | 62 ---- .../typescript-rxjs/builds/3.0/models/Pet.ts | 69 ---- .../typescript-rxjs/builds/3.0/models/Tag.ts | 30 -- .../typescript-rxjs/builds/3.0/models/User.ts | 61 ---- .../builds/3.0/models/index.ts | 6 - .../typescript-rxjs/builds/3.0/runtime.ts | 193 ----------- .../typescript-rxjs/builds/3.0/servers.ts | 45 --- .../typescript-rxjs/builds/3.0/tsconfig.json | 22 -- 21 files changed, 8 insertions(+), 1249 deletions(-) delete mode 100644 bin/configs/typescript-rxjs-3.0.yaml delete mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/.gitignore delete mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/.openapi-generator-ignore delete mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/.openapi-generator/FILES delete mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/.openapi-generator/VERSION delete mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/apis/PetApi.ts delete mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/apis/StoreApi.ts delete mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/apis/UserApi.ts delete mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/apis/index.ts delete mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/index.ts delete mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/models/ApiResponse.ts delete mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/models/Category.ts delete mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/models/Order.ts delete mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/models/Pet.ts delete mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/models/Tag.ts delete mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/models/User.ts delete mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/models/index.ts delete mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/runtime.ts delete mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/servers.ts delete mode 100644 samples/client/petstore/typescript-rxjs/builds/3.0/tsconfig.json diff --git a/bin/configs/typescript-rxjs-3.0.yaml b/bin/configs/typescript-rxjs-3.0.yaml deleted file mode 100644 index 0a0b14b36817..000000000000 --- a/bin/configs/typescript-rxjs-3.0.yaml +++ /dev/null @@ -1,4 +0,0 @@ -generatorName: typescript-rxjs -outputDir: samples/client/petstore/typescript-rxjs/builds/3.0 -inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml -templateDir: modules/openapi-generator/src/main/resources/typescript-rxjs diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java index e6f66ad8f10d..68c2254e5a69 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java @@ -577,10 +577,10 @@ public void allOfCompositionTest() { Assert.assertEquals(cp1.name, "name"); Assert.assertFalse(cp1.required); - CodegenProperty cp2 = superMan.getVars().get(2); - Assert.assertEquals(cp2.name, "nickname"); - Assert.assertFalse(cp2.required); - Assert.assertTrue(cp2.deprecated); + CodegenProperty cp2 = superMan.getVars().get(2); + Assert.assertEquals(cp2.name, "nickname"); + Assert.assertFalse(cp2.required); + Assert.assertTrue(cp2.deprecated); CodegenProperty cp3 = superMan.getVars().get(3); Assert.assertEquals(cp3.name, "reward"); @@ -606,10 +606,10 @@ public void allOfCompositionTest() { Assert.assertEquals(cp8.name, "name"); Assert.assertFalse(cp8.required); - CodegenProperty cp9 = superMan.getAllVars().get(2); - Assert.assertEquals(cp9.name, "nickname"); - Assert.assertFalse(cp9.required); - Assert.assertTrue(cp9.deprecated); + CodegenProperty cp9 = superMan.getAllVars().get(2); + Assert.assertEquals(cp9.name, "nickname"); + Assert.assertFalse(cp9.required); + Assert.assertTrue(cp9.deprecated); CodegenProperty cp10 = superMan.getAllVars().get(3); Assert.assertEquals(cp10.name, "reward"); diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/.gitignore b/samples/client/petstore/typescript-rxjs/builds/3.0/.gitignore deleted file mode 100644 index 149b57654723..000000000000 --- a/samples/client/petstore/typescript-rxjs/builds/3.0/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -wwwroot/*.js -node_modules -typings -dist diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/.openapi-generator-ignore b/samples/client/petstore/typescript-rxjs/builds/3.0/.openapi-generator-ignore deleted file mode 100644 index 7484ee590a38..000000000000 --- a/samples/client/petstore/typescript-rxjs/builds/3.0/.openapi-generator-ignore +++ /dev/null @@ -1,23 +0,0 @@ -# OpenAPI Generator Ignore -# Generated by openapi-generator https://github.com/openapitools/openapi-generator - -# Use this file to prevent files from being overwritten by the generator. -# The patterns follow closely to .gitignore or .dockerignore. - -# As an example, the C# client generator defines ApiClient.cs. -# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: -#ApiClient.cs - -# You can match any string of characters against a directory, file or extension with a single asterisk (*): -#foo/*/qux -# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux - -# You can recursively match patterns against a directory, file or extension with a double asterisk (**): -#foo/**/qux -# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux - -# You can also negate patterns with an exclamation (!). -# For example, you can ignore all files in a docs folder with the file extension .md: -#docs/*.md -# Then explicitly reverse the ignore rule for a single file: -#!docs/README.md diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/.openapi-generator/FILES b/samples/client/petstore/typescript-rxjs/builds/3.0/.openapi-generator/FILES deleted file mode 100644 index e5826f31b67f..000000000000 --- a/samples/client/petstore/typescript-rxjs/builds/3.0/.openapi-generator/FILES +++ /dev/null @@ -1,17 +0,0 @@ -.gitignore -.openapi-generator-ignore -apis/PetApi.ts -apis/StoreApi.ts -apis/UserApi.ts -apis/index.ts -index.ts -models/ApiResponse.ts -models/Category.ts -models/Order.ts -models/Pet.ts -models/Tag.ts -models/User.ts -models/index.ts -runtime.ts -servers.ts -tsconfig.json diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/.openapi-generator/VERSION b/samples/client/petstore/typescript-rxjs/builds/3.0/.openapi-generator/VERSION deleted file mode 100644 index 2fb556b60635..000000000000 --- a/samples/client/petstore/typescript-rxjs/builds/3.0/.openapi-generator/VERSION +++ /dev/null @@ -1 +0,0 @@ -7.18.0-SNAPSHOT diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/apis/PetApi.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/apis/PetApi.ts deleted file mode 100644 index e22240ade71b..000000000000 --- a/samples/client/petstore/typescript-rxjs/builds/3.0/apis/PetApi.ts +++ /dev/null @@ -1,303 +0,0 @@ -// tslint:disable -/** - * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import type { Observable } from 'rxjs'; -import type { AjaxResponse } from 'rxjs/ajax'; -import { BaseAPI, throwIfNullOrUndefined, encodeURI, COLLECTION_FORMATS } from '../runtime'; -import type { OperationOpts, HttpHeaders, HttpQuery } from '../runtime'; -import type { - ApiResponse, - Pet, -} from '../models'; - -export interface AddPetRequest { - pet: Pet; -} - -export interface DeletePetRequest { - petId: number; - apiKey?: string; -} - -export interface FindPetsByStatusRequest { - status: Array; -} - -export interface FindPetsByTagsRequest { - tags: Array; -} - -export interface GetPetByIdRequest { - petId: number; -} - -export interface UpdatePetRequest { - pet: Pet; -} - -export interface UpdatePetWithFormRequest { - petId: number; - name?: string; - status?: string; -} - -export interface UploadFileRequest { - petId: number; - additionalMetadata?: string; - file?: Blob; -} - -/** - * no description - */ -export class PetApi extends BaseAPI { - - /** - * - * Add a new pet to the store - */ - addPet({ pet }: AddPetRequest): Observable - addPet({ pet }: AddPetRequest, opts?: OperationOpts): Observable> - addPet({ pet }: AddPetRequest, opts?: OperationOpts): Observable> { - throwIfNullOrUndefined(pet, 'pet', 'addPet'); - - const headers: HttpHeaders = { - 'Content-Type': 'application/json', - // oauth required - ...(this.configuration.accessToken != null - ? { Authorization: typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken('petstore_auth', ['write:pets', 'read:pets']) - : this.configuration.accessToken } - : undefined - ), - }; - - return this.request({ - url: '/pet', - method: 'POST', - headers, - body: pet, - }, opts?.responseOpts); - }; - - /** - * - * Deletes a pet - */ - deletePet({ petId, apiKey }: DeletePetRequest): Observable - deletePet({ petId, apiKey }: DeletePetRequest, opts?: OperationOpts): Observable> - deletePet({ petId, apiKey }: DeletePetRequest, opts?: OperationOpts): Observable> { - throwIfNullOrUndefined(petId, 'petId', 'deletePet'); - - const headers: HttpHeaders = { - ...(apiKey != null ? { 'api_key': String(apiKey) } : undefined), - // oauth required - ...(this.configuration.accessToken != null - ? { Authorization: typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken('petstore_auth', ['write:pets', 'read:pets']) - : this.configuration.accessToken } - : undefined - ), - }; - - return this.request({ - url: '/pet/{petId}'.replace('{petId}', encodeURI(petId)), - method: 'DELETE', - headers, - }, opts?.responseOpts); - }; - - /** - * Multiple status values can be provided with comma separated strings - * Finds Pets by status - */ - findPetsByStatus({ status }: FindPetsByStatusRequest): Observable> - findPetsByStatus({ status }: FindPetsByStatusRequest, opts?: OperationOpts): Observable>> - findPetsByStatus({ status }: FindPetsByStatusRequest, opts?: OperationOpts): Observable | AjaxResponse>> { - throwIfNullOrUndefined(status, 'status', 'findPetsByStatus'); - - const headers: HttpHeaders = { - // oauth required - ...(this.configuration.accessToken != null - ? { Authorization: typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken('petstore_auth', ['read:pets']) - : this.configuration.accessToken } - : undefined - ), - }; - - const query: HttpQuery = { // required parameters are used directly since they are already checked by throwIfNullOrUndefined - 'status': status.join(COLLECTION_FORMATS['csv']), - }; - - return this.request>({ - url: '/pet/findByStatus', - method: 'GET', - headers, - query, - }, opts?.responseOpts); - }; - - /** - * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - * Finds Pets by tags - * @deprecated - */ - findPetsByTags({ tags }: FindPetsByTagsRequest): Observable> - findPetsByTags({ tags }: FindPetsByTagsRequest, opts?: OperationOpts): Observable>> - findPetsByTags({ tags }: FindPetsByTagsRequest, opts?: OperationOpts): Observable | AjaxResponse>> { - throwIfNullOrUndefined(tags, 'tags', 'findPetsByTags'); - - const headers: HttpHeaders = { - // oauth required - ...(this.configuration.accessToken != null - ? { Authorization: typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken('petstore_auth', ['read:pets']) - : this.configuration.accessToken } - : undefined - ), - }; - - const query: HttpQuery = { // required parameters are used directly since they are already checked by throwIfNullOrUndefined - 'tags': tags.join(COLLECTION_FORMATS['csv']), - }; - - return this.request>({ - url: '/pet/findByTags', - method: 'GET', - headers, - query, - }, opts?.responseOpts); - }; - - /** - * Returns a single pet - * Find pet by ID - */ - getPetById({ petId }: GetPetByIdRequest): Observable - getPetById({ petId }: GetPetByIdRequest, opts?: OperationOpts): Observable> - getPetById({ petId }: GetPetByIdRequest, opts?: OperationOpts): Observable> { - throwIfNullOrUndefined(petId, 'petId', 'getPetById'); - - const headers: HttpHeaders = { - ...(this.configuration.apiKey && { 'api_key': this.configuration.apiKey('api_key') }), // api_key authentication - }; - - return this.request({ - url: '/pet/{petId}'.replace('{petId}', encodeURI(petId)), - method: 'GET', - headers, - }, opts?.responseOpts); - }; - - /** - * - * Update an existing pet - */ - updatePet({ pet }: UpdatePetRequest): Observable - updatePet({ pet }: UpdatePetRequest, opts?: OperationOpts): Observable> - updatePet({ pet }: UpdatePetRequest, opts?: OperationOpts): Observable> { - throwIfNullOrUndefined(pet, 'pet', 'updatePet'); - - const headers: HttpHeaders = { - 'Content-Type': 'application/json', - // oauth required - ...(this.configuration.accessToken != null - ? { Authorization: typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken('petstore_auth', ['write:pets', 'read:pets']) - : this.configuration.accessToken } - : undefined - ), - }; - - return this.request({ - url: '/pet', - method: 'PUT', - headers, - body: pet, - }, opts?.responseOpts); - }; - - /** - * - * Updates a pet in the store with form data - */ - updatePetWithForm({ petId, name, status }: UpdatePetWithFormRequest): Observable - updatePetWithForm({ petId, name, status }: UpdatePetWithFormRequest, opts?: OperationOpts): Observable> - updatePetWithForm({ petId, name, status }: UpdatePetWithFormRequest, opts?: OperationOpts): Observable> { - throwIfNullOrUndefined(petId, 'petId', 'updatePetWithForm'); - - const headers: HttpHeaders = { - // oauth required - ...(this.configuration.accessToken != null - ? { Authorization: typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken('petstore_auth', ['write:pets', 'read:pets']) - : this.configuration.accessToken } - : undefined - ), - }; - - const formData = new FormData(); - if (name !== undefined) { formData.append('name', name as any); } - if (status !== undefined) { formData.append('status', status as any); } - - return this.request({ - url: '/pet/{petId}'.replace('{petId}', encodeURI(petId)), - method: 'POST', - headers, - body: formData, - }, opts?.responseOpts); - }; - - /** - * - * uploads an image - */ - uploadFile({ petId, additionalMetadata, file }: UploadFileRequest): Observable - uploadFile({ petId, additionalMetadata, file }: UploadFileRequest, opts?: OperationOpts): Observable> - uploadFile({ petId, additionalMetadata, file }: UploadFileRequest, opts?: OperationOpts): Observable> { - throwIfNullOrUndefined(petId, 'petId', 'uploadFile'); - - const headers: HttpHeaders = { - // oauth required - ...(this.configuration.accessToken != null - ? { Authorization: typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken('petstore_auth', ['write:pets', 'read:pets']) - : this.configuration.accessToken } - : undefined - ), - }; - - const formData = new FormData(); - if (additionalMetadata !== undefined) { formData.append('additionalMetadata', additionalMetadata as any); } - if (file !== undefined) { formData.append('file', file as any); } - - return this.request({ - url: '/pet/{petId}/uploadImage'.replace('{petId}', encodeURI(petId)), - method: 'POST', - headers, - body: formData, - }, opts?.responseOpts); - }; - -} - -/** - * @export - * @enum {string} - */ -export enum FindPetsByStatusStatusEnum { - Available = 'available', - Pending = 'pending', - Sold = 'sold' -} diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/apis/StoreApi.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/apis/StoreApi.ts deleted file mode 100644 index 102c54d299b2..000000000000 --- a/samples/client/petstore/typescript-rxjs/builds/3.0/apis/StoreApi.ts +++ /dev/null @@ -1,108 +0,0 @@ -// tslint:disable -/** - * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import type { Observable } from 'rxjs'; -import type { AjaxResponse } from 'rxjs/ajax'; -import { BaseAPI, throwIfNullOrUndefined, encodeURI } from '../runtime'; -import type { OperationOpts, HttpHeaders } from '../runtime'; -import type { - Order, -} from '../models'; - -export interface DeleteOrderRequest { - orderId: string; -} - -export interface GetOrderByIdRequest { - orderId: number; -} - -export interface PlaceOrderRequest { - order: Order; -} - -/** - * no description - */ -export class StoreApi extends BaseAPI { - - /** - * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - * Delete purchase order by ID - */ - deleteOrder({ orderId }: DeleteOrderRequest): Observable - deleteOrder({ orderId }: DeleteOrderRequest, opts?: OperationOpts): Observable> - deleteOrder({ orderId }: DeleteOrderRequest, opts?: OperationOpts): Observable> { - throwIfNullOrUndefined(orderId, 'orderId', 'deleteOrder'); - - return this.request({ - url: '/store/order/{orderId}'.replace('{orderId}', encodeURI(orderId)), - method: 'DELETE', - }, opts?.responseOpts); - }; - - /** - * Returns a map of status codes to quantities - * Returns pet inventories by status - */ - getInventory(): Observable<{ [key: string]: number; }> - getInventory(opts?: OperationOpts): Observable> - getInventory(opts?: OperationOpts): Observable<{ [key: string]: number; } | AjaxResponse<{ [key: string]: number; }>> { - const headers: HttpHeaders = { - ...(this.configuration.apiKey && { 'api_key': this.configuration.apiKey('api_key') }), // api_key authentication - }; - - return this.request<{ [key: string]: number; }>({ - url: '/store/inventory', - method: 'GET', - headers, - }, opts?.responseOpts); - }; - - /** - * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions - * Find purchase order by ID - */ - getOrderById({ orderId }: GetOrderByIdRequest): Observable - getOrderById({ orderId }: GetOrderByIdRequest, opts?: OperationOpts): Observable> - getOrderById({ orderId }: GetOrderByIdRequest, opts?: OperationOpts): Observable> { - throwIfNullOrUndefined(orderId, 'orderId', 'getOrderById'); - - return this.request({ - url: '/store/order/{orderId}'.replace('{orderId}', encodeURI(orderId)), - method: 'GET', - }, opts?.responseOpts); - }; - - /** - * - * Place an order for a pet - */ - placeOrder({ order }: PlaceOrderRequest): Observable - placeOrder({ order }: PlaceOrderRequest, opts?: OperationOpts): Observable> - placeOrder({ order }: PlaceOrderRequest, opts?: OperationOpts): Observable> { - throwIfNullOrUndefined(order, 'order', 'placeOrder'); - - const headers: HttpHeaders = { - 'Content-Type': 'application/json', - }; - - return this.request({ - url: '/store/order', - method: 'POST', - headers, - body: order, - }, opts?.responseOpts); - }; - -} diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/apis/UserApi.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/apis/UserApi.ts deleted file mode 100644 index 68cd486e0567..000000000000 --- a/samples/client/petstore/typescript-rxjs/builds/3.0/apis/UserApi.ts +++ /dev/null @@ -1,221 +0,0 @@ -// tslint:disable -/** - * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import type { Observable } from 'rxjs'; -import type { AjaxResponse } from 'rxjs/ajax'; -import { BaseAPI, throwIfNullOrUndefined, encodeURI } from '../runtime'; -import type { OperationOpts, HttpHeaders, HttpQuery } from '../runtime'; -import type { - User, -} from '../models'; - -export interface CreateUserRequest { - user: User; -} - -export interface CreateUsersWithArrayInputRequest { - user: Array; -} - -export interface CreateUsersWithListInputRequest { - user: Array; -} - -export interface DeleteUserRequest { - username: string; -} - -export interface GetUserByNameRequest { - username: string; -} - -export interface LoginUserRequest { - username: string; - password: string; -} - -export interface UpdateUserRequest { - username: string; - user: User; -} - -/** - * no description - */ -export class UserApi extends BaseAPI { - - /** - * This can only be done by the logged in user. - * Create user - */ - createUser({ user }: CreateUserRequest): Observable - createUser({ user }: CreateUserRequest, opts?: OperationOpts): Observable> - createUser({ user }: CreateUserRequest, opts?: OperationOpts): Observable> { - throwIfNullOrUndefined(user, 'user', 'createUser'); - - const headers: HttpHeaders = { - 'Content-Type': 'application/json', - ...(this.configuration.apiKey && { 'api_key': this.configuration.apiKey('api_key') }), // api_key authentication - }; - - return this.request({ - url: '/user', - method: 'POST', - headers, - body: user, - }, opts?.responseOpts); - }; - - /** - * - * Creates list of users with given input array - */ - createUsersWithArrayInput({ user }: CreateUsersWithArrayInputRequest): Observable - createUsersWithArrayInput({ user }: CreateUsersWithArrayInputRequest, opts?: OperationOpts): Observable> - createUsersWithArrayInput({ user }: CreateUsersWithArrayInputRequest, opts?: OperationOpts): Observable> { - throwIfNullOrUndefined(user, 'user', 'createUsersWithArrayInput'); - - const headers: HttpHeaders = { - 'Content-Type': 'application/json', - ...(this.configuration.apiKey && { 'api_key': this.configuration.apiKey('api_key') }), // api_key authentication - }; - - return this.request({ - url: '/user/createWithArray', - method: 'POST', - headers, - body: user, - }, opts?.responseOpts); - }; - - /** - * - * Creates list of users with given input array - */ - createUsersWithListInput({ user }: CreateUsersWithListInputRequest): Observable - createUsersWithListInput({ user }: CreateUsersWithListInputRequest, opts?: OperationOpts): Observable> - createUsersWithListInput({ user }: CreateUsersWithListInputRequest, opts?: OperationOpts): Observable> { - throwIfNullOrUndefined(user, 'user', 'createUsersWithListInput'); - - const headers: HttpHeaders = { - 'Content-Type': 'application/json', - ...(this.configuration.apiKey && { 'api_key': this.configuration.apiKey('api_key') }), // api_key authentication - }; - - return this.request({ - url: '/user/createWithList', - method: 'POST', - headers, - body: user, - }, opts?.responseOpts); - }; - - /** - * This can only be done by the logged in user. - * Delete user - */ - deleteUser({ username }: DeleteUserRequest): Observable - deleteUser({ username }: DeleteUserRequest, opts?: OperationOpts): Observable> - deleteUser({ username }: DeleteUserRequest, opts?: OperationOpts): Observable> { - throwIfNullOrUndefined(username, 'username', 'deleteUser'); - - const headers: HttpHeaders = { - ...(this.configuration.apiKey && { 'api_key': this.configuration.apiKey('api_key') }), // api_key authentication - }; - - return this.request({ - url: '/user/{username}'.replace('{username}', encodeURI(username)), - method: 'DELETE', - headers, - }, opts?.responseOpts); - }; - - /** - * - * Get user by user name - */ - getUserByName({ username }: GetUserByNameRequest): Observable - getUserByName({ username }: GetUserByNameRequest, opts?: OperationOpts): Observable> - getUserByName({ username }: GetUserByNameRequest, opts?: OperationOpts): Observable> { - throwIfNullOrUndefined(username, 'username', 'getUserByName'); - - return this.request({ - url: '/user/{username}'.replace('{username}', encodeURI(username)), - method: 'GET', - }, opts?.responseOpts); - }; - - /** - * - * Logs user into the system - */ - loginUser({ username, password }: LoginUserRequest): Observable - loginUser({ username, password }: LoginUserRequest, opts?: OperationOpts): Observable> - loginUser({ username, password }: LoginUserRequest, opts?: OperationOpts): Observable> { - throwIfNullOrUndefined(username, 'username', 'loginUser'); - throwIfNullOrUndefined(password, 'password', 'loginUser'); - - const query: HttpQuery = { // required parameters are used directly since they are already checked by throwIfNullOrUndefined - 'username': username, - 'password': password, - }; - - return this.request({ - url: '/user/login', - method: 'GET', - query, - }, opts?.responseOpts); - }; - - /** - * - * Logs out current logged in user session - */ - logoutUser(): Observable - logoutUser(opts?: OperationOpts): Observable> - logoutUser(opts?: OperationOpts): Observable> { - const headers: HttpHeaders = { - ...(this.configuration.apiKey && { 'api_key': this.configuration.apiKey('api_key') }), // api_key authentication - }; - - return this.request({ - url: '/user/logout', - method: 'GET', - headers, - }, opts?.responseOpts); - }; - - /** - * This can only be done by the logged in user. - * Updated user - */ - updateUser({ username, user }: UpdateUserRequest): Observable - updateUser({ username, user }: UpdateUserRequest, opts?: OperationOpts): Observable> - updateUser({ username, user }: UpdateUserRequest, opts?: OperationOpts): Observable> { - throwIfNullOrUndefined(username, 'username', 'updateUser'); - throwIfNullOrUndefined(user, 'user', 'updateUser'); - - const headers: HttpHeaders = { - 'Content-Type': 'application/json', - ...(this.configuration.apiKey && { 'api_key': this.configuration.apiKey('api_key') }), // api_key authentication - }; - - return this.request({ - url: '/user/{username}'.replace('{username}', encodeURI(username)), - method: 'PUT', - headers, - body: user, - }, opts?.responseOpts); - }; - -} diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/apis/index.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/apis/index.ts deleted file mode 100644 index 056206bfaca3..000000000000 --- a/samples/client/petstore/typescript-rxjs/builds/3.0/apis/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './PetApi'; -export * from './StoreApi'; -export * from './UserApi'; diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/index.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/index.ts deleted file mode 100644 index b9e2f3ca3b7e..000000000000 --- a/samples/client/petstore/typescript-rxjs/builds/3.0/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './runtime'; -export * from './servers'; -export * from './apis'; -export * from './models'; diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/models/ApiResponse.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/models/ApiResponse.ts deleted file mode 100644 index 942e4b992bf0..000000000000 --- a/samples/client/petstore/typescript-rxjs/builds/3.0/models/ApiResponse.ts +++ /dev/null @@ -1,35 +0,0 @@ -// tslint:disable -/** - * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -/** - * Describes the result of uploading an image resource - * @export - * @interface ApiResponse - */ -export interface ApiResponse { - /** - * @type {number} - * @memberof ApiResponse - */ - code?: number; - /** - * @type {string} - * @memberof ApiResponse - */ - type?: string; - /** - * @type {string} - * @memberof ApiResponse - */ - message?: string; -} diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/models/Category.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/models/Category.ts deleted file mode 100644 index 4e1d3e51e2e3..000000000000 --- a/samples/client/petstore/typescript-rxjs/builds/3.0/models/Category.ts +++ /dev/null @@ -1,30 +0,0 @@ -// tslint:disable -/** - * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -/** - * A category for a pet - * @export - * @interface Category - */ -export interface Category { - /** - * @type {number} - * @memberof Category - */ - id?: number; - /** - * @type {string} - * @memberof Category - */ - name?: string; -} diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/models/Order.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/models/Order.ts deleted file mode 100644 index c6b7790d7024..000000000000 --- a/samples/client/petstore/typescript-rxjs/builds/3.0/models/Order.ts +++ /dev/null @@ -1,62 +0,0 @@ -// tslint:disable -/** - * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -/** - * An order for a pets from the pet store - * @export - * @interface Order - */ -export interface Order { - /** - * @type {number} - * @memberof Order - */ - id?: number; - /** - * @type {number} - * @memberof Order - */ - petId?: number; - /** - * @type {number} - * @memberof Order - */ - quantity?: number; - /** - * @type {string} - * @memberof Order - */ - shipDate?: string; - /** - * Order Status - * @type {string} - * @memberof Order - */ - status?: OrderStatusEnum; - /** - * @type {boolean} - * @memberof Order - */ - complete?: boolean; -} - -/** - * @export - * @enum {string} - */ -export enum OrderStatusEnum { - Placed = 'placed', - Approved = 'approved', - Delivered = 'delivered' -} - diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/models/Pet.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/models/Pet.ts deleted file mode 100644 index 1c62cd065bf2..000000000000 --- a/samples/client/petstore/typescript-rxjs/builds/3.0/models/Pet.ts +++ /dev/null @@ -1,69 +0,0 @@ -// tslint:disable -/** - * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import type { - Category, - Tag, -} from './'; - -/** - * A pet for sale in the pet store - * @export - * @interface Pet - */ -export interface Pet { - /** - * @type {number} - * @memberof Pet - */ - id?: number; - /** - * @type {Category} - * @memberof Pet - */ - category?: Category; - /** - * @type {string} - * @memberof Pet - */ - name: string; - /** - * @type {Array} - * @memberof Pet - */ - photoUrls: Array; - /** - * @type {Array} - * @memberof Pet - */ - tags?: Array; - /** - * pet status in the store - * @deprecated - * @type {string} - * @memberof Pet - */ - status?: PetStatusEnum; -} - -/** - * @export - * @enum {string} - * @deprecated - */ -export enum PetStatusEnum { - Available = 'available', - Pending = 'pending', - Sold = 'sold' -} - diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/models/Tag.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/models/Tag.ts deleted file mode 100644 index 58792b18e6b8..000000000000 --- a/samples/client/petstore/typescript-rxjs/builds/3.0/models/Tag.ts +++ /dev/null @@ -1,30 +0,0 @@ -// tslint:disable -/** - * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -/** - * A tag for a pet - * @export - * @interface Tag - */ -export interface Tag { - /** - * @type {number} - * @memberof Tag - */ - id?: number; - /** - * @type {string} - * @memberof Tag - */ - name?: string; -} diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/models/User.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/models/User.ts deleted file mode 100644 index a642d97bf8cd..000000000000 --- a/samples/client/petstore/typescript-rxjs/builds/3.0/models/User.ts +++ /dev/null @@ -1,61 +0,0 @@ -// tslint:disable -/** - * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -/** - * A User who is purchasing from the pet store - * @export - * @interface User - */ -export interface User { - /** - * @type {number} - * @memberof User - */ - id?: number; - /** - * @type {string} - * @memberof User - */ - username?: string; - /** - * @type {string} - * @memberof User - */ - firstName?: string; - /** - * @type {string} - * @memberof User - */ - lastName?: string; - /** - * @type {string} - * @memberof User - */ - email?: string; - /** - * @type {string} - * @memberof User - */ - password?: string; - /** - * @type {string} - * @memberof User - */ - phone?: string; - /** - * User Status - * @type {number} - * @memberof User - */ - userStatus?: number; -} diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/models/index.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/models/index.ts deleted file mode 100644 index f53c1dd42bdd..000000000000 --- a/samples/client/petstore/typescript-rxjs/builds/3.0/models/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './ApiResponse'; -export * from './Category'; -export * from './Order'; -export * from './Pet'; -export * from './Tag'; -export * from './User'; diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/runtime.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/runtime.ts deleted file mode 100644 index d3934f08cc75..000000000000 --- a/samples/client/petstore/typescript-rxjs/builds/3.0/runtime.ts +++ /dev/null @@ -1,193 +0,0 @@ -// tslint:disable -/** - * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { of } from 'rxjs'; -import type { Observable } from 'rxjs'; -import { ajax } from 'rxjs/ajax'; -import type { AjaxConfig, AjaxResponse } from 'rxjs/ajax'; -import { map, concatMap } from 'rxjs/operators'; -import { servers } from './servers'; - -export const BASE_PATH = servers[0].getUrl(); - -export interface ConfigurationParameters { - basePath?: string; // override base path - middleware?: Middleware[]; // middleware to apply before/after rxjs requests - username?: string; // parameter for basic security - password?: string; // parameter for basic security - apiKey?: string | ((name: string) => string); // parameter for apiKey security - accessToken?: string | ((name?: string, scopes?: string[]) => string); // parameter for oauth2 security -} - -export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} - - get basePath(): string { - return this.configuration.basePath ?? BASE_PATH; - } - - get middleware(): Middleware[] { - return this.configuration.middleware ?? []; - } - - get username(): string | undefined { - return this.configuration.username; - } - - get password(): string | undefined { - return this.configuration.password; - } - - get apiKey(): ((name: string) => string) | undefined { - const { apiKey } = this.configuration; - return apiKey ? (typeof apiKey === 'string' ? () => apiKey : apiKey) : undefined; - } - - get accessToken(): ((name: string, scopes?: string[]) => string) | undefined { - const { accessToken } = this.configuration; - return accessToken ? (typeof accessToken === 'string' ? () => accessToken : accessToken) : undefined; - } -} - -/** - * This is the base class for all generated API classes. - */ -export class BaseAPI { - private middleware: Middleware[] = []; - - constructor(protected configuration = new Configuration()) { - this.middleware = configuration.middleware; - } - - withMiddleware = (middlewares: Middleware[]): this => { - const next = this.clone(); - next.middleware = next.middleware.concat(middlewares); - return next; - }; - - withPreMiddleware = (preMiddlewares: Array) => - this.withMiddleware(preMiddlewares.map((pre) => ({ pre }))); - - withPostMiddleware = (postMiddlewares: Array) => - this.withMiddleware(postMiddlewares.map((post) => ({ post }))); - - protected request(requestOpts: RequestOpts): Observable - protected request(requestOpts: RequestOpts, responseOpts?: ResponseOpts): Observable> - protected request(requestOpts: RequestOpts, responseOpts?: ResponseOpts): Observable> { - return this.rxjsRequest(this.createRequestArgs(requestOpts)).pipe( - map((res) => { - const { status, response } = res; - if (status >= 200 && status < 300) { - return responseOpts?.response === 'raw' ? res : response; - } - throw res; - }) - ); - } - - private createRequestArgs = ({ url: baseUrl, query, method, headers, body, responseType }: RequestOpts): AjaxConfig => { - // only add the queryString to the URL if there are query parameters. - // this is done to avoid urls ending with a '?' character which buggy webservers - // do not handle correctly sometimes. - const url = `${this.configuration.basePath}${baseUrl}${query && Object.keys(query).length ? `?${queryString(query)}`: ''}`; - - return { - url, - method, - headers, - body: body instanceof FormData ? body : JSON.stringify(body), - responseType: responseType ?? 'json', - }; - } - - private rxjsRequest = (params: AjaxConfig): Observable> => - of(params).pipe( - map((request) => { - this.middleware.filter((item) => item.pre).forEach((mw) => (request = mw.pre!(request))); - return request; - }), - concatMap((args) => - ajax(args).pipe( - map((response) => { - this.middleware.filter((item) => item.post).forEach((mw) => (response = mw.post!(response))); - return response; - }) - ) - ) - ); - - /** - * Create a shallow clone of `this` by constructing a new instance - * and then shallow cloning data members. - */ - private clone = (): this => - Object.assign(Object.create(Object.getPrototypeOf(this)), this); -} - -/** - * @deprecated - * export for not being a breaking change - */ -export class RequiredError extends Error { - override name: 'RequiredError' = 'RequiredError'; -} - -export const COLLECTION_FORMATS = { - csv: ',', - ssv: ' ', - tsv: '\t', - pipes: '|', -}; - -export type Json = any; -export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD'; -export type HttpHeaders = { [key: string]: string }; -export type HttpQuery = Partial<{ [key: string]: string | number | null | boolean | Array }>; // partial is needed for strict mode -export type HttpBody = Json | FormData; - -export interface RequestOpts extends AjaxConfig { - // TODO: replace custom 'query' prop with 'queryParams' - query?: HttpQuery; // additional prop - // the following props have improved types over AjaxRequest - method: HttpMethod; - headers?: HttpHeaders; - body?: HttpBody; -} - -export interface ResponseOpts { - response?: 'raw'; -} - -export interface OperationOpts { - responseOpts?: ResponseOpts; -} - -export const encodeURI = (value: any) => encodeURIComponent(`${value}`); - -const queryString = (params: HttpQuery): string => Object.entries(params) - .map(([key, value]) => value instanceof Array - ? value.map((val) => `${encodeURI(key)}=${encodeURI(val)}`).join('&') - : `${encodeURI(key)}=${encodeURI(value)}` - ) - .join('&'); - -export const throwIfNullOrUndefined = (value: any, paramName: string, nickname: string) => { - if (value == null) { - throw new Error(`Parameter "${paramName}" was null or undefined when calling "${nickname}".`); - } -}; - -export interface Middleware { - pre?(request: AjaxConfig): AjaxConfig; - post?(response: AjaxResponse): AjaxResponse; -} diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/servers.ts b/samples/client/petstore/typescript-rxjs/builds/3.0/servers.ts deleted file mode 100644 index c7f87796bc4b..000000000000 --- a/samples/client/petstore/typescript-rxjs/builds/3.0/servers.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * - * Represents the configuration of a server including its - * url template and variable configuration based on the url. - * - */ -export class ServerConfiguration { - public constructor(private url: string, private variableConfiguration: T, private description: string) {} - - /** - * Sets the value of the variables of this server. - * - * @param variableConfiguration a partial variable configuration for the variables contained in the url - */ - public setVariables(variableConfiguration: Partial) { - Object.assign(this.variableConfiguration, variableConfiguration); - } - - public getConfiguration(): T { - return this.variableConfiguration; - } - - public getDescription(): string { - return this.description; - } - - /** - * Constructs the URL for this server using the url with variables - * replaced with their respective values. - */ - public getUrl(): string { - let replacedUrl = this.url; - for (const key in this.variableConfiguration) { - if (this.variableConfiguration.hasOwnProperty(key)) { - const re = new RegExp("{" + key + "}", "g"); - replacedUrl = replacedUrl.replace(re, this.variableConfiguration[key]); - } - } - return replacedUrl; - } -} - -const server1 = new ServerConfiguration<{ }>("http://petstore.swagger.io/v2", { }, ""); - -export const servers = [server1]; diff --git a/samples/client/petstore/typescript-rxjs/builds/3.0/tsconfig.json b/samples/client/petstore/typescript-rxjs/builds/3.0/tsconfig.json deleted file mode 100644 index 59a60838a05c..000000000000 --- a/samples/client/petstore/typescript-rxjs/builds/3.0/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "compilerOptions": { - "declaration": true, - "target": "es5", - "module": "commonjs", - "moduleResolution": "node", - "outDir": "dist", - "rootDir": ".", - "lib": [ - "es6", - "dom", - "es2017" - ], - "typeRoots": [ - "node_modules/@types" - ] - }, - "exclude": [ - "dist", - "node_modules" - ] -}