From 74b4bd1c26911548771171c87d32d2ab49bc8971 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Fri, 9 Nov 2018 18:30:21 +0200 Subject: [PATCH 01/16] use apispec, swagger, py3 --- README.md | 6 +- api/__init__.py | 1 + api/index.py | 15 ++++ app.py | 28 ++++++- package.json | 1 + postsetup.js | 21 +----- requirements.txt | 12 +-- serverless.yml | 5 +- templates/index.html | 176 ------------------------------------------- tox.ini | 3 + 10 files changed, 61 insertions(+), 207 deletions(-) create mode 100644 api/__init__.py create mode 100644 api/index.py delete mode 100644 templates/index.html create mode 100644 tox.ini diff --git a/README.md b/README.md index f5c01fb..ad8d654 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,9 @@ The fastest way to a Flask application with [Serverless](https://github.com/serv ## Usage ``` -$ npm install -g serverless -$ serverless install --url https://github.com/alexdebrie/serverless-flask --name my-flask-app -$ cd my-flask-app && npm run setup +$ yarn global install serverless +$ sls install --url https://github.com/revmischa/serverless-flask --name my-flask-app +$ cd my-flask-app && yarn setup $ serverless deploy ``` diff --git a/api/__init__.py b/api/__init__.py new file mode 100644 index 0000000..e23d45d --- /dev/null +++ b/api/__init__.py @@ -0,0 +1 @@ +"""API endpoints.""" diff --git a/api/index.py b/api/index.py new file mode 100644 index 0000000..63db25a --- /dev/null +++ b/api/index.py @@ -0,0 +1,15 @@ +from flask_apispec import use_kwargs, marshal_with +from marshmallow import Schema, fields +from app import app + + +class IndexSchema(Schema): + name = fields.Str(required=False) + + +@app.route('/api/', methods=['POST']) +@use_kwargs(IndexSchema) +@marshal_with(IndexSchema) +def api_index(name: str = None): + """Main API endpoint.""" + return {'name': f'you entered {name}'} diff --git a/app.py b/app.py index 6b2d107..6997afc 100644 --- a/app.py +++ b/app.py @@ -1,11 +1,35 @@ -from flask import Flask, render_template +"""Lambda entry point.""" +from flask import Flask, redirect, url_for +from flask_cors import CORS +from apispec.ext.marshmallow import MarshmallowPlugin +from flask_apispec.extension import FlaskApiSpec +from apispec import APISpec +from flask_apispec import use_kwargs, marshal_with # noqa: F401 +from marshmallow import Schema, fields # noqa: F401 + +# create app app = Flask(__name__) +CORS(app) +app.config.update({ + 'APISPEC_SPEC': APISpec( + title="Serverless API", + version='1.0', + plugins=[MarshmallowPlugin()], + ), + 'APISPEC_SWAGGER_URL': '/swagger/', +}) +docs = FlaskApiSpec(app) +from api import index + @app.route("/") def main(): - return render_template('index.html') + """Index page.""" + return redirect(url_for('api_index', name="mischa")) + +docs.register_existing_resources() if __name__ == "__main__": app.run() diff --git a/package.json b/package.json index 9b51b99..6e702bf 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "chalk": "^2.1.0", "inquirer": "^3.2.3", "js-yaml": "^3.9.1", + "serverless-domain-manager": "^2.6.6", "serverless-python-requirements": "^2.5.0", "serverless-wsgi": "^1.3.0" } diff --git a/postsetup.js b/postsetup.js index 69cbef8..0fe3a08 100644 --- a/postsetup.js +++ b/postsetup.js @@ -9,21 +9,6 @@ var fs = require('fs'); console.log(chalk.yellow('Hi, a few quick questions before we start:')); var questions = [ - { - type: 'list', - name: 'python', - message: 'What Python version?', - choices: ['python2.7', 'python3.6'], - filter: function (val) { - return val.toLowerCase(); - } - }, - { - type: 'confirm', - name: 'docker', - message: 'Do you have Docker installed? Recommended, but not required.', - default: true - }, { type: 'confirm', name: 'wantsDomain', @@ -41,10 +26,10 @@ var questions = [ ] inquirer.prompt(questions).then(function (answers) { - + var doc = YAML.safeLoad(fs.readFileSync('serverless.yml', 'utf8')); - doc.custom.pythonRequirements.dockerizePip = answers.docker; - doc.provider.runtime = answers.python; + doc.custom.pythonRequirements.dockerizePip = False; + doc.provider.runtime = 'python3.6'; if (answers.wantsDomain) { doc.plugins.push('serverless-domain-manager'); doc.custom.customDomain = createCustomDomain(answers.domainName); diff --git a/requirements.txt b/requirements.txt index 6aee249..1c5206f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ -click==6.7 -Flask==0.12.2 -itsdangerous==0.24 -Jinja2==2.9.6 -MarkupSafe==1.0 -Werkzeug==0.12.2 +Flask +flask_cors +boto3 +flask_apispec +apispec +marshmallow diff --git a/serverless.yml b/serverless.yml index 90e600b..ec10e41 100644 --- a/serverless.yml +++ b/serverless.yml @@ -3,6 +3,7 @@ service: serverless-flask plugins: - serverless-python-requirements - serverless-wsgi + - serverless-domain-manager custom: wsgi: @@ -18,9 +19,9 @@ package: provider: name: aws - runtime: python2.7 + runtime: python3.6 stage: dev - region: us-east-1 + region: eu-central-1 functions: app: diff --git a/templates/index.html b/templates/index.html deleted file mode 100644 index 6a6174e..0000000 --- a/templates/index.html +++ /dev/null @@ -1,176 +0,0 @@ - - - - - - - Serverless Flask App - - - - - - -
-
- -

🐍 Serverless Flask

-
-
-

Congrats on deploying your Flask App 🎉

-

- There are many things you can build with Serverless & Python. The limit is your imagination! -

-

- Here are a couple places we recommend starting: -

-
    -
  1. Set a custom domain
  2. -
  3. Add a DynamoDB table
  4. -
  5. Use secret variables
  6. -
-
-
-

- This project is powered by - -

-
-
-
-

Serverless WSGI:

-

Deploy WSGI apps to AWS Lambda
Read More

-
-
-

Serverless Python Requirements:

-

Utility for compiling Python libs with your functions
Read More

-
-
-
-

© Serverless 2017

-
-
- - - diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..048719d --- /dev/null +++ b/tox.ini @@ -0,0 +1,3 @@ +[flake8] +ignore = E402,E305,E501,I201,I101,I100,D204,D101 +max-line-length = 160 From 202f459dcdd7d0494858dcfab66b80af7709da1d Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Fri, 9 Nov 2018 18:31:53 +0200 Subject: [PATCH 02/16] show swagger UI --- app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.py b/app.py index 6997afc..e0dc73b 100644 --- a/app.py +++ b/app.py @@ -26,7 +26,7 @@ @app.route("/") def main(): """Index page.""" - return redirect(url_for('api_index', name="mischa")) + return redirect('/swagger-ui/') docs.register_existing_resources() From 438ff93ccb00dd30fde0175098d3040d4008e795 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Fri, 9 Nov 2018 18:33:44 +0200 Subject: [PATCH 03/16] readme --- README.md | 12 +++++++----- api/index.py | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ad8d654..4a7be56 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,11 @@ # Serverless-Flask +### API edition. The fastest way to a Flask application with [Serverless](https://github.com/serverless/serverless). +This version includes APISpec and Marshmallow for easy declaration of input and output for API functions +and automatic generation of swagger. + ## Usage ``` @@ -9,7 +13,7 @@ $ yarn global install serverless $ sls install --url https://github.com/revmischa/serverless-flask --name my-flask-app $ cd my-flask-app && yarn setup -$ serverless deploy +$ sls deploy ``` Once the deploy is complete, run `sls info` to get the endpoint: @@ -19,8 +23,8 @@ $ sls info Service Information endpoints: - ANY - https://abc6defghi.execute-api.us-east-1.amazonaws.com/dev <-- Endpoint - ANY - https://abc6defghi.execute-api.us-east-1.amazonaws.com/dev/{proxy+} + ANY - https://abc6defghi.execute-api.eu-central-1.amazonaws.com/dev <-- Endpoint + ANY - https://abc6defghi.execute-api.eu-central-1.amazonaws.com/dev/{proxy+} ``` Copy paste into your browser, and _voila_! @@ -51,6 +55,4 @@ Navigate to [localhost:5000](http://localhost:5000) to see your app running loca The `postsetup.js` prompt will walk you through some setup questions that may be custom to your use case. This includes: -- Python runtime version; -- Whether you have Docker setup, which assists in packaging dependencies. For more info, check out [this post on managing your Python packages with Serverless](https://serverless.com/blog/serverless-python-packaging/); - Whether you want to set up a custom domain that you own, rather than a random assigned one from AWS. For more details on that, look at [this post on setting up a custom domain with API Gateway and Serverless](https://serverless.com/blog/serverless-api-gateway-domain/). diff --git a/api/index.py b/api/index.py index 63db25a..8be0cac 100644 --- a/api/index.py +++ b/api/index.py @@ -8,7 +8,7 @@ class IndexSchema(Schema): @app.route('/api/', methods=['POST']) -@use_kwargs(IndexSchema) +@use_kwargs(IndexSchema(strict=True)) @marshal_with(IndexSchema) def api_index(name: str = None): """Main API endpoint.""" From c658fd4d2bc1ee24bff72579208f417f037a08e7 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Fri, 9 Nov 2018 18:50:45 +0200 Subject: [PATCH 04/16] js not python --- package.json | 4 ++-- postsetup.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 6e702bf..c492dfa 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.js", "scripts": { - "setup": "npm install", + "setup": "yarn install", "postsetup": "node postsetup.js", "test": "echo \"Error: no test specified\" && exit 1" }, @@ -15,7 +15,7 @@ "inquirer": "^3.2.3", "js-yaml": "^3.9.1", "serverless-domain-manager": "^2.6.6", - "serverless-python-requirements": "^2.5.0", + "serverless-python-requirements": "^4.2.5", "serverless-wsgi": "^1.3.0" } } diff --git a/postsetup.js b/postsetup.js index 0fe3a08..586894c 100644 --- a/postsetup.js +++ b/postsetup.js @@ -28,7 +28,7 @@ var questions = [ inquirer.prompt(questions).then(function (answers) { var doc = YAML.safeLoad(fs.readFileSync('serverless.yml', 'utf8')); - doc.custom.pythonRequirements.dockerizePip = False; + doc.custom.pythonRequirements.dockerizePip = false; doc.provider.runtime = 'python3.6'; if (answers.wantsDomain) { doc.plugins.push('serverless-domain-manager'); From 96f3f428d576ebc048e8dec50a9ef6bd0eb59b2f Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Fri, 9 Nov 2018 19:00:41 +0200 Subject: [PATCH 05/16] docs, better redirect --- README.md | 5 ++--- app.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4a7be56..6311e6c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ The fastest way to a Flask application with [Serverless](https://github.com/serverless/serverless). This version includes APISpec and Marshmallow for easy declaration of input and output for API functions -and automatic generation of swagger. +and automatic generation of swagger. CORS is enabled and can be customized. ## Usage @@ -48,11 +48,10 @@ sls wsgi serve * Debugger is active! ``` -Navigate to [localhost:5000](http://localhost:5000) to see your app running locally. +Navigate to [localhost:5000](http://localhost:5000) to see swagger UI for your API. ## Configuration The `postsetup.js` prompt will walk you through some setup questions that may be custom to your use case. This includes: - - Whether you want to set up a custom domain that you own, rather than a random assigned one from AWS. For more details on that, look at [this post on setting up a custom domain with API Gateway and Serverless](https://serverless.com/blog/serverless-api-gateway-domain/). diff --git a/app.py b/app.py index e0dc73b..b65a5a1 100644 --- a/app.py +++ b/app.py @@ -26,7 +26,7 @@ @app.route("/") def main(): """Index page.""" - return redirect('/swagger-ui/') + return redirect(url_for('flask-apispec.swagger-ui')) docs.register_existing_resources() From 2145b47907aa6866c79dd99540176ea7e69fcb83 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Sat, 10 Nov 2018 00:35:37 +0200 Subject: [PATCH 06/16] cleanups --- api/index.py | 3 ++- app.py | 14 +++++--------- package.json | 3 ++- serverless.yml | 1 - 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/api/index.py b/api/index.py index 8be0cac..c01a1c6 100644 --- a/api/index.py +++ b/api/index.py @@ -1,10 +1,11 @@ from flask_apispec import use_kwargs, marshal_with from marshmallow import Schema, fields from app import app +from typing import Optional class IndexSchema(Schema): - name = fields.Str(required=False) + name: Optional[str] = fields.Str(required=False) @app.route('/api/', methods=['POST']) diff --git a/app.py b/app.py index b65a5a1..022bbcc 100644 --- a/app.py +++ b/app.py @@ -1,9 +1,7 @@ """Lambda entry point.""" from flask import Flask, redirect, url_for from flask_cors import CORS -from apispec.ext.marshmallow import MarshmallowPlugin -from flask_apispec.extension import FlaskApiSpec -from apispec import APISpec +from flask_apispec.extension import FlaskApiSpec, make_apispec from flask_apispec import use_kwargs, marshal_with # noqa: F401 from marshmallow import Schema, fields # noqa: F401 @@ -12,15 +10,13 @@ app = Flask(__name__) CORS(app) app.config.update({ - 'APISPEC_SPEC': APISpec( - title="Serverless API", - version='1.0', - plugins=[MarshmallowPlugin()], - ), + 'APISPEC_SPEC': make_apispec(title='Flask API', version='v1'), 'APISPEC_SWAGGER_URL': '/swagger/', }) docs = FlaskApiSpec(app) -from api import index + +# set up views +import api.index @app.route("/") diff --git a/package.json b/package.json index c492dfa..c2b9966 100644 --- a/package.json +++ b/package.json @@ -17,5 +17,6 @@ "serverless-domain-manager": "^2.6.6", "serverless-python-requirements": "^4.2.5", "serverless-wsgi": "^1.3.0" - } + }, + "dependencies": {} } diff --git a/serverless.yml b/serverless.yml index ec10e41..ac4aa76 100644 --- a/serverless.yml +++ b/serverless.yml @@ -3,7 +3,6 @@ service: serverless-flask plugins: - serverless-python-requirements - serverless-wsgi - - serverless-domain-manager custom: wsgi: From a12cebe3db2ce0d89849fcde362093f348bd9811 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Sat, 10 Nov 2018 11:30:21 +0200 Subject: [PATCH 07/16] fix swagger for non-root application paths. use werkzeug proxyfix --- app.py | 11 +++++++++-- requirements.txt | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 022bbcc..e0d4557 100644 --- a/app.py +++ b/app.py @@ -4,6 +4,7 @@ from flask_apispec.extension import FlaskApiSpec, make_apispec from flask_apispec import use_kwargs, marshal_with # noqa: F401 from marshmallow import Schema, fields # noqa: F401 +from werkzeug.contrib.fixers import ProxyFix # create app @@ -14,17 +15,23 @@ 'APISPEC_SWAGGER_URL': '/swagger/', }) docs = FlaskApiSpec(app) +app.wsgi_app = ProxyFix(app.wsgi_app) -# set up views + +# load views import api.index @app.route("/") def main(): - """Index page.""" + """Index page. + + Redirect to swagger UI. + """ return redirect(url_for('flask-apispec.swagger-ui')) +# register swagger for routes docs.register_existing_resources() if __name__ == "__main__": diff --git a/requirements.txt b/requirements.txt index 1c5206f..7d50fa1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,5 +2,6 @@ Flask flask_cors boto3 flask_apispec +git+https://github.com/revmischa/flask-apispec.git@2fff3d58788f4558f67107c79b22f8566b3c2936#egg=flask_apispec apispec marshmallow From 3e6809add38e7e630148000099f44416c25a4983 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Sat, 10 Nov 2018 15:16:06 +0200 Subject: [PATCH 08/16] throw in openapi client codegen for good measure --- .gitignore | 5 +++++ Makefile | 21 +++++++++++++++++++++ README.md | 21 ++++++++++++++++----- api/doc.py | 26 ++++++++++++++++++++++++++ app.py | 23 +++++------------------ serverless.yml | 4 ++++ 6 files changed, 77 insertions(+), 23 deletions(-) create mode 100644 Makefile create mode 100644 api/doc.py diff --git a/.gitignore b/.gitignore index 5d4d1db..cddc94a 100644 --- a/.gitignore +++ b/.gitignore @@ -103,3 +103,8 @@ ENV/ # serverless .serverless/ .requirements/ + +# codegen +sdk/ + +node_modules/ \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..bfe18a1 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ + +SDK_DIR=sdk + +$(SDK_DIR): + mkdir -p $(SDK_DIR) + +generate-openapi: $(SDK_DIR) + $(shell serverless invoke local -f openapi > $(SDK_DIR)/openapi.json) + +generate-client: generate-openapi +ifdef lang + mkdir -p $(SDK_DIR)/$(lang) + docker run --rm -v "$(PWD)/$(SDK_DIR):/local" openapitools/openapi-generator-cli generate \ + -i /local/openapi.json \ + -g $(lang) \ + -o /local/$(lang) + @echo "SDK output to $(SDK_DIR)/$(lang)" +else + @echo "Please specify language with lang=" + @echo "Example: make lang=typescript-axios generate-client" +endif diff --git a/README.md b/README.md index 6311e6c..62e2601 100644 --- a/README.md +++ b/README.md @@ -9,11 +9,12 @@ and automatic generation of swagger. CORS is enabled and can be customized. ## Usage ``` -$ yarn global install serverless -$ sls install --url https://github.com/revmischa/serverless-flask --name my-flask-app -$ cd my-flask-app && yarn setup - -$ sls deploy +yarn global install serverless +sls install --url https://github.com/revmischa/serverless-flask --name my-flask-app +cd my-flask-app +yarn setup +# +sls deploy ``` Once the deploy is complete, run `sls info` to get the endpoint: @@ -50,6 +51,16 @@ sls wsgi serve Navigate to [localhost:5000](http://localhost:5000) to see swagger UI for your API. + +## Client CodeGen + +Want to generate a client library for your API? No problem. + +* Run `make generate-client lang=$LANG` +Where `LANG` can be any language supported by [OpenAPI-Generator](https://github.com/openapitools/openapi-generator#overview). +E.g. `go` or `typescript-axios`. + + ## Configuration The `postsetup.js` prompt will walk you through some setup questions that may be diff --git a/api/doc.py b/api/doc.py new file mode 100644 index 0000000..61052a5 --- /dev/null +++ b/api/doc.py @@ -0,0 +1,26 @@ +"""Generate OpenAPI documentation.""" +from flask import Flask +from flask_apispec.extension import FlaskApiSpec, make_apispec + + +class ServerlessOpenAPI: + def __init__(self, app: Flask) -> None: + app.config.update({ + 'APISPEC_SPEC': make_apispec(title='Flask API', version='v1'), + 'APISPEC_SWAGGER_URL': '/swagger/', + }) + self.apispec = FlaskApiSpec(app) + + def register_all(self): + """Generate documentation. + + Call after all views loaded. + """ + self.apispec.register_existing_resources() + + +# lambda function +def get_openapi(event, context): + """Get raw OpenAPI v2 API description.""" + from app import docs + return docs.apispec.spec.to_dict() diff --git a/app.py b/app.py index e0d4557..e0d10b8 100644 --- a/app.py +++ b/app.py @@ -1,38 +1,25 @@ """Lambda entry point.""" from flask import Flask, redirect, url_for from flask_cors import CORS -from flask_apispec.extension import FlaskApiSpec, make_apispec -from flask_apispec import use_kwargs, marshal_with # noqa: F401 -from marshmallow import Schema, fields # noqa: F401 from werkzeug.contrib.fixers import ProxyFix - +from api.doc import ServerlessOpenAPI # create app app = Flask(__name__) CORS(app) -app.config.update({ - 'APISPEC_SPEC': make_apispec(title='Flask API', version='v1'), - 'APISPEC_SWAGGER_URL': '/swagger/', -}) -docs = FlaskApiSpec(app) app.wsgi_app = ProxyFix(app.wsgi_app) +docs = ServerlessOpenAPI(app) - -# load views +# set up views import api.index +docs.register_all() @app.route("/") def main(): - """Index page. - - Redirect to swagger UI. - """ + """Index page.""" return redirect(url_for('flask-apispec.swagger-ui')) -# register swagger for routes -docs.register_existing_resources() - if __name__ == "__main__": app.run() diff --git a/serverless.yml b/serverless.yml index ac4aa76..e79061e 100644 --- a/serverless.yml +++ b/serverless.yml @@ -28,3 +28,7 @@ functions: events: - http: ANY / - http: 'ANY {proxy+}' + openapi: + handler: api.doc.get_openapi + events: + - http: GET /openapi From a217bb7f90191d01fcfcb613a0304b7f0426b4d2 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Sat, 10 Nov 2018 15:17:48 +0200 Subject: [PATCH 09/16] you need yarn --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 62e2601..44c7b66 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This version includes APISpec and Marshmallow for easy declaration of input and and automatic generation of swagger. CORS is enabled and can be customized. ## Usage - +* [Install yarn](https://yarnpkg.com/lang/en/docs/install/#mac-stable) if you don't have it ``` yarn global install serverless sls install --url https://github.com/revmischa/serverless-flask --name my-flask-app From 1658119a702226e43f4a1e44e5655c63073e46f3 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Sat, 10 Nov 2018 15:19:32 +0200 Subject: [PATCH 10/16] readme --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 44c7b66..b2701c5 100644 --- a/README.md +++ b/README.md @@ -57,8 +57,10 @@ Navigate to [localhost:5000](http://localhost:5000) to see swagger UI for your A Want to generate a client library for your API? No problem. * Run `make generate-client lang=$LANG` + Where `LANG` can be any language supported by [OpenAPI-Generator](https://github.com/openapitools/openapi-generator#overview). -E.g. `go` or `typescript-axios`. + +e.g. `lang=go` or `lang=typescript-axios`. ## Configuration From fc1a5328acec65e510e69fb0c1387ee064f7b236 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Sat, 10 Nov 2018 15:19:54 +0200 Subject: [PATCH 11/16] readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b2701c5..4529125 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ Want to generate a client library for your API? No problem. * Run `make generate-client lang=$LANG` -Where `LANG` can be any language supported by [OpenAPI-Generator](https://github.com/openapitools/openapi-generator#overview). +Where `$LANG` can be any language supported by [OpenAPI-Generator](https://github.com/openapitools/openapi-generator#overview). e.g. `lang=go` or `lang=typescript-axios`. From 9c9dbaa6e952f3b82a2c55d3aac29d77e40339b7 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Wed, 21 Nov 2018 23:33:25 +0200 Subject: [PATCH 12/16] Restore docker setup question --- postsetup.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/postsetup.js b/postsetup.js index 586894c..e4b00ef 100644 --- a/postsetup.js +++ b/postsetup.js @@ -1,4 +1,4 @@ -// Check to see if the user has Docker installed and which version of Python they prefer. +// Check to see if the user has Docker installed 'use strict'; var inquirer = require('inquirer'); @@ -9,6 +9,12 @@ var fs = require('fs'); console.log(chalk.yellow('Hi, a few quick questions before we start:')); var questions = [ + { + type: 'confirm', + name: 'docker', + message: 'Do you have Docker installed? Recommended, but not required.', + default: true + }, { type: 'confirm', name: 'wantsDomain', @@ -28,8 +34,7 @@ var questions = [ inquirer.prompt(questions).then(function (answers) { var doc = YAML.safeLoad(fs.readFileSync('serverless.yml', 'utf8')); - doc.custom.pythonRequirements.dockerizePip = false; - doc.provider.runtime = 'python3.6'; + doc.custom.pythonRequirements.dockerizePip = answers.docker; if (answers.wantsDomain) { doc.plugins.push('serverless-domain-manager'); doc.custom.customDomain = createCustomDomain(answers.domainName); From 94a96555a4acf98496f421d60cf984ff4a0db3a9 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Wed, 21 Nov 2018 23:34:15 +0200 Subject: [PATCH 13/16] docker dox --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4529125..c7d5ca1 100644 --- a/README.md +++ b/README.md @@ -67,4 +67,5 @@ e.g. `lang=go` or `lang=typescript-axios`. The `postsetup.js` prompt will walk you through some setup questions that may be custom to your use case. This includes: +- Whether you have Docker setup, which assists in packaging dependencies. For more info, check out [this post on managing your Python packages with Serverless](https://serverless.com/blog/serverless-python-packaging/); - Whether you want to set up a custom domain that you own, rather than a random assigned one from AWS. For more details on that, look at [this post on setting up a custom domain with API Gateway and Serverless](https://serverless.com/blog/serverless-api-gateway-domain/). From c37ad7b57a16f9e6b410312c07f2f50810cb6430 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Wed, 21 Nov 2018 23:36:26 +0200 Subject: [PATCH 14/16] update flask apispec --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 7d50fa1..352fe5d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,6 @@ Flask flask_cors boto3 flask_apispec -git+https://github.com/revmischa/flask-apispec.git@2fff3d58788f4558f67107c79b22f8566b3c2936#egg=flask_apispec +git+https://github.com/revmischa/flask-apispec.git@b391c6bc511235eae0a8fece07240cad0d7188c0#egg=flask_apispec apispec marshmallow From 1cfc0a41b4cd0a2a3eb9f1eb933f7f5b3342a4fe Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Thu, 22 Nov 2018 00:00:47 +0200 Subject: [PATCH 15/16] flask apispec dep version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 352fe5d..8422650 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,6 @@ Flask flask_cors boto3 flask_apispec -git+https://github.com/revmischa/flask-apispec.git@b391c6bc511235eae0a8fece07240cad0d7188c0#egg=flask_apispec +git+https://github.com/revmischa/flask-apispec.git@7cf50d33189873f498b4474610e32896247a1260#egg=flask_apispec apispec marshmallow From b6b1da9145044f27658800652bd5258d21a3ba99 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Thu, 13 Dec 2018 13:15:01 +0000 Subject: [PATCH 16/16] use fixed flask_apispec --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 8422650..a2502de 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,8 @@ Flask flask_cors boto3 -flask_apispec +# flask_apispec +# use fixed SERVER_NAME https://github.com/revmischa/flask-apispec/commits/script_root git+https://github.com/revmischa/flask-apispec.git@7cf50d33189873f498b4474610e32896247a1260#egg=flask_apispec apispec marshmallow