From 2eb17d80c8ffc41ffa87a4250f091bff5bfaaa85 Mon Sep 17 00:00:00 2001 From: FlomoN Date: Mon, 20 Jun 2022 18:37:13 +0200 Subject: [PATCH] add some more params to other api routes with path based params --- pkg/api/chunked.go | 1 + pkg/api/delay.go | 1 + pkg/api/docs/docs.go | 36 ++++++++++++++++++++++++++++++++++++ pkg/api/docs/swagger.json | 36 ++++++++++++++++++++++++++++++++++++ pkg/api/docs/swagger.yaml | 24 ++++++++++++++++++++++++ pkg/api/status.go | 1 + pkg/api/store.go | 1 + 7 files changed, 100 insertions(+) diff --git a/pkg/api/chunked.go b/pkg/api/chunked.go index 19ee098..0bf668e 100644 --- a/pkg/api/chunked.go +++ b/pkg/api/chunked.go @@ -15,6 +15,7 @@ import ( // @Tags HTTP API // @Accept json // @Produce json +// @Param seconds path int true "seconds to wait for" // @Router /chunked/{seconds} [get] // @Success 200 {object} api.MapResponse func (s *Server) chunkedHandler(w http.ResponseWriter, r *http.Request) { diff --git a/pkg/api/delay.go b/pkg/api/delay.go index 8d6db46..6655cf7 100644 --- a/pkg/api/delay.go +++ b/pkg/api/delay.go @@ -49,6 +49,7 @@ func (m *RandomDelayMiddleware) Handler(next http.Handler) http.Handler { // @Tags HTTP API // @Accept json // @Produce json +// @Param seconds path int true "seconds to wait for" // @Router /delay/{seconds} [get] // @Success 200 {object} api.MapResponse func (s *Server) delayHandler(w http.ResponseWriter, r *http.Request) { diff --git a/pkg/api/docs/docs.go b/pkg/api/docs/docs.go index 1b2b661..aa2b1c4 100644 --- a/pkg/api/docs/docs.go +++ b/pkg/api/docs/docs.go @@ -188,6 +188,15 @@ const docTemplate = `{ "HTTP API" ], "summary": "Chunked transfer encoding", + "parameters": [ + { + "type": "integer", + "description": "seconds to wait for", + "name": "seconds", + "in": "path", + "required": true + } + ], "responses": { "200": { "description": "OK", @@ -211,6 +220,15 @@ const docTemplate = `{ "HTTP API" ], "summary": "Delay", + "parameters": [ + { + "type": "integer", + "description": "seconds to wait for", + "name": "seconds", + "in": "path", + "required": true + } + ], "responses": { "200": { "description": "OK", @@ -408,6 +426,15 @@ const docTemplate = `{ "HTTP API" ], "summary": "Status code", + "parameters": [ + { + "type": "integer", + "description": "status code to return", + "name": "code", + "in": "path", + "required": true + } + ], "responses": { "200": { "description": "OK", @@ -454,6 +481,15 @@ const docTemplate = `{ "HTTP API" ], "summary": "Download file", + "parameters": [ + { + "type": "string", + "description": "hash value", + "name": "hash", + "in": "path", + "required": true + } + ], "responses": { "200": { "description": "file", diff --git a/pkg/api/docs/swagger.json b/pkg/api/docs/swagger.json index 9720822..655632e 100644 --- a/pkg/api/docs/swagger.json +++ b/pkg/api/docs/swagger.json @@ -185,6 +185,15 @@ "HTTP API" ], "summary": "Chunked transfer encoding", + "parameters": [ + { + "type": "integer", + "description": "seconds to wait for", + "name": "seconds", + "in": "path", + "required": true + } + ], "responses": { "200": { "description": "OK", @@ -208,6 +217,15 @@ "HTTP API" ], "summary": "Delay", + "parameters": [ + { + "type": "integer", + "description": "seconds to wait for", + "name": "seconds", + "in": "path", + "required": true + } + ], "responses": { "200": { "description": "OK", @@ -405,6 +423,15 @@ "HTTP API" ], "summary": "Status code", + "parameters": [ + { + "type": "integer", + "description": "status code to return", + "name": "code", + "in": "path", + "required": true + } + ], "responses": { "200": { "description": "OK", @@ -451,6 +478,15 @@ "HTTP API" ], "summary": "Download file", + "parameters": [ + { + "type": "string", + "description": "hash value", + "name": "hash", + "in": "path", + "required": true + } + ], "responses": { "200": { "description": "file", diff --git a/pkg/api/docs/swagger.yaml b/pkg/api/docs/swagger.yaml index 4308297..3c6b1ca 100644 --- a/pkg/api/docs/swagger.yaml +++ b/pkg/api/docs/swagger.yaml @@ -161,6 +161,12 @@ paths: - application/json description: uses transfer-encoding type chunked to give a partial response and then waits for the specified period + parameters: + - description: seconds to wait for + in: path + name: seconds + required: true + type: integer produces: - application/json responses: @@ -176,6 +182,12 @@ paths: consumes: - application/json description: waits for the specified period + parameters: + - description: seconds to wait for + in: path + name: seconds + required: true + type: integer produces: - application/json responses: @@ -306,6 +318,12 @@ paths: consumes: - application/json description: sets the response status code to the specified code + parameters: + - description: status code to return + in: path + name: code + required: true + type: integer produces: - application/json responses: @@ -337,6 +355,12 @@ paths: consumes: - application/json description: returns the content of the file /data/hash if exists + parameters: + - description: hash value + in: path + name: hash + required: true + type: string produces: - text/plain responses: diff --git a/pkg/api/status.go b/pkg/api/status.go index 8407f16..e9e33ae 100644 --- a/pkg/api/status.go +++ b/pkg/api/status.go @@ -14,6 +14,7 @@ import ( // @Tags HTTP API // @Accept json // @Produce json +// @Param code path int true "status code to return" // @Router /status/{code} [get] // @Success 200 {object} api.MapResponse func (s *Server) statusHandler(w http.ResponseWriter, r *http.Request) { diff --git a/pkg/api/store.go b/pkg/api/store.go index 13180c0..73b3943 100644 --- a/pkg/api/store.go +++ b/pkg/api/store.go @@ -45,6 +45,7 @@ func (s *Server) storeWriteHandler(w http.ResponseWriter, r *http.Request) { // @Tags HTTP API // @Accept json // @Produce plain +// @Param hash path string true "hash value" // @Router /store/{hash} [get] // @Success 200 {string} string "file" func (s *Server) storeReadHandler(w http.ResponseWriter, r *http.Request) {