Add endpoint for POST /votes in openapi.yml

This commit is contained in:
2025-01-02 18:05:27 +01:00
parent 7f82a402de
commit 8d3ce36dd9
3 changed files with 79 additions and 1 deletions

View File

@ -101,6 +101,11 @@ func randomVoterIdentity() string {
return string(b)
}
type createVoteRequestWithValidator struct {
api.CreateVotesRequest
validator.Validator
}
func (app *application) createVote(w http.ResponseWriter, r *http.Request) {
}

View File

@ -18,6 +18,8 @@ servers:
tags:
- name: election
description: Retrieve data related to elections
- name: vote
description: Retrieve data related to votes
paths:
/election:
@ -50,6 +52,27 @@ paths:
schema:
$ref: "#/components/schemas/ErrorResponse"
/votes:
post:
tags:
- vote
summary: Cast your votes for an election
operationId: createVotes
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/CreateVotesRequest"
responses:
200:
description: Votes cast
422:
description: Unprocessable content
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
components:
schemas:
Election:
@ -194,9 +217,27 @@ components:
items:
type: string
minLength: 1
maxItems: 1
uniqueItems: true
CreateVotesRequest:
type: object
properties:
voterIdentity:
type: string
minLength: 1
electionId:
type: integer
choices:
type: array
items:
properties:
choiceText:
type: string
minLength: 1
tokens:
type: integer
minimum: 1
ErrorResponse:
type: object
required: