How to intergrate python3 -m swagger_server with wsgi

553 views
Skip to first unread message

Karri Kaksonen

unread,
Mar 23, 2017, 10:09:49 AM3/23/17
to Swagger
My generated swagger_server works great when started with:

python3 -m swagger_server

The problem starts when I want to get the UID of the client certificate when using dual side TLS authentication. Dual side TLS authentication worked well but I did not find out how to grab the UID from the certificate sent to my server.

I started to look at nginx and uWSGI to get the job done.

The problem is that I cannot find the syntax for making the wsgi.py call the swagger_server as it has been built as a module.

So I am looking for some help to write the wsgi.py:

from myproject import application

if __name__ == "__main__":
    application
.run()

My swagger_server/__main__.py looks like this:

#!/usr/bin/env python3
import connexion
from .encoder import JSONEncoder

app
= connexion.App(__name__, specification_dir='swagger/')
app
.app.json_encoder = JSONEncoder
app
.add_api('swagger.yaml', arguments={'title': 'My Service'})
application
= app.app

if __name__ == '__main__':
    app
.run(host='localhost')

So I assume that I should be able to create a wsgi.py file to start my server somehow. So far all my experiments to import swagger_server properly have failed.

from .swagger_server import application

if __name__ == "__main__":
    application
.run()

This produces just

Traceback (most recent call last):
 
File "wsgi.py", line 9, in <module>
   
from .swagger_server import application
SystemError: Parent module '' not loaded, cannot perform relative import






wing328

unread,
Apr 3, 2017, 1:34:02 AM4/3/17
to Swagger
I would suggest you to start a discussion via https://github.com/swagger-api/swagger-codegen/issues/new so that the swagger codegen community can help you out.

Karri Kaksonen於 2017年3月23日星期四 UTC+8下午10時09分49秒寫道:
Reply all
Reply to author
Forward
0 new messages