Skip to content

Instantly share code, notes, and snippets.

@agmcleod
Last active February 19, 2020 21:40
Show Gist options
  • Save agmcleod/529ab83d6980a435e7c9cb07b54b08b4 to your computer and use it in GitHub Desktop.
Save agmcleod/529ab83d6980a435e7c9cb07b54b08b4 to your computer and use it in GitHub Desktop.
{
"openapi" : "3.0.0",
"info" : {
"title" : "Simple Inventory API",
"description" : "This is a simple API",
"contact" : {
"email" : "you@your-company.com"
},
"license" : {
"name" : "Apache 2.0",
"url" : "http://www.apache.org/licenses/LICENSE-2.0.html"
},
"version" : "1.0.0"
},
"servers" : [ {
"url" : "https://virtserver.swaggerhub.com/agmcleod/MyTestAPI/1.0.0",
"description" : "SwaggerHub API Auto Mocking"
} ],
"tags" : [ {
"name" : "admins",
"description" : "Secured Admin-only calls"
}, {
"name" : "developers",
"description" : "Operations available to regular developers"
} ],
"paths" : {
"/inventory" : {
"get" : {
"tags" : [ "developers" ],
"summary" : "searches inventory",
"description" : "By passing in the appropriate options, you can search for\navailable inventory in the system\n",
"operationId" : "searchInventory",
"parameters" : [ {
"name" : "API-Key",
"in" : "header",
"required" : true,
"style" : "simple",
"explode" : false,
"schema" : {
"type" : "string",
"example" : "abcwjdhfisjdfweu4hwiukdjfnalsefj"
}
}, {
"name" : "searchString",
"in" : "query",
"description" : "pass an optional search string for looking up inventory",
"required" : false,
"style" : "form",
"explode" : true,
"schema" : {
"type" : "string"
}
}, {
"name" : "skip",
"in" : "query",
"description" : "number of records to skip for pagination",
"required" : false,
"style" : "form",
"explode" : true,
"schema" : {
"minimum" : 0,
"type" : "integer",
"format" : "int32"
}
}, {
"name" : "limit",
"in" : "query",
"description" : "maximum number of records to return",
"required" : false,
"style" : "form",
"explode" : true,
"schema" : {
"maximum" : 50,
"minimum" : 0,
"type" : "integer",
"format" : "int32"
}
} ],
"responses" : {
"200" : {
"description" : "search results matching criteria",
"content" : {
"application/json" : {
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/components/schemas/InventoryItem"
}
}
}
}
},
"400" : {
"description" : "bad input parameter"
}
}
},
"post" : {
"tags" : [ "admins" ],
"summary" : "adds an inventory item",
"description" : "Adds an item to the system",
"operationId" : "addInventory",
"requestBody" : {
"description" : "Inventory item to add",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/InventoryItem"
}
}
}
},
"responses" : {
"201" : {
"description" : "item created"
},
"400" : {
"description" : "invalid input, object invalid"
},
"409" : {
"description" : "an existing item already exists"
}
}
}
}
},
"components" : {
"schemas" : {
"InventoryItem" : {
"required" : [ "id", "manufacturer", "name", "releaseDate" ],
"type" : "object",
"properties" : {
"id" : {
"type" : "string",
"format" : "uuid",
"example" : "d290f1ee-6c54-4b01-90e6-d701748f0851"
},
"name" : {
"type" : "string",
"example" : "Widget Adapter"
},
"releaseDate" : {
"type" : "string",
"format" : "date-time",
"example" : "2016-08-29T09:12:33.001Z"
},
"manufacturer" : {
"$ref" : "#/components/schemas/Manufacturer"
}
}
},
"Manufacturer" : {
"required" : [ "name" ],
"type" : "object",
"properties" : {
"name" : {
"type" : "string",
"example" : "ACME Corporation"
},
"homePage" : {
"type" : "string",
"format" : "url",
"example" : "https://www.acme-corp.com"
},
"phone" : {
"type" : "string",
"example" : "408-867-5309"
}
}
}
}
}
}
{
"info": {
"_postman_id": "2fb59391-81a0-4411-be6f-6b2cc329fe32",
"name": "Simple Inventory API",
"description": "This is a simple API\n\nContact Support:\n Email: you@your-company.com",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "inventory",
"item": [
{
"name": "searches inventory",
"request": {
"auth": {
"type": "noauth"
},
"method": "GET",
"header": [
{
"key": "API-Key",
"value": "<string>"
}
],
"url": {
"raw": "{{baseUrl}}/inventory?searchString=<string>&skip=<integer>&limit=<integer>",
"host": [
"{{baseUrl}}"
],
"path": [
"inventory"
],
"query": [
{
"key": "searchString",
"value": "<string>",
"description": "pass an optional search string for looking up inventory"
},
{
"key": "skip",
"value": "<integer>",
"description": "number of records to skip for pagination"
},
{
"key": "limit",
"value": "<integer>",
"description": "maximum number of records to return"
}
]
},
"description": "By passing in the appropriate options, you can search for\navailable inventory in the system\n"
},
"response": [
{
"name": "search results matching criteria",
"originalRequest": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/inventory?searchString=<string>&skip=<integer>&limit=<integer>",
"host": [
"{{baseUrl}}"
],
"path": [
"inventory"
],
"query": [
{
"key": "searchString",
"value": "<string>"
},
{
"key": "skip",
"value": "<integer>"
},
{
"key": "limit",
"value": "<integer>"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [],
"body": "[\n {\n \"id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n \"manufacturer\": {\n \"name\": \"ACME Corporation\",\n \"homePage\": \"https://www.acme-corp.com\",\n \"phone\": \"408-867-5309\"\n },\n \"name\": \"Widget Adapter\",\n \"releaseDate\": \"2016-08-29T09:12:33.001Z\"\n },\n {\n \"id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n \"manufacturer\": {\n \"name\": \"ACME Corporation\",\n \"homePage\": \"https://www.acme-corp.com\",\n \"phone\": \"408-867-5309\"\n },\n \"name\": \"Widget Adapter\",\n \"releaseDate\": \"2016-08-29T09:12:33.001Z\"\n }\n]"
},
{
"name": "bad input parameter",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "API-Key",
"value": "abcwjdhfisjdfweu4hwiukdjfnalsefj"
},
{
"key": "API-Key",
"value": "abcwjdhfisjdfweu4hwiukdjfnalsefj"
}
],
"url": {
"raw": "{{baseUrl}}/inventory?searchString=<string>&skip=<integer>&limit=<integer>",
"host": [
"{{baseUrl}}"
],
"path": [
"inventory"
],
"query": [
{
"key": "searchString",
"value": "<string>"
},
{
"key": "skip",
"value": "<integer>"
},
{
"key": "limit",
"value": "<integer>"
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "text",
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"cookie": [],
"body": ""
}
]
},
{
"name": "adds an inventory item",
"request": {
"auth": {
"type": "noauth"
},
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"id\": \"<uuid>\",\n \"manufacturer\": {\n \"name\": \"<string>\",\n \"homePage\": \"<url>\",\n \"phone\": \"<string>\"\n },\n \"name\": \"<string>\",\n \"releaseDate\": \"<dateTime>\"\n}"
},
"url": {
"raw": "{{baseUrl}}/inventory",
"host": [
"{{baseUrl}}"
],
"path": [
"inventory"
]
},
"description": "Adds an item to the system"
},
"response": [
{
"name": "item created",
"originalRequest": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n \"manufacturer\": {\n \"name\": \"ACME Corporation\",\n \"homePage\": \"https://www.acme-corp.com\",\n \"phone\": \"408-867-5309\"\n },\n \"name\": \"Widget Adapter\",\n \"releaseDate\": \"2016-08-29T09:12:33.001Z\"\n}"
},
"url": {
"raw": "{{baseUrl}}/inventory",
"host": [
"{{baseUrl}}"
],
"path": [
"inventory"
]
}
},
"status": "Created",
"code": 201,
"_postman_previewlanguage": "text",
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"cookie": [],
"body": ""
},
{
"name": "invalid input, object invalid",
"originalRequest": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n \"manufacturer\": {\n \"name\": \"ACME Corporation\",\n \"homePage\": \"https://www.acme-corp.com\",\n \"phone\": \"408-867-5309\"\n },\n \"name\": \"Widget Adapter\",\n \"releaseDate\": \"2016-08-29T09:12:33.001Z\"\n}"
},
"url": {
"raw": "{{baseUrl}}/inventory",
"host": [
"{{baseUrl}}"
],
"path": [
"inventory"
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "text",
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"cookie": [],
"body": ""
},
{
"name": "an existing item already exists",
"originalRequest": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n \"manufacturer\": {\n \"name\": \"ACME Corporation\",\n \"homePage\": \"https://www.acme-corp.com\",\n \"phone\": \"408-867-5309\"\n },\n \"name\": \"Widget Adapter\",\n \"releaseDate\": \"2016-08-29T09:12:33.001Z\"\n}"
},
"url": {
"raw": "{{baseUrl}}/inventory",
"host": [
"{{baseUrl}}"
],
"path": [
"inventory"
]
}
},
"status": "Conflict",
"code": 409,
"_postman_previewlanguage": "text",
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"cookie": [],
"body": ""
}
]
}
],
"protocolProfileBehavior": {}
}
],
"variable": [
{
"id": "baseUrl",
"key": "baseUrl",
"value": "https://virtserver.swaggerhub.com/agmcleod/MyTestAPI/1.0.0",
"type": "string"
}
],
"protocolProfileBehavior": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment