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

Pimp my ride

Open revmischa opened this issue 7 years ago • 6 comments

Yo dawg we got API endpoints that document themselves and a CORS plugin in the trunk you gonna love We're using yarn cause npm is played out Kicking that old python 2 nonsense to the curb And it comes pre-loaded with a swagger GUI thats fresher than a lemonade stand

Also: most people don't need to dockerize pip and if they do they know they do and can edit the config in serverless.yml.

pimpmyride

revmischa avatar Nov 09 '18 18:11 revmischa

I opened a PR to fix the swagger paths when it's running under /dev, /prod, etc https://github.com/jmcarp/flask-apispec/pull/125/files

revmischa avatar Nov 10 '18 08:11 revmischa

Hey @revmischa, thanks for the PR. Lots of good stuff here.

I do think it's a little more opinionated than I want for this template. Not everyone will want an OpenAPI. I also think that some people will want a choice between Python2 and Python3. As for dockerizing pip, the reason is if you use packages that need to compile C extensions, like SQLAlchemy or some of the data science stack. I'd rather that be baked in pretty easily rather than have people search for workarounds. As for yarn vs npm, I'm pretty indifferent given that it's a pretty small part of the project.

Given that, I think I'd prefer to keep this template more generic. If there are certain changes that are more generic, I'm happy to take those. For a more opinionated template around OpenAPI, it'd probably be best to create your own fork or start from scratch.

Let me know if you have any questions or would like to discuss!

alexdebrie avatar Nov 18 '18 22:11 alexdebrie

That's all fair.

I'm looking into options now for GraphQL which would obviate the need for OpenAPI.

People should be discouraged from using python 2 IMO

revmischa avatar Nov 19 '18 07:11 revmischa

I restored the docker question. Using OpenAPI isn't very opinionated because you don't actually have to do anything. It just comes free as a bonus if you're already using marshmallow. Marshmallow is pretty essential to most kinds of APIs, and I figure you aren't making a server-side template driven web application if you're making a serverless app. That was just my thinking anyway. OpenAPI comes for free so why not add it, and codegen comes free with OpenAPI so why not add that option too.

revmischa avatar Nov 21 '18 21:11 revmischa

Thanks @revmischa (and @alexdebrie!) this is super helpful and really exciting!

@revmischa, this branch is currently not working({"message": "Internal server error"}). There seems to be some sort of problem with the fixed flask_apispec missing the 'openapi_version' for the MarshmallowPlugin (when I used venv). When I changed requirements.txt to use the latest version of flask_apispec, then it worked locally and loaded on AWS but OpenAPI was not curling the AWS /dev/ path but instead /api/ (without the /dev/ prefix).

Also, the services are all showing up as '/undefined' in the Serverless dashboard. I am not sure how to fix that.

If you have any suggestions on how to fix those issues I would be very grateful for a response. Cheers!

seanpue avatar Aug 05 '19 00:08 seanpue

Oh this is super old. I've been developing this instead, based off the idea of this repo: https://github.com/jetbridge/sls-flask/

revmischa avatar Aug 05 '19 06:08 revmischa