summaryrefslogtreecommitdiff
path: root/internal/api
diff options
context:
space:
mode:
Diffstat (limited to 'internal/api')
-rw-r--r--internal/api/activitypub/users/common.go2
-rw-r--r--internal/api/activitypub/users/featured.go8
-rw-r--r--internal/api/client/accounts/accountupdate.go65
-rw-r--r--internal/api/client/admin/domainkeysexpire.go5
-rw-r--r--internal/api/client/admin/emojicategoriesget.go10
-rw-r--r--internal/api/client/admin/emojicreate.go3
-rw-r--r--internal/api/client/admin/emojiupdate.go7
-rw-r--r--internal/api/client/admin/reportresolve.go3
-rw-r--r--internal/api/client/admin/rulecreate.go9
-rw-r--r--internal/api/client/admin/ruledelete.go6
-rw-r--r--internal/api/client/admin/rulesget.go2
-rw-r--r--internal/api/client/admin/ruleupdate.go18
-rw-r--r--internal/api/client/filters/v1/filterpost.go39
-rw-r--r--internal/api/client/filters/v1/filterput.go39
-rw-r--r--internal/api/client/instance/instancepatch.go10
-rw-r--r--internal/api/client/lists/listupdate.go11
-rw-r--r--internal/api/client/notifications/notificationget.go8
-rw-r--r--internal/api/client/statuses/statuscreate.go139
-rw-r--r--internal/api/client/statuses/statuscreate_test.go70
-rw-r--r--internal/api/client/timelines/tag.go8
-rw-r--r--internal/api/model/account.go4
-rw-r--r--internal/api/model/announcement.go2
-rw-r--r--internal/api/model/announcementreaction.go2
-rw-r--r--internal/api/model/domain.go6
-rw-r--r--internal/api/model/emoji.go4
-rw-r--r--internal/api/model/headerfilter.go8
-rw-r--r--internal/api/model/instancev1.go2
-rw-r--r--internal/api/model/list.go15
-rw-r--r--internal/api/model/marker.go2
-rw-r--r--internal/api/model/multistatus.go6
-rw-r--r--internal/api/model/poll.go10
-rw-r--r--internal/api/model/report.go12
-rw-r--r--internal/api/model/rule.go19
-rw-r--r--internal/api/model/status.go20
34 files changed, 434 insertions, 140 deletions
diff --git a/internal/api/activitypub/users/common.go b/internal/api/activitypub/users/common.go
index 2f16c7331..a10b99d95 100644
--- a/internal/api/activitypub/users/common.go
+++ b/internal/api/activitypub/users/common.go
@@ -72,7 +72,7 @@ type SwaggerFeaturedCollection struct {
// example: OrderedCollection
Type string `json:"type"`
// List of status URIs.
- // example: ['https://example.org/users/some_user/statuses/01GSZ0F7Q8SJKNRF777GJD271R', 'https://example.org/users/some_user/statuses/01GSZ0G012CBQ7TEKX689S3QRE']
+ // example: ["https://example.org/users/some_user/statuses/01GSZ0F7Q8SJKNRF777GJD271R", "https://example.org/users/some_user/statuses/01GSZ0G012CBQ7TEKX689S3QRE"]
Items []string `json:"items"`
// Number of items in this collection.
// example: 2
diff --git a/internal/api/activitypub/users/featured.go b/internal/api/activitypub/users/featured.go
index f256c1e75..b8b4fe681 100644
--- a/internal/api/activitypub/users/featured.go
+++ b/internal/api/activitypub/users/featured.go
@@ -44,6 +44,14 @@ import (
// produces:
// - application/activity+json
//
+// parameters:
+// -
+// name: username
+// type: string
+// description: Account name of the user
+// in: path
+// required: true
+//
// responses:
// '200':
// in: body
diff --git a/internal/api/client/accounts/accountupdate.go b/internal/api/client/accounts/accountupdate.go
index 41f76adf5..02c0fc5ac 100644
--- a/internal/api/client/accounts/accountupdate.go
+++ b/internal/api/client/accounts/accountupdate.go
@@ -120,12 +120,67 @@ import (
// description: Enable RSS feed for this account's Public posts at `/[username]/feed.rss`
// type: boolean
// -
-// name: fields_attributes
+// name: fields_attributes[0][name]
// in: formData
-// description: Profile fields to be added to this account's profile
-// type: array
-// items:
-// type: object
+// description: Name of 1st profile field to be added to this account's profile.
+// (The index may be any string; add more indexes to send more fields.)
+// type: string
+// -
+// name: fields_attributes[0][value]
+// in: formData
+// description: Value of 1st profile field to be added to this account's profile.
+// (The index may be any string; add more indexes to send more fields.)
+// type: string
+// -
+// name: fields_attributes[1][name]
+// in: formData
+// description: Name of 2nd profile field to be added to this account's profile.
+// type: string
+// -
+// name: fields_attributes[1][value]
+// in: formData
+// description: Value of 2nd profile field to be added to this account's profile.
+// type: string
+// -
+// name: fields_attributes[2][name]
+// in: formData
+// description: Name of 3rd profile field to be added to this account's profile.
+// type: string
+// -
+// name: fields_attributes[2][value]
+// in: formData
+// description: Value of 3rd profile field to be added to this account's profile.
+// type: string
+// -
+// name: fields_attributes[3][name]
+// in: formData
+// description: Name of 4th profile field to be added to this account's profile.
+// type: string
+// -
+// name: fields_attributes[3][value]
+// in: formData
+// description: Value of 4th profile field to be added to this account's profile.
+// type: string
+// -
+// name: fields_attributes[4][name]
+// in: formData
+// description: Name of 5th profile field to be added to this account's profile.
+// type: string
+// -
+// name: fields_attributes[4][value]
+// in: formData
+// description: Value of 5th profile field to be added to this account's profile.
+// type: string
+// -
+// name: fields_attributes[5][name]
+// in: formData
+// description: Name of 6th profile field to be added to this account's profile.
+// type: string
+// -
+// name: fields_attributes[5][value]
+// in: formData
+// description: Value of 6th profile field to be added to this account's profile.
+// type: string
//
// security:
// - OAuth2 Bearer:
diff --git a/internal/api/client/admin/domainkeysexpire.go b/internal/api/client/admin/domainkeysexpire.go
index 10a7597a4..4990d879f 100644
--- a/internal/api/client/admin/domainkeysexpire.go
+++ b/internal/api/client/admin/domainkeysexpire.go
@@ -61,8 +61,9 @@ import (
// -
// name: domain
// in: formData
-// description: Domain to expire keys for.
-// example: example.org
+// description: |-
+// Domain to expire keys for.
+// Sample: example.org
// type: string
//
// security:
diff --git a/internal/api/client/admin/emojicategoriesget.go b/internal/api/client/admin/emojicategoriesget.go
index 2c097c6df..51eb8fee4 100644
--- a/internal/api/client/admin/emojicategoriesget.go
+++ b/internal/api/client/admin/emojicategoriesget.go
@@ -38,21 +38,13 @@ import (
// produces:
// - application/json
//
-// parameters:
-// -
-// name: id
-// type: string
-// description: The id of the emoji.
-// in: path
-// required: true
-//
// responses:
// '200':
// description: Array of existing emoji categories.
// schema:
// type: array
// items:
-// "$ref": "#/definitions/adminEmojiCategory"
+// "$ref": "#/definitions/emojiCategory"
// '400':
// description: bad request
// '401':
diff --git a/internal/api/client/admin/emojicreate.go b/internal/api/client/admin/emojicreate.go
index 5d024f039..9086b27e0 100644
--- a/internal/api/client/admin/emojicreate.go
+++ b/internal/api/client/admin/emojicreate.go
@@ -67,10 +67,11 @@ import (
// name: category
// in: formData
// description: >-
-// Category in which to place the new emoji. 64 characters or less.
+// Category in which to place the new emoji.
// If left blank, emoji will be uncategorized. If a category with the
// given name doesn't exist yet, it will be created.
// type: string
+// maximumLength: 64
// required: false
//
// security:
diff --git a/internal/api/client/admin/emojiupdate.go b/internal/api/client/admin/emojiupdate.go
index f531f36f9..ffde2d597 100644
--- a/internal/api/client/admin/emojiupdate.go
+++ b/internal/api/client/admin/emojiupdate.go
@@ -73,6 +73,10 @@ import (
// For REMOTE emojis, `copy` or `disable` are supported.
// For LOCAL emojis, only `modify` is supported.
// type: string
+// enum:
+// - copy
+// - disable
+// - modify
// required: true
// -
// name: shortcode
@@ -94,9 +98,10 @@ import (
// name: category
// in: formData
// description: >-
-// Category in which to place the emoji. 64 characters or less.
+// Category in which to place the emoji.
// If a category with the given name doesn't exist yet, it will be created.
// type: string
+// maximumLength: 64
//
// security:
// - OAuth2 Bearer:
diff --git a/internal/api/client/admin/reportresolve.go b/internal/api/client/admin/reportresolve.go
index 9c1c32afe..2ad979b0b 100644
--- a/internal/api/client/admin/reportresolve.go
+++ b/internal/api/client/admin/reportresolve.go
@@ -60,8 +60,9 @@ import (
// Useful for providing an explanation about what action was taken (if any)
// before the report was marked as resolved. This will be visible to the user
// that created the report!
+//
+// Sample: The reported account was suspended.
// type: string
-// example: The reported account was suspended.
//
// security:
// - OAuth2 Bearer:
diff --git a/internal/api/client/admin/rulecreate.go b/internal/api/client/admin/rulecreate.go
index e838bff1e..155c69db0 100644
--- a/internal/api/client/admin/rulecreate.go
+++ b/internal/api/client/admin/rulecreate.go
@@ -43,15 +43,6 @@ import (
// produces:
// - application/json
//
-// parameters:
-// -
-// name: text
-// in: formData
-// description: >-
-// Text body for the instance rule, plaintext.
-// type: string
-// required: true
-//
// security:
// - OAuth2 Bearer:
// - admin
diff --git a/internal/api/client/admin/ruledelete.go b/internal/api/client/admin/ruledelete.go
index dfa84615f..834149978 100644
--- a/internal/api/client/admin/ruledelete.go
+++ b/internal/api/client/admin/ruledelete.go
@@ -28,7 +28,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/oauth"
)
-// RuleDELETEHandler swagger:operation DELETE /api/v1/admin/instance/rules{id} ruleDelete
+// RuleDELETEHandler swagger:operation DELETE /api/v1/admin/instance/rules/{id} ruleDelete
//
// Delete an existing instance rule.
//
@@ -45,10 +45,10 @@ import (
// parameters:
// -
// name: id
-// in: formData
+// in: path
// description: >-
// The id of the rule to delete.
-// type: path
+// type: string
// required: true
//
// security:
diff --git a/internal/api/client/admin/rulesget.go b/internal/api/client/admin/rulesget.go
index 2cc9e0158..e00ff1c07 100644
--- a/internal/api/client/admin/rulesget.go
+++ b/internal/api/client/admin/rulesget.go
@@ -27,7 +27,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/oauth"
)
-// rulesGETHandler swagger:operation GET /api/v1/admin/rules rules
+// RulesGETHandler swagger:operation GET /api/v1/admin/rules adminsRuleGet
//
// View instance rules, with IDs.
//
diff --git a/internal/api/client/admin/ruleupdate.go b/internal/api/client/admin/ruleupdate.go
index eafa3af34..2ba31485e 100644
--- a/internal/api/client/admin/ruleupdate.go
+++ b/internal/api/client/admin/ruleupdate.go
@@ -29,7 +29,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/oauth"
)
-// RulePATCHHandler swagger:operation PATCH /api/v1/admin/instance/rules{id} ruleUpdate
+// RulePATCHHandler swagger:operation PATCH /api/v1/admin/instance/rules/{id} ruleUpdate
//
// Update an existing instance rule.
//
@@ -43,22 +43,6 @@ import (
// produces:
// - application/json
//
-// parameters:
-// -
-// name: id
-// in: formData
-// description: >-
-// The id of the rule to update.
-// type: path
-// required: true
-// -
-// name: text
-// in: formData
-// description: >-
-// Text body for the updated instance rule, plaintext.
-// type: string
-// required: true
-//
// security:
// - OAuth2 Bearer:
// - admin
diff --git a/internal/api/client/filters/v1/filterpost.go b/internal/api/client/filters/v1/filterpost.go
index b0a626199..e150e8609 100644
--- a/internal/api/client/filters/v1/filterpost.go
+++ b/internal/api/client/filters/v1/filterpost.go
@@ -48,49 +48,58 @@ import (
// name: phrase
// in: formData
// required: true
-// description: The text to be filtered.
+// description: |-
+// The text to be filtered.
+//
+// Sample: fnord
// maxLength: 40
// type: string
-// example: "fnord"
// -
// name: context
// in: formData
// required: true
-// description: The contexts in which the filter should be applied.
+// description: |-
+// The contexts in which the filter should be applied.
+//
+// Sample: home, public
// enum:
// - home
// - notifications
// - public
// - thread
// - account
-// example:
-// - home
-// - public
-// items:
-// $ref: '#/definitions/filterContext'
-// minLength: 1
// type: array
+// items:
+// type:
+// string
+// minItems: 1
// uniqueItems: true
// -
// name: expires_in
// in: formData
-// description: Number of seconds from now that the filter should expire. If omitted, filter never expires.
+// description: |-
+// Number of seconds from now that the filter should expire. If omitted, filter never expires.
+//
+// Sample: 86400
// type: number
-// example: 86400
// -
// name: irreversible
// in: formData
-// description: Should matching entities be removed from the user's timelines/views, instead of hidden? Not supported yet.
+// description: |-
+// Should matching entities be removed from the user's timelines/views, instead of hidden? Not supported yet.
+//
+// Sample: false
// type: boolean
// default: false
-// example: false
// -
// name: whole_word
// in: formData
-// description: Should the filter consider word boundaries?
+// description: |-
+// Should the filter consider word boundaries?
+//
+// Sample: true
// type: boolean
// default: false
-// example: true
//
// security:
// - OAuth2 Bearer:
diff --git a/internal/api/client/filters/v1/filterput.go b/internal/api/client/filters/v1/filterput.go
index c686e4515..1822efb6d 100644
--- a/internal/api/client/filters/v1/filterput.go
+++ b/internal/api/client/filters/v1/filterput.go
@@ -54,49 +54,58 @@ import (
// name: phrase
// in: formData
// required: true
-// description: The text to be filtered.
+// description: |-
+// The text to be filtered.
+//
+// Sample: fnord
// maxLength: 40
// type: string
-// example: "fnord"
// -
// name: context
// in: formData
// required: true
-// description: The contexts in which the filter should be applied.
+// description: |-
+// The contexts in which the filter should be applied.
+//
+// Sample: home, public
// enum:
// - home
// - notifications
// - public
// - thread
// - account
-// example:
-// - home
-// - public
-// items:
-// $ref: '#/definitions/filterContext'
-// minLength: 1
// type: array
+// items:
+// type:
+// string
+// minItems: 1
// uniqueItems: true
// -
// name: expires_in
// in: formData
-// description: Number of seconds from now that the filter should expire. If omitted, filter never expires.
+// description: |-
+// Number of seconds from now that the filter should expire. If omitted, filter never expires.
+//
+// Sample: 86400
// type: number
-// example: 86400
// -
// name: irreversible
// in: formData
-// description: Should matching entities be removed from the user's timelines/views, instead of hidden? Not supported yet.
+// description: |-
+// Should matching entities be removed from the user's timelines/views, instead of hidden? Not supported yet.
+//
+// Sample: false
// type: boolean
// default: false
-// example: false
// -
// name: whole_word
// in: formData
-// description: Should the filter consider word boundaries?
+// description: |-
+// Should the filter consider word boundaries?
+//
+// Sample: true
// type: boolean
// default: false
-// example: true
//
// security:
// - OAuth2 Bearer:
diff --git a/internal/api/client/instance/instancepatch.go b/internal/api/client/instance/instancepatch.go
index 484579cf2..58549a866 100644
--- a/internal/api/client/instance/instancepatch.go
+++ b/internal/api/client/instance/instancepatch.go
@@ -52,7 +52,7 @@ import (
// in: formData
// description: Title to use for the instance.
// type: string
-// maximum: 40
+// maxLength: 40
// allowEmptyValue: true
// -
// name: contact_username
@@ -73,21 +73,21 @@ import (
// in: formData
// description: Short description of the instance.
// type: string
-// maximum: 500
+// maxLength: 500
// allowEmptyValue: true
// -
// name: description
// in: formData
// description: Longer description of the instance.
// type: string
-// maximum: 5000
+// maxLength: 5000
// allowEmptyValue: true
// -
// name: terms
// in: formData
// description: Terms and conditions of the instance.
// type: string
-// maximum: 5000
+// maxLength: 5000
// allowEmptyValue: true
// -
// name: thumbnail
@@ -113,7 +113,7 @@ import (
// '200':
// description: "The newly updated instance."
// schema:
-// "$ref": "#/definitions/instance"
+// "$ref": "#/definitions/instanceV1"
// '400':
// description: bad request
// '401':
diff --git a/internal/api/client/lists/listupdate.go b/internal/api/client/lists/listupdate.go
index 58a4cf1c4..966de4098 100644
--- a/internal/api/client/lists/listupdate.go
+++ b/internal/api/client/lists/listupdate.go
@@ -57,9 +57,10 @@ import (
// -
// name: title
// type: string
-// description: Title of this list.
+// description: |-
+// Title of this list.
+// Sample: Cool People
// in: formData
-// example: Cool People
// -
// name: replies_policy
// type: string
@@ -68,8 +69,12 @@ import (
// followed = Show replies to any followed user
// list = Show replies to members of the list
// none = Show replies to no one
+// Sample: list
+// enum:
+// - followed
+// - list
+// - none
// in: formData
-// example: list
//
// security:
// - OAuth2 Bearer:
diff --git a/internal/api/client/notifications/notificationget.go b/internal/api/client/notifications/notificationget.go
index 551eeca39..66bdefb28 100644
--- a/internal/api/client/notifications/notificationget.go
+++ b/internal/api/client/notifications/notificationget.go
@@ -38,6 +38,14 @@ import (
// produces:
// - application/json
//
+// parameters:
+// -
+// name: id
+// type: string
+// description: The ID of the notification.
+// in: path
+// required: true
+//
// security:
// - OAuth2 Bearer:
// - read:notifications
diff --git a/internal/api/client/statuses/statuscreate.go b/internal/api/client/statuses/statuscreate.go
index 929adaa6f..efbe79223 100644
--- a/internal/api/client/statuses/statuscreate.go
+++ b/internal/api/client/statuses/statuscreate.go
@@ -48,6 +48,145 @@ import (
// - application/xml
// - application/x-www-form-urlencoded
//
+// parameters:
+// -
+// name: status
+// x-go-name: Status
+// description: |-
+// Text content of the status.
+// If media_ids is provided, this becomes optional.
+// Attaching a poll is optional while status is provided.
+// type: string
+// in: formData
+// -
+// name: media_ids
+// x-go-name: MediaIDs
+// description: |-
+// Array of Attachment ids to be attached as media.
+// If provided, status becomes optional, and poll cannot be used.
+//
+// If the status is being submitted as a form, the key is 'media_ids[]',
+// but if it's json or xml, the key is 'media_ids'.
+// type: array
+// items:
+// type: string
+// in: formData
+// -
+// name: poll[options][]
+// x-go-name: PollOptions
+// description: |-
+// Array of possible poll answers.
+// If provided, media_ids cannot be used, and poll[expires_in] must be provided.
+// type: array
+// items:
+// type: string
+// in: formData
+// -
+// name: poll[expires_in]
+// x-go-name: PollExpiresIn
+// description: |-
+// Duration the poll should be open, in seconds.
+// If provided, media_ids cannot be used, and poll[options] must be provided.
+// type: integer
+// format: int64
+// in: formData
+// -
+// name: poll[multiple]
+// x-go-name: PollMultiple
+// description: Allow multiple choices on this poll.
+// type: boolean
+// default: false
+// in: formData
+// -
+// name: poll[hide_totals]
+// x-go-name: PollHideTotals
+// description: Hide vote counts until the poll ends.
+// type: boolean
+// default: true
+// in: formData
+// -
+// name: in_reply_to_id
+// x-go-name: InReplyToID
+// description: ID of the status being replied to, if status is a reply.
+// type: string
+// in: formData
+// -
+// name: sensitive
+// x-go-name: Sensitive
+// description: Status and attached media should be marked as sensitive.
+// type: boolean
+// in: formData
+// -
+// name: spoiler_text
+// x-go-name: SpoilerText
+// description: |-
+// Text to be shown as a warning or subject before the actual content.
+// Statuses are generally collapsed behind this field.
+// type: string
+// in: formData
+// -
+// name: visibility
+// x-go-name: Visibility
+// description: Visibility of the posted status.
+// type: string
+// enum:
+// - public
+// - unlisted
+// - private
+// - mutuals_only
+// - direct
+// in: formData
+// -
+// name: scheduled_at
+// x-go-name: ScheduledAt
+// description: |-
+// ISO 8601 Datetime at which to schedule a status.
+// Providing this parameter will cause ScheduledStatus to be returned instead of Status.
+// Must be at least 5 minutes in the future.
+//
+// This feature isn't implemented yet.
+// type: string
+// in: formData
+// -
+// name: language
+// x-go-name: Language
+// description: ISO 639 language code for this status.
+// type: string
+// in: formData
+// -
+// name: content_type
+// x-go-name: ContentType
+// description: Content type to use when parsing this status.
+// type: string
+// enum:
+// - text/plain
+// - text/markdown
+// in: formData
+// -
+// name: federated
+// x-go-name: Federated
+// description: This status will be federated beyond the local timeline(s).
+// in: formData
+// type: boolean
+// -
+// name: boostable
+// x-go-name: Boostable
+// description: This status can be boosted/reblogged.
+// in: formData
+// type: boolean
+// -
+// name: replyable
+// x-go-name: Replyable
+// description: This status can be replied to.
+// in: formData
+// type: boolean
+// -
+// name: likeable
+// x-go-name: Likeable
+// description: This status can be liked/faved.
+// in: formData
+// type: boolean
+//
// produces:
// - application/json
//
diff --git a/internal/api/client/statuses/statuscreate_test.go b/internal/api/client/statuses/statuscreate_test.go
index 881943450..ab7c67abf 100644
--- a/internal/api/client/statuses/statuscreate_test.go
+++ b/internal/api/client/statuses/statuscreate_test.go
@@ -21,10 +21,12 @@ import (
"context"
"encoding/json"
"fmt"
+ "io"
"io/ioutil"
"net/http"
"net/http/httptest"
"net/url"
+ "strings"
"testing"
"github.com/stretchr/testify/suite"
@@ -427,6 +429,74 @@ func (suite *StatusCreateTestSuite) TestPostNewStatusWithNoncanonicalLanguageTag
suite.Equal("en-US", *statusReply.Language)
}
+// Post a new status with an attached poll.
+func (suite *StatusCreateTestSuite) testPostNewStatusWithPoll(configure func(request *http.Request)) {
+ t := suite.testTokens["local_account_1"]
+ oauthToken := oauth.DBTokenToToken(t)
+
+ // setup
+ recorder := httptest.NewRecorder()
+ ctx, _ := testrig.CreateGinTestContext(recorder, nil)
+ ctx.Set(oauth.SessionAuthorizedApplication, suite.testApplications["application_1"])
+ ctx.Set(oauth.SessionAuthorizedToken, oauthToken)
+ ctx.Set(oauth.SessionAuthorizedUser, suite.testUsers["local_account_1"])
+ ctx.Set(oauth.SessionAuthorizedAccount, suite.testAccounts["local_account_1"])
+ ctx.Request = httptest.NewRequest(http.MethodPost, fmt.Sprintf("http://localhost:8080/%s", statuses.BasePath), nil) // the endpoint we're hitting
+ ctx.Request.Header.Set("accept", "application/json")
+ configure(ctx.Request)
+ suite.statusModule.StatusCreatePOSTHandler(ctx)
+
+ suite.EqualValues(http.StatusOK, recorder.Code)
+
+ result := recorder.Result()
+ defer result.Body.Close()
+ b, err := ioutil.ReadAll(result.Body)
+ suite.NoError(err)
+
+ statusReply := &apimodel.Status{}
+ err = json.Unmarshal(b, statusReply)
+ suite.NoError(err)
+
+ suite.Equal("<p>this is a status with a poll!</p>", statusReply.Content)
+ suite.Equal(apimodel.VisibilityPublic, statusReply.Visibility)
+ if suite.NotNil(statusReply.Poll) {
+ if suite.Len(statusReply.Poll.Options, 2) {
+ suite.Equal("first option", statusReply.Poll.Options[0].Title)
+ suite.Equal("second option", statusReply.Poll.Options[1].Title)
+ }
+ suite.NotZero(statusReply.Poll.ExpiresAt)
+ suite.False(statusReply.Poll.Expired)
+ suite.True(statusReply.Poll.Multiple)
+ }
+}
+
+func (suite *StatusCreateTestSuite) TestPostNewStatusWithPollForm() {
+ suite.testPostNewStatusWithPoll(func(request *http.Request) {
+ request.Form = url.Values{
+ "status": {"this is a status with a poll!"},
+ "visibility": {"public"},
+ "poll[options][]": {"first option", "second option"},
+ "poll[expires_in]": {"3600"},
+ "poll[multiple]": {"true"},
+ }
+ })
+}
+
+func (suite *StatusCreateTestSuite) TestPostNewStatusWithPollJSON() {
+ suite.testPostNewStatusWithPoll(func(request *http.Request) {
+ request.Header.Set("content-type", "application/json")
+ request.Body = io.NopCloser(strings.NewReader(`{
+ "status": "this is a status with a poll!",
+ "visibility": "public",
+ "poll": {
+ "options": ["first option", "second option"],
+ "expires_in": 3600,
+ "multiple": true
+ }
+ }`))
+ })
+}
+
func TestStatusCreateTestSuite(t *testing.T) {
suite.Run(t, new(StatusCreateTestSuite))
}
diff --git a/internal/api/client/timelines/tag.go b/internal/api/client/timelines/tag.go
index 0d95a6c58..e66955a73 100644
--- a/internal/api/client/timelines/tag.go
+++ b/internal/api/client/timelines/tag.go
@@ -26,7 +26,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/oauth"
)
-// HomeTimelineGETHandler swagger:operation GET /api/v1/timelines/tag/{tag_name} tagTimeline
+// TagTimelineGETHandler swagger:operation GET /api/v1/timelines/tag/{tag_name} tagTimeline
//
// See public statuses that use the given hashtag (case insensitive).
//
@@ -49,6 +49,12 @@ import (
//
// parameters:
// -
+// name: tag_name
+// type: string
+// description: Name of the tag
+// in: path
+// required: true
+// -
// name: max_id
// type: string
// description: >-
diff --git a/internal/api/model/account.go b/internal/api/model/account.go
index 46b043f80..7d3fa4b62 100644
--- a/internal/api/model/account.go
+++ b/internal/api/model/account.go
@@ -170,7 +170,7 @@ type UpdateCredentialsRequest struct {
// UpdateSource is to be used specifically in an UpdateCredentialsRequest.
//
-// swagger:model updateSource
+// swagger:ignore
type UpdateSource struct {
// Default post privacy for authored statuses.
Privacy *string `form:"privacy" json:"privacy"`
@@ -185,7 +185,7 @@ type UpdateSource struct {
// UpdateField is to be used specifically in an UpdateCredentialsRequest.
// By default, max 6 fields and 255 characters per property/value.
//
-// swagger:model updateField
+// swagger:ignore
type UpdateField struct {
// Key this form field was submitted with;
// only set if it was submitted as JSON.
diff --git a/internal/api/model/announcement.go b/internal/api/model/announcement.go
index f2b3b102c..f776ecf92 100644
--- a/internal/api/model/announcement.go
+++ b/internal/api/model/announcement.go
@@ -19,7 +19,7 @@ package model
// Announcement models an admin announcement for the instance.
//
-// swagger:model announcement
+// TODO: swagger:model announcement once announcement API is supported
type Announcement struct {
// The ID of the announcement.
// example: 01FC30T7X4TNCZK0TH90QYF3M4
diff --git a/internal/api/model/announcementreaction.go b/internal/api/model/announcementreaction.go
index a77e13bf6..f0a7006e9 100644
--- a/internal/api/model/announcementreaction.go
+++ b/internal/api/model/announcementreaction.go
@@ -19,7 +19,7 @@ package model
// AnnouncementReaction models a user reaction to an announcement.
//
-// swagger:model announcementReaction
+// TODO: swagger:model announcementReaction once announcement API is supported
type AnnouncementReaction struct {
// The emoji used for the reaction. Either a unicode emoji, or a custom emoji's shortcode.
// example: blobcat_uwu
diff --git a/internal/api/model/domain.go b/internal/api/model/domain.go
index a5e1ddf10..ddc96ef05 100644
--- a/internal/api/model/domain.go
+++ b/internal/api/model/domain.go
@@ -65,7 +65,7 @@ type DomainPermission struct {
// DomainPermissionRequest is the form submitted as a POST to create a new domain permission entry (allow/block).
//
-// swagger:model domainPermissionCreateRequest
+// swagger:ignore
type DomainPermissionRequest struct {
// A list of domains for which this permission request should apply.
// Only used if import=true is specified.
@@ -87,9 +87,9 @@ type DomainPermissionRequest struct {
PublicComment string `form:"public_comment" json:"public_comment" xml:"public_comment"`
}
-// DomainBlockCreateRequest is the form submitted as a POST to /api/v1/admin/domain_keys_expire to expire a domain's public keys.
+// DomainKeysExpireRequest is the form submitted as a POST to /api/v1/admin/domain_keys_expire to expire a domain's public keys.
//
-// swagger:model domainKeysExpireRequest
+// swagger:parameters domainKeysExpire
type DomainKeysExpireRequest struct {
// hostname/domain to expire keys for.
Domain string `form:"domain" json:"domain" xml:"domain"`
diff --git a/internal/api/model/emoji.go b/internal/api/model/emoji.go
index acf1f1332..cebc38196 100644
--- a/internal/api/model/emoji.go
+++ b/internal/api/model/emoji.go
@@ -42,7 +42,7 @@ type Emoji struct {
// EmojiCreateRequest represents a request to create a custom emoji made through the admin API.
//
-// swagger:model emojiCreateRequest
+// swagger:ignore
type EmojiCreateRequest struct {
// Desired shortcode for the emoji, without surrounding colons. This must be unique for the domain.
// example: blobcat_uwu
@@ -56,7 +56,7 @@ type EmojiCreateRequest struct {
// EmojiUpdateRequest represents a request to update a custom emoji, made through the admin API.
//
-// swagger:model emojiUpdateRequest
+// swagger:ignore
type EmojiUpdateRequest struct {
// Type of action. One of disable, modify, copy.
Type EmojiUpdateType `form:"type" json:"type" xml:"type"`
diff --git a/internal/api/model/headerfilter.go b/internal/api/model/headerfilter.go
index 96ba819f5..0800adeb2 100644
--- a/internal/api/model/headerfilter.go
+++ b/internal/api/model/headerfilter.go
@@ -18,6 +18,8 @@
package model
// HeaderFilter represents a regex value filter applied to one particular HTTP header (allow / block).
+//
+// swagger:model headerFilter
type HeaderFilter struct {
// The ID of the header filter.
// example: 01FBW21XJA09XYX51KV5JVBW0F
@@ -45,11 +47,15 @@ type HeaderFilter struct {
// HeaderFilterRequest is the form submitted as a POST to create a new header filter entry (allow / block).
//
-// swagger:model headerFilterCreateRequest
+// swagger:parameters headerFilterAllowCreate headerFilterBlockCreate
type HeaderFilterRequest struct {
// The HTTP header to match against (e.g. User-Agent).
+ // required: true
+ // in: formData
Header string `form:"header" json:"header" xml:"header"`
// The header value matching regular expression.
+ // required: true
+ // in: formData
Regex string `form:"regex" json:"regex" xml:"regex"`
}
diff --git a/internal/api/model/instancev1.go b/internal/api/model/instancev1.go
index b402cdefe..03e27619c 100644
--- a/internal/api/model/instancev1.go
+++ b/internal/api/model/instancev1.go
@@ -60,7 +60,7 @@ type InstanceV1 struct {
// example: 0.1.1 cb85f65
Version string `json:"version"`
// Primary language of the instance.
- // example: en
+ // example: ["en"]
Languages []string `json:"languages"`
// New account registrations are enabled on this instance.
Registrations bool `json:"registrations"`
diff --git a/internal/api/model/list.go b/internal/api/model/list.go
index f897bcc88..03ea3420d 100644
--- a/internal/api/model/list.go
+++ b/internal/api/model/list.go
@@ -37,7 +37,7 @@ type List struct {
// swagger:parameters listCreate
type ListCreateRequest struct {
// Title of this list.
- // example: Cool People
+ // Sample: Cool People
// in: formData
// required: true
Title string `form:"title" json:"title" xml:"title"`
@@ -45,28 +45,35 @@ type ListCreateRequest struct {
// followed = Show replies to any followed user
// list = Show replies to members of the list
// none = Show replies to no one
- // example: list
+ // Sample: list
// default: list
// in: formData
+ // enum:
+ // - followed
+ // - list
+ // - none
RepliesPolicy string `form:"replies_policy" json:"replies_policy" xml:"replies_policy"`
}
// ListUpdateRequest models list update parameters.
//
-// swagger:parameters listUpdate
+// swagger:ignore
type ListUpdateRequest struct {
// Title of this list.
- // example: Cool People
+ // Sample: Cool People
// in: formData
Title *string `form:"title" json:"title" xml:"title"`
// RepliesPolicy for this list.
// followed = Show replies to any followed user
// list = Show replies to members of the list
// none = Show replies to no one
+ // Sample: list
// in: formData
RepliesPolicy *string `form:"replies_policy" json:"replies_policy" xml:"replies_policy"`
}
+// ListAccountsChangeRequest is a list of account IDs to add to or remove from a list.
+//
// swagger:ignore
type ListAccountsChangeRequest struct {
AccountIDs []string `form:"account_ids[]" json:"account_ids" xml:"account_ids"`
diff --git a/internal/api/model/marker.go b/internal/api/model/marker.go
index f2d5cb296..d0d5dc67e 100644
--- a/internal/api/model/marker.go
+++ b/internal/api/model/marker.go
@@ -18,6 +18,8 @@
package model
// Marker represents the last read position within a user's timelines.
+//
+// swagger:model markers
type Marker struct {
// Information about the user's position in the home timeline.
Home *TimelineMarker `json:"home,omitempty"`
diff --git a/internal/api/model/multistatus.go b/internal/api/model/multistatus.go
index cac8b4f9b..d58ea8eae 100644
--- a/internal/api/model/multistatus.go
+++ b/internal/api/model/multistatus.go
@@ -22,7 +22,7 @@ package model
// 207 MULTI-STATUS to indicate a mixture of responses.
// See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/207
//
-// swagger:model multiStatus
+// TODO: swagger:model multiStatus once domain permissions API supports HTTP 207
type MultiStatus struct {
Data []MultiStatusEntry `json:"data"`
Metadata MultiStatusMetadata `json:"metadata"`
@@ -34,7 +34,7 @@ type MultiStatus struct {
// the caller, but at minimum it should be expected to be
// JSON-serializable.
//
-// swagger:model multiStatusEntry
+// TODO: swagger:model multiStatusEntry once domain permissions API supports HTTP 207
type MultiStatusEntry struct {
// The resource/result for this entry.
// Value may be any type, check the docs
@@ -49,7 +49,7 @@ type MultiStatusEntry struct {
// MultiStatusMetadata models an at-a-glance summary of
// the data contained in the MultiStatus.
//
-// swagger:model multiStatusMetadata
+// TODO: swagger:model multiStatusMetadata once domain permissions API supports HTTP 207
type MultiStatusMetadata struct {
// Success count + failure count.
Total int `json:"total"`
diff --git a/internal/api/model/poll.go b/internal/api/model/poll.go
index 5603ff222..089dfc0f0 100644
--- a/internal/api/model/poll.go
+++ b/internal/api/model/poll.go
@@ -73,26 +73,26 @@ type PollOption struct {
// PollRequest models a request to create a poll.
//
-// swagger:model pollRequest
+// swagger:ignore
type PollRequest struct {
// Array of possible answers.
// If provided, media_ids cannot be used, and poll[expires_in] must be provided.
// name: poll[options]
- Options []string `form:"options" json:"options" xml:"options"`
+ Options []string `form:"poll[options][]" json:"options" xml:"options"`
// Duration the poll should be open, in seconds.
// If provided, media_ids cannot be used, and poll[options] must be provided.
- ExpiresIn int `form:"expires_in" xml:"expires_in"`
+ ExpiresIn int `form:"poll[expires_in]" xml:"expires_in"`
// Duration the poll should be open, in seconds.
// If provided, media_ids cannot be used, and poll[options] must be provided.
ExpiresInI interface{} `json:"expires_in"`
// Allow multiple choices on this poll.
- Multiple bool `form:"multiple" json:"multiple" xml:"multiple"`
+ Multiple bool `form:"poll[multiple]" json:"multiple" xml:"multiple"`
// Hide vote counts until the poll ends.
- HideTotals bool `form:"hide_totals" json:"hide_totals" xml:"hide_totals"`
+ HideTotals bool `form:"poll[hide_totals]" json:"hide_totals" xml:"hide_totals"`
}
// PollVoteRequest models a request to vote in a poll.
diff --git a/internal/api/model/report.go b/internal/api/model/report.go
index b9b8c77d2..175875204 100644
--- a/internal/api/model/report.go
+++ b/internal/api/model/report.go
@@ -65,31 +65,31 @@ type Report struct {
// swagger:parameters reportCreate
type ReportCreateRequest struct {
// ID of the account to report.
- // example: 01GPE75FXSH2EGFBF85NXPH3KP
+ // Sample: 01GPE75FXSH2EGFBF85NXPH3KP
// in: formData
// required: true
AccountID string `form:"account_id" json:"account_id" xml:"account_id"`
// IDs of statuses to attach to the report to provide additional context.
- // example: ["01GPE76N4SBVRZ8K24TW51ZZQ4","01GPE76WN9JZE62EPT3Q9FRRD4"]
+ // Sample: ["01GPE76N4SBVRZ8K24TW51ZZQ4","01GPE76WN9JZE62EPT3Q9FRRD4"]
// in: formData
StatusIDs []string `form:"status_ids[]" json:"status_ids" xml:"status_ids"`
// The reason for the report. Default maximum of 1000 characters.
- // example: Anti-Blackness, transphobia.
+ // Sample: Anti-Blackness, transphobia.
// in: formData
Comment string `form:"comment" json:"comment" xml:"comment"`
// If the account is remote, should the report be forwarded to the remote admin?
- // example: true
+ // Sample: true
// default: false
// in: formData
Forward bool `form:"forward" json:"forward" xml:"forward"`
// Specify if the report is due to spam, violation of enumerated instance rules, or some other reason.
// Currently only 'other' is supported.
- // example: other
+ // Sample: other
// default: other
// in: formData
Category string `form:"category" json:"category" xml:"category"`
// IDs of rules on this instance which have been broken according to the reporter.
- // example: ["01GPBN5YDY6JKBWE44H7YQBDCQ","01GPBN65PDWSBPWVDD0SQCFFY3"]
+ // Sample: ["01GPBN5YDY6JKBWE44H7YQBDCQ","01GPBN65PDWSBPWVDD0SQCFFY3"]
// in: formData
RuleIDs []string `form:"rule_ids[]" json:"rule_ids" xml:"rule_ids"`
}
diff --git a/internal/api/model/rule.go b/internal/api/model/rule.go
index f4caf7dd0..b94c502c5 100644
--- a/internal/api/model/rule.go
+++ b/internal/api/model/rule.go
@@ -27,15 +27,24 @@ type InstanceRule struct {
// InstanceRuleCreateRequest represents a request to create a new instance rule, made through the admin API.
//
-// swagger:model instanceRuleCreateRequest
+// swagger:parameters ruleCreate
type InstanceRuleCreateRequest struct {
- Text string `form:"text" validation:"required"`
+ // Text body for the instance rule, plaintext.
+ // required: true
+ // in: formData
+ Text string `form:"text" json:"text" validation:"required"`
}
// InstanceRuleUpdateRequest represents a request to update the text of an instance rule, made through the admin API.
//
-// swagger:model instanceRuleUpdateRequest
+// swagger:parameters ruleUpdate
type InstanceRuleUpdateRequest struct {
- ID string `form:"id"`
- Text string `form:"text"`
+ // The id of the rule to update.
+ // required: true
+ // in: path
+ ID string `form:"id" json:"id"`
+ // Text body for the updated instance rule, plaintext.
+ // required: true
+ // in: formData
+ Text string `form:"text" json:"text"`
}
diff --git a/internal/api/model/status.go b/internal/api/model/status.go
index 8ca41c767..fed2cdf37 100644
--- a/internal/api/model/status.go
+++ b/internal/api/model/status.go
@@ -163,47 +163,33 @@ type StatusReblogged struct {
// StatusCreateRequest models status creation parameters.
//
-// swagger:model statusCreateRequest
+// swagger:ignore
type StatusCreateRequest struct {
// Text content of the status.
// If media_ids is provided, this becomes optional.
// Attaching a poll is optional while status is provided.
- // in: formData
Status string `form:"status" json:"status" xml:"status"`
// Array of Attachment ids to be attached as media.
// If provided, status becomes optional, and poll cannot be used.
- //
- // If the status is being submitted as a form, the key is 'media_ids[]',
- // but if it's json or xml, the key is 'media_ids'.
- //
- // in: formData
MediaIDs []string `form:"media_ids[]" json:"media_ids" xml:"media_ids"`
// Poll to include with this status.
- // in: formData
Poll *PollRequest `form:"poll" json:"poll" xml:"poll"`
// ID of the status being replied to, if status is a reply.
- // in: formData
InReplyToID string `form:"in_reply_to_id" json:"in_reply_to_id" xml:"in_reply_to_id"`
// Status and attached media should be marked as sensitive.
- // in: formData
Sensitive bool `form:"sensitive" json:"sensitive" xml:"sensitive"`
// Text to be shown as a warning or subject before the actual content.
// Statuses are generally collapsed behind this field.
- // in: formData
SpoilerText string `form:"spoiler_text" json:"spoiler_text" xml:"spoiler_text"`
// Visibility of the posted status.
- // in: formData
Visibility Visibility `form:"visibility" json:"visibility" xml:"visibility"`
// ISO 8601 Datetime at which to schedule a status.
// Providing this parameter will cause ScheduledStatus to be returned instead of Status.
// Must be at least 5 minutes in the future.
- // in: formData
ScheduledAt string `form:"scheduled_at" json:"scheduled_at" xml:"scheduled_at"`
// ISO 639 language code for this status.
- // in: formData
Language string `form:"language" json:"language" xml:"language"`
// Content type to use when parsing this status.
- // in: formData
ContentType StatusContentType `form:"content_type" json:"content_type" xml:"content_type"`
}
@@ -229,7 +215,7 @@ const (
// AdvancedStatusCreateForm wraps the mastodon-compatible status create form along with the GTS advanced
// visibility settings.
//
-// swagger:parameters statusCreate
+// swagger:ignore
type AdvancedStatusCreateForm struct {
StatusCreateRequest
AdvancedVisibilityFlagsForm
@@ -238,7 +224,7 @@ type AdvancedStatusCreateForm struct {
// AdvancedVisibilityFlagsForm allows a few more advanced flags to be set on new statuses, in addition
// to the standard mastodon-compatible ones.
//
-// swagger:model advancedVisibilityFlagsForm
+// swagger:ignore
type AdvancedVisibilityFlagsForm struct {
// This status will be federated beyond the local timeline(s).
Federated *bool `form:"federated" json:"federated" xml:"federated"`