Add endpoint for POST /votes in openapi.yml
This commit is contained in:
@ -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) {
|
||||
|
||||
}
|
||||
|
@ -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:
|
||||
|
Reference in New Issue
Block a user