@@ -204,32 +204,59 @@ class CodeGenProcess {
204
204
}
205
205
206
206
getRenderTemplateData = ( ) => {
207
+ const { schemaParserFabric } = this ;
208
+ const { schemaFormatters } = schemaParserFabric ;
207
209
return {
208
210
utils : {
209
211
Ts : this . config . Ts ,
210
212
formatDescription :
211
- this . schemaParserFabric . schemaFormatters . formatDescription ,
213
+ schemaParserFabric . schemaFormatters . formatDescription . bind (
214
+ schemaFormatters ,
215
+ ) ,
212
216
internalCase : internalCase ,
213
217
classNameCase : pascalCase ,
214
218
pascalCase : pascalCase ,
215
- getInlineParseContent : this . schemaParserFabric . getInlineParseContent ,
216
- getParseContent : this . schemaParserFabric . getParseContent ,
217
- getComponentByRef : this . schemaComponentsMap . get ,
218
- parseSchema : this . schemaParserFabric . parseSchema ,
219
- checkAndAddNull : this . schemaParserFabric . schemaUtils . safeAddNullToType ,
219
+ getInlineParseContent :
220
+ schemaParserFabric . getInlineParseContent . bind ( schemaParserFabric ) ,
221
+ getParseContent :
222
+ schemaParserFabric . getParseContent . bind ( schemaParserFabric ) ,
223
+ getComponentByRef : this . schemaComponentsMap . get . bind (
224
+ this . schemaComponentsMap ,
225
+ ) ,
226
+ parseSchema : schemaParserFabric . parseSchema . bind ( schemaParserFabric ) ,
227
+ checkAndAddNull : schemaParserFabric . schemaUtils . safeAddNullToType . bind (
228
+ schemaParserFabric . schemaUtils ,
229
+ ) ,
220
230
safeAddNullToType :
221
- this . schemaParserFabric . schemaUtils . safeAddNullToType ,
231
+ schemaParserFabric . schemaUtils . safeAddNullToType . bind (
232
+ schemaParserFabric . schemaUtils ,
233
+ ) ,
222
234
isNeedToAddNull :
223
- this . schemaParserFabric . schemaUtils . isNullMissingInType ,
224
- inlineExtraFormatters : this . schemaParserFabric . schemaFormatters . inline ,
225
- formatters : this . schemaParserFabric . schemaFormatters . base ,
226
- formatModelName : this . typeNameFormatter . format ,
235
+ schemaParserFabric . schemaUtils . isNullMissingInType . bind (
236
+ schemaParserFabric . schemaUtils ,
237
+ ) ,
238
+ inlineExtraFormatters : Object . keys ( schemaFormatters . inline ) . reduce (
239
+ ( prev , each ) => {
240
+ return ( prev [ each ] =
241
+ schemaFormatters . inline [ each ] . bind ( schemaFormatters ) ) ;
242
+ } ,
243
+ { } ,
244
+ ) ,
245
+ formatters : Object . keys ( schemaFormatters . base ) . reduce ( ( prev , each ) => {
246
+ return ( prev [ each ] =
247
+ schemaFormatters . base [ each ] . bind ( schemaFormatters ) ) ;
248
+ } , { } ) ,
249
+ formatModelName : this . typeNameFormatter . format . bind (
250
+ this . typeNameFormatter ,
251
+ ) ,
227
252
fmtToJSDocLine : function fmtToJSDocLine ( line , { eol = true } ) {
228
253
return ` * ${ line } ${ eol ? "\n" : "" } ` ;
229
254
} ,
230
255
NameResolver : NameResolver ,
231
256
_,
232
- require : this . templatesWorker . requireFnFromTemplate ,
257
+ require : this . templatesWorker . requireFnFromTemplate . bind (
258
+ this . templatesWorker ,
259
+ ) ,
233
260
} ,
234
261
config : this . config ,
235
262
} ;
0 commit comments