openapi: "3.0.0" info: title: A personal diary API version: 1.0.0 tags: - name: utils - name: auth - name: users - name: diaries - name: diary-entries - name: sharing-tasks servers: - url: http://localhost:8080/api - url: https://egor-diary-api.herokuapp.com/api security: - BearerAuth: [] paths: /ping: get: tags: - utils responses: 200: description: OK security: [] /v1/auth/register: post: description: Register new user with specified username/password and extra data tags: - auth requestBody: $ref: '#/components/requestBodies/RegisterRequestBody' responses: 200: $ref: '#/components/responses/RegistrationResponse' 400: $ref: '#/components/responses/BadRequestResponse' 401: $ref: '#/components/responses/UnauthorizedResponse' security: [] /v1/auth/login: post: description: Login as an existing user with provided username and password tags: - auth requestBody: $ref: '#/components/requestBodies/LoginRequestBody' responses: 200: $ref: '#/components/responses/AuthResultResponse' 400: $ref: '#/components/responses/BadRequestResponse' 401: $ref: '#/components/responses/UnauthorizedResponse' security: [] /v1/auth/refresh-token: post: description: Refresh existing auth token within 5 minutes until its expiration tags: - auth responses: 200: $ref: '#/components/responses/AuthResultResponse' 400: $ref: '#/components/responses/BadRequestResponse' 401: $ref: '#/components/responses/UnauthorizedResponse' /v1/users/me: get: description: Get full info about current user tags: - users responses: 200: $ref: '#/components/responses/FullUserResponse' 400: $ref: '#/components/responses/BadRequestResponse' 401: $ref: '#/components/responses/UnauthorizedResponse' /v1/users/{id}: get: description: Get public info about user by their ID tags: - users parameters: - name: id in: path description: ID of the user whose info is requested required: true schema: type: string format: uuid responses: 200: $ref: '#/components/responses/ShortUserResponse' 400: $ref: '#/components/responses/BadRequestResponse' 401: $ref: '#/components/responses/UnauthorizedResponse' 404: description: User with given name was not found /v1/users/name={name}: get: description: Get public info about current user tags: - users parameters: - name: name in: path description: Name of the user whose info is requested schema: type: string responses: 200: $ref: '#/components/responses/ShortUserResponse' 400: $ref: '#/components/responses/BadRequestResponse' 401: $ref: '#/components/responses/UnauthorizedResponse' 404: description: User with given name was not found /v1/diaries: get: description: Get available diaries tags: - diaries responses: 200: $ref: '#/components/responses/DiariesResponse' 400: $ref: '#/components/responses/BadRequestResponse' 401: $ref: '#/components/responses/UnauthorizedResponse' /v1/diary-entries: get: description: Get diary entries tags: - diary-entries parameters: - name: diaryId in: query required: false schema: type: string format: uuid - name: date in: query required: false schema: type: string format: date responses: 200: $ref: '#/components/responses/DiaryEntriesResponse' 400: $ref: '#/components/responses/BadRequestResponse' 401: $ref: '#/components/responses/UnauthorizedResponse' post: description: Create diary entry tags: - diary-entries requestBody: $ref: '#/components/requestBodies/CreateDiaryEntryRequestBody' responses: 200: $ref: '#/components/responses/CreateDiaryEntryResponse' 400: $ref: '#/components/responses/BadRequestResponse' 401: $ref: '#/components/responses/UnauthorizedResponse' /v1/diary-entries/{id}: get: description: Get diary entry tags: - diary-entries parameters: - name: id in: path description: ID of entry to get required: true schema: type: string format: uuid responses: 200: $ref: '#/components/responses/GetDiaryEntryResponse' 400: $ref: '#/components/responses/BadRequestResponse' 401: $ref: '#/components/responses/UnauthorizedResponse' patch: description: Update diary entry tags: - diary-entries parameters: - name: id in: path description: ID of the entry to update required: true schema: type: string format: uuid requestBody: $ref: '#/components/requestBodies/UpdateDiaryEntryRequestBody' responses: 200: $ref: '#/components/responses/UpdateDiaryEntryResponse' 400: $ref: '#/components/responses/BadRequestResponse' 401: $ref: '#/components/responses/UnauthorizedResponse' 404: description: Diary entry with given ID was not found delete: description: Update diary entry tags: - diary-entries parameters: - name: id in: path description: ID of the entry to update required: true schema: type: string format: uuid responses: 204: description: Deleted diary entry 400: $ref: '#/components/responses/BadRequestResponse' 401: $ref: '#/components/responses/UnauthorizedResponse' /v1/sharing-tasks: get: description: Get available sharing tasks where current user is receiver tags: - sharing-tasks responses: 200: $ref: '#/components/responses/AvailableSharingTasksResponse' 400: $ref: '#/components/responses/BadRequestResponse' 401: $ref: '#/components/responses/UnauthorizedResponse' post: description: Create sharing task to share a diary tags: - sharing-tasks requestBody: $ref: '#/components/requestBodies/CreateSharingTaskRequestBody' responses: 200: $ref: '#/components/responses/CreateSharingTaskResponse' /v1/sharing-tasks/accept: post: description: Accept shared diary key tags: - sharing-tasks requestBody: $ref: '#/components/requestBodies/AcceptSharedDiaryRequestBody' responses: 204: description: Shared diary was successfully accepted 400: $ref: '#/components/responses/BadRequestResponse' 401: $ref: '#/components/responses/UnauthorizedResponse' 404: description: Shared diary with given diary ID was not found components: schemas: RegisterRequest: type: object required: - username - password - masterKeySalt - publicKeyForSharing - encryptedPrivateKeyForSharing - encryptedDiaryKey properties: username: type: string required: true password: type: string required: true masterKeySalt: type: string required: true publicKeyForSharing: type: string required: true encryptedPrivateKeyForSharing: type: string required: true encryptedDiaryKey: type: string required: true LoginRequest: type: object required: - username - password properties: username: type: string required: true password: type: string required: true RegistrationResult: type: object required: - token - diaryId properties: token: type: string required: true diaryId: description: ID of new diary crated for the registered user type: string format: uuid required: true AuthResult: required: - token type: object properties: token: type: string required: true FullUserDto: required: - masterKeySalt - encryptedPrivateKeyForSharing type: object allOf: - $ref: '#/components/schemas/ShortUserDto' - type: object properties: masterKeySalt: type: string required: true encryptedPrivateKeyForSharing: type: string required: true ShortUserDto: type: object required: - id - username - publicKeyForSharing properties: id: type: string format: uuid required: true username: type: string required: true publicKeyForSharing: type: string required: true ErrorDto: type: object required: - message properties: message: type: string required: true DiaryDto: type: object required: - id - name - ownerId - key properties: id: type: string format: uuid name: type: string ownerId: type: string format: uuid key: type: string DiariesListDto: type: object required: - items properties: items: type: array items: $ref: '#/components/schemas/DiaryDto' ShortDiaryEntryDto: type: object required: - id - diaryId - name - date properties: id: type: string format: uuid diaryId: type: string format: uuid name: type: string date: type: string format: date ShortDiariesEntriesListDto: type: object required: - items properties: items: type: array items: $ref: '#/components/schemas/ShortDiaryEntryDto' FullDiaryEntryDto: type: object required: - value - blocks allOf: - $ref: '#/components/schemas/ShortDiaryEntryDto' - type: object properties: value: type: string blocks: type: array items: $ref: '#/components/schemas/DiaryEntryBlockDto' DiaryEntryBlockDto: type: object required: - id - value properties: id: type: string format: uuid value: type: string SharingTaskDto: type: object required: - diaryId - receiverUserId - encryptedDiaryKey - username - sharedAt properties: diaryId: type: string format: uuid description: ID of the diary being shared receiverUserId: type: string format: uuid description: ID of the user received access to diary encryptedDiaryKey: type: string description: Diary key encrypted with public key of receiving user username: type: string description: Name of the user who owns the shared diary sharedAt: type: string format: date-time AvailableSharingTasksListDto: type: object required: - items properties: items: type: array items: $ref: '#/components/schemas/SharingTaskDto' CreateDiaryEntryRequest: type: object required: - diaryId - name - date - value properties: diaryId: type: string format: uuid required: true name: type: string required: true date: type: string format: date required: true value: type: string required: true UpdateDiaryEntryRequest: type: object properties: diaryId: type: string format: uuid required: false name: type: string required: false date: type: string format: date required: false value: type: string blocksToUpsert: type: array required: false items: $ref: '#/components/schemas/DiaryEntryBlockDto' blocksToDelete: type: array items: type: string format: uuid CreateSharingTaskRequest: required: - entryId - myEncryptedKey - receiverEncryptedKey - receiverUserId - value - blocks type: object properties: entryId: type: string format: uuid description: ID of diary entry to share myEncryptedKey: type: string required: true description: New encryption key with which entry contents were encrypted. The key is encrypted with current user's master-key receiverEncryptedKey: type: string required: true description: New encryption key with which entry contents were encrypted. The key is encrypted with receiver user's public key receiverUserId: type: string format: uuid required: true value: type: string required: true description: Value of the entry encrypted with new encryption key blocks: type: array required: true description: Block of the entry being shared, encrypted with new encryption key items: $ref: '#/components/schemas/DiaryEntryBlockDto' CreateSharingTaskResponseDto: type: object required: - diaryId properties: diaryId: type: string format: uuid description: ID of new diary which now contains the shared entry AcceptSharedDiaryRequest: type: object required: - diaryId - encryptedDiaryKey properties: diaryId: type: string format: uuid required: true description: ID of shared diary which current user accepts encryptedDiaryKey: type: string required: true description: Diary key encrypted with current user's master-key requestBodies: RegisterRequestBody: required: true content: application/json: schema: $ref: '#/components/schemas/RegisterRequest' LoginRequestBody: required: true content: application/json: schema: $ref: '#/components/schemas/LoginRequest' CreateDiaryEntryRequestBody: required: true content: application/json: schema: $ref: '#/components/schemas/CreateDiaryEntryRequest' UpdateDiaryEntryRequestBody: required: true content: application/json: schema: $ref: '#/components/schemas/UpdateDiaryEntryRequest' CreateSharingTaskRequestBody: required: true content: application/json: schema: $ref: '#/components/schemas/CreateSharingTaskRequest' AcceptSharedDiaryRequestBody: required: true content: application/json: schema: $ref: '#/components/schemas/AcceptSharedDiaryRequest' responses: BadRequestResponse: description: Bad request, required parameters are missing or invalid content: application/json: schema: $ref: '#/components/schemas/ErrorDto' UnauthorizedResponse: description: Unauthorized, auth token is missing or invalid content: application/json: schema: $ref: '#/components/schemas/ErrorDto' RegistrationResponse: description: Successful registration content: application/json: schema: $ref: '#/components/schemas/RegistrationResult' AuthResultResponse: description: Successful login content: application/json: schema: $ref: '#/components/schemas/AuthResult' FullUserResponse: description: Successfully received full user info content: application/json: schema: $ref: '#/components/schemas/FullUserDto' ShortUserResponse: description: Successfully received user info content: application/json: schema: $ref: '#/components/schemas/ShortUserDto' DiariesResponse: description: Successfully received available diaries content: application/json: schema: $ref: '#/components/schemas/DiariesListDto' DiaryEntriesResponse: description: Successfully received diary entries with given filters content: application/json: schema: $ref: '#/components/schemas/ShortDiariesEntriesListDto' GetDiaryEntryResponse: description: Got diary entry content: application/json: schema: $ref: '#/components/schemas/FullDiaryEntryDto' CreateDiaryEntryResponse: description: Created diary entry content: application/json: schema: $ref: '#/components/schemas/ShortDiaryEntryDto' UpdateDiaryEntryResponse: description: Updated diary entry content: application/json: schema: $ref: '#/components/schemas/ShortDiaryEntryDto' CreateSharingTaskResponse: description: Entry was successfully shared content: application/json: schema: $ref: '#/components/schemas/CreateSharingTaskResponseDto' AvailableSharingTasksResponse: description: Received available sharing tasks content: application/json: schema: $ref: '#/components/schemas/AvailableSharingTasksListDto' securitySchemes: BearerAuth: type: http scheme: bearer