Eomm / fastify-overview

Build a structure graph of your Fastify application
MIT License
64 stars 6 forks source link

include schema property in route object #93

Closed matthyk closed 5 months ago

matthyk commented 5 months ago

Currently the route object only contains the method, url, prefix and the hooks.

https://github.com/Eomm/fastify-overview/blob/140b0ee77c7ac3d6b06a5485337382ec3a4d9244/lib/utils.js#L37-L42

Maybe we can provide a plugin option to optionally get the route schema. Another idea would be, for example, to give a function as a plugin option that transforms the routeOptions object. This would give the user complete control over what is contained in the route object.

Eomm commented 5 months ago

Maybe we can provide a plugin option to optionally get the route schema

TBH I can't see the PRO on this feature. This plugin is intended to:

The schemas do not have a constant structure, if a dev customizes the schemaController, schemas are not a JSON too, so it would create caos to use the returned data-structure.

Another idea would be, for example, to give a function as a plugin option that transforms the routeOptions object

That indeed is a generic approach that could be useful tho, and if users want the schema (whatever format it is) they could implement by themself

matthyk commented 5 months ago

Are you open for a PR for the second approach? Maybe my usecase for this Feature is helpful: I want to use this Plugin to go through my Fastify Application and generate test cases for routes and decorators. To generate valid route test cases I need the validation schemas of the routes

Eomm commented 5 months ago

Are you open for a PR for the second approach?

Sure

I want to use this Plugin to go through my Fastify Application and generate test cases for routes and decorators

Wow, I would like to see it in action! Did not think about this use case

matthyk commented 5 months ago

Happy to ping you if I have a prototype! I think it could even be a nice feature for the fastify-cli like fastify generate-test-cases

matthyk commented 5 months ago

Closed with #96