-
Notifications
You must be signed in to change notification settings - Fork 460
Open
Description
gem "apipie-rails", "~> 1.3"
Config
api! "Create a new post (multipart/form-data)"
param :post, Hash, required: true, action_aware: true do
param :title, String, desc: 'Title', required: true
param :body, String, desc: 'Body', required: true
param :region_id, :number, desc: 'Region ID', required: false, default_value: nil
param :files, Array, of: ActionDispatch::Http::UploadedFile,
desc: 'Array of files to be attached to the post (multipart/form-data array)',
required: false, default_value: []
param :images, Array, of: ActionDispatch::Http::UploadedFile,
desc: 'Array of images to be attached to the post (multipart/form-data array)',
required: false, default_value: []
endHave a look at files and images, they are wrong. Problem: it generates string fields and doesn't send them like value[] which is not recognized by rails server.
{
"name": "post[files]",
"type": "array",
"items": {
"type": "string"
},
"in": "formData",
"default": [
],
"description": "Array of files to be attached to the post (multipart/form-data array)"
},
{
"name": "post[images]",
"type": "array",
"items": {
"type": "string"
},
"in": "formData",
"default": [
],
"description": "Array of images to be attached to the post (multipart/form-data array)"
}Full output
"post": {
"tags": [
"posts"
],
"consumes": [
"application/x-www-form-urlencoded",
"multipart/form-data"
],
"operationId": "post_posts",
"summary": "Create a new post (multipart/form-data)",
"parameters": [
{
"name": "post[title]",
"type": "string",
"in": "formData",
"required": true,
"description": "Title"
},
{
"name": "post[body]",
"type": "string",
"in": "formData",
"required": true,
"description": "Body"
},
{
"name": "post[region_id]",
"type": "number",
"in": "formData",
"default": null,
"description": "Region ID"
},
{
"name": "post[files]",
"type": "array",
"items": {
"type": "string"
},
"in": "formData",
"default": [
],
"description": "Array of files to be attached to the post (multipart/form-data array)"
},
{
"name": "post[images]",
"type": "array",
"items": {
"type": "string"
},
"in": "formData",
"default": [
],
"description": "Array of images to be attached to the post (multipart/form-data array)"
}
],
"responses": {
"200": {
"description": "All posts for user with region",
"schema": {
"type": "object",
"properties": {
"status": {
"type": "object",
"properties": {
"code": {
"type": "number",
"required": true
},
"message": {
"type": "string",
"required": true
}
},
"additionalProperties": false,
"required": [
"code",
"message"
]
},
"data": {
"type": "object",
"properties": {
"post": {
"type": "object",
"properties": {
"id": {
"type": "string",
"required": true
},
"title": {
"type": "string",
"required": true
},
"body": {
"type": "string",
"required": true
},
"files": {
"items": {
"type": "string"
},
"type": "array",
"required": true
},
"images": {
"items": {
"type": "string"
},
"type": "array",
"required": true
}
},
"additionalProperties": false,
"required": [
"id",
"title",
"body",
"files",
"images"
]
}
},
"additionalProperties": false,
"required": [
"post"
]
}
},
"additionalProperties": false,
"required": [
"status",
"data"
]
}
},
"422": {
"description": "Unprocessable entity",
"schema": {
"type": "object",
"properties": {
"status": {
"type": "object",
"properties": {
"code": {
"type": "number",
"required": true
},
"message": {
"type": "string",
"required": true
}
},
"additionalProperties": false,
"required": [
"code",
"message"
]
}
},
"additionalProperties": false,
"required": [
"status"
]
}
}
},
"description": ""
}
},In full output you can see, that consumes contains application/x-www-form-urlencoded which is used by swagger as primary method too while it should be multipart/form-data for files.
jayneticsmathieujobin
Metadata
Metadata
Assignees
Labels
No labels