express-openapi-validator icon indicating copy to clipboard operation
express-openapi-validator copied to clipboard

Use OpenAPIValidator request ajv out of OpenAPI usage (websocket...)

Open pilerou opened this issue 3 years ago • 3 comments

Is your feature request related to a problem? Please describe. It could be great to use OpenAPIValidator mecanism to generate an AJV object and use it outside of an OpenAPI and Express usage. Users could have the guarantee that validation and transformation (serdes) are the same in their OpenAPI usage and when they validate a JSON. For example, it would be possible to develop a new module that plugin on express-openapi-validator and that uses his request AJV in order to validate request received from Websocket. I could develop a new module for that with socket.io.

Describe the solution you'd like In addition to middleware function, we would have a new ajv function in OpenAPIValidator. This function could use the same init mecanism and return request AJV. Then this AJV could be used by client.

I developed it. I'm going to add a pull request for that and I'll be able to change some things with your recommandations.

Describe alternatives you've considered As initialization return a list of express middleware and not objects that can be called, I don't see a lot of other ways to do that.

pilerou avatar Dec 24 '21 09:12 pilerou

Hi @cdimascio Do you think this feature could be interesting in order to use the same validations and transformations as OpenAPI Rest with other channels (Socket...) ? I already developed a generic module (with sociket.io), I could share next to this project but using it as dependency. It would enhance this project ecosystem.

My PR #685 is out of date but I can create a new branch based on your master and add the feature.

Leading this project and its roadmap must be time consuming. When you feel, it can be inserted in the roadmap, you can ask me and I'll make the changes in a new PR.

pilerou avatar Aug 23 '22 07:08 pilerou

Hi @cdimascio If you also think it can be interesting and if it can be integrated to the roadmap, I can update my branch and the PR.

pilerou avatar Mar 15 '23 08:03 pilerou

This is interesting. If we can build it as a reusable module that both web apis i.e the existing middleware and sockets use, I'm all for it. Such an approach can help to enable other web frameworks as well.

This may be worth a conversation outside this comment thread. Please reach out over email or DM on Twitter. Let's set up some time to chat

cdimascio at gmail.com @CarmineDiMascio

cdimascio avatar Mar 21 '23 23:03 cdimascio