@@ -111,7 +111,8 @@ export function generateClient({
111111 responseBinaryType,
112112 binaryTypes,
113113 jsDocRenderConfig,
114- commentsConfig
114+ commentsConfig,
115+ deprecatedOperations
115116} : {
116117 commonHttpClientClassName : string ;
117118 commonHttpClientClassOptionsName : string ;
@@ -132,6 +133,7 @@ export function generateClient({
132133 binaryTypes : OpenApiClientCustomizableBinaryType [ ] ;
133134 jsDocRenderConfig : JsDocRenderConfig ;
134135 commentsConfig : CommentsRenderConfig ;
136+ deprecatedOperations : { [ methodAndPath : string ] : string } ;
135137} ) : ClientGenerationResultFile {
136138 const clientPropertyName = 'client' ;
137139 const commonHttpClientImportName = 'commonHttpClient' ;
@@ -156,22 +158,48 @@ export function generateClient({
156158 )
157159 ) ;
158160
161+ const generatedMethods = generateOperationMethods ( {
162+ paths,
163+ commonHttpClientImportName,
164+ operationImportPath : clientImportPath ,
165+ operationsConfig,
166+ getModelData,
167+ validationContext,
168+ binaryTypes,
169+ jsDocRenderConfig
170+ } ) ;
171+
172+ const clientConstructorOptionsObject = objectExpression ( [
173+ objectProperty ( identifier ( 'baseUrl' ) , stringLiteral ( baseUrl ?? servers [ 0 ] ?. url ?? defaultServerUrl ) ) ,
174+ objectProperty ( identifier ( 'binaryResponseType' ) , stringLiteral ( responseBinaryType ) ) ,
175+ objectProperty ( identifier ( 'errorClass' ) , identifier ( errorTypeName ) )
176+ ] ) ;
177+
178+ const deprecatedOperationsTotal = {
179+ ...deprecatedOperations ,
180+ ...generatedMethods . deprecatedOperations
181+ } ;
182+
183+ if ( operationsConfig ?. showDeprecatedWarnings && Object . keys ( deprecatedOperationsTotal ) . length > 0 ) {
184+ clientConstructorOptionsObject . properties . push (
185+ objectProperty (
186+ identifier ( 'deprecatedOperations' ) ,
187+ objectExpression (
188+ Object . entries ( deprecatedOperationsTotal ) . map ( ( [ methodAndPath , operationName ] ) =>
189+ objectProperty ( stringLiteral ( methodAndPath ) , stringLiteral ( operationName ) )
190+ )
191+ )
192+ )
193+ ) ;
194+ }
195+
159196 const clientClassBody = classBody ( [
160197 makeProtected (
161198 classProperty (
162199 identifier ( clientPropertyName ) ,
163200 newExpression (
164201 memberExpression ( identifier ( commonHttpClientImportName ) , identifier ( commonHttpClientClassName ) ) ,
165- [
166- objectExpression ( [
167- objectProperty (
168- identifier ( 'baseUrl' ) ,
169- stringLiteral ( baseUrl ?? servers [ 0 ] ?. url ?? defaultServerUrl )
170- ) ,
171- objectProperty ( identifier ( 'binaryResponseType' ) , stringLiteral ( responseBinaryType ) ) ,
172- objectProperty ( identifier ( 'errorClass' ) , identifier ( errorTypeName ) )
173- ] )
174- ]
202+ [ clientConstructorOptionsObject ]
175203 )
176204 )
177205 ) ,
@@ -242,16 +270,6 @@ export function generateClient({
242270 const optionsTypeStatement =
243271 exportOptionsType === false ? optionsTypeDeclaration : exportNamedDeclaration ( optionsTypeDeclaration ) ;
244272
245- const generatedMethods = generateOperationMethods ( {
246- paths,
247- commonHttpClientImportName,
248- operationImportPath : clientImportPath ,
249- operationsConfig,
250- getModelData,
251- validationContext,
252- binaryTypes,
253- jsDocRenderConfig
254- } ) ;
255273 clientClassBody . body . push ( ...generatedMethods . methods ) ;
256274 extendDependencyImports ( dependencyImports , generatedMethods . dependencyImports ) ;
257275 clientClassBody . body . push (
0 commit comments