|
| 1 | +// Jest Snapshot v1, https://goo.gl/fbAQLP |
| 2 | + |
| 3 | +exports[`Multi Type apiClient 1`] = ` |
| 4 | +"// |
| 5 | +// Generated by @himenon/openapi-typescript-code-generator |
| 6 | +// |
| 7 | +// OpenApi : 3.0.1 |
| 8 | +// |
| 9 | +// License : MIT |
| 10 | +// |
| 11 | +
|
| 12 | +
|
| 13 | +import { Schemas } from \\"./types\\"; |
| 14 | +export interface RequestBody$putAnyOf { |
| 15 | + \\"application/json\\": Schemas.Cat | Schemas.Dog; |
| 16 | +} |
| 17 | +export interface RequestBody$patchOneOf { |
| 18 | + \\"application/json\\": Schemas.Cat | Schemas.Dog; |
| 19 | +} |
| 20 | +export type RequestContentType$putAnyOf = keyof RequestBody$putAnyOf; |
| 21 | +export interface Params$putAnyOf { |
| 22 | + requestBody: RequestBody$putAnyOf[\\"application/json\\"]; |
| 23 | +} |
| 24 | +export type RequestContentType$patchOneOf = keyof RequestBody$patchOneOf; |
| 25 | +export interface Params$patchOneOf { |
| 26 | + requestBody: RequestBody$patchOneOf[\\"application/json\\"]; |
| 27 | +} |
| 28 | +export type HttpMethod = \\"GET\\" | \\"PUT\\" | \\"POST\\" | \\"DELETE\\" | \\"OPTIONS\\" | \\"HEAD\\" | \\"PATCH\\" | \\"TRACE\\"; |
| 29 | +export interface ObjectLike { |
| 30 | + [key: string]: any; |
| 31 | +} |
| 32 | +export interface QueryParameter { |
| 33 | + value: any; |
| 34 | + style?: \\"form\\" | \\"spaceDelimited\\" | \\"pipeDelimited\\" | \\"deepObject\\"; |
| 35 | + explode: boolean; |
| 36 | +} |
| 37 | +export interface QueryParameters { |
| 38 | + [key: string]: QueryParameter; |
| 39 | +} |
| 40 | +export type SuccessResponses = void; |
| 41 | +export namespace ErrorResponse { |
| 42 | + export type putAnyOf = void; |
| 43 | + export type patchOneOf = void; |
| 44 | +} |
| 45 | +export interface ApiClient<RequestOption> { |
| 46 | + request: <T = SuccessResponses>(httpMethod: HttpMethod, url: string, headers: ObjectLike | any, requestBody: ObjectLike | any, queryParameters: QueryParameters | undefined, options?: RequestOption) => Promise<T>; |
| 47 | +} |
| 48 | +export class Client<RequestOption> { |
| 49 | + private baseUrl: string; |
| 50 | + constructor(private apiClient: ApiClient<RequestOption>, baseUrl: string) { this.baseUrl = baseUrl.replace(/\\\\/$/, \\"\\"); } |
| 51 | + /** |
| 52 | + * operationId: putAnyOf |
| 53 | + * Request URI: /pets |
| 54 | + */ |
| 55 | + public async putAnyOf(params: Params$putAnyOf, option?: RequestOption): Promise<void> { |
| 56 | + const url = this.baseUrl + \`/pets\`; |
| 57 | + const headers = { |
| 58 | + \\"Content-Type\\": \\"application/json\\" |
| 59 | + }; |
| 60 | + return this.apiClient.request(\\"PUT\\", url, headers, params.requestBody, undefined, option); |
| 61 | + } |
| 62 | + /** |
| 63 | + * operationId: patchOneOf |
| 64 | + * Request URI: /pets |
| 65 | + */ |
| 66 | + public async patchOneOf(params: Params$patchOneOf, option?: RequestOption): Promise<void> { |
| 67 | + const url = this.baseUrl + \`/pets\`; |
| 68 | + const headers = { |
| 69 | + \\"Content-Type\\": \\"application/json\\" |
| 70 | + }; |
| 71 | + return this.apiClient.request(\\"PATCH\\", url, headers, params.requestBody, undefined, option); |
| 72 | + } |
| 73 | +} |
| 74 | +" |
| 75 | +`; |
| 76 | +
|
| 77 | +exports[`Multi Type types 1`] = ` |
| 78 | +"// |
| 79 | +// Generated by @himenon/openapi-typescript-code-generator |
| 80 | +// |
| 81 | +// OpenApi : 3.0.1 |
| 82 | +// |
| 83 | +// License : MIT |
| 84 | +// |
| 85 | +
|
| 86 | +
|
| 87 | +export namespace Schemas { |
| 88 | + export interface Pet { |
| 89 | + pet_type: string; |
| 90 | + } |
| 91 | + export type Dog = Schemas.Pet & { |
| 92 | + bark?: boolean; |
| 93 | + breed?: \\"Dingo\\" | \\"Husky\\" | \\"Retriever\\" | \\"Shepherd\\"; |
| 94 | + }; |
| 95 | + export type Cat = Schemas.Pet & { |
| 96 | + hunts?: boolean; |
| 97 | + age?: number; |
| 98 | + }; |
| 99 | +} |
| 100 | +" |
| 101 | +`; |
0 commit comments