Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tournaments): Create/List tournaments API #26

Merged
merged 5 commits into from
Aug 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
250 changes: 240 additions & 10 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,54 @@ paths:
$ref: "#/components/responses/notFound"
tags:
- locations
###
# Tournaments
###
/tournaments:
get:
description: Retrieve a list of tournaments
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/tournamentListResponse'
description: Successful response
"400":
$ref: "#/components/responses/badRequest"
"401":
$ref: "#/components/responses/unauthorized"
"403":
$ref: "#/components/responses/forbidden"
tags:
- tournaments
post:
description: Create a new tournament
security:
- pinmanAuth:
- user
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/tournamentCreate'
required: true
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/tournamentResponse'
description: Tournament was created successfully
"400":
$ref: "#/components/responses/badRequest"
"401":
$ref: "#/components/responses/unauthorized"
"403":
$ref: "#/components/responses/forbidden"
tags:
- tournaments

components:
responses:
unauthorized:
Expand Down Expand Up @@ -283,7 +331,7 @@ components:
created_at: created_at
id: id
slug: slug
ownerId: ownerId
owner_id: owner_id
location:
id: id
name: name
Expand All @@ -305,16 +353,16 @@ components:
type: string
x-oapi-codegen-extra-tags:
binding: requred
ownerId:
owner_id:
type: string
x-oapi-codegen-extra-tags:
binding: requred
location:
allOf:
- $ref: '#/components/schemas/location'
- x-oapi-codegen-extra-tags:
binding: requred
x-go-type: Location
x-oapi-codegen-extra-tags:
binding: requred
x-go-type: Location
created_at:
type: string
x-oapi-codegen-extra-tags:
Expand All @@ -327,7 +375,7 @@ components:
- id
- name
- slug
- ownerId
- owner_id
- location
- created_at
- updated_at
Expand Down Expand Up @@ -419,6 +467,106 @@ components:
- pinball_map_id
- created_at
- updated_at

tournamentType:
type: string
enum:
- multi_round_tournament

tournament:
example:
name: name
id: id
slug: slug
league_id: league_id
address: address
type: multi_round_tournament
created_at: created_at
updated_at: updated_at
properties:
id:
type: string
x-oapi-codegen-extra-tags:
binding: required
name:
type: string
x-oapi-codegen-extra-tags:
binding: required
slug:
type: string
x-oapi-codegen-extra-tags:
binding: required
type:
allOf:
- $ref: '#/components/schemas/tournamentType'
x-oapi-codegen-extra-tags:
binding: required
x-go-type: TournamentType
settings:
allOf:
- $ref: '#/components/schemas/tournamentSettings'
x-oapi-codegen-extra-tags:
binding: required
x-go-type: TournamentSettings
league_id:
type: string
x-oapi-codegen-extra-tags:
binding: required
location_id:
type: string
x-oapi-codegen-extra-tags:
binding: required
created_at:
type: string
x-oapi-codegen-extra-tags:
binding: required
updated_at:
type: string
x-oapi-codegen-extra-tags:
binding: required
required:
- id
- name
- slug
- league_id
- location_id
- type
- settings
- created_at
- updated_at
tournamentSettings:
description: The settings for a tournament. Fields vary depending on the type of tournament.
oneOf:
- $ref: '#/components/schemas/multiRoundTournamentSettings'
multiRoundTournamentSettings:
example:
rounds: 8
games_per_round: 4
lowest_scores_dropped: 3
properties:
rounds:
type: integer
description: The number of rounds in the tournament
x-oapi-codegen-extra-tags:
binding: required
games_per_round:
type: integer
description: The number of games played by each group per round
x-oapi-codegen-extra-tags:
binding: required
lowest_scores_dropped:
type: integer
description: |
How many of a player's lowest-scored rounds are dropped when calculating the rankings of the tournament.

Rounds a player did not participate in are counted as them having scored zero points.
x-oapi-codegen-extra-tags:
binding: required
required:
- rounds
- games_per_round
- lowest_scores_dropped

###
# Generic Request/Response Schemas
###
Expand Down Expand Up @@ -515,7 +663,7 @@ components:
created_at: created_at
id: id
slug: slug
ownerId: ownerId
owner_id: owner_id
location:
id: id
name: name
Expand All @@ -536,7 +684,7 @@ components:
created_at: created_at
id: id
slug: slug
ownerId: ownerId
owner_id: owner_id
location:
id: id
name: name
Expand All @@ -559,7 +707,7 @@ components:
type: string
x-oapi-codegen-extra-tags:
binding: required
locationId:
location_id:
type: string
x-oapi-codegen-extra-tags:
binding: required
Expand All @@ -570,7 +718,7 @@ components:
type: object
required:
- name
- locationId
- location_id
- slug
###
# Location Request/Response Schemas
Expand Down Expand Up @@ -620,6 +768,88 @@ components:
type: object
required:
- pinball_map_id

###
# Tournament Request/Response Schemas
###
tournamentResponse:
example:
tournament:
updated_at: updated_at
name: name
created_at: created_at
id: id
slug: slug
league_id: league_id
settings:
rounds: rounds
games_per_round: games_per_round
lowest_scores_dropped: lowest_scores_dropped
properties:
tournament:
$ref: '#/components/schemas/tournament'
type: object
required:
- tournament
tournamentListResponse:
example:
tournaments:
- updated_at: updated_at
name: name
created_at: created_at
id: id
slug: slug
league_id: league_id
rounds: rounds
games_per_round: games_per_round
lowest_scores_dropped: lowest_scores_dropped
properties:
tournaments:
type: array
items:
$ref: '#/components/schemas/tournament'
type: object
required:
- tournaments
tournamentCreate:
properties:
name:
type: string
x-oapi-codegen-extra-tags:
binding: required
league_id:
type: string
x-oapi-codegen-extra-tags:
binding: required
slug:
type: string
x-oapi-codegen-extra-tags:
binding: required
location_id:
type: string
x-oapi-codegen-extra-tags:
binding: required
type:
allOf:
- $ref: '#/components/schemas/tournamentType'
x-oapi-codegen-extra-tags:
binding: required
x-go-type: TournamentType
settings:
allOf:
- $ref: '#/components/schemas/tournamentSettings'
x-oapi-codegen-extra-tags:
binding: required
x-go-type: TournamentSettings
type: object
required:
- name
- league_id
- slug
- location_id
- type
- settings

securitySchemes:
pinmanAuth:
flows:
Expand Down
18 changes: 8 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ require (
github.com/stretchr/testify v1.8.3
golang.org/x/crypto v0.9.0
golang.org/x/exp v0.0.0-20230725093048-515e97ebf090
gorm.io/driver/postgres v1.4.5
gorm.io/gorm v1.24.1
gorm.io/datatypes v1.2.0
gorm.io/driver/postgres v1.5.0
gorm.io/gorm v1.25.2
)

require (
Expand All @@ -29,16 +30,10 @@ require (
github.com/golang-jwt/jwt/v4 v4.4.3 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.13.0 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgproto3/v2 v2.3.1 // indirect
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
github.com/jackc/pgtype v1.12.0 // indirect
github.com/jackc/pgx/v4 v4.17.2 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.4 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
Expand All @@ -62,6 +57,8 @@ require (
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.14.0 // indirect
github.com/go-sql-driver/mysql v1.7.0 // indirect
github.com/jackc/pgx/v5 v5.3.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/labstack/echo/v4 v4.10.2 // indirect
Expand All @@ -82,4 +79,5 @@ require (
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/driver/mysql v1.4.7 // indirect
)
Loading