Generate voter data for known elections and simplify MaxVoters (0 = no maximum)

This commit is contained in:
2024-12-30 23:01:32 +01:00
parent 218f56c060
commit 195bc7d85e
6 changed files with 132 additions and 47 deletions

View File

@ -32,8 +32,12 @@ paths:
schema:
$ref: "#/components/schemas/CreateElectionRequest"
responses:
201:
description: Election created
200:
description: Election created. Body only returned if voterAreKnown is true
content:
application/json:
schema:
$ref: "#/components/schemas/CreateElectionResponse"
422:
description: Unprocessable Content
content:
@ -49,8 +53,9 @@ components:
- id
- name
- tokens
- are_voters_known
- expires_at
- areVotersKnown
- maxVoters
- expiresAt
properties:
id:
type: integer
@ -60,20 +65,19 @@ components:
type: string
minLength: 1
tokens:
type: integer
minimum: 0
are_voters_known:
type: boolean
max_voters:
type: integer
minimum: 1
nullable: true
description: Required when voters are known
created_at:
areVotersKnown:
type: boolean
maxVoters:
type: integer
minimum: 0
description: Must be greater than 0 when voters are known
createdAt:
type: string
format: date-time
readOnly: true
expires_at:
expiresAt:
type: string
format: date-time
choices:
@ -89,12 +93,12 @@ components:
type: object
required:
- text
- election_id
- electionId
properties:
text:
type: string
minLength: 1
election_id:
electionId:
type: integer
format: int64
@ -102,13 +106,13 @@ components:
type: object
required:
- identity
- election_id
- electionId
properties:
identity:
type: string
minLength: 1
description: When voters are known, passcodes will be pre-generated
election_id:
electionId:
type: integer
format: int64
votes:
@ -119,27 +123,27 @@ components:
Vote:
type: object
required:
- voter_identity
- election_id
- voterIdentity
- electionId
properties:
voter_identity:
voterIdentity:
type: string
minLength: 1
election_id:
electionId:
type: integer
format: int64
choice_text:
choiceText:
type: string
nullable: true
tokens:
type: integer
minimum: 0
minimum: 1
nullable: true
calculated_vote_count:
calculatedVoteCount:
type: integer
readOnly: true
description: Calculated as floor(sqrt(tokens))
created_at:
createdAt:
type: string
format: date-time
readOnly: true
@ -149,24 +153,24 @@ components:
required:
- name
- tokens
- are_voters_known
- expires_at
- areVotersKnown
- maxVoters
- expiresAt
- choices
properties:
name:
type: string
minLength: 1
tokens:
type: integer
minimum: 0
are_voters_known:
type: boolean
max_voters:
type: integer
minimum: 1
nullable: true
description: Required when voters are known
expires_at:
areVotersKnown:
type: boolean
maxVoters:
type: integer
minimum: 0
description: Must be greater than 0 when voters are known; 0 = no limit
expiresAt:
type: string
format: date-time
choices:
@ -177,6 +181,17 @@ components:
minItems: 1
uniqueItems: true
CreateElectionResponse:
type: object
properties:
voterIdentities:
type: array
items:
type: string
minLength: 1
maxItems: 1
uniqueItems: true
ErrorResponse:
type: object
required: