Skip to content

Instantly share code, notes, and snippets.

@haisum
Created September 3, 2016 00:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haisum/144b0a52f8105ff40ac5704133f40f57 to your computer and use it in GitHub Desktop.
Save haisum/144b0a52f8105ff40ac5704133f40f57 to your computer and use it in GitHub Desktop.
first swagger
{
"swagger": "2.0",
"info": {
"description": "This is API documentation for SMS gateway.",
"version": "1.0.0",
"title": "SMS Gateway",
"contact": {
"email": "haisumbhatti@gmail.com"
}
},
"host": "",
"basePath": "/api",
"tags": [{
"name": "sms",
"description": "Sending single sms/bulk campaigns"
}, {
"name": "files",
"description": "Operations about uploading and managing files."
}, {
"name": "users",
"description": "Operations about user authentication, addition and modification."
}, {
"name": "services",
"description": "Operations about configuring smpp connections and checking service status."
}],
"schemes": ["https"],
"paths": {
"/message": {
"post": {
"tags": ["sms"],
"summary": "Send a new sms.",
"description": "This endpoint sends a single sms to specified number. To successfully send a message, in addition to relevant sms parameters, you also need to pass a valid authentication token, obtained from /user/auth endpoint.<br/><br/> User of given token must have \"Send message\" permission. If Mask is set to true, user must also have \"Mask Messages\" permission.<br/><br/> When message contains non latin characters, it's sent with UCS data coding. By default we use raw sms encoding. Messages larger than 140 bytes (70 chars in UCS, 160 latin) are automatically splitted in multiple sms. <br/><br/> Connection is chosen for a message based on user's ConnectionGroup setting and prefix of destination number. See user and services endpoints for details about connection settings.",
"consumes": ["application/json"],
"produces": ["application/json"],
"parameters": [{
"in": "body",
"name": "body",
"description": "Message request object that contains necessary parameters.",
"required": true,
"schema": {
"$ref": "#/definitions/Message"
}
}],
"responses": {
"200": {
"description" : "Request completed successfully",
"schema": {
"$ref": "#/definitions/MessageResponse"
}
},
"400": {
"description": "Bad request. Occurs, when we submit json/form request with wrong input type or format.",
"schema": {
"$ref": "#/definitions/BadRequestResponse"
}
},
"401": {
"description": "Unauthorized. This error happens when either token is invalid, user no longer exists or user is suspended.",
"schema": {
"$ref": "#/definitions/MessageResponse"
}
},
"403": {
"description": "This error occurs when user is trying to perform an action that they don't have permission to perform.",
"schema": {
"$ref": "#/definitions/MessageResponse"
}
},
"500": {
"description": "Internal server error."
}
}
}
}
},
"definitions": {
"ScheduledAt": {
"type": "integer",
"format": "int64",
"description": "Unix UTC timestamp at which this message should be sent."
},
"Token": {
"type": "string",
"example": "kODrTQZrwfkHESKqZTwXhkhIlAucHxPkODrTQZrw",
"description" : "Token obtained after authentication"
},
"Src": {
"type": "string",
"example": "AADC009",
"description": "Source from which message should be sent. This is also called short code by some operators."
},
"Msg": {
"type": "string",
"description": "Message text. When message contains non latin characters, it's sent with UCS data coding. By default we use raw sms encoding. Messages larger than 140 bytes (70 chars in UCS, 160 latin) are automatically splitted in multiple sms.",
"example": "Hello this is test message."
},
"Dst": {
"type": "string",
"example": "023994334",
"description": "Destination number where message should be sent."
},
"SendBefore": {
"type": "string",
"description": "Hour and minute of the day before which all messages should be sent. Should be in 24 hour format HH:MM. All messages after this time are scheduled for one minute after next SendAfter time.",
"example": "19:00"
},
"SendAfter": {
"type": "string",
"description": "Hour and minute of the day after which all messages should be sent. Should be in 24 hour format HH:MM.",
"example": "07:00"
},
"Mask": {
"type": "boolean",
"default": false,
"description": "When set to true, all values in sms enclosed in two square brackets [[]] are masked. User must have masking permissions to do this."
},
"Message": {
"type": "object",
"required": ["Token", "Src", "Dst", "Msg"],
"properties": {
"ScheduledAt" : {
"$ref": "#/definitions/ScheduledAt"
},
"Token": {
"$ref": "#/definitions/Token"
},
"Src": {
"$ref": "#/definitions/Src"
},
"Dst": {
"$ref": "#/definitions/Dst"
},
"Msg": {
"$ref": "#/definitions/Msg"
},
"SendBefore": {
"$ref": "#/definitions/SendBefore"
},
"SendAfter": {
"$ref": "#/definitions/SendAfter"
},
"Mask": {
"$ref": "#/definitions/Mask"
}
}
},
"ResponseError" : {
"type": "object",
"properties": {
"Message" : {
"type": "string",
"description": "Summary of error."
},
"Type" : {
"type": "string",
"description": "Type of error. This classifies errors in 6 types. When error type is form, user may use additional info in Field to find which field caused this error.",
"enum" : ["form","db","request","auth","config","queue"]
},
"Field" : {
"type": "string",
"description": "Populated when Type is set to form. If Msg field had errors in request, Type will be set to form and this will be set to Msg."
}
}
},
"Response": {
"type": "object",
"properties": {
"Errors": {
"type": "array",
"items": {
"$ref": "#/definitions/ResponseError"
}
},
"Ok": {
"type": "boolean",
"description": "Set to true when request is successful otherwise false.",
"default": false
}
}
},
"BadRequestResponse": {
"required": ["Errors", "Ok"],
"allOf":[
{ "$ref": "#/definitions/Response" },
{ "properties": {
"Response": {
"type": "object"
},
"Request": {
"type": "object"
}
}
}
]
},
"MessageResponse":{
"required": ["Errors", "Ok", "Request", "Response"],
"allOf":[
{ "$ref": "#/definitions/Response" },
{ "properties": {
"Response": {
"type": "object",
"properties" : {
"ID" :{
"type": "string"
}
}
},
"Request": {
"$ref": "#/definitions/Message"
}
}
}
]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment