3
0

fix(sam): spec for attachments

This commit is contained in:
Tit Petric
2018-11-05 15:09:54 +01:00
parent 8bf8c0dcf6
commit 3963aa9653
4 changed files with 45 additions and 4 deletions
+2
View File
@@ -13,6 +13,7 @@
| Parameter | Type | Method | Description | Default | Required? |
| --------- | ---- | ------ | ----------- | ------- | --------- |
| download | bool | GET | Force file download | N/A | NO |
| name | string | PATH | File name | N/A | YES |
| attachmentID | uint64 | PATH | Attachment ID | N/A | YES |
## Serves preview of an attached file
@@ -27,6 +28,7 @@
| Parameter | Type | Method | Description | Default | Required? |
| --------- | ---- | ------ | ----------- | ------- | --------- |
| ext | string | PATH | Preview extension/format | N/A | YES |
| attachmentID | uint64 | PATH | Attachment ID | N/A | YES |
+20 -2
View File
@@ -526,7 +526,15 @@
"method": "GET",
"title": "Serves attached file",
"parameters": {
"GET": [
"path": [
{
"name": "name",
"type": "string",
"required": true,
"title": "File name"
}
],
"get": [
{
"type": "bool",
"name": "download",
@@ -540,7 +548,17 @@
"name": "preview",
"path": "/preview.{ext}",
"method": "GET",
"title": "Serves preview of an attached file"
"title": "Serves preview of an attached file",
"parameters": {
"path": [
{
"name": "ext",
"type": "string",
"required": true,
"title": "Preview extension/format"
}
]
}
}
]
},
+19 -2
View File
@@ -26,13 +26,21 @@
"Title": "Serves attached file",
"Path": "/original/{name}",
"Parameters": {
"GET": [
"get": [
{
"name": "download",
"required": false,
"title": "Force file download",
"type": "bool"
}
],
"path": [
{
"name": "name",
"required": true,
"title": "File name",
"type": "string"
}
]
}
},
@@ -41,7 +49,16 @@
"Method": "GET",
"Title": "Serves preview of an attached file",
"Path": "/preview.{ext}",
"Parameters": null
"Parameters": {
"path": [
{
"name": "ext",
"required": true,
"title": "Preview extension/format",
"type": "string"
}
]
}
}
]
}
+4
View File
@@ -33,6 +33,7 @@ var _ = multipart.FileHeader{}
// Attachment original request parameters
type AttachmentOriginal struct {
Download bool
Name string
AttachmentID uint64 `json:",string"`
}
@@ -71,6 +72,7 @@ func (a *AttachmentOriginal) Fill(r *http.Request) (err error) {
a.Download = parseBool(val)
}
a.Name = chi.URLParam(r, "name")
a.AttachmentID = parseUInt64(chi.URLParam(r, "attachmentID"))
return err
@@ -80,6 +82,7 @@ var _ RequestFiller = NewAttachmentOriginal()
// Attachment preview request parameters
type AttachmentPreview struct {
Ext string
AttachmentID uint64 `json:",string"`
}
@@ -114,6 +117,7 @@ func (a *AttachmentPreview) Fill(r *http.Request) (err error) {
post[name] = string(param[0])
}
a.Ext = chi.URLParam(r, "ext")
a.AttachmentID = parseUInt64(chi.URLParam(r, "attachmentID"))
return err