Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- openapi: 3.0.0
- info:
- title: Messenger API
- version: 1.0.0
- tags:
- - name: Conversations
- description: API for handling conversations
- ################################# PATHS ########################################
- paths:
- '/conversations/{userId}':
- get:
- tags:
- - Conversations
- operationId: getConversations
- summary: 'Get all conversations (conversation user) for specific user'
- parameters:
- - $ref: '#/components/parameters/userId'
- responses:
- 200:
- description: 'List of conversations for user'
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/GetConversationsResponse'
- 400:
- $ref: '#/components/responses/BadRequest'
- 401:
- $ref: '#/components/responses/Unauthorized'
- 404:
- $ref: '#/components/responses/NotFound'
- 403:
- $ref: '#/components/responses/Forbidden'
- 500:
- $ref: '#/components/responses/InternalServerError'
- '/conversations/{conversationId}/messages':
- get:
- tags:
- - Conversations
- operationId: getMessagesByConversation
- summary: 'Get all messages for single conversation'
- parameters:
- - $ref: '#/components/parameters/conversationId'
- responses:
- 200:
- description: 'List of messages per conversation'
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/ListOfMessagesReponse'
- 400:
- $ref: '#/components/responses/BadRequest'
- 401:
- $ref: '#/components/responses/Unauthorized'
- 404:
- $ref: '#/components/responses/NotFound'
- 403:
- $ref: '#/components/responses/Forbidden'
- 500:
- $ref: '#/components/responses/InternalServerError'
- put:
- tags:
- - Conversations
- operationId: CreateNewConversation
- summary: 'Send messages to list of users or single user and create conversation for it'
- parameters:
- - $ref: '#/components/parameters/conversationId'
- requestBody:
- required: true
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/ConversationPutRequest'
- responses:
- 200:
- description: 'Conversation already exist, if messages is sent its saved to conversation'
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/GetConversationsResponse'
- 201:
- description: 'Created message and conversation'
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/ConversationPutResponse'
- 400:
- $ref: '#/components/responses/BadRequest'
- 401:
- $ref: '#/components/responses/Unauthorized'
- 404:
- $ref: '#/components/responses/NotFound'
- 403:
- $ref: '#/components/responses/Forbidden'
- 500:
- $ref: '#/components/responses/InternalServerError'
- post:
- tags:
- - Conversations
- operationId: SendNewMessage
- summary: 'Send new message to existing conversation'
- parameters:
- - $ref: '#/components/parameters/conversationId'
- requestBody:
- required: true
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/MessageRequest'
- responses:
- 200:
- description: 'Conversation already exist, if messages is sent its saved to conversation'
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/GetConversationsResponse'
- 201:
- description: 'Created message and conversation'
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/ConversationPutResponse'
- 400:
- $ref: '#/components/responses/BadRequest'
- 401:
- $ref: '#/components/responses/Unauthorized'
- 404:
- $ref: '#/components/responses/NotFound'
- 403:
- $ref: '#/components/responses/Forbidden'
- 500:
- $ref: '#/components/responses/InternalServerError'
- ############################# PARAMETERS #######################################
- components:
- parameters:
- userId:
- name: userId
- in: path
- description: id of user
- required: true
- schema:
- type: string
- example: '12345678'
- conversationId:
- name: conversationId
- in: path
- description: id of conversation
- required: true
- schema:
- type: string
- example: 1234567
- ############################ DEFAULT RESPONSES ###############################
- responses:
- NoContent:
- description: 'No Content. The request was accepted and performed successfully, there is no response payload on purpose.'
- Unauthorized:
- description: 'Unauthorized'
- Forbidden:
- description: 'Forbidden. Client has insufficient rights to call the operation'
- NotFound:
- description: 'Not found. Resource not found'
- BadRequest:
- description: 'Bad request - contract violation, invalid request parameters for operation'
- InternalServerError:
- description: 'Technical error - see reponse payload for more detailed information'
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/GenericError'
- ################################ SCHEMAS #####################################
- schemas:
- GetConversationsResponse:
- type: object
- required:
- - conversationId
- properties:
- conversationUserId:
- type: string
- example: 123456
- muted:
- type: boolean
- example: false
- conversationProperties:
- $ref: '#/components/schemas/ConversationProperties'
- ConversationProperties:
- type: object
- properties:
- converationId:
- type: string
- example: 123456
- color:
- type: string
- example: red
- ConversationPutRequest:
- type: object
- properties:
- users:
- type: array
- items:
- type: string
- example: 1234567
- minItems: 1
- message:
- $ref: '#/components/schemas/MessageRequest'
- ConversationPutResponse:
- type: object
- properties:
- message:
- $ref: '#/components/schemas/MessagesResponse'
- conversation:
- $ref: '#/components/schemas/GetConversationsResponse'
- MessageRequest:
- type: object
- properties:
- message:
- type: string
- example: "Dummy message"
- minLength: 1
- maxLength: 500
- messageType:
- type: string
- example: 1
- creatorId:
- type: string
- example: 34
- MessagesResponse:
- type: object
- properties:
- messageId:
- type: string
- example: 1234567
- messageCreator:
- type: integer
- example: 34
- message:
- type: string
- example: "Dummy message"
- minLength: 1
- maxLength: 500
- messageType:
- type: string
- example: 1
- createdAt:
- type: string
- example: '21-11-2019-11-23-23-321'
- conversationId:
- type: integer
- ListOfMessagesReponse:
- type: array
- items:
- $ref: '#/components/schemas/MessagesResponse'
- GenericError:
- type: object
- properties:
- errorCode:
- type: string
- description: 'qualifier of the error e.g. TECHNICAL_ERROR in case of any technical error while doing this action.'
- example: 'TECHNICAL_ERROR'
- message:
- type: string
- description: 'any text to describe the error more detailed.'
- example: 'Unexpected technical error occured'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement