flask-raml icon indicating copy to clipboard operation
flask-raml copied to clipboard

Simplest Example Possible

Open mpetyx opened this issue 10 years ago • 5 comments

Hey! I really like raml, and I love flask! I just stumbled upon this project and I would like to start using it. The way I understood it, having a raml file I can have a simple server like osprey does but for python.. Right? If you could provide a super small example of usage or some basic walkthrough I would like to use or contribute to this library. Cheers, Michael.

mpetyx avatar Oct 02 '15 15:10 mpetyx

+1

I'm starting to work with RAML for an application using Flask-RESTful, and am looking at integration options.

freddrake avatar Oct 08 '15 20:10 freddrake

I agree, a very simple practical example would be invaluable.

wasade avatar Nov 04 '15 16:11 wasade

+1

astewart-twist avatar Nov 06 '15 22:11 astewart-twist

Will try to do find time for a basic sample around the end of year.

For now, what about very basic:

from flask.ext.raml import API

api = API(app, path='static/docs/api/api.yaml')
   # generate an all-inclusive yaml with gulp apiyaml task https://gist.github.com/iki/784ddd5ab33c1e1b726b 

@api.route('/my/route/path/1', 'post')
def handler(id):
  if not data:
    api.abort(404, 'id does not exist');
  return dict(received=True)

from handlers import handler2
api.add_route('/my/route/path/2', handler2)

More info on route params in source for now.

cc @mpetyx @freddrake @wasade @astewart-twist

iki avatar Nov 18 '15 19:11 iki

This does not do any kind of payload validation, does it?

s0undt3ch avatar May 26 '16 22:05 s0undt3ch