Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 8.16 KB | None | 0 0
  1. openapi: 3.0.0
  2. info:
  3.   title: Messenger API
  4.   version: 1.0.0
  5. tags:
  6.   - name: Conversations
  7.     description: API for handling conversations
  8.  
  9. ################################# PATHS ########################################
  10.  
  11. paths:
  12.   '/conversations/{userId}':
  13.     get:
  14.       tags:
  15.        - Conversations
  16.       operationId: getConversations
  17.       summary: 'Get all conversations (conversation user) for specific user'
  18.       parameters:
  19.         - $ref: '#/components/parameters/userId'
  20.       responses:
  21.         200:
  22.           description: 'List of conversations for user'
  23.           content:
  24.             application/json:
  25.               schema:
  26.                 $ref: '#/components/schemas/GetConversationsResponse'
  27.         400:
  28.           $ref: '#/components/responses/BadRequest'
  29.         401:
  30.           $ref: '#/components/responses/Unauthorized'
  31.         404:
  32.           $ref: '#/components/responses/NotFound'
  33.         403:
  34.           $ref: '#/components/responses/Forbidden'
  35.         500:
  36.           $ref: '#/components/responses/InternalServerError'
  37.        
  38.   '/conversations/{conversationId}/messages':
  39.     get:
  40.       tags:
  41.        - Conversations
  42.       operationId: getMessagesByConversation
  43.       summary: 'Get all messages for single conversation'
  44.       parameters:
  45.         - $ref: '#/components/parameters/conversationId'
  46.       responses:
  47.         200:
  48.           description: 'List of messages per conversation'
  49.           content:
  50.             application/json:
  51.               schema:
  52.                 $ref: '#/components/schemas/ListOfMessagesReponse'
  53.         400:
  54.           $ref: '#/components/responses/BadRequest'
  55.         401:
  56.           $ref: '#/components/responses/Unauthorized'
  57.         404:
  58.           $ref: '#/components/responses/NotFound'
  59.         403:
  60.           $ref: '#/components/responses/Forbidden'
  61.         500:
  62.           $ref: '#/components/responses/InternalServerError'
  63.     put:
  64.       tags:
  65.         - Conversations
  66.       operationId: CreateNewConversation
  67.       summary: 'Send messages to list of users or single user and create conversation for it'
  68.       parameters:
  69.         - $ref: '#/components/parameters/conversationId'
  70.       requestBody:
  71.         required: true
  72.         content:
  73.           application/json:
  74.             schema:
  75.               $ref: '#/components/schemas/ConversationPutRequest'
  76.       responses:
  77.         200:
  78.           description: 'Conversation already exist, if messages is sent its saved to conversation'
  79.           content:
  80.             application/json:
  81.               schema:
  82.                 $ref: '#/components/schemas/GetConversationsResponse'
  83.         201:
  84.           description: 'Created message and conversation'
  85.           content:
  86.             application/json:
  87.               schema:
  88.                 $ref: '#/components/schemas/ConversationPutResponse'
  89.         400:
  90.           $ref: '#/components/responses/BadRequest'
  91.         401:
  92.           $ref: '#/components/responses/Unauthorized'
  93.         404:
  94.           $ref: '#/components/responses/NotFound'
  95.         403:
  96.           $ref: '#/components/responses/Forbidden'
  97.         500:
  98.           $ref: '#/components/responses/InternalServerError'
  99.     post:
  100.       tags:
  101.        - Conversations
  102.       operationId: SendNewMessage
  103.       summary: 'Send new message to existing conversation'
  104.       parameters:
  105.         - $ref: '#/components/parameters/conversationId'
  106.       requestBody:
  107.         required: true
  108.         content:
  109.           application/json:
  110.             schema:
  111.               $ref: '#/components/schemas/MessageRequest'
  112.       responses:
  113.         200:
  114.           description: 'Conversation already exist, if messages is sent its saved to conversation'
  115.           content:
  116.             application/json:
  117.               schema:
  118.                 $ref: '#/components/schemas/GetConversationsResponse'
  119.         201:
  120.           description: 'Created message and conversation'
  121.           content:
  122.             application/json:
  123.               schema:
  124.                 $ref: '#/components/schemas/ConversationPutResponse'
  125.         400:
  126.           $ref: '#/components/responses/BadRequest'
  127.         401:
  128.           $ref: '#/components/responses/Unauthorized'
  129.         404:
  130.           $ref: '#/components/responses/NotFound'
  131.         403:
  132.           $ref: '#/components/responses/Forbidden'
  133.         500:
  134.           $ref: '#/components/responses/InternalServerError'
  135.  
  136. ############################# PARAMETERS #######################################
  137.  
  138. components:
  139.   parameters:
  140.     userId:
  141.       name: userId
  142.       in: path
  143.       description: id of user
  144.       required: true
  145.       schema:
  146.         type: string
  147.         example: '12345678'
  148.     conversationId:
  149.       name: conversationId
  150.       in: path
  151.       description: id of conversation
  152.       required: true
  153.       schema:
  154.         type: string
  155.         example: 1234567
  156.    
  157.   ############################ DEFAULT RESPONSES ###############################
  158.  
  159.   responses:
  160.     NoContent:
  161.       description: 'No Content. The request was accepted and performed successfully, there is no response payload on purpose.'
  162.     Unauthorized:
  163.       description: 'Unauthorized'
  164.     Forbidden:
  165.       description: 'Forbidden. Client has insufficient rights to call the operation'
  166.     NotFound:
  167.       description: 'Not found. Resource not found'
  168.     BadRequest:
  169.       description: 'Bad request - contract violation, invalid request parameters for operation'
  170.     InternalServerError:
  171.       description: 'Technical error - see reponse payload for more detailed information'
  172.       content:
  173.         application/json:
  174.           schema:
  175.             $ref: '#/components/schemas/GenericError'
  176.  
  177.   ################################ SCHEMAS #####################################
  178.  
  179.   schemas:
  180.     GetConversationsResponse:
  181.       type: object
  182.       required:
  183.         - conversationId
  184.       properties:
  185.         conversationUserId:
  186.           type: string
  187.           example: 123456
  188.         muted:
  189.           type: boolean
  190.           example: false
  191.         conversationProperties:
  192.           $ref: '#/components/schemas/ConversationProperties'
  193.     ConversationProperties:
  194.       type: object
  195.       properties:
  196.         converationId:
  197.           type: string
  198.           example: 123456
  199.         color:
  200.           type: string
  201.           example: red
  202.     ConversationPutRequest:
  203.       type: object
  204.       properties:
  205.         users:
  206.           type: array
  207.           items:
  208.             type: string
  209.             example: 1234567
  210.           minItems: 1
  211.         message:
  212.           $ref: '#/components/schemas/MessageRequest'
  213.     ConversationPutResponse:
  214.       type: object
  215.       properties:
  216.         message:
  217.           $ref: '#/components/schemas/MessagesResponse'
  218.         conversation:
  219.           $ref: '#/components/schemas/GetConversationsResponse'
  220.     MessageRequest:
  221.       type: object
  222.       properties:
  223.         message:
  224.           type: string
  225.           example: "Dummy message"
  226.           minLength: 1
  227.           maxLength: 500
  228.         messageType:
  229.           type: string
  230.           example: 1
  231.         creatorId:
  232.           type: string
  233.           example: 34
  234.     MessagesResponse:
  235.       type: object
  236.       properties:
  237.         messageId:
  238.           type: string
  239.           example: 1234567
  240.         messageCreator:
  241.           type: integer
  242.           example: 34
  243.         message:
  244.           type: string
  245.           example: "Dummy message"
  246.           minLength: 1
  247.           maxLength: 500
  248.         messageType:
  249.           type: string
  250.           example: 1
  251.         createdAt:
  252.           type: string
  253.           example: '21-11-2019-11-23-23-321'
  254.         conversationId:
  255.           type: integer
  256.     ListOfMessagesReponse:
  257.       type: array
  258.       items:
  259.         $ref: '#/components/schemas/MessagesResponse'
  260.        
  261.     GenericError:
  262.       type: object
  263.       properties:
  264.         errorCode:
  265.           type: string
  266.           description: 'qualifier of the error e.g. TECHNICAL_ERROR in case of any technical error while doing this action.'
  267.           example: 'TECHNICAL_ERROR'
  268.         message:
  269.           type: string
  270.           description: 'any text to describe the error more detailed.'
  271.           example: 'Unexpected technical error occured'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement