Gobliins Gobliins - 5 months ago 15
JSON Question

Swagger-ui how is the name of api (resource) generated?

When I create an API with swagger, normaly my API has the name of the resource:

Tasks
/tasks
/tasks/{id}
etc.


Sometimes I only get a default:

Default
GET /tasks
GET /tasks/{uuid}
etc.


What determines the header name of the API generated?

Screenshot of wished behaviour (tasks is sometimes default):

enter image description here

Answer

Do you mean these headers in Swagger UI?

headers

They are generated based on the tags of your API operations. For example, to group operations under "Tasks", use:

{
  ...

  "paths": {
    "\/tasks:": {
       "tags": [
         "Tasks"
       ],
       ...

Each operation can have any number of tags. Operations with no tags will be listed under the "Default" group.

To provide description for the tags, use the top-level tags section:

{
  ...

  "tags": [
    {
      "name": "Tasks",
      "description": "Operations to manage tasks"
      }
    },
    {
      "name": "Notes",
      "description": "Operations to manage notes"
      }
    }
  ],
  ...
Comments