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

include schema property in route object #93

Closed
matthyk opened this issue Jan 21, 2024 · 5 comments
Closed

include schema property in route object #93

matthyk opened this issue Jan 21, 2024 · 5 comments

Comments

@matthyk
Copy link
Contributor

matthyk commented Jan 21, 2024

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

return {
method: routeOpts.method,
url: routeOpts.url,
prefix: routeOpts.prefix,
hooks
}

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
Copy link
Owner

Eomm commented Jan 27, 2024

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:

  • debug the application low-lever structure
  • provide a solid data structure that can be visualized

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
Copy link
Contributor Author

matthyk commented Jan 27, 2024

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
Copy link
Owner

Eomm commented Jan 27, 2024

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
Copy link
Contributor Author

matthyk commented Jan 27, 2024

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
Copy link
Contributor Author

matthyk commented Feb 4, 2024

Closed with #96

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants