Actions require an explicit HttpMethod binding for Swagger/OpenAPI 3.0
时间: 2024-03-21 10:37:53 浏览: 217
Yes, that's correct. In Swagger/OpenAPI 3.0, it's mandatory to specify the HTTP method for each API endpoint. This is typically done using the `get`, `post`, `put`, `delete` and other similar keywords in the API definition. If the method is not specified, the Swagger/OpenAPI specification will not be valid, and the API will not be able to be properly documented or used by clients.
To specify the HTTP method for an endpoint in Swagger/OpenAPI 3.0, you can use the following syntax:
```yaml
paths:
/users:
get:
summary: Get a list of users
description: Retrieve a list of user objects
responses:
'200':
description: A list of user objects
post:
summary: Add a new user
description: Add a new user object
responses:
'201':
description: The newly created user object
```
In the above example, there are two endpoints under the `/users` path: `GET` and `POST`. Each endpoint specifies the HTTP method explicitly using the `get` and `post` keywords. Additionally, you can provide a summary, a description and response examples for each endpoint, to help document and understand their behavior.
阅读全文