<i id='iQtZv'><tr id='iQtZv'><dt id='iQtZv'><q id='iQtZv'><span id='iQtZv'><b id='iQtZv'><form id='iQtZv'><ins id='iQtZv'></ins><ul id='iQtZv'></ul><sub id='iQtZv'></sub></form><legend id='iQtZv'></legend><bdo id='iQtZv'><pre id='iQtZv'><center id='iQtZv'></center></pre></bdo></b><th id='iQtZv'></th></span></q></dt></tr></i><div id='iQtZv'><tfoot id='iQtZv'></tfoot><dl id='iQtZv'><fieldset id='iQtZv'></fieldset></dl></div>

      • <bdo id='iQtZv'></bdo><ul id='iQtZv'></ul>
    1. <legend id='iQtZv'><style id='iQtZv'><dir id='iQtZv'><q id='iQtZv'></q></dir></style></legend>

      <small id='iQtZv'></small><noframes id='iQtZv'>

    2. <tfoot id='iQtZv'></tfoot>

      1. Python 连接不显示 Swagger UI

        Python connexion not displaying Swagger UI(Python 连接不显示 Swagger UI)

              <tbody id='6UrGf'></tbody>
            <legend id='6UrGf'><style id='6UrGf'><dir id='6UrGf'><q id='6UrGf'></q></dir></style></legend>
            <tfoot id='6UrGf'></tfoot>
            <i id='6UrGf'><tr id='6UrGf'><dt id='6UrGf'><q id='6UrGf'><span id='6UrGf'><b id='6UrGf'><form id='6UrGf'><ins id='6UrGf'></ins><ul id='6UrGf'></ul><sub id='6UrGf'></sub></form><legend id='6UrGf'></legend><bdo id='6UrGf'><pre id='6UrGf'><center id='6UrGf'></center></pre></bdo></b><th id='6UrGf'></th></span></q></dt></tr></i><div id='6UrGf'><tfoot id='6UrGf'></tfoot><dl id='6UrGf'><fieldset id='6UrGf'></fieldset></dl></div>
              <bdo id='6UrGf'></bdo><ul id='6UrGf'></ul>

                <small id='6UrGf'></small><noframes id='6UrGf'>

                  本文介绍了Python 连接不显示 Swagger UI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我使用 connexion 模块构建了一个基于 Python/Flask 的 REST API.这与使用 swagger.yml 文件定义 REST API 效果很好.应用程序正在运行,但是当我导航到/ui 时,我在浏览器中得到的只是:

                  I've built a Python/Flask based REST API using the connexion module. This working well as defining the REST API with with swagger.yml file works very well. The application is running, but when I navigate to /ui all I get in my browser is this:

                  我没有禁用 UI,所以我不确定发生了什么以及为什么 UI 没有显示.我的应用程序没有/static 文件夹(它只是一个 API),因此该应用程序不提供任何静态文件,不确定这是否与问题有关.

                  I haven't disabled the UI, so I'm not sure what's going on and why the UI isn't being displayed. My application doesn't have a /static folder (it's only an API), so the app isn't serving any static files, not sure if that's related to the problem or not.

                  任何关于我做错了什么的建议、指示或提示将不胜感激!

                  Any suggestions, pointers or hints about what I'm doing wrong would be most appreciated!

                  这是我的代码的简化示例:

                  Here is a simplified example of my code:

                  # 3rd party libraries
                  from flask_cors import CORS
                  import connexion
                  
                  def create_app(config_key, instance_config=None):
                      # create the connexion instance
                      connex_app = connexion.FlaskApp(__name__, specification_dir='./files/swagger/')
                      connex_app.server = 'gevent'
                  
                      # get the Flask app instance
                      app = connex_app.app
                  
                      # configure the application
                      app.config.from_object(config_key)
                  
                      # add CORS support to application
                      CORS(app)
                  
                      # define the API with the SWAGGER API definition YAML file
                      connex_app.add_api('line_controller_api.yml',
                                         base_path='{url_prefix}'.format(url_prefix=app.config.get('URL_PREFIX', '/')),
                                         resolver=AppResolver())
                  
                      return connex_app
                  
                  
                  def production_app(instance_config=None):
                      app = create_app('api_config.ProductionConfig', instance_config)
                      return app
                  
                  if __name__ == '__main__':
                      app = create_app('api_config.DevelopmentConfig')
                      port = 5001
                      logger.info('Line Controller API running on port %s', port)
                      app.run(host='0.0.0.0', port=port)
                  

                  提前致谢,道格

                  推荐答案

                  connexion 从 2.0.1 版本开始,里面没有捆绑 swagger-ui.您已使用以下命令显式安装它(注意引号)

                  connexion from 2.0.1 version onward don't have swagger-ui bundled inside it. You have install it explicitly using the below command (note the quotes)

                  pip install 'connexion[swagger-ui]'
                  

                  安装后.swagger 将与 connexion 一起使用.在早期版本中,swagger 曾经与/ui 一起工作,在末尾添加到您的 url http(s)://host:port

                  Once you install it. swagger will work with connexion. In the earlier version swagger used to work with /ui added to your url at the end http(s)://host:port

                  但在 2.0.x 以后使用 http(s)://host:port/<basepath>/ui

                  But in 2.0.x onward use http(s)://host:port/<basepath>/ui

                  这篇关于Python 连接不显示 Swagger UI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding config modes to Plotly.Py offline - modebar(将配置模式添加到 Plotly.Py 离线 - 模式栏)
                  Plotly: How to style a plotly figure so that it doesn#39;t display gaps for missing dates?(Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙?)
                  python save plotly plot to local file and insert into html(python将绘图保存到本地文件并插入到html中)
                  Plotly: What color cycle does plotly express follow?(情节:情节表达遵循什么颜色循环?)
                  How to save plotly express plot into a html or static image file?(如何将情节表达图保存到 html 或静态图像文件中?)
                  Plotly: How to make a line plot from a pandas dataframe with a long or wide format?(Plotly:如何使用长格式或宽格式的 pandas 数据框制作线图?)
                  <legend id='2CEiN'><style id='2CEiN'><dir id='2CEiN'><q id='2CEiN'></q></dir></style></legend>

                    <small id='2CEiN'></small><noframes id='2CEiN'>

                    • <bdo id='2CEiN'></bdo><ul id='2CEiN'></ul>
                      <i id='2CEiN'><tr id='2CEiN'><dt id='2CEiN'><q id='2CEiN'><span id='2CEiN'><b id='2CEiN'><form id='2CEiN'><ins id='2CEiN'></ins><ul id='2CEiN'></ul><sub id='2CEiN'></sub></form><legend id='2CEiN'></legend><bdo id='2CEiN'><pre id='2CEiN'><center id='2CEiN'></center></pre></bdo></b><th id='2CEiN'></th></span></q></dt></tr></i><div id='2CEiN'><tfoot id='2CEiN'></tfoot><dl id='2CEiN'><fieldset id='2CEiN'></fieldset></dl></div>
                            <tbody id='2CEiN'></tbody>

                            <tfoot id='2CEiN'></tfoot>