HTTP JSON 端点

以 Markdown 格式查看

端点在 Fern 中定义在 endpoints 键下。以下是定义单个 REST 端点的示例:

users.yml
1service:
2 base-path: /users
3 auth: false
4 endpoints:
5 createUser:
6 path: /create
7 method: POST
8 request:
9 body:
10 properties:
11 userName: string

示例

您可以通过使用 examples 键来提供请求和响应的示例。

1service:
2 base-path: /users
3 auth: false
4 endpoints:
5 getUser:
6 path: /{userId}
7 path-parameters:
8 userId: string
9 method: GET
10 response: User
11 examples:
12 - path-parameters:
13 userId: alice-user-id
14 response:
15 body:
16 userId: alice-user-id
17 name: Alice