It basically de-references all the $refs that the router would not handle by its own. Best would be to not have to do this and instead get the router to cleanly handle those refs.
The schema may not be compiled upfront (maybe check AJVs options) but those reusable components could probably:
parameters
responses
requestBodies
headers
In a more general manner, replacing the WhookRawOperation type by either : just the route operationId for the http-router or the openapi file reduced in order to be valid but scoped to the operationid openapi file for the aws lambdas/gcp functions would probably be the more wide usable and generic way to handle the parameters handling of the routes.
Technical tasks
[ ] split code that compile parameters / responses / requestBodies / headers schemas into separate functions
[ ] create a schemaValidator service that take care of every validation concern (isolation principle)
[ ] eventually take advantage of Ajv compilation at build time ( https://ajv.js.org/standalone.html ) to substitue the schemaValidation service by compiled built at build time
[ ] try to mutualize code / resources between common schemas included in other schemas (not sur Ajv can atm)
[ ] eventually see what can be done with src/commands files too
[ ] change siso to take validators instead of sechamas in input to allow to use ajv for validation
Currently, we are doing some ugly hacks to properly handle the OpenAPI files due to some legacy in the HTTP router. Most of it is done here: https://github.com/nfroidure/whook/blob/master/packages/whook-http-router/src/libs/openAPIUtils.ts#L108-L257
It basically de-references all the $refs that the router would not handle by its own. Best would be to not have to do this and instead get the router to cleanly handle those refs.
It would make the overhaul more memory efficient (no duplication) and the first boot would be more perfomant. It would also allow to simplify the AWS Lambda / GCP Functions builds done here: https://github.com/nfroidure/whook/blob/master/packages/whook-aws-lambda/src/services/_autoload.ts#L74-L117
It will also help to avoid having to merge parameters here: https://github.com/nfroidure/whook/blob/master/packages/whook-http-router/src/libs/openAPIUtils.ts#L87-L88
The schema may not be compiled upfront (maybe check AJVs options) but those reusable components could probably:
In a more general manner, replacing the
WhookRawOperation
type by either : just the route operationId for thehttp-router
or the openapi file reduced in order to be valid but scoped to the operationid openapi file for the aws lambdas/gcp functions would probably be the more wide usable and generic way to handle the parameters handling of the routes.Technical tasks
schemaValidator
service that take care of every validation concern (isolation principle)Ajv
compilation at build time ( https://ajv.js.org/standalone.html ) to substitue theschemaValidation
service by compiled built at build timesrc/commands
files tooajv
for validation