diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-04-20 20:53:00 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-04-21 23:57:47 +0300 |
| commit | 4004ac9b925f6f9377533ce9ff349a5db681e7d4 (patch) | |
| tree | 21aeaf9998fe098dbb0b999b5b1ea965fe957bb5 | |
| parent | fix: empty country code on user creation (#36) (diff) | |
| download | lphub-4004ac9b925f6f9377533ce9ff349a5db681e7d4.tar.gz lphub-4004ac9b925f6f9377533ce9ff349a5db681e7d4.tar.bz2 lphub-4004ac9b925f6f9377533ce9ff349a5db681e7d4.zip | |
doc: add auth header fields (#34)
Diffstat (limited to '')
| -rw-r--r-- | backend/controllers/recordController.go | 1 | ||||
| -rw-r--r-- | backend/controllers/userController.go | 15 | ||||
| -rw-r--r-- | docs/docs.go | 41 | ||||
| -rw-r--r-- | docs/swagger.json | 35 | ||||
| -rw-r--r-- | docs/swagger.yaml | 27 |
5 files changed, 102 insertions, 17 deletions
diff --git a/backend/controllers/recordController.go b/backend/controllers/recordController.go index 27f39fc..3e64e14 100644 --- a/backend/controllers/recordController.go +++ b/backend/controllers/recordController.go | |||
| @@ -23,6 +23,7 @@ import ( | |||
| 23 | // @Summary Post record with demo of a specific map. | 23 | // @Summary Post record with demo of a specific map. |
| 24 | // @Accept mpfd | 24 | // @Accept mpfd |
| 25 | // @Produce json | 25 | // @Produce json |
| 26 | // @Param Authorization header string true "JWT Token" | ||
| 26 | // @Param demos formData []file true "Demos" | 27 | // @Param demos formData []file true "Demos" |
| 27 | // @Param score_count formData int true "Score Count" | 28 | // @Param score_count formData int true "Score Count" |
| 28 | // @Param score_time formData int true "Score Time" | 29 | // @Param score_time formData int true "Score Time" |
diff --git a/backend/controllers/userController.go b/backend/controllers/userController.go index cb6c15d..51c18d5 100644 --- a/backend/controllers/userController.go +++ b/backend/controllers/userController.go | |||
| @@ -16,9 +16,10 @@ import ( | |||
| 16 | // @Summary Get profile page of session user. | 16 | // @Summary Get profile page of session user. |
| 17 | // @Accept json | 17 | // @Accept json |
| 18 | // @Produce json | 18 | // @Produce json |
| 19 | // @Success 200 {object} models.Response{data=models.ProfileResponse} | 19 | // @Param Authorization header string true "JWT Token" |
| 20 | // @Failure 400 {object} models.Response | 20 | // @Success 200 {object} models.Response{data=models.ProfileResponse} |
| 21 | // @Failure 401 {object} models.Response | 21 | // @Failure 400 {object} models.Response |
| 22 | // @Failure 401 {object} models.Response | ||
| 22 | // @Router /profile [get] | 23 | // @Router /profile [get] |
| 23 | func Profile(c *gin.Context) { | 24 | func Profile(c *gin.Context) { |
| 24 | // Check if user exists | 25 | // Check if user exists |
| @@ -202,9 +203,10 @@ func FetchUser(c *gin.Context) { | |||
| 202 | // @Summary Update profile page of session user. | 203 | // @Summary Update profile page of session user. |
| 203 | // @Accept json | 204 | // @Accept json |
| 204 | // @Produce json | 205 | // @Produce json |
| 205 | // @Success 200 {object} models.Response{data=models.ProfileResponse} | 206 | // @Param Authorization header string true "JWT Token" |
| 206 | // @Failure 400 {object} models.Response | 207 | // @Success 200 {object} models.Response{data=models.ProfileResponse} |
| 207 | // @Failure 401 {object} models.Response | 208 | // @Failure 400 {object} models.Response |
| 209 | // @Failure 401 {object} models.Response | ||
| 208 | // @Router /profile [post] | 210 | // @Router /profile [post] |
| 209 | func UpdateUser(c *gin.Context) { | 211 | func UpdateUser(c *gin.Context) { |
| 210 | // Check if user exists | 212 | // Check if user exists |
| @@ -243,6 +245,7 @@ func UpdateUser(c *gin.Context) { | |||
| 243 | // @Summary Update country code of session user. | 245 | // @Summary Update country code of session user. |
| 244 | // @Accept json | 246 | // @Accept json |
| 245 | // @Produce json | 247 | // @Produce json |
| 248 | // @Param Authorization header string true "JWT Token" | ||
| 246 | // @Param country_code query string true "Country Code [XX]" | 249 | // @Param country_code query string true "Country Code [XX]" |
| 247 | // @Success 200 {object} models.Response{data=models.ProfileResponse} | 250 | // @Success 200 {object} models.Response{data=models.ProfileResponse} |
| 248 | // @Failure 400 {object} models.Response | 251 | // @Failure 400 {object} models.Response |
diff --git a/docs/docs.go b/docs/docs.go index 70a7267..5cf5e50 100644 --- a/docs/docs.go +++ b/docs/docs.go | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | // Code generated by swaggo/swag. DO NOT EDIT. | 1 | // Package docs GENERATED BY SWAG; DO NOT EDIT |
| 2 | 2 | // This file was generated by swaggo/swag | |
| 3 | package docs | 3 | package docs |
| 4 | 4 | ||
| 5 | import "github.com/swaggo/swag" | 5 | import "github.com/swaggo/swag" |
| @@ -148,11 +148,17 @@ const docTemplate = `{ | |||
| 148 | "summary": "Post record with demo of a specific map.", | 148 | "summary": "Post record with demo of a specific map.", |
| 149 | "parameters": [ | 149 | "parameters": [ |
| 150 | { | 150 | { |
| 151 | "type": "string", | ||
| 152 | "description": "JWT Token", | ||
| 153 | "name": "Authorization", | ||
| 154 | "in": "header", | ||
| 155 | "required": true | ||
| 156 | }, | ||
| 157 | { | ||
| 151 | "type": "array", | 158 | "type": "array", |
| 152 | "items": { | 159 | "items": { |
| 153 | "type": "file" | 160 | "type": "file" |
| 154 | }, | 161 | }, |
| 155 | "collectionFormat": "csv", | ||
| 156 | "description": "Demos", | 162 | "description": "Demos", |
| 157 | "name": "demos", | 163 | "name": "demos", |
| 158 | "in": "formData", | 164 | "in": "formData", |
| @@ -230,6 +236,15 @@ const docTemplate = `{ | |||
| 230 | "application/json" | 236 | "application/json" |
| 231 | ], | 237 | ], |
| 232 | "summary": "Get profile page of session user.", | 238 | "summary": "Get profile page of session user.", |
| 239 | "parameters": [ | ||
| 240 | { | ||
| 241 | "type": "string", | ||
| 242 | "description": "JWT Token", | ||
| 243 | "name": "Authorization", | ||
| 244 | "in": "header", | ||
| 245 | "required": true | ||
| 246 | } | ||
| 247 | ], | ||
| 233 | "responses": { | 248 | "responses": { |
| 234 | "200": { | 249 | "200": { |
| 235 | "description": "OK", | 250 | "description": "OK", |
| @@ -274,6 +289,13 @@ const docTemplate = `{ | |||
| 274 | "parameters": [ | 289 | "parameters": [ |
| 275 | { | 290 | { |
| 276 | "type": "string", | 291 | "type": "string", |
| 292 | "description": "JWT Token", | ||
| 293 | "name": "Authorization", | ||
| 294 | "in": "header", | ||
| 295 | "required": true | ||
| 296 | }, | ||
| 297 | { | ||
| 298 | "type": "string", | ||
| 277 | "description": "Country Code [XX]", | 299 | "description": "Country Code [XX]", |
| 278 | "name": "country_code", | 300 | "name": "country_code", |
| 279 | "in": "query", | 301 | "in": "query", |
| @@ -321,6 +343,15 @@ const docTemplate = `{ | |||
| 321 | "application/json" | 343 | "application/json" |
| 322 | ], | 344 | ], |
| 323 | "summary": "Update profile page of session user.", | 345 | "summary": "Update profile page of session user.", |
| 346 | "parameters": [ | ||
| 347 | { | ||
| 348 | "type": "string", | ||
| 349 | "description": "JWT Token", | ||
| 350 | "name": "Authorization", | ||
| 351 | "in": "header", | ||
| 352 | "required": true | ||
| 353 | } | ||
| 354 | ], | ||
| 324 | "responses": { | 355 | "responses": { |
| 325 | "200": { | 356 | "200": { |
| 326 | "description": "OK", | 357 | "description": "OK", |
| @@ -555,11 +586,9 @@ var SwaggerInfo = &swag.Spec{ | |||
| 555 | BasePath: "/v1", | 586 | BasePath: "/v1", |
| 556 | Schemes: []string{}, | 587 | Schemes: []string{}, |
| 557 | Title: "Least Portals Database API", | 588 | Title: "Least Portals Database API", |
| 558 | Description: "Backend API endpoints for Least Portals Database.", | 589 | Description: "Backend API endpoints for the Least Portals Database.", |
| 559 | InfoInstanceName: "swagger", | 590 | InfoInstanceName: "swagger", |
| 560 | SwaggerTemplate: docTemplate, | 591 | SwaggerTemplate: docTemplate, |
| 561 | LeftDelim: "{{", | ||
| 562 | RightDelim: "}}", | ||
| 563 | } | 592 | } |
| 564 | 593 | ||
| 565 | func init() { | 594 | func init() { |
diff --git a/docs/swagger.json b/docs/swagger.json index 861610b..82fb64c 100644 --- a/docs/swagger.json +++ b/docs/swagger.json | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | { | 1 | { |
| 2 | "swagger": "2.0", | 2 | "swagger": "2.0", |
| 3 | "info": { | 3 | "info": { |
| 4 | "description": "Backend API endpoints for Least Portals Database.", | 4 | "description": "Backend API endpoints for the Least Portals Database.", |
| 5 | "title": "Least Portals Database API", | 5 | "title": "Least Portals Database API", |
| 6 | "contact": {}, | 6 | "contact": {}, |
| 7 | "license": { | 7 | "license": { |
| @@ -141,11 +141,17 @@ | |||
| 141 | "summary": "Post record with demo of a specific map.", | 141 | "summary": "Post record with demo of a specific map.", |
| 142 | "parameters": [ | 142 | "parameters": [ |
| 143 | { | 143 | { |
| 144 | "type": "string", | ||
| 145 | "description": "JWT Token", | ||
| 146 | "name": "Authorization", | ||
| 147 | "in": "header", | ||
| 148 | "required": true | ||
| 149 | }, | ||
| 150 | { | ||
| 144 | "type": "array", | 151 | "type": "array", |
| 145 | "items": { | 152 | "items": { |
| 146 | "type": "file" | 153 | "type": "file" |
| 147 | }, | 154 | }, |
| 148 | "collectionFormat": "csv", | ||
| 149 | "description": "Demos", | 155 | "description": "Demos", |
| 150 | "name": "demos", | 156 | "name": "demos", |
| 151 | "in": "formData", | 157 | "in": "formData", |
| @@ -223,6 +229,15 @@ | |||
| 223 | "application/json" | 229 | "application/json" |
| 224 | ], | 230 | ], |
| 225 | "summary": "Get profile page of session user.", | 231 | "summary": "Get profile page of session user.", |
| 232 | "parameters": [ | ||
| 233 | { | ||
| 234 | "type": "string", | ||
| 235 | "description": "JWT Token", | ||
| 236 | "name": "Authorization", | ||
| 237 | "in": "header", | ||
| 238 | "required": true | ||
| 239 | } | ||
| 240 | ], | ||
| 226 | "responses": { | 241 | "responses": { |
| 227 | "200": { | 242 | "200": { |
| 228 | "description": "OK", | 243 | "description": "OK", |
| @@ -267,6 +282,13 @@ | |||
| 267 | "parameters": [ | 282 | "parameters": [ |
| 268 | { | 283 | { |
| 269 | "type": "string", | 284 | "type": "string", |
| 285 | "description": "JWT Token", | ||
| 286 | "name": "Authorization", | ||
| 287 | "in": "header", | ||
| 288 | "required": true | ||
| 289 | }, | ||
| 290 | { | ||
| 291 | "type": "string", | ||
| 270 | "description": "Country Code [XX]", | 292 | "description": "Country Code [XX]", |
| 271 | "name": "country_code", | 293 | "name": "country_code", |
| 272 | "in": "query", | 294 | "in": "query", |
| @@ -314,6 +336,15 @@ | |||
| 314 | "application/json" | 336 | "application/json" |
| 315 | ], | 337 | ], |
| 316 | "summary": "Update profile page of session user.", | 338 | "summary": "Update profile page of session user.", |
| 339 | "parameters": [ | ||
| 340 | { | ||
| 341 | "type": "string", | ||
| 342 | "description": "JWT Token", | ||
| 343 | "name": "Authorization", | ||
| 344 | "in": "header", | ||
| 345 | "required": true | ||
| 346 | } | ||
| 347 | ], | ||
| 317 | "responses": { | 348 | "responses": { |
| 318 | "200": { | 349 | "200": { |
| 319 | "description": "OK", | 350 | "description": "OK", |
diff --git a/docs/swagger.yaml b/docs/swagger.yaml index db0ab47..76b4e7b 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml | |||
| @@ -93,7 +93,7 @@ definitions: | |||
| 93 | host: lp.ardapektezol.com/api | 93 | host: lp.ardapektezol.com/api |
| 94 | info: | 94 | info: |
| 95 | contact: {} | 95 | contact: {} |
| 96 | description: Backend API endpoints for Least Portals Database. | 96 | description: Backend API endpoints for the Least Portals Database. |
| 97 | license: | 97 | license: |
| 98 | name: GNU General Public License, Version 2 | 98 | name: GNU General Public License, Version 2 |
| 99 | url: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html | 99 | url: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
| @@ -175,8 +175,12 @@ paths: | |||
| 175 | consumes: | 175 | consumes: |
| 176 | - multipart/form-data | 176 | - multipart/form-data |
| 177 | parameters: | 177 | parameters: |
| 178 | - collectionFormat: csv | 178 | - description: JWT Token |
| 179 | description: Demos | 179 | in: header |
| 180 | name: Authorization | ||
| 181 | required: true | ||
| 182 | type: string | ||
| 183 | - description: Demos | ||
| 180 | in: formData | 184 | in: formData |
| 181 | items: | 185 | items: |
| 182 | type: file | 186 | type: file |
| @@ -228,6 +232,12 @@ paths: | |||
| 228 | get: | 232 | get: |
| 229 | consumes: | 233 | consumes: |
| 230 | - application/json | 234 | - application/json |
| 235 | parameters: | ||
| 236 | - description: JWT Token | ||
| 237 | in: header | ||
| 238 | name: Authorization | ||
| 239 | required: true | ||
| 240 | type: string | ||
| 231 | produces: | 241 | produces: |
| 232 | - application/json | 242 | - application/json |
| 233 | responses: | 243 | responses: |
| @@ -252,6 +262,12 @@ paths: | |||
| 252 | post: | 262 | post: |
| 253 | consumes: | 263 | consumes: |
| 254 | - application/json | 264 | - application/json |
| 265 | parameters: | ||
| 266 | - description: JWT Token | ||
| 267 | in: header | ||
| 268 | name: Authorization | ||
| 269 | required: true | ||
| 270 | type: string | ||
| 255 | produces: | 271 | produces: |
| 256 | - application/json | 272 | - application/json |
| 257 | responses: | 273 | responses: |
| @@ -277,6 +293,11 @@ paths: | |||
| 277 | consumes: | 293 | consumes: |
| 278 | - application/json | 294 | - application/json |
| 279 | parameters: | 295 | parameters: |
| 296 | - description: JWT Token | ||
| 297 | in: header | ||
| 298 | name: Authorization | ||
| 299 | required: true | ||
| 300 | type: string | ||
| 280 | - description: Country Code [XX] | 301 | - description: Country Code [XX] |
| 281 | in: query | 302 | in: query |
| 282 | name: country_code | 303 | name: country_code |