diff --git a/pkg/routes/api/v1/testing.go b/pkg/routes/api/v1/testing.go index 7c6807340..5fb04e547 100644 --- a/pkg/routes/api/v1/testing.go +++ b/pkg/routes/api/v1/testing.go @@ -25,6 +25,16 @@ import ( "net/http" ) +// HandleTesting is the web handler to reset the db +// @Summary Reset the db to a defined state +// @Description Fills the specified table with the content provided in the payload. You need to enable the testing endpoint before doing this and provide the `Authorization: ` secret when making requests to this endpoint. See docs for more details. +// @tags testing +// @Accept json +// @Produce json +// @Param table path string true "The table to reset" +// @Success 201 {array} user.User "Everything has been imported successfully." +// @Failure 500 {object} models.Message "Internal server error." +// @Router /test/{table} [patch] func HandleTesting(c echo.Context) error { token := c.Request().Header.Get("Authorization") if token != config.ServiceTestingtoken.GetString() { diff --git a/pkg/swagger/docs.go b/pkg/swagger/docs.go index 75a15be9f..6c6e77231 100644 --- a/pkg/swagger/docs.go +++ b/pkg/swagger/docs.go @@ -5605,6 +5605,47 @@ var doc = `{ } } }, + "/test/{table}": { + "patch": { + "description": "Fills the specified table with the content provided in the payload. You need to enable the testing endpoint before doing this and provide the ` + "`" + `Authorization: \u003ctoken\u003e` + "`" + ` secret when making requests to this endpoint. See docs for more details.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "testing" + ], + "summary": "Reset the db to a defined state", + "parameters": [ + { + "type": "string", + "description": "The table to reset", + "name": "table", + "in": "path", + "required": true + } + ], + "responses": { + "201": { + "description": "Everything has been imported successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/user.User" + } + } + }, + "500": { + "description": "Internal server error.", + "schema": { + "$ref": "#/definitions/models.Message" + } + } + } + } + }, "/user": { "get": { "security": [ diff --git a/pkg/swagger/swagger.json b/pkg/swagger/swagger.json index ce5b38a28..28280ba85 100644 --- a/pkg/swagger/swagger.json +++ b/pkg/swagger/swagger.json @@ -5588,6 +5588,47 @@ } } }, + "/test/{table}": { + "patch": { + "description": "Fills the specified table with the content provided in the payload. You need to enable the testing endpoint before doing this and provide the `Authorization: \u003ctoken\u003e` secret when making requests to this endpoint. See docs for more details.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "testing" + ], + "summary": "Reset the db to a defined state", + "parameters": [ + { + "type": "string", + "description": "The table to reset", + "name": "table", + "in": "path", + "required": true + } + ], + "responses": { + "201": { + "description": "Everything has been imported successfully.", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/user.User" + } + } + }, + "500": { + "description": "Internal server error.", + "schema": { + "$ref": "#/definitions/models.Message" + } + } + } + } + }, "/user": { "get": { "security": [ diff --git a/pkg/swagger/swagger.yaml b/pkg/swagger/swagger.yaml index 8823fdbc9..b69133e67 100644 --- a/pkg/swagger/swagger.yaml +++ b/pkg/swagger/swagger.yaml @@ -4653,6 +4653,33 @@ paths: summary: Toggle a team member's admin status tags: - team + /test/{table}: + patch: + consumes: + - application/json + description: 'Fills the specified table with the content provided in the payload. You need to enable the testing endpoint before doing this and provide the `Authorization: ` secret when making requests to this endpoint. See docs for more details.' + parameters: + - description: The table to reset + in: path + name: table + required: true + type: string + produces: + - application/json + responses: + "201": + description: Everything has been imported successfully. + schema: + items: + $ref: '#/definitions/user.User' + type: array + "500": + description: Internal server error. + schema: + $ref: '#/definitions/models.Message' + summary: Reset the db to a defined state + tags: + - testing /user: get: consumes: