Tôi muốn Đăng một cơ thể json với Swagger, như thế này:Đăng một cơ thể json với vênh vang
curl -H "Content-Type: application/json" -X POST -d {"username":"foobar","password":"xxxxxxxxxxxxxxxxx", "email": "[email protected]"}' http://localhost/user/register
Hiện nay, tôi có định nghĩa này:
"/auth/register": {
"post": {
"tags": [
"auth"
],
"summary": "Create a new user account",
"parameters": [
{
"name": "username",
"in": "query",
"description": "The username of the user",
"required": true,
"type": "string"
},
{
"name": "password",
"in": "query",
"description": "The password of the user",
"required": true,
"type": "string",
"format": "password"
},
{
"name": "email",
"in": "query",
"description": "The email of the user",
"required": true,
"type": "string",
"format": "email"
}
],
"responses": {
"201": {
"description": "The user account has been created",
"schema": {
"$ref": "#/definitions/User"
}
},
"default": {
"description": "Unexpected error",
"schema": {
"$ref": "#/definitions/Errors"
}
}
}
}
}
Nhưng các dữ liệu được gửi đi trong URL. Ở đây, tạo curl cung cấp bởi Swagger:
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' 'http://localhost/user/register?username=foobar&password=password&email=foo%40bar.com'
Tôi hiểu rằng query
keywork là không tốt, nhưng tôi không tìm thấy cách để Đăng một cơ thể JSON. Tôi đã thử formData
nhưng nó không hoạt động.
Nó hoàn hảo, cảm ơn! – ncrocfer
Làm thế nào để tạo mô hình trong laravel-5.5? –