Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 431
Gobliins Avatar asked Oct 29 '25 07:10

Gobliins


2 Answers

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"
      }
    }
  ],
  ...
like image 146
Helen Avatar answered Oct 31 '25 00:10

Helen


This depends on what you have passed on as an argument to swagger's Api annotation (io.swagger.annotations.Api) at the top of your RESTful service implementation -

@Path(value="/")
@Api(value="/")
public interface YourService {
    ....
}

@Api(value="/") will generate default

@Api(value="/Tasks") will generate Tasks

like image 37
Sampada Avatar answered Oct 31 '25 00:10

Sampada



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!