I’m trying to build a Pyramid equivalent to flask-apispec. I’d like to attach a schema to a view (marshmallow is the schema library I’m using) to validate the return value of the view and marshal it into something more readily JSON serializable.
My first thought was to use a view deriver, but calling the view outputs a fully-formed Response object, so that’s a no-go. I looked at using a view mapper, but I’m not sure I want to mess with Pyramid’s default mapper. I tried utilizing the BeforeRender hook, but that doesn’t offer a way to replace the dictionary being passed into the renderer. I could hack it by emptying the dictionary and inserting the new keys. I considered building a custom renderer, but I can’t figure how I’d pass the schema into it. I could also just use a vanilla decorator, but that covers up the view call signature. Not the end of the world, so this is looking like the best option so far. Any suggestions on the best way to achieve this? — Theron -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+unsubscr...@googlegroups.com. To post to this group, send email to pylons-discuss@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/A7342B9B-4824-468A-991E-F7FC46699077%40luhn.com. For more options, visit https://groups.google.com/d/optout.