You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
414 lines
11 KiB
414 lines
11 KiB
openapi: 3.0.0
|
|
info:
|
|
title: Mieux Voter
|
|
description: A poll application based on Majority Judgment (MJ).
|
|
version: 1.0.1-oas3
|
|
termsOfService: 'https://github.com/MieuxVoter'
|
|
contact:
|
|
name: Mieux Voter app developpers team
|
|
email: app@mieuxvoter.fr
|
|
servers:
|
|
- url: 'https://api.mieuxvoter.fr/v1'
|
|
description: Main (production) server
|
|
- url: 'https://sandboxapi.mieuxvoter.fr/v1'
|
|
description: Internal staging server for testing
|
|
paths:
|
|
/polls:
|
|
get:
|
|
summary: Gets all polls.
|
|
responses:
|
|
'200':
|
|
description: OK
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: array
|
|
items:
|
|
$ref: '#/components/schemas/Poll'
|
|
post:
|
|
summary: Creates a poll.
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/Poll'
|
|
responses:
|
|
'201':
|
|
description: Created
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
properties:
|
|
id:
|
|
type: string
|
|
description: Id of the created poll.
|
|
links:
|
|
GetPollByPollId:
|
|
$ref: '#/components/links/GetPollByPollId'
|
|
SetPollByPollId:
|
|
$ref: '#/components/links/SetPollByPollId'
|
|
DelPollByPollId:
|
|
$ref: '#/components/links/DelPollByPollId'
|
|
JudgeByPollId:
|
|
$ref: '#/components/links/JudgeByPollId'
|
|
ResultsByPollId:
|
|
$ref: '#/components/links/ResultsByPollId'
|
|
'400':
|
|
description: Bad Request. Expect at least 2 candidates and a title.
|
|
'/polls/{poll-id}':
|
|
parameters:
|
|
- in: path
|
|
name: poll-id
|
|
required: true
|
|
schema:
|
|
type: integer
|
|
format: int64
|
|
get:
|
|
summary: Gets a poll by ID
|
|
responses:
|
|
'200':
|
|
description: OK
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/Poll'
|
|
'404':
|
|
$ref: '#/components/responses/PollNotFound'
|
|
patch:
|
|
summary: Updates a poll
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/Poll'
|
|
security:
|
|
- {}
|
|
- pollAuth: []
|
|
responses:
|
|
'200':
|
|
description: OK
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: array
|
|
items:
|
|
$ref: '#/components/schemas/Poll'
|
|
delete:
|
|
summary: Deletes a poll
|
|
responses:
|
|
'200':
|
|
description: OK
|
|
'404':
|
|
$ref: '#/components/responses/PollNotFound'
|
|
security:
|
|
- pollAuth: []
|
|
'/polls/{poll-id}/judges':
|
|
parameters:
|
|
- in: path
|
|
name: poll-id
|
|
required: true
|
|
schema:
|
|
type: string
|
|
post:
|
|
description: Add a judge to a poll
|
|
requestBody:
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/Judge'
|
|
responses:
|
|
'200':
|
|
description: Invitation was sent
|
|
content:
|
|
text/plain:
|
|
schema:
|
|
type: string
|
|
'404':
|
|
$ref: '#/components/responses/PollNotFound'
|
|
'/polls/{poll-id}/results':
|
|
parameters:
|
|
- in: path
|
|
name: poll-id
|
|
required: true
|
|
schema:
|
|
type: string
|
|
get:
|
|
description: Get results of a poll
|
|
responses:
|
|
'200':
|
|
description: OK
|
|
content:
|
|
text/plain:
|
|
schema:
|
|
$ref: '#/components/schemas/Result'
|
|
'404':
|
|
$ref: '#/components/responses/PollNotFound'
|
|
'/polls/{poll-id}/judgments':
|
|
parameters:
|
|
- in: path
|
|
name: poll-id
|
|
required: true
|
|
schema:
|
|
type: string
|
|
post:
|
|
summary: Creates a judgment
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/Judgment'
|
|
security:
|
|
- {}
|
|
- judgeAuth: []
|
|
responses:
|
|
'201':
|
|
description: Created
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
properties:
|
|
id:
|
|
type: string
|
|
description: Id of the created judgment.
|
|
links:
|
|
GetJudgmentByJudgmentId:
|
|
$ref: '#/components/links/GetJudgmentByJudgmentId'
|
|
DelJudgmentByJudgmentId:
|
|
$ref: '#/components/links/DelJudgmentByJudgmentId'
|
|
'/judgments/{judgment-id}':
|
|
parameters:
|
|
- in: path
|
|
name: judgment-id
|
|
required: true
|
|
schema:
|
|
type: string
|
|
get:
|
|
summary: Gets a judgment by ID
|
|
responses:
|
|
'200':
|
|
description: A judgment object
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/Judgment'
|
|
delete:
|
|
summary: Deletes a judgment
|
|
responses:
|
|
'200':
|
|
description: OK
|
|
'404':
|
|
$ref: '#/components/responses/JudgmentNotFound'
|
|
security:
|
|
- judgeAuth: []
|
|
'/polls/{poll-id}/judges/{judge-id}/':
|
|
parameters:
|
|
- in: path
|
|
name: judge-id
|
|
required: true
|
|
schema:
|
|
type: string
|
|
get:
|
|
summary: Get a judge from a poll
|
|
responses:
|
|
'200':
|
|
description: OK
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/Judge'
|
|
'404':
|
|
$ref: '#/components/responses/JudgeNotFound'
|
|
security:
|
|
- {}
|
|
- pollAuth: []
|
|
delete:
|
|
summary: Delete a judge from a poll
|
|
responses:
|
|
'200':
|
|
description: OK
|
|
'404':
|
|
$ref: '#/components/responses/JudgeNotFound'
|
|
security:
|
|
- pollAuth: []
|
|
components:
|
|
securitySchemes:
|
|
judgeAuth:
|
|
type: http
|
|
scheme: bearer
|
|
pollAuth:
|
|
type: http
|
|
scheme: bearer
|
|
resultAuth:
|
|
type: http
|
|
scheme: bearer
|
|
schemas:
|
|
Judgment:
|
|
type: object
|
|
properties:
|
|
id:
|
|
type: string
|
|
readOnly: true
|
|
grade:
|
|
type: string
|
|
Candidate:
|
|
type: object
|
|
properties:
|
|
id:
|
|
type: string
|
|
readOnly: true
|
|
name:
|
|
type: string
|
|
description: Unique but short name of the candidate.
|
|
judgments:
|
|
type: array
|
|
items:
|
|
$ref: '#/components/schemas/Judgment'
|
|
description: The judgments received by this candidate.
|
|
Grade:
|
|
type: object
|
|
properties:
|
|
id:
|
|
type: string
|
|
readOnly: true
|
|
name:
|
|
type: string
|
|
description: 'Unique but short name of the grade, like "Excellent" or "To reject".'
|
|
Judge:
|
|
type: object
|
|
properties:
|
|
id:
|
|
type: string
|
|
readOnly: true
|
|
has-voted:
|
|
type: string
|
|
poll-id:
|
|
type: string
|
|
mail:
|
|
type: object
|
|
description: >-
|
|
Send a mail at the creation of the judge. The mail is not kept in
|
|
memory.
|
|
Poll:
|
|
type: object
|
|
properties:
|
|
id:
|
|
type: string
|
|
readOnly: true
|
|
title:
|
|
type: string
|
|
description: 'As <title>, I find these candidates:'
|
|
candidates:
|
|
type: array
|
|
minItems: 2
|
|
maxItems: 20
|
|
items:
|
|
$ref: '#/components/schemas/Candidate'
|
|
description: The candidates being judged in a poll.
|
|
grades:
|
|
type: array
|
|
items:
|
|
$ref: '#/components/schemas/Grade'
|
|
description: The grades on which one judges a candidate.
|
|
judges:
|
|
type: array
|
|
items:
|
|
$ref: '#/components/schemas/Judge'
|
|
description: The judges that are allowed to participate to the election.
|
|
restrict_judges:
|
|
type: boolean
|
|
description: Can anyone create a judge?
|
|
Error:
|
|
type: object
|
|
properties:
|
|
code:
|
|
type: string
|
|
message:
|
|
type: string
|
|
required:
|
|
- code
|
|
- message
|
|
Result:
|
|
type: object
|
|
properties:
|
|
poll:
|
|
$ref: '#/components/schemas/Poll'
|
|
ranking:
|
|
type: array
|
|
items:
|
|
type: integer
|
|
format: int16
|
|
links:
|
|
GetPollByPollId:
|
|
operationRef: '#/paths/~1polls/~1{poll-id}/get'
|
|
parameters:
|
|
pollId: $response.body#/id
|
|
description: >
|
|
The `id` value returned in the response can be used as the `poll-id`
|
|
parameter in GET /polls/{poll-id}.
|
|
SetPollByPollId:
|
|
operationRef: '#/paths/~1polls/~1{poll-id}/patch'
|
|
parameters:
|
|
pollId: $response.body#/id
|
|
description: >
|
|
The `id` value returned in the response can be used as the `poll-id`
|
|
parameter in PATCH /polls/{poll-id}.
|
|
DelPollByPollId:
|
|
operationRef: '#/paths/~1polls/~1{poll-id}/delete'
|
|
parameters:
|
|
pollId: $response.body#/id
|
|
description: >
|
|
The `id` value returned in the response can be used as the `poll-id`
|
|
parameter in DELETE /polls/{poll-id}.
|
|
JudgeByPollId:
|
|
operationRef: '#/paths/~1judges/~1{poll-id}/post'
|
|
parameters:
|
|
userId: $response.body#/id
|
|
description: >
|
|
The `id` value returned in the response can be used as the `poll-id`
|
|
parameter in GET /judgments/{poll-id}.
|
|
ResultsByPollId:
|
|
operationRef: '#/paths/~1polls/~1{poll-id}/results/get'
|
|
parameters:
|
|
pollId: $response.body#/id
|
|
description: >
|
|
The `id` value returned in the response can be used as the `poll-id`
|
|
parameter in GET /results/{result-id}.
|
|
GetJudgmentByJudgmentId:
|
|
operationRef: '#/paths/~1judgments/~1{judgment-id}/get'
|
|
parameters:
|
|
judgmentId: $response.body#/id
|
|
description: >
|
|
The `id` value returned in the response can be used as the `judgment-id`
|
|
parameter in GET /judgments/{judgment-id}.
|
|
DelJudgmentByJudgmentId:
|
|
operationRef: '#/paths/~1judgments/~1{judgment-id}/delete'
|
|
parameters:
|
|
judgmentId: $response.body#/id
|
|
description: >
|
|
The `id` value returned in the response can be used as the `judgment-id`
|
|
parameter in DELETE /judgments/{judgment-id}.
|
|
responses:
|
|
PollNotFound:
|
|
description: The specified poll was not found
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/Error'
|
|
JudgmentNotFound:
|
|
description: The specified judgment was not found
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/Error'
|
|
JudgeNotFound:
|
|
description: The specified judge was not found
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/Error'
|