|
| 1 | +{{>header}} |
| 2 | + |
| 3 | +{{#equals @root.httpClient 'angular'}} |
| 4 | +{{#if @root.exportClient}} |
| 5 | +import { Injectable } from '@angular/core'; |
| 6 | +import type { Observable } from 'rxjs'; |
| 7 | +{{else}} |
| 8 | +import { Injectable } from '@angular/core'; |
| 9 | +import { HttpClient } from '@angular/common/http'; |
| 10 | +import type { Observable } from 'rxjs'; |
| 11 | +{{/if}} |
| 12 | + |
| 13 | +{{/equals}} |
| 14 | +{{#if imports}} |
| 15 | +{{#each imports}} |
| 16 | +import type { {{{this}}} } from '../models/{{{this}}}'; |
| 17 | +{{/each}} |
| 18 | + |
| 19 | +{{/if}} |
| 20 | +{{#notEquals @root.httpClient 'angular'}} |
| 21 | +import type { CancelablePromise } from '../core/CancelablePromise'; |
| 22 | +{{/notEquals}} |
| 23 | +{{#if @root.exportClient}} |
| 24 | +{{#equals @root.httpClient 'angular'}} |
| 25 | +import { BaseHttpRequest } from '../core/BaseHttpRequest'; |
| 26 | +{{else}} |
| 27 | +import type { BaseHttpRequest } from '../core/BaseHttpRequest'; |
| 28 | +{{/equals}} |
| 29 | +{{else}} |
| 30 | +import { OpenAPI } from '../core/OpenAPI'; |
| 31 | +import { request as __request } from '../core/request'; |
| 32 | +{{/if}} |
| 33 | + |
| 34 | +{{#equals @root.httpClient 'angular'}} |
| 35 | +@Injectable() |
| 36 | +{{/equals}} |
| 37 | +export class {{{name}}}{{{@root.postfix}}} { |
| 38 | + {{#if @root.exportClient}} |
| 39 | + |
| 40 | + constructor(public readonly httpRequest: BaseHttpRequest) {} |
| 41 | + {{else}} |
| 42 | + {{#equals @root.httpClient 'angular'}} |
| 43 | + |
| 44 | + constructor(public readonly http: HttpClient) {} |
| 45 | + {{/equals}} |
| 46 | + {{/if}} |
| 47 | + |
| 48 | + {{#each operations}} |
| 49 | + /** |
| 50 | + {{#if deprecated}} |
| 51 | + * @deprecated |
| 52 | + {{/if}} |
| 53 | + {{#if summary}} |
| 54 | + * {{{escapeComment summary}}} |
| 55 | + {{/if}} |
| 56 | + {{#if description}} |
| 57 | + * {{{escapeComment description}}} |
| 58 | + {{/if}} |
| 59 | + {{#unless @root.useOptions}} |
| 60 | + {{#if parameters}} |
| 61 | + {{#each parameters}} |
| 62 | + * @param {{{name}}} {{#if description}}{{{escapeComment description}}}{{/if}} |
| 63 | + {{/each}} |
| 64 | + {{/if}} |
| 65 | + {{/unless}} |
| 66 | + {{#each results}} |
| 67 | + * @returns {{{type}}} {{#if description}}{{{escapeComment description}}}{{/if}} |
| 68 | + {{/each}} |
| 69 | + * @throws ApiError |
| 70 | + */ |
| 71 | + {{#if @root.exportClient}} |
| 72 | + {{#equals @root.httpClient 'angular'}} |
| 73 | + public {{{name}}}({{>parameters}}): Observable<{{>result}}> { |
| 74 | + return this.httpRequest.request({ |
| 75 | + {{else}} |
| 76 | + public {{{name}}}({{>parameters}}): CancelablePromise<{{>result}}> { |
| 77 | + return this.httpRequest.request({ |
| 78 | + {{/equals}} |
| 79 | + {{else}} |
| 80 | + {{#equals @root.httpClient 'angular'}} |
| 81 | + public {{{name}}}({{>parameters}}): Observable<{{>result}}> { |
| 82 | + return __request(OpenAPI, this.http, { |
| 83 | + {{else}} |
| 84 | + public static {{{name}}}({{>parameters}}): CancelablePromise<{{>result}}> { |
| 85 | + return __request(OpenAPI, { |
| 86 | + {{/equals}} |
| 87 | + {{/if}} |
| 88 | + method: '{{{method}}}', |
| 89 | + url: '{{{path}}}', |
| 90 | + {{#if parametersPath}} |
| 91 | + path: { |
| 92 | + {{#each parametersPath}} |
| 93 | + '{{{prop}}}': {{{name}}}, |
| 94 | + {{/each}} |
| 95 | + }, |
| 96 | + {{/if}} |
| 97 | + {{#if parametersCookie}} |
| 98 | + cookies: { |
| 99 | + {{#each parametersCookie}} |
| 100 | + '{{{prop}}}': {{{name}}}, |
| 101 | + {{/each}} |
| 102 | + }, |
| 103 | + {{/if}} |
| 104 | + {{#if parametersHeader}} |
| 105 | + headers: { |
| 106 | + {{#each parametersHeader}} |
| 107 | + '{{{prop}}}': {{{name}}}, |
| 108 | + {{/each}} |
| 109 | + }, |
| 110 | + {{/if}} |
| 111 | + {{#if parametersQuery}} |
| 112 | + query: { |
| 113 | + {{#each parametersQuery}} |
| 114 | + '{{{prop}}}': {{{name}}}, |
| 115 | + {{/each}} |
| 116 | + }, |
| 117 | + {{/if}} |
| 118 | + {{#if parametersForm}} |
| 119 | + formData: { |
| 120 | + {{#each parametersForm}} |
| 121 | + '{{{prop}}}': {{{name}}}, |
| 122 | + {{/each}} |
| 123 | + }, |
| 124 | + {{/if}} |
| 125 | + {{#if parametersBody}} |
| 126 | + {{#equals parametersBody.in 'formData'}} |
| 127 | + formData: {{{parametersBody.name}}}, |
| 128 | + {{/equals}} |
| 129 | + {{#equals parametersBody.in 'body'}} |
| 130 | + body: {{{parametersBody.name}}}, |
| 131 | + {{/equals}} |
| 132 | + {{#if parametersBody.mediaType}} |
| 133 | + mediaType: '{{{parametersBody.mediaType}}}', |
| 134 | + {{/if}} |
| 135 | + {{/if}} |
| 136 | + {{#if responseHeader}} |
| 137 | + responseHeader: '{{{responseHeader}}}', |
| 138 | + {{/if}} |
| 139 | + {{#if errors}} |
| 140 | + errors: { |
| 141 | + {{#each errors}} |
| 142 | + {{{code}}}: `{{{escapeDescription description}}}`, |
| 143 | + {{/each}} |
| 144 | + }, |
| 145 | + {{/if}} |
| 146 | + }); |
| 147 | + } |
| 148 | + |
| 149 | + {{/each}} |
| 150 | +} |
0 commit comments