Falcon - how to validate incoming requests against Swagger specification?
Asked Answered
O

0

7

What is the most convenient and comprehensive way of validating incoming requests in Falcon views against Swagger 2.0 specification written in json?

I used to do the same for Pyramid apps with great tool called pyramid_swagger. It was seamlessly pluggable on application level and it attached validated dict to the request object. It contained everything, including path parameters, querystring parameters and of course body params.

I tried Flex and falcon-json-io, but couldn't make it do what I need. Also serve_swagger is completely different story, I don't need an autogenerated API.

At this point I am considering writing my own tool or extending Flex or falcon-json-io. Is there something I missed?

Oldline answered 30/7, 2016 at 10:0 Comment(7)
Hi, how do you generate swagger documentation for your api written in falcon?Hay
@AyushiDalmia I don't. I write it myself with consultation with the end user of future API. In my case I do it together with our front-end developers. To generate Swagger docs would mean that it's generated from something. What would that be? A whiteboard after product meeting? :) My point is that you need to document API before implementing it. At least that's my opinion.Oldline
Gotcha! I used editor.swagger.io/# and generated my json file. However, I am not able to integrate well with the index.html in the dist folder of the Swagger-UI repo. Any pointers on how to add the json? Through url or spec?Hay
I don't use Swagger UI yet. You should search for answers or post a new question if you cannot find anything appropriate.Oldline
In case anyone is looking for an answer, I have put together a small lib that does it: github.com/gwaramadze/falguardOldline
@gwaramadze Your library should be an answer.Enriqueenriqueta
@AlisterLee hey thanks! It actually was, but local "bureaucracy" got it deleted...Oldline

© 2022 - 2024 — McMap. All rights reserved.