openapi: 3.0.1 info: version: '0.1' title: 'DC Project' description: 'A free comunity program for create constitution' paths: /register: post: summary: Create account tags: - authentification operationId: register requestBody: $ref: '#/components/requestBodies/RegisterRequest' responses: 200: description: User created and JWT returned content: text/plain: example: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBdXRoZW50aWNhdGlvbiIsImlzcyI6ImRjLXByb2plY3QuZnIiLCJpZCI6ImQ1NDRhNmE4LWJhYjgtNDU2MC05NWIxLThhZjAyMDNkOTEwNCIsImV4cCI6MTU2NzA3Mzc0Mn0.0VTetv8fZFjVgpJ-bwJpidGNHJUOmgj8vuZcZXzwnLa7TtFwcXWvh3bDPYHqB66nmOfXyM57XnHDbmRwtipCag /login: post: summary: sign in tags: - authentification operationId: login requestBody: $ref: '#/components/requestBodies/LoginRequest' responses: 200: description: return JWT content: text/plain: example: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBdXRoZW50aWNhdGlvbiIsImlzcyI6ImRjLXByb2plY3QuZnIiLCJpZCI6ImQ1NDRhNmE4LWJhYjgtNDU2MC05NWIxLThhZjAyMDNkOTEwNCIsImV4cCI6MTU2NzA3Mzc0Mn0.0VTetv8fZFjVgpJ-bwJpidGNHJUOmgj8vuZcZXzwnLa7TtFwcXWvh3bDPYHqB66nmOfXyM57XnHDbmRwtipCag /citizens/{citizen}: get: security: - JWTAuth: [] summary: Get Citizen tags: - citizen operationId: getCitizen parameters: - name: citizen in: path description: ID of citizen example: e74be8e4-6823-47c4-bd1b-789725b2fa8e required: true schema: type: string format: uuid responses: 200: description: The Citizen object content: application/json: schema: $ref: '#/components/schemas/CitizenResponse' 404: description: Citizen not found /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' /articles: get: summary: Get all articles tags: - article operationId: getArticles 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 Article objects content: application/json: schema: allOf: - $ref: '#/components/schemas/Paginated' - type: object properties: result: type: array items: $ref: '#/components/schemas/ArticleResponse' 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' /articles/{article}: get: summary: Get all articles tags: - article operationId: getArticle parameters: - name: article in: path required: true description: the ID of article schema: type: string format: uuid responses: 200: description: The Article objects content: application/json: schema: $ref: '#/components/schemas/ArticleResponse' /articles/{article}/versions: get: summary: Get all versions of articles tags: - article operationId: getArticleVersions parameters: - name: article in: path required: true description: the ID of article schema: type: string format: uuid 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' /constitutions/{constitution}: get: summary: Get all constitutions tags: - constitution operationId: getConstitutions parameters: - name: constitution in: query required: true description: the ID of constitution schema: type: string format: uuid responses: 200: description: The Constitution objects content: application/json: schema: $ref: '#/components/schemas/ConstitutionResponse' /comments/{comment}: get: summary: Get Comment and children 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' /articles/{article}/comments: parameters: - name: article in: path description: The ID of article example: e74be8e4-6823-47c4-bd1b-789725b2fa8e required: true schema: type: string format: uuid get: summary: Get comment and children of one article tags: - comment responses: 200: description: Return Comment and children content: application/json: schema: $ref: '#/components/schemas/CommentResponse' post: security: - JWTAuth: [] summary: Create Comment to article 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' /constitutions/{constitution}/comments: parameters: - name: constitution in: path description: The ID of constitution example: e74be8e4-6823-47c4-bd1b-789725b2fa8e required: true schema: type: string format: uuid get: summary: Get comment and children of one constitution tags: - comment 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 requestBody: content: application/json: schema: $ref: '#/components/schemas/CommentRequest' responses: 200: description: Return Comment and children content: application/json: schema: $ref: '#/components/schemas/CommentResponse' /articles/{article}/follows: parameters: - name: article in: path description: The ID of article example: e74be8e4-6823-47c4-bd1b-789725b2fa8e required: true schema: type: string format: uuid post: security: - JWTAuth: [] summary: Follow one article tags: - follow responses: 201: description: Return only http status 201 on success delete: security: - JWTAuth: [] summary: Unfollow one article tags: - follow responses: 204: description: Return only http status 204 on success /constitutions/{constitution}/follows: parameters: - name: constitution in: path description: The ID of constitution example: e74be8e4-6823-47c4-bd1b-789725b2fa8e required: true schema: type: string format: uuid post: security: - JWTAuth: [] summary: Follow one constitution tags: - follow responses: 201: description: Return only http status 201 on success delete: security: - JWTAuth: [] summary: Unfollow one constitution tags: - follow responses: 204: description: Return only http status 204 on success /articles/{article}/vote: parameters: - name: article in: path description: The ID of article example: e74be8e4-6823-47c4-bd1b-789725b2fa8e required: true schema: type: string format: uuid put: security: - JWTAuth: [] summary: Vote for one article tags: - vote requestBody: content: application/json: schema: $ref: '#/components/schemas/VoteRequest' responses: 201: description: Return only http status 201 on success /constitutions/{constitution}/vote: parameters: - name: constitution in: path description: The ID of constitution example: e74be8e4-6823-47c4-bd1b-789725b2fa8e required: true schema: type: string format: uuid put: security: - JWTAuth: [] summary: Vote for one constitution tags: - vote requestBody: content: application/json: schema: $ref: '#/components/schemas/VoteRequest' responses: 201: description: Return only http status 201 on success 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: first_name required: false schema: type: string 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: John Doe required: false schema: type: string securitySchemes: JWTAuth: type: http scheme: bearer description: call /login to get token 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 UuidEntity: properties: id: $ref: '#/components/schemas/UUID' CreatedBy: properties: created_by: $ref: '#/components/schemas/UuidEntity' CreatedAt: properties: created_at: type: string format: 'date-time' UpdatedAt: properties: updated_at: type: string format: 'date-time' versionId: properties: version_id: $ref: '#/components/schemas/UUID' Paginated: properties: result: type: array items: $ref: '#/components/schemas/UuidEntity' count: type: integer minimum: 0 example: 1 currentPage: type: integer minimum: 0 example: 1 limit: type: integer minimum: 0 example: 50 offset: type: integer minimum: 0 example: 1 total: type: integer minimum: 0 example: 1 UserBase: properties: username: type: string required: true example: john-doe UserResponse: allOf: - $ref: '#/components/schemas/UserBase' - $ref: '#/components/schemas/UuidEntity' UserRequest: allOf: - $ref: '#/components/schemas/UserBase' - type: object properties: plain_password: type: string required: true example: azerty format: password CitizenResponse: allOf: - $ref: '#/components/schemas/CitizenBase' - $ref: '#/components/schemas/CreatedAt' - $ref: '#/components/schemas/UuidEntity' - type: object properties: user: $ref: '#/components/schemas/UserResponse' CitizenBase: type: object properties: name: type: object properties: first_name: type: string required: true example: john last_name: type: string required: true example: Doe birthday: type: string example: 1984-12-25 CitizenRequest: allOf: - $ref: '#/components/schemas/CitizenBase' - type: object properties: user: $ref: '#/components/schemas/UserRequest' RegisterRequest: $ref: '#/components/schemas/CitizenRequest' LoginRequest: properties: name: type: string description: username required: true example: john-doe password: type: string description: Pasword required: true example: azerty ArticleBase: type: object allOf: - type: object properties: title: type: string required: true example: Limit power of press content: type: string required: true example: Lorem upsum... descritption: type: string required: true example: I think is the bether choice tags: type: array items: type: string required: false default: [] example: [power, press] annonymous: type: boolean required: false default: true - $ref: '#/components/schemas/versionId' ArticleResponse: type: object allOf: - $ref: '#/components/schemas/ArticleBase' - $ref: '#/components/schemas/UuidEntity' - $ref: '#/components/schemas/CreatedBy' - $ref: '#/components/schemas/CreatedAt' ArticleRequest: $ref: '#/components/schemas/ArticleBase' ConstitutionBase: type: object allOf: - type: object properties: title: type: string required: true example: Constitution for the liberty titles: type: array required: false default: [] items: $ref: '#/components/schemas/TitleBase' annonymous: type: boolean required: false default: true - $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: type: object properties: name: type: string required: true 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 properties: content: type: string required: true example: Lorem ipsum... CommentRequest: allOf: - $ref: '#/components/schemas/CommentBase' CommentResponse: allOf: - $ref: '#/components/schemas/CommentBase' - $ref: '#/components/schemas/UpdatedAt' - $ref: '#/components/schemas/Extra' - type: object properties: parents_ids: type: array required: false items: $ref: '#/components/schemas/UUID' parent: required: false allOf: - $ref: '#/components/schemas/UUID' - $ref: '#/components/schemas/UUID' FollowBase: allOf: - $ref: '#/components/schemas/Extra' FollowResponse: allOf: - $ref: '#/components/schemas/FollowBase' VoteBase: allOf: - type: object properties: note: type: integer minimum: -1 maximum: 1 required: true VoteRequest: allOf: - $ref: '#/components/schemas/VoteBase' VoteResponse: allOf: - $ref: '#/components/schemas/VoteBase' - $ref: '#/components/schemas/Extra' 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 servers: - description: localhost url: http://localhost:8080 - description: production url: http://dc-project.fr - description: SwaggerHub API Auto Mocking url: https://virtserver.swaggerhub.com/flecomte/dc-project/0.1