From 0c7b069c4a09f01a3a6c59bd7b66f096f8dcec40 Mon Sep 17 00:00:00 2001 From: Vyr Cossont Date: Tue, 11 Nov 2025 19:39:09 +0100 Subject: [chore] Apply schema for OpenAPI errors (#4511) Adds an error struct to Swagger covering normal and OAuth errors for client API endpoints. Now clients using Swagger codegen can handle errors. Specifically, if you _don't_ have typed errors in your Swagger IDL and you're using `go-swagger` to generate your API client, the error message is discarded and you are only told the status code. With this change in place, clients like `slurp` can tell the user that they tried to upload an emoji that was too big or whatever. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4511 Reviewed-by: tobi Co-authored-by: Vyr Cossont Co-committed-by: Vyr Cossont --- internal/api/client/exports/blocks.go | 6 ++++++ internal/api/client/exports/followers.go | 6 ++++++ internal/api/client/exports/following.go | 6 ++++++ internal/api/client/exports/lists.go | 6 ++++++ internal/api/client/exports/mutes.go | 6 ++++++ internal/api/client/exports/stats.go | 6 ++++++ 6 files changed, 36 insertions(+) (limited to 'internal/api/client/exports') diff --git a/internal/api/client/exports/blocks.go b/internal/api/client/exports/blocks.go index fae8a201b..614073971 100644 --- a/internal/api/client/exports/blocks.go +++ b/internal/api/client/exports/blocks.go @@ -45,10 +45,16 @@ import ( // name: accounts // description: CSV file of accounts that you block. // '401': +// schema: +// "$ref": "#/definitions/error" // description: unauthorized // '406': +// schema: +// "$ref": "#/definitions/error" // description: not acceptable // '500': +// schema: +// "$ref": "#/definitions/error" // description: internal server error func (m *Module) ExportBlocksGETHandler(c *gin.Context) { authed, errWithCode := apiutil.TokenAuth(c, diff --git a/internal/api/client/exports/followers.go b/internal/api/client/exports/followers.go index 520fbef70..7a5ce075d 100644 --- a/internal/api/client/exports/followers.go +++ b/internal/api/client/exports/followers.go @@ -45,10 +45,16 @@ import ( // name: accounts // description: CSV file of accounts that follow you. // '401': +// schema: +// "$ref": "#/definitions/error" // description: unauthorized // '406': +// schema: +// "$ref": "#/definitions/error" // description: not acceptable // '500': +// schema: +// "$ref": "#/definitions/error" // description: internal server error func (m *Module) ExportFollowersGETHandler(c *gin.Context) { authed, errWithCode := apiutil.TokenAuth(c, diff --git a/internal/api/client/exports/following.go b/internal/api/client/exports/following.go index 8d6306092..e7fb908fb 100644 --- a/internal/api/client/exports/following.go +++ b/internal/api/client/exports/following.go @@ -45,10 +45,16 @@ import ( // name: accounts // description: CSV file of accounts that you follow. // '401': +// schema: +// "$ref": "#/definitions/error" // description: unauthorized // '406': +// schema: +// "$ref": "#/definitions/error" // description: not acceptable // '500': +// schema: +// "$ref": "#/definitions/error" // description: internal server error func (m *Module) ExportFollowingGETHandler(c *gin.Context) { authed, errWithCode := apiutil.TokenAuth(c, diff --git a/internal/api/client/exports/lists.go b/internal/api/client/exports/lists.go index cf152bf55..ccd4b9012 100644 --- a/internal/api/client/exports/lists.go +++ b/internal/api/client/exports/lists.go @@ -45,10 +45,16 @@ import ( // name: accounts // description: CSV file of lists. // '401': +// schema: +// "$ref": "#/definitions/error" // description: unauthorized // '406': +// schema: +// "$ref": "#/definitions/error" // description: not acceptable // '500': +// schema: +// "$ref": "#/definitions/error" // description: internal server error func (m *Module) ExportListsGETHandler(c *gin.Context) { authed, errWithCode := apiutil.TokenAuth(c, diff --git a/internal/api/client/exports/mutes.go b/internal/api/client/exports/mutes.go index 0db94db62..66550950e 100644 --- a/internal/api/client/exports/mutes.go +++ b/internal/api/client/exports/mutes.go @@ -45,10 +45,16 @@ import ( // name: accounts // description: CSV file of accounts that you mute. // '401': +// schema: +// "$ref": "#/definitions/error" // description: unauthorized // '406': +// schema: +// "$ref": "#/definitions/error" // description: not acceptable // '500': +// schema: +// "$ref": "#/definitions/error" // description: internal server error func (m *Module) ExportMutesGETHandler(c *gin.Context) { authed, errWithCode := apiutil.TokenAuth(c, diff --git a/internal/api/client/exports/stats.go b/internal/api/client/exports/stats.go index 6b9436065..3eccfb644 100644 --- a/internal/api/client/exports/stats.go +++ b/internal/api/client/exports/stats.go @@ -46,10 +46,16 @@ import ( // schema: // "$ref": "#/definitions/accountExportStats" // '401': +// schema: +// "$ref": "#/definitions/error" // description: unauthorized // '406': +// schema: +// "$ref": "#/definitions/error" // description: not acceptable // '500': +// schema: +// "$ref": "#/definitions/error" // description: internal server error func (m *Module) ExportStatsGETHandler(c *gin.Context) { authed, errWithCode := apiutil.TokenAuth(c, -- cgit v1.2.3