Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mutualise compilation of OpenAPI schemas #118

Open
6 tasks
nfroidure opened this issue Sep 25, 2021 · 0 comments
Open
6 tasks

Mutualise compilation of OpenAPI schemas #118

nfroidure opened this issue Sep 25, 2021 · 0 comments
Assignees
Labels
enhancement performance Performance concern

Comments

@nfroidure
Copy link
Owner

nfroidure commented Sep 25, 2021

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:

  • 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
@nfroidure nfroidure changed the title Fully support internal refs of OpenAPI Mutualise compilation of OpenAPI schemas Mar 1, 2024
@nfroidure nfroidure added the performance Performance concern label Mar 1, 2024
@nfroidure nfroidure self-assigned this Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement performance Performance concern
Projects
None yet
Development

No branches or pull requests

1 participant