From 5114332d5a568af82d677d98b93b143f6bdc83b8 Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Wed, 10 Jul 2024 07:23:01 -0700 Subject: [PATCH] moving new rss to accept a body request --- docs/docs.go | 35 +++++++++++++++++++++------------- docs/swagger.json | 35 +++++++++++++++++++++------------- docs/swagger.yaml | 25 ++++++++++++++---------- domain/requests.go | 8 ++++---- internal/handler/v1/sources.go | 7 +++---- 5 files changed, 66 insertions(+), 44 deletions(-) diff --git a/docs/docs.go b/docs/docs.go index 2862d26..61c249f 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -719,18 +719,13 @@ const docTemplate = `{ "summary": "Creates a new rss source to monitor.", "parameters": [ { - "type": "string", - "description": "Site Name", - "name": "name", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "RSS Url", - "name": "url", - "in": "query", - "required": true + "description": "body", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.NewSourceParamRequest" + } } ], "responses": { @@ -863,7 +858,7 @@ const docTemplate = `{ "parameters": [ { "type": "integer", - "description": "uuid", + "description": "id", "name": "id", "in": "path", "required": true @@ -1435,6 +1430,20 @@ const docTemplate = `{ } } }, + "domain.NewSourceParamRequest": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "tags": { + "type": "string" + }, + "url": { + "type": "string" + } + } + }, "domain.RefreshTokenRequest": { "type": "object", "properties": { diff --git a/docs/swagger.json b/docs/swagger.json index 10d542c..f67f4ad 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -710,18 +710,13 @@ "summary": "Creates a new rss source to monitor.", "parameters": [ { - "type": "string", - "description": "Site Name", - "name": "name", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "RSS Url", - "name": "url", - "in": "query", - "required": true + "description": "body", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.NewSourceParamRequest" + } } ], "responses": { @@ -854,7 +849,7 @@ "parameters": [ { "type": "integer", - "description": "uuid", + "description": "id", "name": "id", "in": "path", "required": true @@ -1426,6 +1421,20 @@ } } }, + "domain.NewSourceParamRequest": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "tags": { + "type": "string" + }, + "url": { + "type": "string" + } + } + }, "domain.RefreshTokenRequest": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 77354da..973d9f4 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -99,6 +99,15 @@ definitions: type: type: string type: object + domain.NewSourceParamRequest: + properties: + name: + type: string + tags: + type: string + url: + type: string + type: object domain.RefreshTokenRequest: properties: refreshToken: @@ -487,7 +496,7 @@ paths: /v1/sources/{id}: get: parameters: - - description: uuid + - description: id in: path name: id required: true @@ -688,16 +697,12 @@ paths: /v1/sources/new/rss: post: parameters: - - description: Site Name - in: query - name: name + - description: body + in: body + name: request required: true - type: string - - description: RSS Url - in: query - name: url - required: true - type: string + schema: + $ref: '#/definitions/domain.NewSourceParamRequest' responses: "200": description: ok diff --git a/domain/requests.go b/domain/requests.go index 557e3b5..72a73e9 100644 --- a/domain/requests.go +++ b/domain/requests.go @@ -11,9 +11,9 @@ type GetSourceBySourceAndNameParamRequest struct { } type NewSourceParamRequest struct { - Name string `query:"name"` - Url string `query:"url"` - Tags string `query:"tags"` + Name string `json:"name"` + Url string `json:"url"` + Tags string `json:"tags"` } type RefreshTokenRequest struct { @@ -24,4 +24,4 @@ type RefreshTokenRequest struct { type UpdateScopesRequest struct { Username string `json:"username"` Scopes []string `json:"scopes" validate:"required"` -} \ No newline at end of file +} diff --git a/internal/handler/v1/sources.go b/internal/handler/v1/sources.go index ef994eb..8ccc224 100644 --- a/internal/handler/v1/sources.go +++ b/internal/handler/v1/sources.go @@ -397,8 +397,7 @@ func (s *Handler) newTwitchSource(c echo.Context) error { // NewRssSource // @Summary Creates a new rss source to monitor. -// @Param name query string true "Site Name" -// @Param url query string true "RSS Url" +// @Param request body domain.NewSourceParamRequest true "body" // @Tags Source // @Router /v1/sources/new/rss [post] // @Success 200 {object} domain.SourcesResponse "ok" @@ -419,8 +418,8 @@ func (s *Handler) newRssSource(c echo.Context) error { return c.JSON(http.StatusUnauthorized, p) } - var param domain.NewSourceParamRequest - err = c.Bind(¶m) + param := domain.NewSourceParamRequest{} + err = (&echo.DefaultBinder{}).BindBody(c, ¶m) if err != nil { p.BaseResponse.Message = err.Error() return c.JSON(http.StatusBadRequest, p) -- 2.45.2