Python Flask: Go from Swagger YAML to Google App Engine?
<p>I have used the Swagger Editor to create a REST API and I have requested the server code download for Python Flask. I'm trying to deploy this out to Google Cloud Platform (I think that's the latest name? Or is it still GAE?) but I need to fill in some gaps. </p>

<p>I know the Swagger code works because I have deployed it locally without any issues. However, it uses the connexion library instead of Flask outright.</p>

<p>I'm mostly lost on how I can incorporate an app.yaml file for GCP and the right entrypoints within the generated code. In addition, I know that the generated code declares it's own app server which I don't think you need to do for GCP. 
Here's my current <strong>app.yaml</strong></p>

<pre><code>application: some-app-name
version: 1
runtime: python27
api_version: 1
threadsafe: yes
entrypoint: python app.py

libraries:
- name: connexion
  version: "latest"
</code></pre>

<p>And here's my <strong>app.py</strong></p>

<pre><code>import connexion

if __name__ == '__main__':
    app = connexion.App(__name__, specification_dir='./swagger/')
    app.add_api('swagger.yaml', arguments={'title': 'this is my API'})
    app.run(port=8080)
</code></pre>

<p>The primary error I'm getting now is</p>

<pre><code>google.appengine.api.yaml_errors.EventError: the library "connexion" is not supported
</code></pre>

<p>I have a feeling that's because of the way I am declaring an app server in my app.py - it probably shouldn't be needed. How would I modify this file to still use my Swagger code but run on GCP?</p>

<p>You seem to have some inconsistencies in your file, it's unclear if you intended it to be a <a href="https://cloud.google.com/appengine/docs/python/config/appref" rel="nofollow">standard environment <code>app.yaml</code> file</a> or a <a href="https://cloud.google.com/appengine/docs/flexible/python/runtime#overview" rel="nofollow">flexible environment</a> one. I can't tell as I'm unfamiliar with swagger and flask.</p>

<p>If it's supposed to be a standard environment one then:</p>

<ul>
<li>the <code>entrypoint:</code> is not a supported config keyword</li>
<li>the <code>connexion</code> library is not one of <a href="https://cloud.google.com/appengine/docs/python/tools/built-in-libraries-27" rel="nofollow">the runtime-provided third-party libraries</a>, so you can't <a href="https://cloud.google.com/appengine/docs/python/tools/using-libraries-python-27#requesting_a_library" rel="nofollow">request it</a> (i.e. listing it in the <code>libraries</code> section). You need to <a href="https://cloud.google.com/appengine/docs/python/tools/using-libraries-python-27#installing_a_library" rel="nofollow">install it (vendor it in)</a>.

<ul>
<li>it's missing the <code>handlers</code> section</li>
</ul></li>
</ul>

<p>Probably a good idea to go through  <a href="https://cloud.google.com/appengine/docs/python/getting-started/python-standard-env" rel="nofollow">Getting Started with Flask on App Engine Standard Environment</a> </p>

<p>If, however, your goal was a flexible environment <code>app.yaml</code> file then:</p>

<ul>
<li>you need the <code>vm: true</code> config in it</li>
<li><a href="https://cloud.google.com/appengine/docs/flexible/python/runtime#dependencies" rel="nofollow">installing/specifying dependencies</a> is done differently, not via the <code>libraries</code> section.</li>
</ul>

python google-app-engine flask swagger google-cloud-platform