chore: Swagger documentation for public APIs (#2417)

This commit is contained in:
Sojan Jose 2021-06-16 00:14:09 +05:30 committed by GitHub
parent 2b9c93a1b3
commit af8223545e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 978 additions and 186 deletions

View file

@ -1,10 +1,15 @@
# ERROR
## ---------- ERRORS ------------- ##
## -------------------------------- ##
bad_request_error:
$ref: ./error/bad_request.yml
request_error:
$ref: ./error/request.yml
# RESOURCE
## ---------- RESOURCE ------------- ##
## -------------------------------- ##
generic_id:
$ref: ./resource/extension/generic.yml
contact:
@ -30,11 +35,63 @@ platform_account:
team:
$ref: ./resource/team.yml
integrations_app:
$ref: ./resource/integrations/app.yml
$ref: ./resource/integrations/app.yml
integrations_hook:
$ref: ./resource/integrations/hook.yml
$ref: ./resource/integrations/hook.yml
# RESPONSE
## public resources
public_contact:
$ref: ./resource/public/contact.yml
public_conversation:
$ref: ./resource/public/conversation.yml
public_message:
$ref: ./resource/public/message.yml
## ---------- REQUEST------------- ##
## -------------------------------- ##
account_create_update_payload:
$ref: ./request/account/create_update_payload.yml
agent_bot_create_update_payload:
$ref: ./request/agent_bot/create_update_payload.yml
user_create_update_payload:
$ref: ./request/user/create_update_payload.yml
## contact
contact_create:
$ref: ./request/contact/create.yml
contact_update:
$ref: ./request/contact/update.yml
## conversation
conversation_message_create:
$ref: ./request/conversation/create_message.yml
# Team request Payload
team_create_update_payload:
$ref: ./request/team/create_update_payload.yml
integrations_hook_create_payload:
$ref: ./request/integrations/hook_create_payload.yml
integrations_hook_update_payload:
$ref: ./request/integrations/hook_update_payload.yml
## public requests
public_contact_create_update_payload:
$ref: ./request/public/contact/create_update_payload.yml
public_message_create_payload:
$ref: ./request/public/message/create_payload.yml
public_message_update_payload:
$ref: ./request/public/message/update_payload.yml
## ---------- RESPONSE ------------- ##
## -------------------------------- ##
## contact
extended_contact:
@ -77,34 +134,3 @@ extended_message:
- $ref: '#/definitions/generic_id'
- $ref: '#/definitions/message'
- $ref: ./resource/extension/message/with_source_sender.yml
# REQUEST
account_create_update_payload:
$ref: ./request/account/create_update_payload.yml
agent_bot_create_update_payload:
$ref: ./request/agent_bot/create_update_payload.yml
user_create_update_payload:
$ref: ./request/account/create_update_payload.yml
## contact
contact_create:
$ref: ./request/contact/create.yml
contact_update:
$ref: ./request/contact/update.yml
## conversation
conversation_message_create:
$ref: ./request/conversation/create_message.yml
# Team request Payload
team_create_update_payload:
$ref: ./request/team/create_update_payload.yml
integrations_hook_create_payload:
$ref: ./request/integrations/hook_create_payload.yml
integrations_hook_update_payload:
$ref: ./request/integrations/hook_update_payload.yml

View file

@ -0,0 +1,21 @@
type: object
properties:
identifier:
type: string
description: External identifier of the contact
identifier_hash:
type: string
description: Identifier hash prepared for HMAC authentication
email:
type: string
description: Email of the contact
name:
type: string
description: Name of the contact
avatar_url:
type: string
description: The url to a jpeg, png file for the user avatar
custom_attributes:
type: object
description: Custom attributes of the customer

View file

@ -0,0 +1,10 @@
type: object
properties:
content:
type: string
description: Content for the message
echo_id:
type: string
description: Temporary identifier which will be passed back via websockets

View file

@ -0,0 +1,8 @@
type: object
properties:
submitted_values:
type: object
description: Replies to the Bot Message Types

View file

@ -0,0 +1,17 @@
type: object
properties:
id:
type: integer
description: Id of the contact
source_id:
type: string
description: The session identifier of the contact
name:
type: string
description: Name of the contact
email:
type: string
description: Email of the contact
pubsub_token:
type: string
description: The token to be used to connect to chatwoot websocket

View file

@ -0,0 +1,14 @@
type: object
properties:
id:
type: integer
description: Id of the conversation
inbox_id:
type: string
description: The inbox id of the conversation
messages:
type: array
description: Messages in the conversation
contact:
type: object
description: The contact information associated to the conversation

View file

@ -0,0 +1,36 @@
type: object
properties:
id:
type: string
description: Id of the message
content:
type: string
description: Text content of the message
message_type:
type: string
description: Denotes the message type
content_type:
type: string
description: Content type of the message
content_attributes:
type: string
description: Additional content attributes of the message
created_at:
type: string
description: Created at time stamp of the message
conversation_id:
type: string
description: Conversation Id of the message
attachments:
type: array
description: Attachments if any
sender:
type: object
description: Details of the sender

View file

@ -19,8 +19,6 @@ properties:
enum: ['agent', 'administrator']
confirmed:
type: boolean
display_name:
type: string
accounts:
type: array
items:

View file

@ -62,3 +62,8 @@ x-tagGroups:
- Integrations
- Profile
- Teams
- name: Public
tags:
- Contacts API
- Conversations API
- Messages API

View file

@ -27,3 +27,10 @@ page:
platform_user_id:
$ref: ./platform_user_id.yml
public_inbox_identifier:
$ref: ./public/inbox_identifier.yml
public_contact_identifier:
$ref: ./public/contact_identifier.yml

View file

@ -0,0 +1,6 @@
in: path
name: contact_identifier
schema:
type: string
required: true
description: The source id of contact obtained on contact create

View file

@ -0,0 +1,6 @@
in: path
name: inbox_identifier
schema:
type: string
required: true
description: The identifier obtained from API inbox channel

View file

@ -67,6 +67,55 @@ platform/api/v1/users/{id}/login:
# ---------------- end of platform path -----------#
# ------------ Public API routes ------------#
# Contacts
public/api/v1/inboxes/{inbox_identifier}/contacts:
parameters:
- $ref: '#/parameters/public_inbox_identifier'
post:
$ref: ./public/inboxes/contacts/create.yml
public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}:
parameters:
- $ref: '#/parameters/public_inbox_identifier'
- $ref: '#/parameters/public_contact_identifier'
get:
$ref: './public/inboxes/contacts/show.yml'
patch:
$ref: ./public/inboxes/contacts/update.yml
public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations:
parameters:
- $ref: '#/parameters/public_inbox_identifier'
- $ref: '#/parameters/public_contact_identifier'
post:
$ref: ./public/inboxes/conversations/create.yml
get:
$ref: ./public/inboxes/conversations/index.yml
public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations/{conversation_id}/messages:
parameters:
- $ref: '#/parameters/public_inbox_identifier'
- $ref: '#/parameters/public_contact_identifier'
- $ref: '#/parameters/conversation_id'
post:
$ref: ./public/inboxes/messages/create.yml
get:
$ref: ./public/inboxes/messages/index.yml
public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations/{conversation_id}/messages/{message_id}:
parameters:
- $ref: '#/parameters/public_inbox_identifier'
- $ref: '#/parameters/public_contact_identifier'
- $ref: '#/parameters/conversation_id'
- $ref: '#/parameters/message_id'
patch:
$ref: ./public/inboxes/messages/update.yml
# ---------------- end of public api routes-----------#
# ------------ Application API routes ------------#
# AgentBots
/api/v1/accounts/{account_id}/agent_bots:

View file

@ -0,0 +1,20 @@
tags:
- Contacts API
operationId: create-a-contact
summary: Create a contact
description: Create a contact
security:
- nil
parameters:
- name: data
in: body
required: true
schema:
$ref: '#/definitions/public_contact_create_update_payload'
responses:
200:
description: Success
schema:
$ref: '#/definitions/public_contact'
401:
description: Unauthorized

View file

@ -0,0 +1,16 @@
tags:
- Contacts API
operationId: get-details-of-a-contact
summary: Get a contact
description: Get the details of a contact
security:
- nil
responses:
200:
description: Success
schema:
$ref: '#/definitions/public_contact'
401:
description: Unauthorized
404:
description: The given contact does not exist

View file

@ -0,0 +1,20 @@
tags:
- Contacts API
operationId: update-a-contact
summary: Update a contact
description: Update a contact's attributes
security:
- nil
parameters:
- name: data
in: body
required: true
schema:
$ref: '#/definitions/public_contact_create_update_payload'
responses:
200:
description: Success
schema:
$ref: '#/definitions/public_contact'
401:
description: Unauthorized

View file

@ -0,0 +1,14 @@
tags:
- Conversations API
operationId: create-a-conversation
summary: Create a conversation
description: Create a conversation
security:
- nil
responses:
200:
description: Success
schema:
$ref: '#/definitions/public_conversation'
401:
description: Unauthorized

View file

@ -0,0 +1,15 @@
tags:
- Conversations API
operationId: list-all-contact-conversations
summary: List all conversations
description: List all conversations for the contact
responses:
200:
description: Success
schema:
type: array
description: 'Array of conversations'
items:
$ref: '#/definitions/public_conversation'
401:
description: Unauthorized

View file

@ -0,0 +1,20 @@
tags:
- Messages API
operationId: create-a-message
summary: Create a message
description: Create a message
security:
- nil
parameters:
- name: data
in: body
required: true
schema:
$ref: '#/definitions/public_message_create_payload'
responses:
200:
description: Success
schema:
$ref: '#/definitions/public_message'
401:
description: Unauthorized

View file

@ -0,0 +1,15 @@
tags:
- Messages API
operationId: list-all-converation-messages
summary: List all messages
description: List all messages in the conversation
responses:
200:
description: Success
schema:
type: array
description: 'Array of messages'
items:
$ref: '#/definitions/public_message'
401:
description: Unauthorized

View file

@ -0,0 +1,20 @@
tags:
- Messages API
operationId: update-a-message
summary: Update a message
description: Update a message
security:
- nil
parameters:
- name: data
in: body
required: true
schema:
$ref: '#/definitions/public_message_update_payload'
responses:
200:
description: Success
schema:
$ref: '#/definitions/public_message'
401:
description: Unauthorized

View file

@ -682,6 +682,283 @@
}
}
},
"public/api/v1/inboxes/{inbox_identifier}/contacts": {
"parameters": [
{
"$ref": "#/parameters/public_inbox_identifier"
}
],
"post": {
"tags": [
"Contacts API"
],
"operationId": "create-a-contact",
"summary": "Create a contact",
"description": "Create a contact",
"security": [
"nil"
],
"parameters": [
{
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/public_contact_create_update_payload"
}
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"$ref": "#/definitions/public_contact"
}
},
"401": {
"description": "Unauthorized"
}
}
}
},
"public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}": {
"parameters": [
{
"$ref": "#/parameters/public_inbox_identifier"
},
{
"$ref": "#/parameters/public_contact_identifier"
}
],
"get": {
"tags": [
"Contacts API"
],
"operationId": "get-details-of-a-contact",
"summary": "Get a contact",
"description": "Get the details of a contact",
"security": [
"nil"
],
"responses": {
"200": {
"description": "Success",
"schema": {
"$ref": "#/definitions/public_contact"
}
},
"401": {
"description": "Unauthorized"
},
"404": {
"description": "The given contact does not exist"
}
}
},
"patch": {
"tags": [
"Contacts API"
],
"operationId": "update-a-contact",
"summary": "Update a contact",
"description": "Update a contact's attributes",
"security": [
"nil"
],
"parameters": [
{
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/public_contact_create_update_payload"
}
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"$ref": "#/definitions/public_contact"
}
},
"401": {
"description": "Unauthorized"
}
}
}
},
"public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations": {
"parameters": [
{
"$ref": "#/parameters/public_inbox_identifier"
},
{
"$ref": "#/parameters/public_contact_identifier"
}
],
"post": {
"tags": [
"Conversations API"
],
"operationId": "create-a-conversation",
"summary": "Create a conversation",
"description": "Create a conversation",
"security": [
"nil"
],
"responses": {
"200": {
"description": "Success",
"schema": {
"$ref": "#/definitions/public_conversation"
}
},
"401": {
"description": "Unauthorized"
}
}
},
"get": {
"tags": [
"Conversations API"
],
"operationId": "list-all-contact-conversations",
"summary": "List all conversations",
"description": "List all conversations for the contact",
"responses": {
"200": {
"description": "Success",
"schema": {
"type": "array",
"description": "Array of conversations",
"items": {
"$ref": "#/definitions/public_conversation"
}
}
},
"401": {
"description": "Unauthorized"
}
}
}
},
"public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations/{conversation_id}/messages": {
"parameters": [
{
"$ref": "#/parameters/public_inbox_identifier"
},
{
"$ref": "#/parameters/public_contact_identifier"
},
{
"$ref": "#/parameters/conversation_id"
}
],
"post": {
"tags": [
"Messages API"
],
"operationId": "create-a-message",
"summary": "Create a message",
"description": "Create a message",
"security": [
"nil"
],
"parameters": [
{
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/public_message_create_payload"
}
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"$ref": "#/definitions/public_message"
}
},
"401": {
"description": "Unauthorized"
}
}
},
"get": {
"tags": [
"Messages API"
],
"operationId": "list-all-converation-messages",
"summary": "List all messages",
"description": "List all messages in the conversation",
"responses": {
"200": {
"description": "Success",
"schema": {
"type": "array",
"description": "Array of messages",
"items": {
"$ref": "#/definitions/public_message"
}
}
},
"401": {
"description": "Unauthorized"
}
}
}
},
"public/api/v1/inboxes/{inbox_identifier}/contacts/{contact_identifier}/conversations/{conversation_id}/messages/{message_id}": {
"parameters": [
{
"$ref": "#/parameters/public_inbox_identifier"
},
{
"$ref": "#/parameters/public_contact_identifier"
},
{
"$ref": "#/parameters/conversation_id"
},
{
"$ref": "#/parameters/message_id"
}
],
"patch": {
"tags": [
"Messages API"
],
"operationId": "update-a-message",
"summary": "Update a message",
"description": "Update a message",
"security": [
"nil"
],
"parameters": [
{
"name": "data",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/public_message_update_payload"
}
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"$ref": "#/definitions/public_message"
}
},
"401": {
"description": "Unauthorized"
}
}
}
},
"/api/v1/accounts/{account_id}/agent_bots": {
"parameters": [
{
@ -2698,6 +2975,299 @@
}
}
},
"public_contact": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"description": "Id of the contact"
},
"source_id": {
"type": "string",
"description": "The session identifier of the contact"
},
"name": {
"type": "string",
"description": "Name of the contact"
},
"email": {
"type": "string",
"description": "Email of the contact"
},
"pubsub_token": {
"type": "string",
"description": "The token to be used to connect to chatwoot websocket"
}
}
},
"public_conversation": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"description": "Id of the conversation"
},
"inbox_id": {
"type": "string",
"description": "The inbox id of the conversation"
},
"messages": {
"type": "array",
"description": "Messages in the conversation"
},
"contact": {
"type": "object",
"description": "The contact information associated to the conversation"
}
}
},
"public_message": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "Id of the message"
},
"content": {
"type": "string",
"description": "Text content of the message"
},
"message_type": {
"type": "string",
"description": "Denotes the message type"
},
"content_type": {
"type": "string",
"description": "Content type of the message"
},
"content_attributes": {
"type": "string",
"description": "Additional content attributes of the message"
},
"created_at": {
"type": "string",
"description": "Created at time stamp of the message"
},
"conversation_id": {
"type": "string",
"description": "Conversation Id of the message"
},
"attachments": {
"type": "array",
"description": "Attachments if any"
},
"sender": {
"type": "object",
"description": "Details of the sender"
}
}
},
"account_create_update_payload": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Name of the account"
}
}
},
"agent_bot_create_update_payload": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the agent bot"
},
"description": {
"type": "string",
"description": "The description about the agent bot"
},
"outgoing_url": {
"type": "string",
"description": "The webhook URL for the bot"
}
}
},
"user_create_update_payload": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Name of the user"
},
"email": {
"type": "string",
"description": "Email of the user"
},
"password": {
"type": "string",
"description": "Password must contain uppercase, lowercase letters, number and a special character"
}
}
},
"contact_create": {
"type": "object",
"properties": {
"inbox_id": {
"type": "number",
"required": true
},
"name": {
"type": "string"
},
"email": {
"type": "string"
},
"phone_number": {
"type": "string"
}
}
},
"contact_update": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"email": {
"type": "string"
},
"phone_number": {
"type": "string"
}
}
},
"conversation_message_create": {
"type": "object",
"properties": {
"content": {
"type": "string",
"description": "The content of the message",
"required": true
},
"message_type": {
"type": "string",
"enum": [
"outgoing",
"incoming"
]
},
"private": {
"type": "boolean",
"description": "Flag to identify if it is a private note"
},
"content_type": {
"type": "string",
"enum": [
"input_email",
"cards",
"input_select",
"form",
"article"
],
"example": "cards",
"description": "if you want to create custom message types"
},
"content_attributes": {
"type": "object",
"description": "attributes based on your content type"
}
}
},
"team_create_update_payload": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the team"
},
"description": {
"type": "string",
"description": "The description of the team"
},
"allow_auto_assign": {
"type": "boolean",
"description": "If this setting is turned on, the system would automatically assign the conversation to an agent in the team while assigning the conversation to a team"
}
}
},
"integrations_hook_create_payload": {
"type": "object",
"properties": {
"app_id": {
"type": "string",
"description": "The ID of app for which integration hook is being created"
},
"inbox_id": {
"type": "string",
"description": "The inbox ID, if the hook is an inbox hook"
},
"settings": {
"type": "object",
"description": "The settings required by the integration"
}
}
},
"integrations_hook_update_payload": {
"type": "object",
"properties": {
"settings": {
"type": "object",
"description": "The settings required by the integration"
}
}
},
"public_contact_create_update_payload": {
"type": "object",
"properties": {
"identifier": {
"type": "string",
"description": "External identifier of the contact"
},
"identifier_hash": {
"type": "string",
"description": "Identifier hash prepared for HMAC authentication"
},
"email": {
"type": "string",
"description": "Email of the contact"
},
"name": {
"type": "string",
"description": "Name of the contact"
},
"avatar_url": {
"type": "string",
"description": "The url to a jpeg, png file for the user avatar"
},
"custom_attributes": {
"type": "object",
"description": "Custom attributes of the customer"
}
}
},
"public_message_create_payload": {
"type": "object",
"properties": {
"content": {
"type": "string",
"description": "Content for the message"
},
"echo_id": {
"type": "string",
"description": "Temporary identifier which will be passed back via websockets"
}
}
},
"public_message_update_payload": {
"type": "object",
"properties": {
"submitted_values": {
"type": "object",
"description": "Replies to the Bot Message Types"
}
}
},
"extended_contact": {
"allOf": [
{
@ -2974,153 +3544,6 @@
}
}
]
},
"account_create_update_payload": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Name of the account"
}
}
},
"agent_bot_create_update_payload": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the agent bot"
},
"description": {
"type": "string",
"description": "The description about the agent bot"
},
"outgoing_url": {
"type": "string",
"description": "The webhook URL for the bot"
}
}
},
"user_create_update_payload": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Name of the account"
}
}
},
"contact_create": {
"type": "object",
"properties": {
"inbox_id": {
"type": "number",
"required": true
},
"name": {
"type": "string"
},
"email": {
"type": "string"
},
"phone_number": {
"type": "string"
}
}
},
"contact_update": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"email": {
"type": "string"
},
"phone_number": {
"type": "string"
}
}
},
"conversation_message_create": {
"type": "object",
"properties": {
"content": {
"type": "string",
"description": "The content of the message",
"required": true
},
"message_type": {
"type": "string",
"enum": [
"outgoing",
"incoming"
]
},
"private": {
"type": "boolean",
"description": "Flag to identify if it is a private note"
},
"content_type": {
"type": "string",
"enum": [
"input_email",
"cards",
"input_select",
"form",
"article"
],
"example": "cards",
"description": "if you want to create custom message types"
},
"content_attributes": {
"type": "object",
"description": "attributes based on your content type"
}
}
},
"team_create_update_payload": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the team"
},
"description": {
"type": "string",
"description": "The description of the team"
},
"allow_auto_assign": {
"type": "boolean",
"description": "If this setting is turned on, the system would automatically assign the conversation to an agent in the team while assigning the conversation to a team"
}
}
},
"integrations_hook_create_payload": {
"type": "object",
"properties": {
"app_id": {
"type": "string",
"description": "The ID of app for which integration hook is being created"
},
"inbox_id": {
"type": "string",
"description": "The inbox ID, if the hook is an inbox hook"
},
"settings": {
"type": "object",
"description": "The settings required by the integration"
}
}
},
"integrations_hook_update_payload": {
"type": "object",
"properties": {
"settings": {
"type": "object",
"description": "The settings required by the integration"
}
}
}
},
"parameters": {
@ -3219,6 +3642,24 @@
},
"required": true,
"description": "The numeric ID of the user on the platform"
},
"public_inbox_identifier": {
"in": "path",
"name": "inbox_identifier",
"schema": {
"type": "string"
},
"required": true,
"description": "The identifier obtained from API inbox channel"
},
"public_contact_identifier": {
"in": "path",
"name": "contact_identifier",
"schema": {
"type": "string"
},
"required": true,
"description": "The source id of contact obtained on contact create"
}
},
"x-tagGroups": [
@ -3245,6 +3686,14 @@
"Profile",
"Teams"
]
},
{
"name": "Public",
"tags": [
"Contacts API",
"Conversations API",
"Messages API"
]
}
]
}