自定义访问连接python服务的服务器URL时返回的消息

问题描述

我正在使用connexion编写python服务。我可以通过localhost:<port>/ui访问该服务的一般GUI。但是,当我在浏览器中输入localhost:<port>而没有/ui(由connexion添加automatically)时,出现以下消息:

{
  "detail": "The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.","status": 404,"title": "Not Found","type": "about:blank"
}

是否可以自定义此消息?就我而言,我希望localhost:<port>返回以下消息:

{"message": "check /ui to have access to the Swagger UI"}

解决方法

我想我找到了解决方案。只需将以下内容添加到openspec api:

  /:
    get:
      operationId: path.to.function
      summary: "my personlized message"
      responses:
      ......

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...