Meta endpoint to retrieve validation rules #5348
Unanswered
balexandre
asked this question in
Ideas
Replies: 1 comment
-
I have done this in the past. The general idea is to:
'use strict';
module.exports = function getSchema(req, res) {
const { schemaId } = req.params;
const schema = this.schemas.getSchema(schemaId, true);
res.success(schema);
}; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm new to Fastify, and to help the client side (both web and mobile) I've been wondering if we could have a plugin that would automagically create an endpoint for metadata regarding the validation rules of the endpoint
meaning that, what's I'm after is to help the client side to have the data for validation, for example, if the schema is something like
I would love to have a reply to a "automagically" created endpoint that would output something like
the "automatically" routes could be something like:
if
POST /expenses
exist, then a new routeGET /expenses/meta
would be created, same forPATCH
andPUT
sthat way, the client side, could use it for client-side-validation and use enums to fill dropdown for example, not depending on hardcoded values, and they could safely change when the API changes
I found this plugin https://github.com/fastify/fastify-response-validation but it's not exactly what I was looking for...
Beta Was this translation helpful? Give feedback.
All reactions