MCPcopy Create free account
hub / github.com/fastify/fastify / setSerializerCompiler

Method setSerializerCompiler

lib/schema-controller.js:97–117  ·  view source on GitHub ↗
(serializerCompiler)

Source from the content-addressed store, hash-verified

95 }
96
97 setSerializerCompiler (serializerCompiler) {
98 // Set up as if the fixed serializer compiler had been provided
99 // by a custom 'options.compilersFactory.buildSerializer' that
100 // always returns the same compiler object. This is required because:
101 //
102 // - setSerializerCompiler must immediately install a compiler to preserve
103 // legacy behavior
104 // - setupSerializer will recreate compilers from builders in some
105 // circumstances, so we have to install this adapter to make it
106 // behave the same if the legacy API is used
107 //
108 // The cloning of the compilersFactory object is necessary because
109 // we are aliasing the parent compilersFactory if none was provided
110 // to us (see constructor.)
111 this.compilersFactory = Object.assign(
112 {},
113 this.compilersFactory,
114 { buildSerializer: () => serializerCompiler })
115 this.serializerCompiler = serializerCompiler
116 this.isCustomSerializerCompiler = true
117 }
118
119 getValidatorCompiler () {
120 return this.validatorCompiler || (this.parent && this.parent.getValidatorCompiler())

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected