Merge pull request #14 from MieuxVoter/guhur-user

feat(user): create user schema
master
Dominique Merle 4 years ago committed by GitHub
commit 33d3dd7a24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -253,6 +253,97 @@ paths:
$ref: '#/components/schemas/result' $ref: '#/components/schemas/result'
'404': '404':
$ref: '#/components/responses/poll-not-found' $ref: '#/components/responses/poll-not-found'
/users:
get:
operationId: get-users
summary: Gets all users.
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/user'
post:
operationId: create-user
summary: Creates an user
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/user'
responses:
'201':
description: Created
content:
application/json:
schema:
type: object
properties:
id:
type: string
description: Id of the created user.
links:
get-user:
$ref: '#/components/links/get-user'
update-user:
$ref: '#/components/links/update-user'
delete-user:
$ref: '#/components/links/delete-user'
'/users/{user-id}':
parameters:
- in: path
name: user-id
required: true
schema:
type: integer
format: int64
get:
operationId: get-user
summary: Gets a user by ID
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/user'
'404':
$ref: '#/components/responses/user-not-found'
patch:
operationId: update-user
summary: Updates a user
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/user'
security:
- {}
- userAuth: []
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/user'
delete:
operationId: delete-user
summary: Deletes a user
responses:
'200':
description: OK
'404':
$ref: '#/components/responses/user-not-found'
security:
- userAuth: []
components: components:
securitySchemes: securitySchemes:
participantAuth: participantAuth:
@ -264,6 +355,9 @@ components:
resultAuth: resultAuth:
type: http type: http
scheme: bearer scheme: bearer
userAuth:
type: http
scheme: bearer
schemas: schemas:
ballot: ballot:
type: object type: object
@ -296,6 +390,12 @@ components:
description: The ballots received by this proposal. description: The ballots received by this proposal.
items: items:
$ref: '#/components/schemas/ballot' $ref: '#/components/schemas/ballot'
description:
type: string
description: An optional description of the proposal
example: This school would welcome 500 pupils.
required:
- name
mention: mention:
type: object type: object
properties: properties:
@ -307,33 +407,49 @@ components:
name: name:
type: string type: string
description: >- description: >-
Unique but short name of the mention, like "Excellent" or "To Unique but short name of the mention, like *Excellent* or *To
reject". reject*.
example: Excellent example: Excellent
description:
type: string
description: An optional description of the mention
example: 'In this poll, the mention *To reject* disqualifies the proposal.'
required:
- name
participant: participant:
type: object type: object
properties: properties:
id: id:
type: string type: string
description: A unique identifier description: A unique identifier.
example: JtRm05yjMAuFCI2uwnFp example: JtRm05yjMAuFCI2uwnFp
readOnly: true readOnly: true
description:
type: string
description: An optional description of the participant.
example: John Doe
has-participed: has-participed:
type: boolean type: boolean
description: >- description: >-
True if the participant already participed to the poll, False True if the participant already participed to the poll, False
otherwise otherwise.
example: true example: true
poll-id: poll-id:
type: string type: string
description: The identifier of the poll that the participant participates on. description: The identifier of the poll that the participant participates on.
example: 1jDe1e5eF_IkaYPuoIYX example: 1jDe1e5eF_IkaYPuoIYX
user-id:
type: string
description: The identifier of the user.
example: 1jDe1e5eF_IkaYPuoIYX
mail: mail:
type: object type: string
description: >- description: >-
The mail that will eventually created at the creation of the The mail that will eventually created at the creation of the
participant (not kept in memory). participant (not kept in memory).
example: john-doe@example.com example: john-doe@example.com
required:
- poll-id
poll: poll:
type: object type: object
properties: properties:
@ -346,6 +462,10 @@ components:
type: string type: string
example: What project should our neighbourhood invest in for the next year? example: What project should our neighbourhood invest in for the next year?
description: The title of the poll description: The title of the poll
description:
type: string
description: A description of the poll
example: null
proposals: proposals:
type: array type: array
description: The proposals being voted in a poll. description: The proposals being voted in a poll.
@ -365,10 +485,16 @@ components:
description: The participants that are allowed to participate to the election. description: The participants that are allowed to participate to the election.
items: items:
$ref: '#/components/schemas/participant' $ref: '#/components/schemas/participant'
restrict_participants: user-id:
type: string
description: 'Organizer id. If not given, a dummy user is created.'
restrict-participants:
type: boolean type: boolean
description: 'True if anyone can participate to this poll, False otherwise.' description: 'True if anyone can participate to this poll, False otherwise.'
example: false example: false
required:
- title
- proposals
error: error:
type: object type: object
properties: properties:
@ -405,6 +531,27 @@ components:
items: items:
type: integer type: integer
format: int16 format: int16
required:
- ranking
- poll
user:
type: object
properties:
id:
type: integer
description: A unique identifier
example: 0
readOnly: true
name:
type: string
description: Unique user-name
example: john.doe
description:
type: string
description: An optional description of the user
example: >-
John Doe is a multiple-use name that is used when the true name of a
person is unknown or is being intentionally concealed
links: links:
get-poll: get-poll:
operationId: get-poll operationId: get-poll
@ -455,6 +602,27 @@ components:
description: > description: >
The `id` value returned in the response can be used as the `ballot-id` The `id` value returned in the response can be used as the `ballot-id`
parameter in DELETE /polls/{poll-id}/ballots/{ballot-id}. parameter in DELETE /polls/{poll-id}/ballots/{ballot-id}.
get-user:
operationId: get-user
parameters:
userId: $response.body#/id
description: >
The `id` value returned in the response can be used as the `user-id`
parameter in GET /users/{user-id}.
update-user:
operationId: update-user
parameters:
userId: $response.body#/id
description: >
The `id` value returned in the response can be used as the `user-id`
parameter in PATCH /users/{user-id}.
delete-user:
operationId: delete-user
parameters:
userId: $response.body#/id
description: >
The `id` value returned in the response can be used as the `user-id`
parameter in DELETE /users/{user-id}.
responses: responses:
poll-not-found: poll-not-found:
description: The specified poll was not found description: The specified poll was not found
@ -474,3 +642,9 @@ components:
application/json: application/json:
schema: schema:
$ref: '#/components/schemas/error' $ref: '#/components/schemas/error'
user-not-found:
description: The specified user was not found
content:
application/json:
schema:
$ref: '#/components/schemas/error'

@ -0,0 +1,6 @@
operationId: 'delete-user'
parameters:
userId: $response.body#/id
description: >
The `id` value returned in the response can be used as the `user-id` parameter
in DELETE /users/{user-id}.

@ -0,0 +1,6 @@
operationId: 'get-user'
parameters:
userId: $response.body#/id
description: >
The `id` value returned in the response can be used as the `user-id` parameter
in GET /users/{user-id}.

@ -0,0 +1,6 @@
operationId: 'update-user'
parameters:
userId: $response.body#/id
description: >
The `id` value returned in the response can be used as the `user-id` parameter
in PATCH /users/{user-id}.

@ -0,0 +1,5 @@
description: The specified user was not found
content:
application/json:
schema:
$ref: ../schemas/error.yaml

@ -7,9 +7,11 @@ properties:
readOnly: true readOnly: true
name: name:
type: string type: string
description: Unique but short name of the mention, like "Excellent" or "To reject". description: Unique but short name of the mention, like *Excellent* or *To reject*.
example: Excellent example: Excellent
description: description:
type: string type: string
description: An optional description of the mention description: An optional description of the mention
example: In this poll, the mention "To reject" disqualifies the proposal. example: In this poll, the mention *To reject* disqualifies the proposal.
required:
- name

@ -2,22 +2,28 @@ type: object
properties: properties:
id: id:
type: string type: string
description: A unique identifier description: A unique identifier.
example: JtRm05yjMAuFCI2uwnFp example: JtRm05yjMAuFCI2uwnFp
readOnly: true readOnly: true
description: description:
type: string type: string
description: An optional description of the participant description: An optional description of the participant.
example: John Doe example: John Doe
has-participed: has-participed:
type: boolean type: boolean
description: True if the participant already participed to the poll, False otherwise description: True if the participant already participed to the poll, False otherwise.
example: true example: true
poll-id: poll-id:
type: string type: string
description: The identifier of the poll that the participant participates on. description: The identifier of the poll that the participant participates on.
example: 1jDe1e5eF_IkaYPuoIYX example: 1jDe1e5eF_IkaYPuoIYX
user-id:
type: string
description: The identifier of the user.
example: 1jDe1e5eF_IkaYPuoIYX
mail: mail:
type: string type: string
description: The mail that will eventually created at the creation of the participant (not kept in memory). description: The mail that will eventually created at the creation of the participant (not kept in memory).
example: john-doe@example.com example: john-doe@example.com
required:
- poll-id

@ -32,7 +32,13 @@ properties:
description: The participants that are allowed to participate to the election. description: The participants that are allowed to participate to the election.
items: items:
$ref: ./participant.yaml $ref: ./participant.yaml
restrict_participants: user-id:
type: string
description: Organizer id. If not given, a dummy user is created.
restrict-participants:
type: boolean type: boolean
description: True if anyone can participate to this poll, False otherwise. description: True if anyone can participate to this poll, False otherwise.
example: false example: false
required:
- title
- proposals

@ -18,3 +18,5 @@ properties:
type: string type: string
description: An optional description of the proposal description: An optional description of the proposal
example: This school would welcome 500 pupils. example: This school would welcome 500 pupils.
required:
- name

@ -13,3 +13,6 @@ properties:
items: items:
type: integer type: integer
format: int16 format: int16
required:
- ranking
- poll

@ -0,0 +1,15 @@
type: object
properties:
id:
type: integer
description: A unique identifier
example: 0
readOnly: true
name:
type: string
description: Unique user-name
example: john.doe
description:
type: string
description: An optional description of the user
example: John Doe is a multiple-use name that is used when the true name of a person is unknown or is being intentionally concealed

@ -27,6 +27,10 @@ paths:
$ref: 'paths/polls@{poll-id}@participants@{participant-id}@.yaml' $ref: 'paths/polls@{poll-id}@participants@{participant-id}@.yaml'
'/polls/{poll-id}/results': '/polls/{poll-id}/results':
$ref: 'paths/polls@{poll-id}@results.yaml' $ref: 'paths/polls@{poll-id}@results.yaml'
/users:
$ref: paths/users.yaml
'/users/{user-id}':
$ref: 'paths/users@{user-id}.yaml'
components: components:
securitySchemes: securitySchemes:
participantAuth: participantAuth:
@ -38,3 +42,6 @@ components:
resultAuth: resultAuth:
type: http type: http
scheme: bearer scheme: bearer
userAuth:
type: http
scheme: bearer

@ -0,0 +1,39 @@
get:
operationId: get-users
summary: Gets all users.
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: ../components/schemas/user.yaml
post:
operationId: create-user
summary: Creates an user
requestBody:
required: true
content:
application/json:
schema:
$ref: ../components/schemas/user.yaml
responses:
'201':
description: Created
content:
application/json:
schema:
type: object
properties:
id:
type: string
description: Id of the created user.
links:
get-user:
$ref: ../components/links/get-user.yaml
update-user:
$ref: ../components/links/update-user.yaml
delete-user:
$ref: ../components/links/delete-user.yaml

@ -0,0 +1,50 @@
parameters:
- in: path
name: user-id
required: true
schema:
type: integer
format: int64
get:
operationId: get-user
summary: Gets a user by ID
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: ../components/schemas/user.yaml
'404':
$ref: ../components/responses/user-not-found.yaml
patch:
operationId: update-user
summary: Updates a user
requestBody:
required: true
content:
application/json:
schema:
$ref: ../components/schemas/user.yaml
security:
- {}
- userAuth: []
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: ../components/schemas/user.yaml
delete:
operationId: delete-user
summary: Deletes a user
responses:
'200':
description: OK
'404':
$ref: ../components/responses/user-not-found.yaml
security:
- userAuth: []
Loading…
Cancel
Save