diff --git a/README.md b/README.md index aab1e9e..0031dba 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![CodeFactor](https://www.codefactor.io/repository/github/flecomte/dc-project/badge?s=869dc426625a253a07bea95f9380e23fdb048b94)](https://www.codefactor.io/repository/github/flecomte/dc-project) [![Tests](https://github.com/flecomte/dc-project/actions/workflows/tests.yml/badge.svg)](https://github.com/flecomte/dc-project/actions/workflows/tests.yml) -[Installation](./doc/installation) +[Installation](./doc/installation/Installation.md) ### Run dockers ```bash diff --git a/src/main/resources/openapi.yaml b/src/main/resources/openapi.yaml index 9e7d336..e016f54 100644 --- a/src/main/resources/openapi.yaml +++ b/src/main/resources/openapi.yaml @@ -1,26 +1,188 @@ -openapi: 3.0.0 +openapi: 3.0.2 info: - version: '0.1' + version: '' title: 'DC Project' - description: 'A free comunity program for create constitution' + description: 'A free community program for create constitution' paths: - /register: - post: - summary: Create account + /articles: + get: + summary: Get all articles tags: - - authentification - operationId: register - requestBody: - $ref: '#/components/requestBodies/RegisterRequest' - + - article + operationId: getArticles + parameters: + - $ref: '#/components/parameters/page' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/articleSort' + - $ref: '#/components/parameters/direction' + - $ref: '#/components/parameters/search' + - $ref: '#/components/parameters/createdBy' + - name: workgroup + in: query + description: ID of workgroup + example: 82a0e60a-bb55-dbc0-1c3d-0a804df2b5df + required: false + schema: + type: string + format: uuid responses: 200: - description: User created and JWT returned + description: The Article objects content: - text/plain: - example: - eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBdXRoZW50aWNhdGlvbiIsImlzcyI6ImRjLXByb2plY3QuZnIiLCJpZCI6ImQ1NDRhNmE4LWJhYjgtNDU2MC05NWIxLThhZjAyMDNkOTEwNCIsImV4cCI6MTU2NzA3Mzc0Mn0.0VTetv8fZFjVgpJ-bwJpidGNHJUOmgj8vuZcZXzwnLa7TtFwcXWvh3bDPYHqB66nmOfXyM57XnHDbmRwtipCag + application/json: + schema: + allOf: + - $ref: '#/components/schemas/Paginated' + - type: object + properties: + result: + type: array + maxItems: 50 + items: + $ref: '#/components/schemas/ArticleListingResponse' + post: + security: + - JWTAuth: [] + summary: Create new Article + tags: + - article + operationId: insertArticle + requestBody: + required: true + content: + application/json: + schema: + required: + - title + - content + - description + - tags + properties: + title: + type: string + example: + Limit power of press + content: + type: string + example: + Lorem upsum... + description: + type: string + example: + I think is the bether choice + tags: + type: array + items: + type: string + default: [ ] + example: [ power, press ] + anonymous: + type: boolean + default: true + draft: + type: boolean + default: false + workgroup: + default: null + additionalProperties: false + required: + - id + properties: + id: + $ref: "#/components/schemas/UUID" + responses: + 200: + description: Article created + content: + application/json: + schema: + properties: + id: + type: string + format: uuid + versionId: + type: string + format: uuid + versionNumber: + type: integer + 401: + $ref: '#/components/responses/401' + /articles/{article}: + parameters: + - $ref: '#/components/parameters/article' + get: + security: + - JWTAuth: [] + summary: Get one article + tags: + - article + operationId: getArticle + responses: + 200: + description: The Article objects + content: + application/json: + schema: + $ref: '#/components/schemas/ArticleResponse' + /articles/{article}/versions: + parameters: + - $ref: '#/components/parameters/article' + get: + summary: Get all versions of articles + tags: + - article + operationId: getArticleVersions + responses: + 200: + description: The versions of Article + content: + application/json: + schema: + allOf: + - $ref: '#/components/schemas/Paginated' + - type: object + properties: + result: + type: array + items: + additionalProperties: false + properties: + id: + type: string + format: uuid + title: + type: string + draft: + type: boolean + lastVersion: + type: boolean + createdBy: + type: object + additionalProperties: false + properties: + id: + type: string + format: uuid + name: + type: object + properties: + firstName: + type: string + lastName: + type: string + email: + type: string + workgroup: + type: object + nullable: true + additionalProperties: false + properties: + id: + type: string + format: uuid + name: + type: string /login: post: @@ -29,14 +191,116 @@ paths: - authentification operationId: login requestBody: - $ref: '#/components/requestBodies/LoginRequest' + description: Login + required: true + content: + application/json: + schema: + required: + - username + - password + properties: + username: + type: string + description: username + example: + john-doe + password: + type: string + description: Pasword + example: + azerty responses: 200: description: return JWT + content: + text/plain: + schema: + type: string + format: byte + example: + 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBdXRoZW50aWNhdGlvbiIsImlzcyI6ImRjLXByb2plY3QuZnIiLCJpZCI6ImQ1NDRhNmE4LWJhYjgtNDU2MC05NWIxLThhZjAyMDNkOTEwNCIsImV4cCI6MTU2NzA3Mzc0Mn0.0VTetv8fZFjVgpJ-bwJpidGNHJUOmgj8vuZcZXzwnLa7TtFwcXWvh3bDPYHqB66nmOfXyM57XnHDbmRwtipCag' + application/json: + schema: + properties: + token: + type: string + example: + 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBdXRoZW50aWNhdGlvbiIsImlzcyI6ImRjLXByb2plY3QuZnIiLCJpZCI6ImQ1NDRhNmE4LWJhYjgtNDU2MC05NWIxLThhZjAyMDNkOTEwNCIsImV4cCI6MTU2NzA3Mzc0Mn0.0VTetv8fZFjVgpJ-bwJpidGNHJUOmgj8vuZcZXzwnLa7TtFwcXWvh3bDPYHqB66nmOfXyM57XnHDbmRwtipCag' + /register: + post: + summary: Create account + tags: + - authentification + operationId: register + requestBody: + content: + application/json: + schema: + type: object + required: + - name + - birthday + - email + - user + properties: + name: + type: object + required: + - firstName + - lastName + properties: + firstName: + type: string + example: + john + lastName: + type: string + example: + Doe + birthday: + type: string + format: 'date' + example: '1984-12-25' + email: + type: string + format: email + example: my.email@dc-project.fr + user: + type: object + required: + - username + - password + properties: + username: + type: string + example: + john-doe + password: + type: string + example: + azerty + format: password + responses: + 200: + description: User created and JWT returned content: text/plain: example: - eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBdXRoZW50aWNhdGlvbiIsImlzcyI6ImRjLXByb2plY3QuZnIiLCJpZCI6ImQ1NDRhNmE4LWJhYjgtNDU2MC05NWIxLThhZjAyMDNkOTEwNCIsImV4cCI6MTU2NzA3Mzc0Mn0.0VTetv8fZFjVgpJ-bwJpidGNHJUOmgj8vuZcZXzwnLa7TtFwcXWvh3bDPYHqB66nmOfXyM57XnHDbmRwtipCag + 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBdXRoZW50aWNhdGlvbiIsImlzcyI6ImRjLXByb2plY3QuZnIiLCJpZCI6ImQ1NDRhNmE4LWJhYjgtNDU2MC05NWIxLThhZjAyMDNkOTEwNCIsImV4cCI6MTU2NzA3Mzc0Mn0.0VTetv8fZFjVgpJ-bwJpidGNHJUOmgj8vuZcZXzwnLa7TtFwcXWvh3bDPYHqB66nmOfXyM57XnHDbmRwtipCag' + application/json: + schema: + properties: + token: + type: string + example: + 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBdXRoZW50aWNhdGlvbiIsImlzcyI6ImRjLXByb2plY3QuZnIiLCJpZCI6ImQ1NDRhNmE4LWJhYjgtNDU2MC05NWIxLThhZjAyMDNkOTEwNCIsImV4cCI6MTU2NzA3Mzc0Mn0.0VTetv8fZFjVgpJ-bwJpidGNHJUOmgj8vuZcZXzwnLa7TtFwcXWvh3bDPYHqB66nmOfXyM57XnHDbmRwtipCag' + 400: + description: Bad request + content: + application/json: + schema: + description: sdf /auth/passwordless: post: summary: Send a connexion link by email @@ -63,13 +327,42 @@ paths: description: url tu redirect with the token example: http://dc-project.fr/auth/passwordless - responses: 204: description: email send 404: description: no user with this email + /citizens: + get: + security: + - JWTAuth: [] + summary: Get all citizens + tags: + - citizen + operationId: getCitizens + parameters: + - $ref: '#/components/parameters/page' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/sort' + - $ref: '#/components/parameters/direction' + - $ref: '#/components/parameters/search' + responses: + 200: + description: The Citizen objects + content: + application/json: + schema: + allOf: + - $ref: '#/components/schemas/Paginated' + - type: object + properties: + result: + type: array + items: + $ref: '#/components/schemas/CitizenListResponse' + 401: + $ref: '#/components/responses/401' /citizens/current: get: security: @@ -106,48 +399,12 @@ paths: description: Citizen not found 401: $ref: '#/components/responses/401' - /citizens/{citizen}/votes: - parameters: - - $ref: '#/components/parameters/citizen' - get: - security: - - JWTAuth: [] - summary: Get Citizen - tags: - - vote - - citizen - operationId: getCitizenVotes - parameters: - - name: id - in: query - required: true - example: - - 1329ab90-edae-cfed-f863-c8cb069fa327 - - cab54e50-ce85-bba0-da23-fc9f75feeaf5 - schema: - type: array - items: - type: string - format: uuid - responses: - 200: - description: The Votes objects - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/VoteResponse' - 404: - description: Citizen not found - 401: - $ref: '#/components/responses/401' /citizens/{citizen}/password/change: parameters: - $ref: '#/components/parameters/citizen' put: security: - - JWTAuth: [] + - JWTAuth: [ ] summary: Change Citizen Password tags: - citizen @@ -158,15 +415,15 @@ paths: application/json: schema: required: - - old_password - - new_password + - oldPassword + - newPassword properties: - old_password: + oldPassword: type: string format: password example: azerty - new_password: + newPassword: type: string format: password example: @@ -174,318 +431,12 @@ paths: responses: 201: description: Password changed + 400: + description: Bad request + 401: + $ref: '#/components/responses/401' 404: description: Citizen not found - 401: - $ref: '#/components/responses/401' - - /citizens: - get: - security: - - JWTAuth: [] - summary: Get all citizens - tags: - - citizen - operationId: getCitizens - parameters: - - $ref: '#/components/parameters/page' - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/sort' - - $ref: '#/components/parameters/direction' - - $ref: '#/components/parameters/search' - responses: - 200: - description: The Citizen objects - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/Paginated' - - type: object - properties: - result: - type: array - items: - $ref: '#/components/schemas/CitizenResponse' - 401: - $ref: '#/components/responses/401' - - /articles: - get: - summary: Get all articles - tags: - - article - operationId: getArticles - parameters: - - $ref: '#/components/parameters/page' - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/articleSort' - - $ref: '#/components/parameters/direction' - - $ref: '#/components/parameters/search' - - $ref: '#/components/parameters/createdBy' - - name: workgroup - in: query - description: ID of workgroup - example: 82a0e60a-bb55-dbc0-1c3d-0a804df2b5df - required: false - schema: - type: string - format: uuid - responses: - 200: - description: The Article objects - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/Paginated' - - type: object - properties: - result: - type: array - items: - properties: - id: - type: string - format: uuid - title: - type: string - created_by: - type: object - properties: - id: - type: string - format: uuid - name: - type: object - properties: - first_name: - type: string - last_name: - type: string - email: - type: string - workgroup: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - draft: - type: boolean - post: - security: - - JWTAuth: [] - summary: Create new Article - tags: - - article - operationId: insertArticle - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/ArticleRequest' - responses: - 201: - description: Article created - content: - application/json: - schema: - $ref: '#/components/schemas/ArticleResponse' - 401: - $ref: '#/components/responses/401' - /articles/{article}: - parameters: - - $ref: '#/components/parameters/article' - get: - security: - - {} - - JWTAuth: [] - summary: Get one article - tags: - - article - operationId: getArticle - responses: - 200: - description: The Article objects - content: - application/json: - schema: - $ref: '#/components/schemas/ArticleResponse' - /articles/{article}/versions: - parameters: - - $ref: '#/components/parameters/article' - get: - summary: Get all versions of articles - tags: - - article - operationId: getArticleVersions - responses: - 200: - description: The versions of Article - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/Paginated' - - type: object - properties: - result: - type: array - items: - $ref: '#/components/schemas/ArticleResponse' - - /constitutions: - get: - summary: Get all constitutions - tags: - - constitution - operationId: getConstitutions - parameters: - - $ref: '#/components/parameters/page' - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/sort' - - $ref: '#/components/parameters/direction' - - $ref: '#/components/parameters/search' - responses: - 200: - description: The Constitution objects - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/Paginated' - - type: object - properties: - result: - type: array - items: - $ref: '#/components/schemas/ConstitutionResponse' - post: - security: - - JWTAuth: [] - summary: Create new Constitution - tags: - - constitution - operationId: insertConstitution - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/ConstitutionRequest' - responses: - 201: - description: Constitution created - content: - application/json: - schema: - $ref: '#/components/schemas/ConstitutionResponse' - 401: - $ref: '#/components/responses/401' - /constitutions/{constitution}: - parameters: - - $ref: '#/components/parameters/constitution' - get: - summary: Get all constitutions - tags: - - constitution - operationId: getConstitutions - responses: - 200: - description: The Constitution objects - content: - application/json: - schema: - $ref: '#/components/schemas/ConstitutionResponse' - - /comments/{comment}: - parameters: - - $ref: '#/components/parameters/comment' - get: - summary: Get Comment by Comment ID - tags: - - comment - responses: - 200: - description: Return Comment and children - content: - application/json: - schema: - $ref: '#/components/schemas/CommentResponse' - put: - security: - - JWTAuth: [] - summary: Edit existing comment - tags: - - comment - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/CommentRequest' - responses: - 200: - description: Return Comment and children - content: - application/json: - schema: - $ref: '#/components/schemas/CommentResponse' - 401: - $ref: '#/components/responses/401' - /comments/{comment}/children: - parameters: - - $ref: '#/components/parameters/comment' - get: - summary: Get Comment children by Comment ID - tags: - - comment - responses: - 200: - description: Return Comment children - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/Paginated' - - type: object - properties: - result: - type: array - items: - $ref: '#/components/schemas/CommentResponse' - post: - security: - - JWTAuth: [] - summary: Create Comment on other comment - tags: - - comment - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/CommentRequest' - responses: - 201: - description: Return the created Comment - content: - application/json: - schema: - allOf: - - type: object - properties: - result: - type: array - items: - $ref: '#/components/schemas/CommentResponse' - 404: - description: Comment not found - 401: - $ref: '#/components/responses/401' /articles/{article}/comments: parameters: @@ -513,14 +464,21 @@ paths: - votes responses: 200: - description: Return Comment and children + description: Return paginated comments of article content: application/json: schema: - $ref: '#/components/schemas/CommentResponse' + allOf: + - $ref: '#/components/schemas/Paginated' + - type: object + properties: + result: + type: array + items: + $ref: '#/components/schemas/CommentResponse' post: security: - - JWTAuth: [] + - JWTAuth: [ ] summary: Create Comment to article tags: - comment @@ -529,16 +487,138 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/CommentRequest' + type: object + required: + - content + properties: + content: + type: string + example: + Lorem ipsum... responses: - 200: - description: Return Comment and children + 201: + description: Return created Comment content: application/json: schema: $ref: '#/components/schemas/CommentResponse' 401: $ref: '#/components/responses/401' + /comments/{comment}: + parameters: + - $ref: '#/components/parameters/comment' + get: + summary: Get Comment by Comment ID + tags: + - comment + responses: + 200: + description: Return Comment + content: + application/json: + schema: + $ref: '#/components/schemas/CommentResponse' + put: + security: + - JWTAuth: [] + summary: Edit existing comment + tags: + - comment + requestBody: + content: + application/json: + schema: + required: + - content + properties: + content: + type: string + example: + Lorem ipsum... + responses: + 200: + description: Return updated comment + content: + application/json: + schema: + $ref: '#/components/schemas/CommentResponse' + 401: + $ref: '#/components/responses/401' + /comments/{comment}/children: + parameters: + - $ref: '#/components/parameters/comment' + get: + summary: Get Comment children by Comment ID + tags: + - comment + responses: + 200: + description: Return Comment children + content: + application/json: + schema: + allOf: + - $ref: '#/components/schemas/Paginated' + - type: object + properties: + result: + type: array + items: + $ref: '#/components/schemas/CommentResponse' + /citizens/{citizen}/comments/articles: + parameters: + - $ref: '#/components/parameters/citizen' + get: + security: + - JWTAuth: [] + summary: all article comments for one citizen + tags: + - comment + - article + - citizen + responses: + 200: + description: Comments + content: + application/json: + schema: + allOf: + - $ref: '#/components/schemas/Paginated' + - type: object + properties: + result: + type: array + items: + $ref: '#/components/schemas/CommentResponse' + 401: + $ref: '#/components/responses/401' + /citizens/{citizen}/comments/constitutions: + parameters: + - $ref: '#/components/parameters/citizen' + get: + security: + - JWTAuth: [] + summary: all constitution comments for one citizen + tags: + - comment + - constitution + - citizen + responses: + 200: + description: Comments + content: + application/json: + schema: + allOf: + - $ref: '#/components/schemas/Paginated' + - type: object + properties: + result: + type: array + items: + $ref: '#/components/schemas/CommentResponse' + 401: + $ref: '#/components/responses/401' /constitutions/{constitution}/comments: parameters: - $ref: '#/components/parameters/constitution' @@ -565,10 +645,16 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/CommentRequest' + required: + - content + properties: + content: + type: string + example: + Lorem ipsum... responses: - 200: - description: Return Comment and children + 201: + description: Return created comment content: application/json: schema: @@ -576,12 +662,79 @@ paths: 401: $ref: '#/components/responses/401' + /constitutions: + get: + summary: Get all constitutions + tags: + - constitution + operationId: getConstitutions + parameters: + - $ref: '#/components/parameters/page' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/sort' + - $ref: '#/components/parameters/direction' + - $ref: '#/components/parameters/search' + responses: + 200: + description: The Constitution objects + content: + application/json: + schema: + allOf: + - $ref: '#/components/schemas/Paginated' + - type: object + properties: + result: + type: array + items: + $ref: '#/components/schemas/ConstitutionListingResponse' + post: + security: + - JWTAuth: [ ] + summary: Create new Constitution + tags: + - constitution + operationId: insertConstitution + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ConstitutionRequest' + + responses: + 201: + description: Constitution created + content: + application/json: + schema: + $ref: '#/components/schemas/ConstitutionResponse' + 401: + $ref: '#/components/responses/401' + 400: + $ref: '#/components/responses/400' + /constitutions/{constitution}: + parameters: + - $ref: '#/components/parameters/constitution' + get: + summary: Get all constitutions + tags: + - constitution + operationId: getConstitutions + responses: + 200: + description: The Constitution objects + content: + application/json: + schema: + $ref: '#/components/schemas/ConstitutionResponse' + /articles/{article}/follows: parameters: - $ref: '#/components/parameters/article' get: security: - - JWTAuth: [] + - JWTAuth: [ ] summary: Return Follow or nothing if you not follow tags: - follow @@ -597,7 +750,7 @@ paths: description: You not follow this article post: security: - - JWTAuth: [] + - JWTAuth: [ ] summary: Follow one article tags: - follow @@ -607,7 +760,7 @@ paths: description: Return only http status 201 on success delete: security: - - JWTAuth: [] + - JWTAuth: [ ] summary: Unfollow one article tags: - follow @@ -617,12 +770,53 @@ paths: description: Return only http status 204 on success 401: $ref: '#/components/responses/401' + /citizens/{citizen}/follows/articles: + parameters: + - $ref: '#/components/parameters/citizen' + get: + security: + - JWTAuth: [ ] + summary: Return Follow or nothing if you not follow + tags: + - follow + - article + - citizen + responses: + 200: + description: Return your follows + content: + application/json: + schema: + allOf: + - $ref: '#/components/schemas/Paginated' + - type: object + properties: + result: + type: array + items: + $ref: '#/components/schemas/FollowResponse' /constitutions/{constitution}/follows: parameters: - $ref: '#/components/parameters/constitution' + get: + security: + - JWTAuth: [ ] + summary: Return Follow or nothing if you not follow + tags: + - follow + - constitution + responses: + 200: + description: Return your follow + content: + application/json: + schema: + $ref: '#/components/schemas/FollowResponse' + 404: + description: You not follow this constitution post: security: - - JWTAuth: [] + - JWTAuth: [ ] summary: Follow one constitution tags: - follow @@ -634,7 +828,7 @@ paths: $ref: '#/components/responses/401' delete: security: - - JWTAuth: [] + - JWTAuth: [ ] summary: Unfollow one constitution tags: - follow @@ -644,98 +838,32 @@ paths: description: Return only http status 204 on success 401: $ref: '#/components/responses/401' - - /articles/{article}/vote: + /citizens/{citizen}/follows/constitutions: parameters: - - $ref: '#/components/parameters/article' - put: + - $ref: '#/components/parameters/citizen' + get: security: - - JWTAuth: [] - summary: Vote for one article + - JWTAuth: [ ] + summary: Return Follow or nothing if you not follow tags: - - vote - - article - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/VoteRequest' - responses: - 201: - description: Return only http status 201 on success - content: - application/json: - schema: - $ref: '#/components/schemas/VoteAggregation' - 401: - $ref: '#/components/responses/401' - /constitutions/{constitution}/vote: - parameters: - - $ref: '#/components/parameters/constitution' - put: - security: - - JWTAuth: [] - summary: Vote for one constitution - tags: - - vote + - follow - constitution - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/VoteRequest' + - citizen responses: - 201: - description: Return only http status 201 on success - /comments/{comment}/vote: - parameters: - - $ref: '#/components/parameters/comment' - put: - security: - - JWTAuth: [] - summary: Vote for a comment - tags: - - vote - - comment - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/VoteRequest' - responses: - 201: - description: Return votes aggregation + 200: + description: Return your follows content: application/json: schema: - $ref: '#/components/schemas/VoteAggregation' - 401: - $ref: '#/components/responses/401' + allOf: + - $ref: '#/components/schemas/Paginated' + - type: object + properties: + result: + type: array + items: + $ref: '#/components/schemas/FollowResponse' - /articles/{article}/opinions: - parameters: - - $ref: '#/components/parameters/article' - put: - security: - - JWTAuth: [] - summary: Add Opinion on one article - tags: - - opinion - - article - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ArticleOpinionRequest' - responses: - 201: - description: Return the opinion - content: - application/json: - schema: - $ref: '#/components/schemas/Opinion' - 401: - $ref: '#/components/responses/401' /opinions: get: summary: Get all opinions choices @@ -758,13 +886,14 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/OpinionChoices' + description: Opinion Choice + type: array + items: + $ref: '#/components/schemas/OpinionChoice' /opinions/{opinion}: parameters: - $ref: '#/components/parameters/opinion' get: - security: - - {} summary: Get one opinion Choices tags: - opinion @@ -780,7 +909,7 @@ paths: - $ref: '#/components/parameters/citizen' get: security: - - JWTAuth: [] + - JWTAuth: [ ] summary: Get all opinions of citizen filtered by target ids tags: - opinion @@ -830,14 +959,124 @@ paths: type: array items: $ref: '#/components/schemas/Opinion' + /articles/{article}/opinions: + parameters: + - $ref: '#/components/parameters/article' + put: + security: + - JWTAuth: [] + summary: Add Opinion on one article + tags: + - opinion + - article + requestBody: + content: + application/json: + schema: + type: object + properties: + ids: + type: array + items: + type: string + format: uuid + example: 6e978eb5-3c48-0def-b093-e01f43983adb + responses: + 201: + description: Return the opinion + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Opinion' + 401: + $ref: '#/components/responses/401' - + /constitutions/{constitution}/vote: + parameters: + - $ref: '#/components/parameters/constitution' + put: + security: + - JWTAuth: [ ] + summary: Vote for one constitution + tags: + - vote + - constitution + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/VoteRequest' + responses: + 201: + description: Return only http status 201 on success + /citizens/{citizen}/votes: + parameters: + - $ref: '#/components/parameters/citizen' + get: + security: + - JWTAuth: [ ] + summary: Get Citizen + tags: + - vote + - citizen + operationId: getCitizenVotes + parameters: + - name: id + in: query + required: true + example: + - 1329ab90-edae-cfed-f863-c8cb069fa327 + - cab54e50-ce85-bba0-da23-fc9f75feeaf5 + schema: + type: array + items: + type: string + format: uuid + responses: + 200: + description: The Votes objects + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/VoteResponse' + 404: + description: Citizen not found + 401: + $ref: '#/components/responses/401' + /comments/{comment}/vote: + parameters: + - $ref: '#/components/parameters/comment' + put: + security: + - JWTAuth: [] + summary: Vote for a comment + tags: + - vote + - comment + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/VoteRequest' + responses: + 201: + description: Return votes aggregation + content: + application/json: + schema: + $ref: '#/components/schemas/VoteAggregation' + 401: + $ref: '#/components/responses/401' /citizens/{citizen}/votes/articles: parameters: - $ref: '#/components/parameters/citizen' get: security: - - JWTAuth: [] + - JWTAuth: [ ] summary: all article vote for one citizen tags: - vote @@ -859,31 +1098,28 @@ paths: $ref: '#/components/schemas/VoteResponse' 401: $ref: '#/components/responses/401' - /citizens/{citizen}/comments/articles: + /articles/{article}/vote: parameters: - - $ref: '#/components/parameters/citizen' - get: + - $ref: '#/components/parameters/article' + put: security: - - JWTAuth: [] - summary: all article comments for one citizen + - JWTAuth: [ ] + summary: Vote for one article tags: - - comment + - vote - article - - citizen + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/VoteRequest' responses: - 200: - description: Comments + 201: + description: Return only http status 201 on success content: application/json: schema: - allOf: - - $ref: '#/components/schemas/Paginated' - - type: object - properties: - result: - type: array - items: - $ref: '#/components/schemas/CommentResponse' + $ref: '#/components/schemas/VoteAggregation' 401: $ref: '#/components/responses/401' @@ -891,8 +1127,7 @@ paths: get: summary: Get all Workgroup (Paginated) security: - - {} - - JWTAuth: [] + - JWTAuth: [ ] tags: - workgroup parameters: @@ -915,11 +1150,11 @@ paths: result: type: array items: - $ref: '#/components/schemas/WorkgroupSimple' + $ref: '#/components/schemas/WorkgroupListing' post: summary: Create new Workgroup security: - - JWTAuth: [] + - JWTAuth: [ ] tags: - workgroup requestBody: @@ -947,43 +1182,20 @@ paths: example: false nullable: true default: true - owner: - type: string - format: uuid - example: 6434f4f9-f570-f22a-c134-8668350651ff - nullable: true responses: 201: description: Workgroup created content: application/json: schema: - properties: - id: - type: string - format: uuid - name: - type: string - example: Les partisants du RIC - description: - type: string - example: Group formé pour la conception d'un RIC - logo: - type: string - anonymous: - type: boolean - example: false - owner: - type: string - format: uuid + $ref: '#/components/schemas/Workgroup' /workgroups/{workgroup}: parameters: - $ref: '#/components/parameters/workgroup' get: summary: Get one workgroup by ID security: - - {} - - JWTAuth: [] + - JWTAuth: [ ] tags: - workgroup responses: @@ -992,20 +1204,19 @@ paths: content: application/json: schema: - allOf: - - $ref: '#/components/schemas/Workgroup' + $ref: '#/components/schemas/Workgroup' + 404: + description: Workshop not exist or are deleted put: summary: Edit one workgroup security: - - JWTAuth: [] + - JWTAuth: [ ] tags: - workgroup requestBody: content: application/json: schema: - required: - - name properties: name: type: string @@ -1021,44 +1232,24 @@ paths: example: false nullable: true default: true - owner: - type: string - format: uuid - example: 6434f4f9-f570-f22a-c134-8668350651ff - nullable: true responses: 200: description: Workgroup updated content: application/json: schema: - properties: - id: - type: string - format: uuid - name: - type: string - example: Les partisants du RIC - description: - type: string - example: Group formé pour la conception d'un RIC - logo: - type: string - anonymous: - type: boolean - example: false - owner: - type: string - format: uuid + $ref: '#/components/schemas/Workgroup' delete: summary: Delete one workgroup security: - - JWTAuth: [] + - JWTAuth: [ ] tags: - workgroup responses: 204: description: Workgroup deleted + 404: + description: Workshop not exist or are already deleted /workgroups/{workgroup}/members: parameters: - $ref: '#/components/parameters/workgroup' @@ -1081,25 +1272,8 @@ paths: schema: $ref: '#/components/schemas/MembersResponse' put: - summary: Updates ALL members. PLEASE NOTE this removes all members who are not in request! - security: - - JWTAuth: [] - tags: - - workgroup - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/MembersRequest' - responses: - 201: - description: the list of members - content: - application/json: - schema: - $ref: '#/components/schemas/MembersResponse' - delete: - summary: Delete members of workgroup + summary: Updates ALL members. + description: ⚠ PLEASE NOTE ⚠ This request removes all members who are not in request! security: - JWTAuth: [] tags: @@ -1116,15 +1290,40 @@ paths: application/json: schema: $ref: '#/components/schemas/MembersResponse' + 400: + $ref: '#/components/responses/400' + delete: + summary: Delete members of workgroup + security: + - JWTAuth: [] + tags: + - workgroup + requestBody: + content: + application/json: + schema: + description: members of workgroup + type: array + items: + type: object + properties: + citizen: + required: + - id + properties: + id: + $ref: '#/components/schemas/UUID' + responses: + 200: + description: the list of members + content: + application/json: + schema: + $ref: '#/components/schemas/MembersResponse' + 400: + $ref: '#/components/responses/400' components: - responses: - 401: - description: Unautorized - content: - application/json: - schema: - description: noting parameters: page: name: page @@ -1151,7 +1350,7 @@ components: name: sort in: query description: The sort field name - example: first_name + example: firstName required: false schema: type: string @@ -1207,16 +1406,6 @@ components: type: string format: uuid - citizen: - name: citizen - in: path - description: ID of citizen - example: 6434f4f9-f570-f22a-c134-8668350651ff - required: true - schema: - type: string - format: uuid - article: name: article in: path @@ -1226,22 +1415,13 @@ components: schema: type: string format: uuid - opinion: - in: path - required: true - name: opinion - description: Opinion ID - example: 6e978eb5-3c48-0def-b093-e01f43983adb - schema: - type: string - format: uuid - constitution: - name: constitution + citizen: + name: citizen in: path + description: ID of citizen + example: 6434f4f9-f570-f22a-c134-8668350651ff required: true - description: the ID of constitution - example: e74be8e4-6823-47c4-bd1b-789725b2fa8e schema: type: string format: uuid @@ -1256,6 +1436,26 @@ components: type: string format: uuid + constitution: + name: constitution + in: path + required: true + description: the ID of constitution + example: e74be8e4-6823-47c4-bd1b-789725b2fa8e + schema: + type: string + format: uuid + + opinion: + in: path + required: true + name: opinion + description: Opinion ID + example: 6e978eb5-3c48-0def-b093-e01f43983adb + schema: + type: string + format: uuid + workgroup: name: workgroup in: path @@ -1266,12 +1466,20 @@ components: type: string format: uuid - securitySchemes: - JWTAuth: - type: http - scheme: bearer - description: call /login to get token - bearerFormat: JWT + + responses: + 401: + description: Unautorized + content: + application/json: + schema: + description: noting + 400: + description: BadReqest + content: + application/json: + schema: + description: noting schemas: UUID: @@ -1281,52 +1489,24 @@ components: format: uuid example: e74be8e4-6823-47c4-bd1b-789725b2fa8e - - UuidEntity: - properties: - id: - $ref: '#/components/schemas/UUID' - - CreatedBy: - properties: - created_by: - $ref: '#/components/schemas/CitizenResponse' - - CreatedAt: - properties: - created_at: - type: string - format: 'date-time' - UpdatedAt: - properties: - updated_at: - type: string - format: 'date-time' - DeletedAt: - properties: - deleted_at: - type: string - format: 'date-time' - deleted: - type: boolean - - versionId: - properties: - version_id: - $ref: '#/components/schemas/UUID' - - lastVersion: - properties: - last_version: - type: boolean - default: false - Paginated: + required: + - total + - count + - currentPage + - limit + - offset + - result properties: result: type: array + maxItems: 50 items: - $ref: '#/components/schemas/UuidEntity' + required: + - id + properties: + id: + $ref: '#/components/schemas/UUID' count: type: integer minimum: 0 @@ -1338,6 +1518,7 @@ components: limit: type: integer minimum: 0 + maximum: 50 example: 50 offset: type: integer @@ -1347,306 +1528,301 @@ components: type: integer minimum: 0 example: 1 - - UserBase: + ArticleResponse: + additionalProperties: false required: - - username + - id + - versionId + - versionNumber + - title + - anonymous + - content + - description + - tags + - draft + - lastVersion + - createdBy + - views + - opinions + - votes properties: - username: + id: type: string - example: - john-doe - UserResponse: - allOf: - - $ref: '#/components/schemas/UserBase' - - $ref: '#/components/schemas/UuidEntity' - UserRequest: - allOf: - - $ref: '#/components/schemas/UserBase' - - type: object + format: uuid + versionId: + type: string + format: uuid + versionNumber: + type: integer + minimum: 0 + title: + type: string + anonymous: + type: boolean + content: + type: string + description: + type: string + tags: + type: array + items: + type: string + draft: + type: boolean + lastVersion: + type: boolean + createdAt: + type: string + format: 'date-time' + createdBy: + type: object + additionalProperties: false required: - - password + - id + - name + - email properties: - password: + id: type: string - example: - azerty - format: password - - CitizenResponse: - allOf: - - $ref: '#/components/schemas/CitizenBase' - - $ref: '#/components/schemas/CreatedAt' - - $ref: '#/components/schemas/UuidEntity' - - type: object + format: uuid + name: + type: object + required: + - firstName + - lastName + properties: + firstName: + type: string + lastName: + type: string + email: + type: string + workgroup: + type: object + nullable: true + additionalProperties: false properties: - user: - $ref: '#/components/schemas/UserResponse' - CitizenBase: + id: + type: string + format: uuid + name: + type: string + views: + additionalProperties: false + required: + - total + - unique + properties: + total: + type: integer + unique: + type: integer + opinions: + additionalProperties: + type: integer + example: + 'good writed': 5 + 'to short': 19 + votes: + additionalProperties: false + required: + - up + - neutral + - down + - total + - score + properties: + up: + type: integer + neutral: + type: integer + down: + type: integer + total: + type: integer + score: + type: integer + ArticleListingResponse: + required: + - id + - title + - createdBy + - workgroup + - draft + properties: + id: + type: string + format: uuid + title: + type: string + createdBy: + $ref: '#/components/schemas/CitizenCreator' + workgroup: + type: object + nullable: true + additionalProperties: false + properties: + id: + type: string + format: uuid + name: + type: string + draft: + type: boolean + + CitizenListResponse: + additionalProperties: false type: object required: - - first_name - - last_name + - id + - name + - email properties: + id: + $ref: '#/components/schemas/UUID' name: type: object + required: + - firstName + - lastName properties: - first_name: + firstName: type: string example: john - last_name: + lastName: type: string example: Doe - birthday: - type: string - format: 'date' - example: '1984-12-25' email: type: string format: email example: my.email@dc-project.fr - CitizenRequest: - allOf: - - $ref: '#/components/schemas/CitizenBase' - - type: object - properties: - user: - $ref: '#/components/schemas/UserRequest' - - RegisterRequest: - $ref: '#/components/schemas/CitizenRequest' - - LoginRequest: - required: - - name - - password - properties: - name: - type: string - description: username - example: - john-doe - password: - type: string - description: Pasword - example: - azerty - - ArticleBase: - type: object - allOf: - - type: object - required: - - title - - content - - description - - tags - - anonymous - - draft - properties: - title: - type: string - example: - Limit power of press - content: - type: string - example: - Lorem upsum... - description: - type: string - example: - I think is the bether choice - tags: - type: array - items: - type: string - default: [] - example: [power, press] - anonymous: - type: boolean - default: true - draft: - type: boolean - default: false - workgroup: - allOf: - - $ref: '#/components/schemas/UuidEntity' - - default: null - - $ref: '#/components/schemas/versionId' - ArticleResponse: - type: object - allOf: - - $ref: '#/components/schemas/ArticleBase' - - $ref: '#/components/schemas/UuidEntity' - - $ref: '#/components/schemas/CreatedBy' - - $ref: '#/components/schemas/CreatedAt' - - $ref: '#/components/schemas/lastVersion' - - $ref: '#/components/schemas/Votable' - - $ref: '#/components/schemas/Opinionable' - - ArticleRequest: - $ref: '#/components/schemas/ArticleBase' - - ConstitutionBase: - type: object - allOf: - - type: object - required: - - title - properties: - title: - type: string - example: - Constitution for the liberty - titles: - type: array - default: [] - items: - $ref: '#/components/schemas/TitleBase' - anonymous: - type: boolean - default: true - draft: - type: boolean - default: false - - $ref: '#/components/schemas/versionId' - ConstitutionResponse: - type: object - allOf: - - $ref: '#/components/schemas/ConstitutionBase' - - $ref: '#/components/schemas/UuidEntity' - - $ref: '#/components/schemas/CreatedBy' - - $ref: '#/components/schemas/CreatedAt' - - type: object - properties: - titles: - type: array - items: - $ref: '#/components/schemas/TitleResponse' - ConstitutionRequest: - allOf: - - $ref: '#/components/schemas/ConstitutionBase' - - type: object - properties: - titles: - type: array - items: - $ref: '#/components/schemas/TitleRequest' - - TitleBase: + CitizenResponse: + additionalProperties: false type: object required: + - id - name + - email + - createdAt + - user properties: + id: + $ref: '#/components/schemas/UUID' name: - type: string - example: - The liberties - rank: - type: integer - minimum: 0 - example: - 0 - TitleRequest: - type: object - allOf: - - $ref: '#/components/schemas/TitleBase' - - $ref: '#/components/schemas/UuidEntity' - - type: object - properties: - articles: - type: array - items: - $ref: '#/components/schemas/UuidEntity' - TitleResponse: - type: object - allOf: - - $ref: '#/components/schemas/TitleBase' - - $ref: '#/components/schemas/UuidEntity' - - $ref: '#/components/schemas/CreatedAt' - - $ref: '#/components/schemas/CreatedBy' - - type: object - properties: - articles: - type: array - items: - $ref: '#/components/schemas/ArticleResponse' - - Extra: - type: object - allOf: - - $ref: '#/components/schemas/UuidEntity' - - $ref: '#/components/schemas/CreatedAt' - - $ref: '#/components/schemas/CreatedBy' - - type: object - properties: - target: - $ref: '#/components/schemas/UuidEntity' - - CommentBase: - type: object - allOf: - - type: object + type: object required: - - content + - firstName + - lastName properties: - content: + firstName: type: string example: - Lorem ipsum... - CommentRequest: - allOf: - - $ref: '#/components/schemas/CommentBase' + john + lastName: + type: string + example: + Doe + email: + type: string + format: email + example: my.email@dc-project.fr + birthday: + type: string + format: 'date' + example: '1984-12-25' + createdAt: + type: string + format: 'date-time' + user: + type: object + required: + - username + properties: + username: + type: string + example: + john-doe + CitizenCreator: + additionalProperties: false + type: object + required: + - id + - name + - user + properties: + id: + $ref: '#/components/schemas/UUID' + name: + type: object + required: + - firstName + - lastName + properties: + firstName: + type: string + example: + john + lastName: + type: string + example: + Doe + user: + type: object + required: + - username + properties: + username: + type: string + example: + john-doe CommentResponse: - allOf: - - $ref: '#/components/schemas/CommentBase' - - $ref: '#/components/schemas/UpdatedAt' - - $ref: '#/components/schemas/Extra' - - $ref: '#/components/schemas/Votable' - - type: object - required: - - parent_ids - - parent + additionalProperties: false + type: object + required: + - id + - content + - parent + - createdAt + - createdBy + - votes + - target + - childrenCount + properties: + id: + $ref: '#/components/schemas/UUID' + content: + type: string + example: + Lorem ipsum... + parent: + nullable: true properties: - parents_ids: - type: array - items: - $ref: '#/components/schemas/UUID' - parent: - allOf: - - $ref: '#/components/schemas/UUID' - - FollowBase: - allOf: - - $ref: '#/components/schemas/Extra' - FollowResponse: - allOf: - - $ref: '#/components/schemas/FollowBase' - - - VoteBase: - allOf: - - type: object - required: - - note + id: + $ref: '#/components/schemas/UUID' + reference: + type: string + createdBy: + $ref: '#/components/schemas/CitizenCreator' + createdAt: + type: string + format: 'date-time' + updatedAt: + type: string + format: 'date-time' + target: + additionalProperties: false properties: - note: - type: integer - minimum: -1 - maximum: 1 - VoteRequest: - allOf: - - $ref: '#/components/schemas/VoteBase' - VoteResponse: - allOf: - - $ref: '#/components/schemas/VoteBase' - - $ref: '#/components/schemas/Extra' - VoteAggregation: - allOf: - - type: object + id: + $ref: '#/components/schemas/UUID' + reference: + type: string + childrenCount: + type: integer + minimum: 0 + votes: properties: up: type: number @@ -1662,182 +1838,377 @@ components: minimum: 0 score: type: number - - $ref: '#/components/schemas/UpdatedAt' - Votable: + ConstitutionRequest: + additionalProperties: false + description: The versionId field must be defined for update contitution type: object + required: + - title properties: - votes: - $ref: '#/components/schemas/VoteAggregation' - Opinionable: - type: object - properties: - opinions: + id: + $ref: '#/components/schemas/UUID' + title: type: string - additionalProperties: true example: - Opinion1: 1 - Opinion2: 55 - - ArticleOpinionRequest: - type: object - properties: - ids: + Constitution for the liberty + titles: type: array + default: [ ] items: - type: string - format: uuid - example: 6e978eb5-3c48-0def-b093-e01f43983adb + additionalProperties: false + type: object + required: + - name + properties: + id: + $ref: '#/components/schemas/UUID' + name: + type: string + example: + The liberties + articles: + type: array + items: + required: + - id + properties: + id: + $ref: '#/components/schemas/UUID' + anonymous: + type: boolean + default: true + draft: + type: boolean + default: false + versionId: + $ref: '#/components/schemas/UUID' + ConstitutionResponse: + additionalProperties: false + type: object + required: + - id + - title + - titles + - anonymous + - draft + - versionId + - createdBy + - createdAt + properties: + id: + $ref: '#/components/schemas/UUID' + title: + type: string + example: + Constitution for the liberty + titles: + type: array + default: [ ] + items: + additionalProperties: false + type: object + required: + - id + - name + - rank + - articles + properties: + id: + $ref: '#/components/schemas/UUID' + name: + type: string + example: + The liberties + rank: + type: integer + minimum: 0 + example: 0 + createdBy: + $ref: '#/components/schemas/CitizenCreator' + createdAt: + type: string + format: 'date-time' + articles: + type: array + items: + $ref: '#/components/schemas/ArticleListingResponse' + anonymous: + type: boolean + default: true + draft: + type: boolean + default: false + versionId: + $ref: '#/components/schemas/UUID' + createdBy: + $ref: '#/components/schemas/CitizenCreator' + createdAt: + type: string + format: 'date-time' + ConstitutionListingResponse: + additionalProperties: false + type: object + required: + - id + - title + - versionId + - createdAt + - createdBy + properties: + id: + $ref: '#/components/schemas/UUID' + title: + type: string + example: + Constitution for the liberty + versionId: + $ref: '#/components/schemas/UUID' + createdBy: + $ref: '#/components/schemas/CitizenCreator' + createdAt: + type: string + format: 'date-time' - OpinionChoices: - description: Opinion Choice - type: array - items: - $ref: '#/components/schemas/OpinionChoice' + FollowResponse: + additionalProperties: false + required: + - id + - createdBy + - createdAt + - target + properties: + id: + $ref: '#/components/schemas/UUID' + createdBy: + $ref: '#/components/schemas/CitizenCreator' + createdAt: + type: string + format: 'date-time' + target: + required: + - id + - reference + additionalProperties: false + properties: + id: + $ref: '#/components/schemas/UUID' + reference: + type: string OpinionChoice: description: Opinion Choice - allOf: - - type: object - required: - - name - properties: - id: - type: string - format: uuid - name: - type: string - example: opinion1 - target: - type: array - nullable: true - items: - type: string - description: the name of the target - - $ref: '#/components/schemas/CreatedAt' - - $ref: '#/components/schemas/DeletedAt' - + type: object + required: + - name + properties: + id: + type: string + format: uuid + name: + type: string + example: opinion1 + target: + type: array + nullable: true + items: + type: string + description: the name of the target Opinion: description: Opinion - allOf: - - type: object + type: object + properties: + id: + type: string + format: uuid + name: + type: string + example: opinion1 + target: + type: object properties: id: type: string format: uuid - name: - type: string - example: opinion1 - target: - type: object - properties: - id: - type: string - format: uuid - reference: - type: string - example: article - choice: - type: object - allOf: - - $ref: '#/components/schemas/OpinionChoice' reference: type: string - example: opinion_on_article - - $ref: '#/components/schemas/CreatedBy' - - $ref: '#/components/schemas/CreatedAt' + example: article + choice: + type: object + allOf: + - $ref: '#/components/schemas/OpinionChoice' + reference: + type: string + example: opinion_on_article + createdBy: + $ref: '#/components/schemas/CitizenCreator' + createdAt: + type: string + format: 'date-time' - WorkgroupSimple: - description: Workgroup - allOf: - - type: object + VoteRequest: + type: object + additionalProperties: false + required: + - note + properties: + note: + type: integer + minimum: -1 + maximum: 1 + VoteResponse: + type: object + additionalProperties: false + required: + - id + - note + - createdAt + - createdBy + - target + properties: + id: + $ref: '#/components/schemas/UUID' + note: + type: integer + minimum: -1 + maximum: 1 + createdAt: + type: string + format: 'date-time' + createdBy: + $ref: '#/components/schemas/CitizenCreator' + target: + required: + - id + - reference properties: id: + $ref: '#/components/schemas/UUID' + reference: type: string - format: uuid - name: - type: string - example: Les partisants du RIC - description: - type: string - example: Group formé pour la conception d'un RIC - logo: - type: string - anonymous: - type: boolean - example: false - - $ref: '#/components/schemas/CreatedBy' - - $ref: '#/components/schemas/DeletedAt' + VoteAggregation: + additionalProperties: false + type: object + required: + - up + - neutral + - down + - total + - score + - updatedAt + properties: + up: + type: number + minimum: 0 + neutral: + type: number + minimum: 0 + down: + type: number + minimum: 0 + total: + type: number + minimum: 0 + score: + type: number + updatedAt: + type: string + format: 'date-time' + + WorkgroupListing: + description: Workgroup + type: object + properties: + id: + type: string + format: uuid + name: + type: string + example: Les partisants du RIC + description: + type: string + example: Group formé pour la conception d'un RIC + logo: + type: string + nullable: true Workgroup: description: Workgroup - allOf: - - $ref: '#/components/schemas/WorkgroupSimple' - - type: object - properties: - members: - $ref: '#/components/schemas/MembersResponse' - - $ref: '#/components/schemas/CreatedAt' - - $ref: '#/components/schemas/UpdatedAt' + type: object + required: + - id + - name + - description + - logo + - anonymous + - createdBy + - members + properties: + id: + type: string + format: uuid + name: + type: string + example: Les partisants du RIC + description: + type: string + example: Group formé pour la conception d'un RIC + logo: + type: string + nullable: true + anonymous: + type: boolean + createdBy: + $ref: '#/components/schemas/CitizenCreator' + members: + $ref: '#/components/schemas/MembersResponse' + MembersRequest: description: members of workgroup type: array items: - $ref: '#/components/schemas/MemberRequest' + type: object + properties: + citizen: + required: + - id + properties: + id: + $ref: '#/components/schemas/UUID' + roles: + type: array + items: + type: string + enum: + - MASTER + - MANAGER + - EDITOR + - REPORTER + example: MASTER MembersResponse: description: members of workgroup type: array items: - $ref: '#/components/schemas/MemberResponse' - MemberResponse: - description: Member of workgroup - type: object - properties: - citizen: - $ref: '#/components/schemas/CitizenResponse' - roles: - type: array - items: - type: string - enum: - - MASTER - - MANAGER - - EDITOR - - REPORTER - example: MASTER - MemberRequest: - description: Member of workgroup - type: object - properties: - citizen: - $ref: '#/components/schemas/UuidEntity' - roles: - type: array - items: - type: string - enum: - - MASTER - - MANAGER - - EDITOR - - REPORTER - example: MASTER + description: Member of workgroup + type: object + properties: + citizen: + $ref: '#/components/schemas/CitizenCreator' + roles: + type: array + items: + type: string + enum: + - MASTER + - MANAGER + - EDITOR + - REPORTER + example: MASTER - - - requestBodies: - RegisterRequest: - content: - application/json: - schema: - $ref: '#/components/schemas/RegisterRequest' - description: Register - required: true - - LoginRequest: - content: - application/json: - schema: - $ref: '#/components/schemas/LoginRequest' - description: Login - required: true + securitySchemes: + JWTAuth: + type: http + scheme: bearer + description: call /login to get token + bearerFormat: JWT servers: - description: localhost diff --git a/src/main/resources/openapi2.yaml b/src/main/resources/openapi2.yaml deleted file mode 100644 index e016f54..0000000 --- a/src/main/resources/openapi2.yaml +++ /dev/null @@ -1,2217 +0,0 @@ -openapi: 3.0.2 -info: - version: '' - title: 'DC Project' - description: 'A free community program for create constitution' - -paths: - /articles: - get: - summary: Get all articles - tags: - - article - operationId: getArticles - parameters: - - $ref: '#/components/parameters/page' - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/articleSort' - - $ref: '#/components/parameters/direction' - - $ref: '#/components/parameters/search' - - $ref: '#/components/parameters/createdBy' - - name: workgroup - in: query - description: ID of workgroup - example: 82a0e60a-bb55-dbc0-1c3d-0a804df2b5df - required: false - schema: - type: string - format: uuid - responses: - 200: - description: The Article objects - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/Paginated' - - type: object - properties: - result: - type: array - maxItems: 50 - items: - $ref: '#/components/schemas/ArticleListingResponse' - post: - security: - - JWTAuth: [] - summary: Create new Article - tags: - - article - operationId: insertArticle - requestBody: - required: true - content: - application/json: - schema: - required: - - title - - content - - description - - tags - properties: - title: - type: string - example: - Limit power of press - content: - type: string - example: - Lorem upsum... - description: - type: string - example: - I think is the bether choice - tags: - type: array - items: - type: string - default: [ ] - example: [ power, press ] - anonymous: - type: boolean - default: true - draft: - type: boolean - default: false - workgroup: - default: null - additionalProperties: false - required: - - id - properties: - id: - $ref: "#/components/schemas/UUID" - responses: - 200: - description: Article created - content: - application/json: - schema: - properties: - id: - type: string - format: uuid - versionId: - type: string - format: uuid - versionNumber: - type: integer - 401: - $ref: '#/components/responses/401' - /articles/{article}: - parameters: - - $ref: '#/components/parameters/article' - get: - security: - - JWTAuth: [] - summary: Get one article - tags: - - article - operationId: getArticle - responses: - 200: - description: The Article objects - content: - application/json: - schema: - $ref: '#/components/schemas/ArticleResponse' - /articles/{article}/versions: - parameters: - - $ref: '#/components/parameters/article' - get: - summary: Get all versions of articles - tags: - - article - operationId: getArticleVersions - responses: - 200: - description: The versions of Article - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/Paginated' - - type: object - properties: - result: - type: array - items: - additionalProperties: false - properties: - id: - type: string - format: uuid - title: - type: string - draft: - type: boolean - lastVersion: - type: boolean - createdBy: - type: object - additionalProperties: false - properties: - id: - type: string - format: uuid - name: - type: object - properties: - firstName: - type: string - lastName: - type: string - email: - type: string - workgroup: - type: object - nullable: true - additionalProperties: false - properties: - id: - type: string - format: uuid - name: - type: string - - /login: - post: - summary: sign in - tags: - - authentification - operationId: login - requestBody: - description: Login - required: true - content: - application/json: - schema: - required: - - username - - password - properties: - username: - type: string - description: username - example: - john-doe - password: - type: string - description: Pasword - example: - azerty - responses: - 200: - description: return JWT - content: - text/plain: - schema: - type: string - format: byte - example: - 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBdXRoZW50aWNhdGlvbiIsImlzcyI6ImRjLXByb2plY3QuZnIiLCJpZCI6ImQ1NDRhNmE4LWJhYjgtNDU2MC05NWIxLThhZjAyMDNkOTEwNCIsImV4cCI6MTU2NzA3Mzc0Mn0.0VTetv8fZFjVgpJ-bwJpidGNHJUOmgj8vuZcZXzwnLa7TtFwcXWvh3bDPYHqB66nmOfXyM57XnHDbmRwtipCag' - application/json: - schema: - properties: - token: - type: string - example: - 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBdXRoZW50aWNhdGlvbiIsImlzcyI6ImRjLXByb2plY3QuZnIiLCJpZCI6ImQ1NDRhNmE4LWJhYjgtNDU2MC05NWIxLThhZjAyMDNkOTEwNCIsImV4cCI6MTU2NzA3Mzc0Mn0.0VTetv8fZFjVgpJ-bwJpidGNHJUOmgj8vuZcZXzwnLa7TtFwcXWvh3bDPYHqB66nmOfXyM57XnHDbmRwtipCag' - /register: - post: - summary: Create account - tags: - - authentification - operationId: register - requestBody: - content: - application/json: - schema: - type: object - required: - - name - - birthday - - email - - user - properties: - name: - type: object - required: - - firstName - - lastName - properties: - firstName: - type: string - example: - john - lastName: - type: string - example: - Doe - birthday: - type: string - format: 'date' - example: '1984-12-25' - email: - type: string - format: email - example: my.email@dc-project.fr - user: - type: object - required: - - username - - password - properties: - username: - type: string - example: - john-doe - password: - type: string - example: - azerty - format: password - responses: - 200: - description: User created and JWT returned - content: - text/plain: - example: - 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBdXRoZW50aWNhdGlvbiIsImlzcyI6ImRjLXByb2plY3QuZnIiLCJpZCI6ImQ1NDRhNmE4LWJhYjgtNDU2MC05NWIxLThhZjAyMDNkOTEwNCIsImV4cCI6MTU2NzA3Mzc0Mn0.0VTetv8fZFjVgpJ-bwJpidGNHJUOmgj8vuZcZXzwnLa7TtFwcXWvh3bDPYHqB66nmOfXyM57XnHDbmRwtipCag' - application/json: - schema: - properties: - token: - type: string - example: - 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBdXRoZW50aWNhdGlvbiIsImlzcyI6ImRjLXByb2plY3QuZnIiLCJpZCI6ImQ1NDRhNmE4LWJhYjgtNDU2MC05NWIxLThhZjAyMDNkOTEwNCIsImV4cCI6MTU2NzA3Mzc0Mn0.0VTetv8fZFjVgpJ-bwJpidGNHJUOmgj8vuZcZXzwnLa7TtFwcXWvh3bDPYHqB66nmOfXyM57XnHDbmRwtipCag' - 400: - description: Bad request - content: - application/json: - schema: - description: sdf - /auth/passwordless: - post: - summary: Send a connexion link by email - description: Send a connexion link by email with the token required to the connexion - externalDocs: - description: Explanation of Passwordless auth - url: https://en.wikipedia.org/wiki/Passwordless_authentication - tags: - - authentification - operationId: passwordless - requestBody: - content: - application/json: - schema: - properties: - email: - type: string - format: email - description: email to send the token - example: - my.email@dc-project.fr - url: - type: string - description: url tu redirect with the token - example: - http://dc-project.fr/auth/passwordless - responses: - 204: - description: email send - 404: - description: no user with this email - - /citizens: - get: - security: - - JWTAuth: [] - summary: Get all citizens - tags: - - citizen - operationId: getCitizens - parameters: - - $ref: '#/components/parameters/page' - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/sort' - - $ref: '#/components/parameters/direction' - - $ref: '#/components/parameters/search' - responses: - 200: - description: The Citizen objects - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/Paginated' - - type: object - properties: - result: - type: array - items: - $ref: '#/components/schemas/CitizenListResponse' - 401: - $ref: '#/components/responses/401' - /citizens/current: - get: - security: - - JWTAuth: [] - summary: Get Citizen - tags: - - citizen - operationId: getCurrentCitizen - responses: - 200: - description: The Citizen object - content: - application/json: - schema: - $ref: '#/components/schemas/CitizenResponse' - /citizens/{citizen}: - parameters: - - $ref: '#/components/parameters/citizen' - get: - security: - - JWTAuth: [] - summary: Get Citizen - tags: - - citizen - operationId: getCitizen - responses: - 200: - description: The Citizen object - content: - application/json: - schema: - $ref: '#/components/schemas/CitizenResponse' - 404: - description: Citizen not found - 401: - $ref: '#/components/responses/401' - /citizens/{citizen}/password/change: - parameters: - - $ref: '#/components/parameters/citizen' - put: - security: - - JWTAuth: [ ] - summary: Change Citizen Password - tags: - - citizen - operationId: changePassword - requestBody: - required: true - content: - application/json: - schema: - required: - - oldPassword - - newPassword - properties: - oldPassword: - type: string - format: password - example: - azerty - newPassword: - type: string - format: password - example: - qwerty - responses: - 201: - description: Password changed - 400: - description: Bad request - 401: - $ref: '#/components/responses/401' - 404: - description: Citizen not found - - /articles/{article}/comments: - parameters: - - $ref: '#/components/parameters/article' - get: - summary: Get comments of one article - tags: - - comment - - article - parameters: - - $ref: '#/components/parameters/page' - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/search' - - name: sort - in: query - required: false - example: - - created_at - - votes - schema: - type: string - default: created_at - enum: - - created_at - - votes - responses: - 200: - description: Return paginated comments of article - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/Paginated' - - type: object - properties: - result: - type: array - items: - $ref: '#/components/schemas/CommentResponse' - post: - security: - - JWTAuth: [ ] - summary: Create Comment to article - tags: - - comment - - article - requestBody: - content: - application/json: - schema: - type: object - required: - - content - properties: - content: - type: string - example: - Lorem ipsum... - responses: - 201: - description: Return created Comment - content: - application/json: - schema: - $ref: '#/components/schemas/CommentResponse' - 401: - $ref: '#/components/responses/401' - /comments/{comment}: - parameters: - - $ref: '#/components/parameters/comment' - get: - summary: Get Comment by Comment ID - tags: - - comment - responses: - 200: - description: Return Comment - content: - application/json: - schema: - $ref: '#/components/schemas/CommentResponse' - put: - security: - - JWTAuth: [] - summary: Edit existing comment - tags: - - comment - requestBody: - content: - application/json: - schema: - required: - - content - properties: - content: - type: string - example: - Lorem ipsum... - responses: - 200: - description: Return updated comment - content: - application/json: - schema: - $ref: '#/components/schemas/CommentResponse' - 401: - $ref: '#/components/responses/401' - /comments/{comment}/children: - parameters: - - $ref: '#/components/parameters/comment' - get: - summary: Get Comment children by Comment ID - tags: - - comment - responses: - 200: - description: Return Comment children - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/Paginated' - - type: object - properties: - result: - type: array - items: - $ref: '#/components/schemas/CommentResponse' - /citizens/{citizen}/comments/articles: - parameters: - - $ref: '#/components/parameters/citizen' - get: - security: - - JWTAuth: [] - summary: all article comments for one citizen - tags: - - comment - - article - - citizen - responses: - 200: - description: Comments - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/Paginated' - - type: object - properties: - result: - type: array - items: - $ref: '#/components/schemas/CommentResponse' - 401: - $ref: '#/components/responses/401' - /citizens/{citizen}/comments/constitutions: - parameters: - - $ref: '#/components/parameters/citizen' - get: - security: - - JWTAuth: [] - summary: all constitution comments for one citizen - tags: - - comment - - constitution - - citizen - responses: - 200: - description: Comments - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/Paginated' - - type: object - properties: - result: - type: array - items: - $ref: '#/components/schemas/CommentResponse' - 401: - $ref: '#/components/responses/401' - /constitutions/{constitution}/comments: - parameters: - - $ref: '#/components/parameters/constitution' - get: - summary: Get comment and children of one constitution - tags: - - comment - - constitution - responses: - 200: - description: Return Comment and children - content: - application/json: - schema: - $ref: '#/components/schemas/CommentResponse' - post: - security: - - JWTAuth: [] - summary: Create Comment to constitution - tags: - - comment - - constitution - requestBody: - content: - application/json: - schema: - required: - - content - properties: - content: - type: string - example: - Lorem ipsum... - responses: - 201: - description: Return created comment - content: - application/json: - schema: - $ref: '#/components/schemas/CommentResponse' - 401: - $ref: '#/components/responses/401' - - /constitutions: - get: - summary: Get all constitutions - tags: - - constitution - operationId: getConstitutions - parameters: - - $ref: '#/components/parameters/page' - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/sort' - - $ref: '#/components/parameters/direction' - - $ref: '#/components/parameters/search' - responses: - 200: - description: The Constitution objects - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/Paginated' - - type: object - properties: - result: - type: array - items: - $ref: '#/components/schemas/ConstitutionListingResponse' - post: - security: - - JWTAuth: [ ] - summary: Create new Constitution - tags: - - constitution - operationId: insertConstitution - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/ConstitutionRequest' - - responses: - 201: - description: Constitution created - content: - application/json: - schema: - $ref: '#/components/schemas/ConstitutionResponse' - 401: - $ref: '#/components/responses/401' - 400: - $ref: '#/components/responses/400' - /constitutions/{constitution}: - parameters: - - $ref: '#/components/parameters/constitution' - get: - summary: Get all constitutions - tags: - - constitution - operationId: getConstitutions - responses: - 200: - description: The Constitution objects - content: - application/json: - schema: - $ref: '#/components/schemas/ConstitutionResponse' - - /articles/{article}/follows: - parameters: - - $ref: '#/components/parameters/article' - get: - security: - - JWTAuth: [ ] - summary: Return Follow or nothing if you not follow - tags: - - follow - - article - responses: - 200: - description: Return your follow - content: - application/json: - schema: - $ref: '#/components/schemas/FollowResponse' - 404: - description: You not follow this article - post: - security: - - JWTAuth: [ ] - summary: Follow one article - tags: - - follow - - article - responses: - 201: - description: Return only http status 201 on success - delete: - security: - - JWTAuth: [ ] - summary: Unfollow one article - tags: - - follow - - article - responses: - 204: - description: Return only http status 204 on success - 401: - $ref: '#/components/responses/401' - /citizens/{citizen}/follows/articles: - parameters: - - $ref: '#/components/parameters/citizen' - get: - security: - - JWTAuth: [ ] - summary: Return Follow or nothing if you not follow - tags: - - follow - - article - - citizen - responses: - 200: - description: Return your follows - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/Paginated' - - type: object - properties: - result: - type: array - items: - $ref: '#/components/schemas/FollowResponse' - /constitutions/{constitution}/follows: - parameters: - - $ref: '#/components/parameters/constitution' - get: - security: - - JWTAuth: [ ] - summary: Return Follow or nothing if you not follow - tags: - - follow - - constitution - responses: - 200: - description: Return your follow - content: - application/json: - schema: - $ref: '#/components/schemas/FollowResponse' - 404: - description: You not follow this constitution - post: - security: - - JWTAuth: [ ] - summary: Follow one constitution - tags: - - follow - - constitution - responses: - 201: - description: Return only http status 201 on success - 401: - $ref: '#/components/responses/401' - delete: - security: - - JWTAuth: [ ] - summary: Unfollow one constitution - tags: - - follow - - constitution - responses: - 204: - description: Return only http status 204 on success - 401: - $ref: '#/components/responses/401' - /citizens/{citizen}/follows/constitutions: - parameters: - - $ref: '#/components/parameters/citizen' - get: - security: - - JWTAuth: [ ] - summary: Return Follow or nothing if you not follow - tags: - - follow - - constitution - - citizen - responses: - 200: - description: Return your follows - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/Paginated' - - type: object - properties: - result: - type: array - items: - $ref: '#/components/schemas/FollowResponse' - - /opinions: - get: - summary: Get all opinions choices - tags: - - opinion - parameters: - - in: query - required: false - name: targets - description: opinion available for defined target - example: - - article - schema: - type: array - items: - type: string - responses: - 200: - description: return - content: - application/json: - schema: - description: Opinion Choice - type: array - items: - $ref: '#/components/schemas/OpinionChoice' - /opinions/{opinion}: - parameters: - - $ref: '#/components/parameters/opinion' - get: - summary: Get one opinion Choices - tags: - - opinion - responses: - 200: - description: return - content: - application/json: - schema: - $ref: '#/components/schemas/OpinionChoice' - /citizens/{citizen}/opinions: - parameters: - - $ref: '#/components/parameters/citizen' - get: - security: - - JWTAuth: [ ] - summary: Get all opinions of citizen filtered by target ids - tags: - - opinion - - citizen - parameters: - - in: query - required: true - name: id - description: target ids - example: - - 9226c1a3-8091-c3fa-7d0d-c2e98c9bee7b - schema: - type: array - items: - type: string - format: uuid - responses: - 200: - description: Opinions - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Opinion' - /citizens/{citizen}/opinions/articles: - parameters: - - $ref: '#/components/parameters/citizen' - get: - security: - - JWTAuth: [] - summary: Get all opinions of one citizen - tags: - - opinion - - citizen - responses: - 200: - description: Opinions - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/Paginated' - - type: object - properties: - result: - type: array - items: - $ref: '#/components/schemas/Opinion' - /articles/{article}/opinions: - parameters: - - $ref: '#/components/parameters/article' - put: - security: - - JWTAuth: [] - summary: Add Opinion on one article - tags: - - opinion - - article - requestBody: - content: - application/json: - schema: - type: object - properties: - ids: - type: array - items: - type: string - format: uuid - example: 6e978eb5-3c48-0def-b093-e01f43983adb - responses: - 201: - description: Return the opinion - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Opinion' - 401: - $ref: '#/components/responses/401' - - /constitutions/{constitution}/vote: - parameters: - - $ref: '#/components/parameters/constitution' - put: - security: - - JWTAuth: [ ] - summary: Vote for one constitution - tags: - - vote - - constitution - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/VoteRequest' - responses: - 201: - description: Return only http status 201 on success - /citizens/{citizen}/votes: - parameters: - - $ref: '#/components/parameters/citizen' - get: - security: - - JWTAuth: [ ] - summary: Get Citizen - tags: - - vote - - citizen - operationId: getCitizenVotes - parameters: - - name: id - in: query - required: true - example: - - 1329ab90-edae-cfed-f863-c8cb069fa327 - - cab54e50-ce85-bba0-da23-fc9f75feeaf5 - schema: - type: array - items: - type: string - format: uuid - responses: - 200: - description: The Votes objects - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/VoteResponse' - 404: - description: Citizen not found - 401: - $ref: '#/components/responses/401' - /comments/{comment}/vote: - parameters: - - $ref: '#/components/parameters/comment' - put: - security: - - JWTAuth: [] - summary: Vote for a comment - tags: - - vote - - comment - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/VoteRequest' - responses: - 201: - description: Return votes aggregation - content: - application/json: - schema: - $ref: '#/components/schemas/VoteAggregation' - 401: - $ref: '#/components/responses/401' - /citizens/{citizen}/votes/articles: - parameters: - - $ref: '#/components/parameters/citizen' - get: - security: - - JWTAuth: [ ] - summary: all article vote for one citizen - tags: - - vote - - article - - citizen - responses: - 200: - description: Votes - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/Paginated' - - type: object - properties: - result: - type: array - items: - $ref: '#/components/schemas/VoteResponse' - 401: - $ref: '#/components/responses/401' - /articles/{article}/vote: - parameters: - - $ref: '#/components/parameters/article' - put: - security: - - JWTAuth: [ ] - summary: Vote for one article - tags: - - vote - - article - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/VoteRequest' - responses: - 201: - description: Return only http status 201 on success - content: - application/json: - schema: - $ref: '#/components/schemas/VoteAggregation' - 401: - $ref: '#/components/responses/401' - - /workgroups: - get: - summary: Get all Workgroup (Paginated) - security: - - JWTAuth: [ ] - tags: - - workgroup - parameters: - - $ref: '#/components/parameters/page' - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/workgroupSort' - - $ref: '#/components/parameters/direction' - - $ref: '#/components/parameters/search' - - $ref: '#/components/parameters/createdBy' - responses: - 200: - description: paginated list of workgroup - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/Paginated' - - type: object - properties: - result: - type: array - items: - $ref: '#/components/schemas/WorkgroupListing' - post: - summary: Create new Workgroup - security: - - JWTAuth: [ ] - tags: - - workgroup - requestBody: - content: - application/json: - schema: - required: - - name - properties: - id: - type: string - format: uuid - nullable: true - name: - type: string - example: Les partisants du RIC - description: - type: string - example: Group formé pour la conception d'un RIC - logo: - type: string - nullable: true - anonymous: - type: boolean - example: false - nullable: true - default: true - responses: - 201: - description: Workgroup created - content: - application/json: - schema: - $ref: '#/components/schemas/Workgroup' - /workgroups/{workgroup}: - parameters: - - $ref: '#/components/parameters/workgroup' - get: - summary: Get one workgroup by ID - security: - - JWTAuth: [ ] - tags: - - workgroup - responses: - 200: - description: Workgroup - content: - application/json: - schema: - $ref: '#/components/schemas/Workgroup' - 404: - description: Workshop not exist or are deleted - put: - summary: Edit one workgroup - security: - - JWTAuth: [ ] - tags: - - workgroup - requestBody: - content: - application/json: - schema: - properties: - name: - type: string - example: Les partisants du RIC - description: - type: string - example: Group formé pour la conception d'un RIC - logo: - type: string - nullable: true - anonymous: - type: boolean - example: false - nullable: true - default: true - responses: - 200: - description: Workgroup updated - content: - application/json: - schema: - $ref: '#/components/schemas/Workgroup' - delete: - summary: Delete one workgroup - security: - - JWTAuth: [ ] - tags: - - workgroup - responses: - 204: - description: Workgroup deleted - 404: - description: Workshop not exist or are already deleted - /workgroups/{workgroup}/members: - parameters: - - $ref: '#/components/parameters/workgroup' - post: - summary: Add members to the workgroup - security: - - JWTAuth: [] - tags: - - workgroup - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/MembersRequest' - responses: - 201: - description: the list of members - content: - application/json: - schema: - $ref: '#/components/schemas/MembersResponse' - put: - summary: Updates ALL members. - description: ⚠ PLEASE NOTE ⚠ This request removes all members who are not in request! - security: - - JWTAuth: [] - tags: - - workgroup - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/MembersRequest' - responses: - 200: - description: the list of members - content: - application/json: - schema: - $ref: '#/components/schemas/MembersResponse' - 400: - $ref: '#/components/responses/400' - delete: - summary: Delete members of workgroup - security: - - JWTAuth: [] - tags: - - workgroup - requestBody: - content: - application/json: - schema: - description: members of workgroup - type: array - items: - type: object - properties: - citizen: - required: - - id - properties: - id: - $ref: '#/components/schemas/UUID' - responses: - 200: - description: the list of members - content: - application/json: - schema: - $ref: '#/components/schemas/MembersResponse' - 400: - $ref: '#/components/responses/400' - -components: - parameters: - page: - name: page - in: query - description: The current page - example: 1 - required: false - schema: - default: 1 - type: integer - minimum: 1 - limit: - name: limit - in: query - description: The number of object per page - example: 50 - required: false - schema: - default: 50 - type: integer - minimum: 1 - maximum: 50 - sort: - name: sort - in: query - description: The sort field name - example: firstName - required: false - schema: - type: string - articleSort: - name: sort - in: query - description: The sort field name - example: createdAt - required: false - schema: - type: string - enum: - - title - - createdAt - - vote - - popularity - workgroupSort: - name: sort - in: query - description: The sort field name - example: createdAt - required: false - schema: - type: string - enum: - - name - - createdAt - direction: - name: direction - in: query - description: The sort direction - example: asc - required: false - schema: - type: string - default: asc - enum: [asc, desc] - search: - name: search - in: query - description: A text to seach - example: content50 - required: false - schema: - type: string - createdBy: - name: createdBy - in: query - description: filter by Author - example: 4d673bfa-eaef-4290-b52f-85a9c8a7eba5 - required: false - schema: - type: string - format: uuid - - article: - name: article - in: path - required: true - description: the ID of article - example: d91aa0cd-61d6-83cc-41bb-8d5656e130f7 - schema: - type: string - format: uuid - - citizen: - name: citizen - in: path - description: ID of citizen - example: 6434f4f9-f570-f22a-c134-8668350651ff - required: true - schema: - type: string - format: uuid - - comment: - name: comment - in: path - description: The ID of comment - example: 701dc504-db49-7e3a-2c0a-32542507ea57 - required: true - schema: - type: string - format: uuid - - constitution: - name: constitution - in: path - required: true - description: the ID of constitution - example: e74be8e4-6823-47c4-bd1b-789725b2fa8e - schema: - type: string - format: uuid - - opinion: - in: path - required: true - name: opinion - description: Opinion ID - example: 6e978eb5-3c48-0def-b093-e01f43983adb - schema: - type: string - format: uuid - - workgroup: - name: workgroup - in: path - description: ID of workgroup - example: 82a0e60a-bb55-dbc0-1c3d-0a804df2b5df - required: true - schema: - type: string - format: uuid - - - responses: - 401: - description: Unautorized - content: - application/json: - schema: - description: noting - 400: - description: BadReqest - content: - application/json: - schema: - description: noting - - schemas: - UUID: - type: string - pattern: '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}' - description: UUID - format: uuid - example: - e74be8e4-6823-47c4-bd1b-789725b2fa8e - Paginated: - required: - - total - - count - - currentPage - - limit - - offset - - result - properties: - result: - type: array - maxItems: 50 - items: - required: - - id - properties: - id: - $ref: '#/components/schemas/UUID' - count: - type: integer - minimum: 0 - example: 1 - currentPage: - type: integer - minimum: 0 - example: 1 - limit: - type: integer - minimum: 0 - maximum: 50 - example: 50 - offset: - type: integer - minimum: 0 - example: 1 - total: - type: integer - minimum: 0 - example: 1 - ArticleResponse: - additionalProperties: false - required: - - id - - versionId - - versionNumber - - title - - anonymous - - content - - description - - tags - - draft - - lastVersion - - createdBy - - views - - opinions - - votes - properties: - id: - type: string - format: uuid - versionId: - type: string - format: uuid - versionNumber: - type: integer - minimum: 0 - title: - type: string - anonymous: - type: boolean - content: - type: string - description: - type: string - tags: - type: array - items: - type: string - draft: - type: boolean - lastVersion: - type: boolean - createdAt: - type: string - format: 'date-time' - createdBy: - type: object - additionalProperties: false - required: - - id - - name - - email - properties: - id: - type: string - format: uuid - name: - type: object - required: - - firstName - - lastName - properties: - firstName: - type: string - lastName: - type: string - email: - type: string - workgroup: - type: object - nullable: true - additionalProperties: false - properties: - id: - type: string - format: uuid - name: - type: string - views: - additionalProperties: false - required: - - total - - unique - properties: - total: - type: integer - unique: - type: integer - opinions: - additionalProperties: - type: integer - example: - 'good writed': 5 - 'to short': 19 - votes: - additionalProperties: false - required: - - up - - neutral - - down - - total - - score - properties: - up: - type: integer - neutral: - type: integer - down: - type: integer - total: - type: integer - score: - type: integer - ArticleListingResponse: - required: - - id - - title - - createdBy - - workgroup - - draft - properties: - id: - type: string - format: uuid - title: - type: string - createdBy: - $ref: '#/components/schemas/CitizenCreator' - workgroup: - type: object - nullable: true - additionalProperties: false - properties: - id: - type: string - format: uuid - name: - type: string - draft: - type: boolean - - CitizenListResponse: - additionalProperties: false - type: object - required: - - id - - name - - email - properties: - id: - $ref: '#/components/schemas/UUID' - name: - type: object - required: - - firstName - - lastName - properties: - firstName: - type: string - example: - john - lastName: - type: string - example: - Doe - email: - type: string - format: email - example: my.email@dc-project.fr - CitizenResponse: - additionalProperties: false - type: object - required: - - id - - name - - email - - createdAt - - user - properties: - id: - $ref: '#/components/schemas/UUID' - name: - type: object - required: - - firstName - - lastName - properties: - firstName: - type: string - example: - john - lastName: - type: string - example: - Doe - email: - type: string - format: email - example: my.email@dc-project.fr - birthday: - type: string - format: 'date' - example: '1984-12-25' - createdAt: - type: string - format: 'date-time' - user: - type: object - required: - - username - properties: - username: - type: string - example: - john-doe - CitizenCreator: - additionalProperties: false - type: object - required: - - id - - name - - user - properties: - id: - $ref: '#/components/schemas/UUID' - name: - type: object - required: - - firstName - - lastName - properties: - firstName: - type: string - example: - john - lastName: - type: string - example: - Doe - user: - type: object - required: - - username - properties: - username: - type: string - example: - john-doe - - CommentResponse: - additionalProperties: false - type: object - required: - - id - - content - - parent - - createdAt - - createdBy - - votes - - target - - childrenCount - properties: - id: - $ref: '#/components/schemas/UUID' - content: - type: string - example: - Lorem ipsum... - parent: - nullable: true - properties: - id: - $ref: '#/components/schemas/UUID' - reference: - type: string - createdBy: - $ref: '#/components/schemas/CitizenCreator' - createdAt: - type: string - format: 'date-time' - updatedAt: - type: string - format: 'date-time' - target: - additionalProperties: false - properties: - id: - $ref: '#/components/schemas/UUID' - reference: - type: string - childrenCount: - type: integer - minimum: 0 - votes: - properties: - up: - type: number - minimum: 0 - neutral: - type: number - minimum: 0 - down: - type: number - minimum: 0 - total: - type: number - minimum: 0 - score: - type: number - ConstitutionRequest: - additionalProperties: false - description: The versionId field must be defined for update contitution - type: object - required: - - title - properties: - id: - $ref: '#/components/schemas/UUID' - title: - type: string - example: - Constitution for the liberty - titles: - type: array - default: [ ] - items: - additionalProperties: false - type: object - required: - - name - properties: - id: - $ref: '#/components/schemas/UUID' - name: - type: string - example: - The liberties - articles: - type: array - items: - required: - - id - properties: - id: - $ref: '#/components/schemas/UUID' - anonymous: - type: boolean - default: true - draft: - type: boolean - default: false - versionId: - $ref: '#/components/schemas/UUID' - ConstitutionResponse: - additionalProperties: false - type: object - required: - - id - - title - - titles - - anonymous - - draft - - versionId - - createdBy - - createdAt - properties: - id: - $ref: '#/components/schemas/UUID' - title: - type: string - example: - Constitution for the liberty - titles: - type: array - default: [ ] - items: - additionalProperties: false - type: object - required: - - id - - name - - rank - - articles - properties: - id: - $ref: '#/components/schemas/UUID' - name: - type: string - example: - The liberties - rank: - type: integer - minimum: 0 - example: 0 - createdBy: - $ref: '#/components/schemas/CitizenCreator' - createdAt: - type: string - format: 'date-time' - articles: - type: array - items: - $ref: '#/components/schemas/ArticleListingResponse' - anonymous: - type: boolean - default: true - draft: - type: boolean - default: false - versionId: - $ref: '#/components/schemas/UUID' - createdBy: - $ref: '#/components/schemas/CitizenCreator' - createdAt: - type: string - format: 'date-time' - ConstitutionListingResponse: - additionalProperties: false - type: object - required: - - id - - title - - versionId - - createdAt - - createdBy - properties: - id: - $ref: '#/components/schemas/UUID' - title: - type: string - example: - Constitution for the liberty - versionId: - $ref: '#/components/schemas/UUID' - createdBy: - $ref: '#/components/schemas/CitizenCreator' - createdAt: - type: string - format: 'date-time' - - FollowResponse: - additionalProperties: false - required: - - id - - createdBy - - createdAt - - target - properties: - id: - $ref: '#/components/schemas/UUID' - createdBy: - $ref: '#/components/schemas/CitizenCreator' - createdAt: - type: string - format: 'date-time' - target: - required: - - id - - reference - additionalProperties: false - properties: - id: - $ref: '#/components/schemas/UUID' - reference: - type: string - - OpinionChoice: - description: Opinion Choice - type: object - required: - - name - properties: - id: - type: string - format: uuid - name: - type: string - example: opinion1 - target: - type: array - nullable: true - items: - type: string - description: the name of the target - Opinion: - description: Opinion - type: object - properties: - id: - type: string - format: uuid - name: - type: string - example: opinion1 - target: - type: object - properties: - id: - type: string - format: uuid - reference: - type: string - example: article - choice: - type: object - allOf: - - $ref: '#/components/schemas/OpinionChoice' - reference: - type: string - example: opinion_on_article - createdBy: - $ref: '#/components/schemas/CitizenCreator' - createdAt: - type: string - format: 'date-time' - - VoteRequest: - type: object - additionalProperties: false - required: - - note - properties: - note: - type: integer - minimum: -1 - maximum: 1 - VoteResponse: - type: object - additionalProperties: false - required: - - id - - note - - createdAt - - createdBy - - target - properties: - id: - $ref: '#/components/schemas/UUID' - note: - type: integer - minimum: -1 - maximum: 1 - createdAt: - type: string - format: 'date-time' - createdBy: - $ref: '#/components/schemas/CitizenCreator' - target: - required: - - id - - reference - properties: - id: - $ref: '#/components/schemas/UUID' - reference: - type: string - VoteAggregation: - additionalProperties: false - type: object - required: - - up - - neutral - - down - - total - - score - - updatedAt - properties: - up: - type: number - minimum: 0 - neutral: - type: number - minimum: 0 - down: - type: number - minimum: 0 - total: - type: number - minimum: 0 - score: - type: number - updatedAt: - type: string - format: 'date-time' - - WorkgroupListing: - description: Workgroup - type: object - properties: - id: - type: string - format: uuid - name: - type: string - example: Les partisants du RIC - description: - type: string - example: Group formé pour la conception d'un RIC - logo: - type: string - nullable: true - Workgroup: - description: Workgroup - type: object - required: - - id - - name - - description - - logo - - anonymous - - createdBy - - members - properties: - id: - type: string - format: uuid - name: - type: string - example: Les partisants du RIC - description: - type: string - example: Group formé pour la conception d'un RIC - logo: - type: string - nullable: true - anonymous: - type: boolean - createdBy: - $ref: '#/components/schemas/CitizenCreator' - members: - $ref: '#/components/schemas/MembersResponse' - - MembersRequest: - description: members of workgroup - type: array - items: - type: object - properties: - citizen: - required: - - id - properties: - id: - $ref: '#/components/schemas/UUID' - roles: - type: array - items: - type: string - enum: - - MASTER - - MANAGER - - EDITOR - - REPORTER - example: MASTER - MembersResponse: - description: members of workgroup - type: array - items: - description: Member of workgroup - type: object - properties: - citizen: - $ref: '#/components/schemas/CitizenCreator' - roles: - type: array - items: - type: string - enum: - - MASTER - - MANAGER - - EDITOR - - REPORTER - example: MASTER - - securitySchemes: - JWTAuth: - type: http - scheme: bearer - description: call /login to get token - bearerFormat: JWT - -servers: - - description: localhost - url: http://localhost:8080 - - description: production - url: http://dc-project.fr \ No newline at end of file diff --git a/src/test/kotlin/integration/steps/then/schema.kt b/src/test/kotlin/integration/steps/then/schema.kt index a3df36e..bde3e69 100644 --- a/src/test/kotlin/integration/steps/then/schema.kt +++ b/src/test/kotlin/integration/steps/then/schema.kt @@ -33,7 +33,7 @@ fun Schema.validate(api: OpenApi3, toValidate: JsonNode) { } fun TestApplicationResponse.operation(route: String? = null, callback: Operation.(OpenApi3, String) -> Unit): Operation { - val filePath = "/openapi2.yaml" + val filePath = "/openapi.yaml" return OpenApi3Parser().parse(File(filePath.getResource().toURI()), true).let { api: OpenApi3 -> val httpMethod = call.request.httpMethod val uri = route ?: "/" + Url(call.request.uri).encodedPath