swagger: "2.0" info: version: "0.0.1" title: vote-rs API description: API for conducting electronic voting basePath: /api schemes: - https consumes: - application/json produces: - application/json securityDefinitions: JWT: type: apiKey name: Authorization in: header security: - JWT: [] definitions: User: type: object properties: username: type: string password: type: string Authorization: type: object properties: username: type: string namespace: type: string AuthorizationItems: type: array items: $ref: "#/definitions/Authorization" Election: type: object properties: username: type: string namespace: type: string name: type: string description: type: string start_date: type: string format: date-time end_date: type: string format: date-time items: type: array items: $ref: "#/definitions/ElectionItem" ElectionItem: type: object properties: name: type: string ElectionList: type: array items: $ref: "#/definitions/Election" VoteItem: type: object properties: item: $ref: "#/definitions/ElectionItem" value: type: number Vote: type: object properties: userid: type: string data: type: array items: $ref: "#/definitions/VoteItem" paths: /auth/login: post: summary: Authenticate user consumes: - application/json produces: - application/json parameters: - in: body name: credentials required: true schema: type: object properties: username: type: string password: type: string format: password responses: 200: description: Login successful schema: type: object properties: token: type: string 401: description: Unauthorized /auth/authorization: post: summary: Generate authentication token for another user consumes: - application/json produces: - application/json parameters: - in: header name: Authorization description: Your authorization token required: true type: string format: JWT - in: body name: authorization required: true schema: $ref: "#/definitions/Authorization" responses: 200: description: Token generated successfully schema: type: object properties: token: type: string format: JWT 401: description: Unauthorized get: summary: Generate authentication token for another user consumes: - application/json produces: - application/json parameters: - in: header name: Authorization description: Your authorization token required: true type: string format: JWT responses: 200: description: List of authorizations you have gotten. schema: $ref: "#/definitions/AuthorizationItems" 401: description: Unauthorized delete: summary: Delete all Authorization you have given to a user consumes: - application/json produces: - application/json parameters: - in: header name: Authorization description: Your authorization token required: true type: string format: JWT - in: body name: Authorisation description: The authorization token you want to delete schema: $ref: "#/definitions/Authorization" responses: 200: description: Sucsess 401: description: Unauthorized /elections: post: summary: Create new election consumes: - application/json produces: - application/json parameters: - in: header name: Authorization description: Your authorization token required: true type: string format: JWT - in: body name: election required: true schema: $ref: "#/definitions/Election" responses: 201: description: Election created successfully schema: $ref: "#/definitions/Election" 401: description: Unauthorized get: summary: Get all existing elections parameters: - in: header name: Authorization description: Your authorization token required: true type: string format: JWT responses: 200: description: List of all existing elections schema: $ref: "#/definitions/ElectionList" 401: description: Unauthorized /elections/{id}: get: summary: Get all existing elections parameters: - in: header name: Authorization description: Your authorization token required: true type: string format: JWT - in: path name: id type: string required: true responses: 200: description: List of all existing elections schema: $ref: "#/definitions/Election" 401: description: Unauthorized post: summary: Vote in exsisting election consumes: - application/json produces: - application/json parameters: - in: header name: Authorization description: Your authorization token required: true type: string format: JWT - in: body name: election required: true schema: $ref: "#/definitions/Vote" responses: 201: description: Election created successfully schema: $ref: "#/definitions/Vote" 401: description: Unauthorized