Open jenstroeger opened 6 years ago
We ended up using the get_services()
function, which returns a service
object. Then use service.name
and service.definitions
, where the definitions contain the method, view, args = definition
with arguments args
to the view handlers of the service, and args["schema"]
then is the Colander schema object.
I’m trying to find a good way of handling request (and maybe response) schemas for the routes registered by the Cornice services.
Considering that every
Service()
registers an endpoint, and that decorated functions then supply the request validator and view implementation for that endpoint:it would make sense to fetch the request schema for a view from right here. In fact, Cornice now supports Marshmallow schemas which can return a JSON Schema version for a data schema.
So my question: is there a good way to return the schema for a given view handler function, perhaps using Pyramid introspection? For example: