Customize the message returned when accessing the server url of a connexion (python) service

25 views Asked by At

I am writing a python service with connexion. I have access to the swagger gui of the service via localhost:<port>/ui. However, when I enter localhost:<port> in the browser without the /ui (automatically added by connexion), I get the following message:

{
  "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"
}

Is it possible to customize this message ? In my case, I want localhost:<port> to return the following message instead:

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

There are 1 answers

0
dada On

I think I found a solution. Just add the following to the openspec api:

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