Skip to content

Commit

Permalink
Fixed Get Logo By ID endpoint to return the image (#183)
Browse files Browse the repository at this point in the history
* Fixed Get Logo By ID endpoint to return the image

* Updated comment

* Fixed Open API spec after comments

* "Banging head against the wall"
  • Loading branch information
ryanbarlow1 authored Jun 13, 2024
1 parent 5039310 commit 9013b6c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
5 changes: 3 additions & 2 deletions backend/internal/server/apis/sports/components/logo.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
func init() {
apis.RegisterHandler(fiber.MethodPost, "/logos", auth.Public, handleLogoUpload)
apis.RegisterHandler(fiber.MethodGet, "/logos/:id<int>", auth.Public, handleGetLogoByID)
// Need to be able to specify ctx.Type (the request's Content-Type) in the RegisterHandler
}

func handleLogoUpload(c *fiber.Ctx) error {
Expand Down Expand Up @@ -57,6 +58,6 @@ func handleGetLogoByID(c *fiber.Ctx) error {
return responder.InternalServerError(c)
}

// Send JSON response
return responder.OkWithData(c, logo)
c.Type("png")
return c.Send(logo.Image)
}
4 changes: 2 additions & 2 deletions static/oas/v1/sports/components/games.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ paths:
in: path
required: true
schema:
type: string
type: integer
responses:
200:
description: The response body should contain the game details
Expand All @@ -63,7 +63,7 @@ paths:
in: path
required: true
schema:
type: string
type: integer
description: Update game details by ID
requestBody:
required: true
Expand Down
20 changes: 9 additions & 11 deletions static/oas/v1/sports/components/logos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ paths:
tags:
- Logos
summary: Create Team Logo
description: Uploads a team's logo
description: Uploads a team's logo. This currently supports png files only.
requestBody:
content:
multipart/form-data:
Expand All @@ -13,14 +13,15 @@ paths:
properties:
image:
type: string
contentMediaType: image/png
format: binary
responses:
200:
description: Successfully uploaded a team's logo
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/PostLogoResponse'
$ref: '#/components/schemas/PostLogoResponse'
400:
$ref: "../../common/errors.yml#/components/responses/BadRequest"
/logos/{id}:
Expand All @@ -35,18 +36,15 @@ paths:
required: true
description: The ID of the logo to retrieve
schema:
type: string
type: integer
responses:
200:
description: The response body should contain the logo binary
description: OK
content:
multipart/form-data:
image/png:
schema:
type: object
properties:
image:
type: string
format: binary
type: string
format: binary
400:
$ref: "../../common/errors.yml#/components/responses/BadRequest"

Expand Down
4 changes: 2 additions & 2 deletions static/oas/v1/sports/components/teams.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ paths:
required: true
description: The ID of the team to retrieve
schema:
type: string
type: integer
responses:
200:
description: The response body should contain the list of teams
Expand All @@ -68,7 +68,7 @@ paths:
required: true
description: The ID of the team to update
schema:
type: string
type: integer
requestBody:
description: A JSON object with a valid team
required: true
Expand Down

0 comments on commit 9013b6c

Please sign in to comment.