File tree Expand file tree Collapse file tree 2 files changed +15
-13
lines changed Expand file tree Collapse file tree 2 files changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ class Response extends Writable {
2121 this . master_context = route . app
2222 this . app_options = route . app . _options
2323
24- this . decorators = route . requestDecorators
24+ this . decorators = route . responseDecorators
2525
2626 this . locals = { }
2727
Original file line number Diff line number Diff line change @@ -281,20 +281,22 @@ class Server extends Router {
281281 // Mark route as temporary if specified from options
282282 if ( record . options . _temporary === true ) route . _temporary = true
283283
284- // JSON Schema validators
284+ // JSON Schema validation
285285 if ( record . options . has ( 'schema' ) ) {
286286 const schema = record . options . get ( 'schema' )
287- if ( schema . request ) {
288- route . setRequestDecorator ( {
289- name : 'JSONParse' ,
290- fn : this . ajv . compileParser ( schema . request )
291- } )
292- }
293- if ( schema . response ) {
294- route . setResponseDecorator ( {
295- name : 'JSONSerialize' ,
296- fn : this . ajv . compileSerializer ( schema . response )
297- } )
287+ if ( typeof schema === 'object' ) {
288+ if ( typeof schema . request === 'object' ) {
289+ route . setRequestDecorator ( {
290+ name : 'JSONParse' ,
291+ fn : this . ajv . compileParser ( schema . request )
292+ } )
293+ }
294+ if ( typeof schema . response === 'object' ) {
295+ route . setResponseDecorator ( {
296+ name : 'JSONSerialize' ,
297+ fn : this . ajv . compileSerializer ( schema . response )
298+ } )
299+ }
298300 }
299301 }
300302
You can’t perform that action at this time.
0 commit comments