@@ -204,32 +204,60 @@ 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 (
221
+ schemaParserFabric ,
222
+ ) ,
223
+ getParseContent : schemaParserFabric . getParseContent . bind (
224
+ schemaParserFabric ,
225
+ ) ,
226
+ getComponentByRef : this . schemaComponentsMap . get . bind (
227
+ this . schemaComponentsMap ,
228
+ ) ,
229
+ parseSchema : schemaParserFabric . parseSchema . bind (
230
+ schemaParserFabric ,
231
+ ) ,
232
+ checkAndAddNull :
233
+ schemaParserFabric . schemaUtils . safeAddNullToType . bind (
234
+ schemaParserFabric . schemaUtils ,
235
+ ) ,
220
236
safeAddNullToType :
221
- this . schemaParserFabric . schemaUtils . safeAddNullToType ,
237
+ schemaParserFabric . schemaUtils . safeAddNullToType . bind (
238
+ schemaParserFabric . schemaUtils ,
239
+ ) ,
222
240
isNeedToAddNull :
223
- this . schemaParserFabric . schemaUtils . isNullMissingInType ,
224
- inlineExtraFormatters : this . schemaParserFabric . schemaFormatters . inline ,
225
- formatters : this . schemaParserFabric . schemaFormatters . base ,
226
- formatModelName : this . typeNameFormatter . format ,
241
+ schemaParserFabric . schemaUtils . isNullMissingInType . bind (
242
+ schemaParserFabric . schemaUtils ,
243
+ ) ,
244
+ inlineExtraFormatters : Object . keys ( schemaFormatters . inline ) . reduce ( ( prev , each ) => {
245
+ return prev [ each ] = schemaFormatters . inline [ each ] . bind ( schemaFormatters )
246
+ } , { } ) ,
247
+ formatters : Object . keys ( schemaFormatters . base ) . reduce ( ( prev , each ) => {
248
+ return prev [ each ] = schemaFormatters . base [ each ] . bind ( schemaFormatters )
249
+ } , { } ) ,
250
+ formatModelName : this . typeNameFormatter . format . bind (
251
+ this . typeNameFormatter ,
252
+ ) ,
227
253
fmtToJSDocLine : function fmtToJSDocLine ( line , { eol = true } ) {
228
254
return ` * ${ line } ${ eol ? "\n" : "" } ` ;
229
255
} ,
230
256
NameResolver : NameResolver ,
231
257
_,
232
- require : this . templatesWorker . requireFnFromTemplate ,
258
+ require : this . templatesWorker . requireFnFromTemplate . bind (
259
+ this . templatesWorker ,
260
+ ) ,
233
261
} ,
234
262
config : this . config ,
235
263
} ;
0 commit comments