See More

{ "tags": [ "pet" ], "description": "Add new pet to the store inventory.", "operationId": "addPet", "responses": { "405": { "description": "Invalid input" } }, "security": [ { "petstore_auth": [ "write:pets", "read:pets" ] }, { "api_key": [] }, { "ApiKeyAuth": [] }, { "BasicAuth": [] }, { "BearerAuth": [] }, { "OAuth2": [] }, { "OpenID": [] } ], "x-codeSamples": [ { "lang": "C#", "source": "PetStore.v1.Pet pet = new PetStore.v1.Pet();\npet.setApiKey(\"your api key\");\npet.petType = PetStore.v1.Pet.TYPE_DOG;\npet.name = \"Rex\";\n// set other fields\nPetStoreResponse response = pet.create();\nif (response.statusCode == HttpStatusCode.Created)\n{\n // Successfully created\n}\nelse\n{\n // Something wrong -- check response for errors\n Console.WriteLine(response.getRawResponse());\n}\n" }, { "lang": "PHP", "source": "$form = new \\PetStore\\Entities\\Pet();\n$form->setPetType(\"Dog\");\n$form->setName(\"Rex\");\n// set other fields\ntry {\n $pet = $client->pets()->create($form);\n} catch (UnprocessableEntityException $e) {\n var_dump($e->getErrors());\n}\n" } ], "requestBody": { "content": { "application/json": { "schema": { "allOf": [ { "description": "My Pet", "title": "Pettie" }, { "type": "object", "required": [ "name", "photoUrls", "tags" ], "discriminator": { "propertyName": "petType", "mapping": { "cat": { "description": "A representation of a cat", "allOf": [ "circular(Pet)", { "type": "object", "properties": { "huntingSkill": { "type": "string", "description": "The measured skill for hunting", "default": "lazy", "example": "adventurous", "enum": [ "clueless", "lazy", "adventurous", "aggressive" ] } }, "required": [ "huntingSkill" ] } ], "title": "Cat" }, "dog": { "description": "A representation of a dog", "allOf": [ "circular(Pet)", { "type": "object", "properties": { "packSize": { "type": "integer", "format": "int32", "description": "The size of the pack the dog is from", "default": 1, "minimum": 1 } }, "required": [ "packSize" ] } ], "title": "Dog" }, "bee": { "description": "A representation of a honey bee", "allOf": [ "circular(Pet)", { "type": "object", "properties": { "honeyPerDay": { "type": "number", "description": "Average amount of honey produced per day in ounces", "example": 3.14, "multipleOf": 0.01 } }, "required": [ "honeyPerDay" ] } ], "title": "HoneyBee" } } }, "properties": { "id": { "externalDocs": { "description": "Find more info here", "url": "https://example.com" }, "description": "Pet ID", "allOf": [ { "type": "integer", "format": "int64", "readOnly": true, "title": "Id" } ] }, "category": { "description": "Categories this pet belongs to", "allOf": [ { "type": "object", "properties": { "id": { "description": "Category ID", "allOf": [ { "type": "integer", "format": "int64", "readOnly": true, "title": "Id" } ] }, "name": { "description": "Category name", "type": "string", "minLength": 1 }, "sub": { "description": "Test Sub Category", "type": "object", "properties": { "prop1": { "type": "string", "description": "Dumb Property" } } } }, "xml": { "name": "Category" }, "title": "Category" } ] }, "name": { "description": "The name given to a pet", "type": "string", "example": "Guru" }, "photoUrls": { "description": "The list of URL to a cute photos featuring pet", "type": "array", "maxItems": 20, "xml": { "name": "photoUrl", "wrapped": true }, "items": { "type": "string", "format": "url" } }, "friend": { "allOf": [ "circular(Pet)" ] }, "tags": { "description": "Tags attached to the pet", "type": "array", "minItems": 1, "xml": { "name": "tag", "wrapped": true }, "items": { "type": "object", "properties": { "id": { "description": "Tag ID", "allOf": [ { "type": "integer", "format": "int64", "readOnly": true, "title": "Id" } ] }, "name": { "description": "Tag name", "type": "string", "minLength": 1 } }, "xml": { "name": "Tag" }, "title": "Tag" } }, "status": { "type": "string", "description": "Pet status in the store", "enum": [ "available", "pending", "sold" ] }, "petType": { "description": "Type of a pet", "type": "string", "oneOf": [ { "description": "A representation of a cat", "allOf": [ "circular(Pet)", { "type": "object", "properties": { "huntingSkill": { "type": "string", "description": "The measured skill for hunting", "default": "lazy", "example": "adventurous", "enum": [ "clueless", "lazy", "adventurous", "aggressive" ] } }, "required": [ "huntingSkill" ] } ], "title": "Cat" }, { "description": "A representation of a dog", "allOf": [ "circular(Pet)", { "type": "object", "properties": { "packSize": { "type": "integer", "format": "int32", "description": "The size of the pack the dog is from", "default": 1, "minimum": 1 } }, "required": [ "packSize" ] } ], "title": "Dog" }, { "description": "A representation of a honey bee", "allOf": [ "circular(Pet)", { "type": "object", "properties": { "honeyPerDay": { "type": "number", "description": "Average amount of honey produced per day in ounces", "example": 3.14, "multipleOf": 0.01 } }, "required": [ "honeyPerDay" ] } ], "title": "HoneyBee" } ] } }, "xml": { "name": "Pet" }, "title": "Pet" } ] }, "example": { "category": { "name": "Great Dane", "sub": { "prop1": "Just a test property" } }, "name": "Pepper", "photoUrls": [ "https://assets.orvis.com/is/image/orvisprd/great-dane" ], "tags": [ { "name": "Great Danes" } ], "status": "pending", "petType": { "huntingSkill": "lazy" } } }, "application/xml": { "schema": { "type": "object", "properties": { "name": { "type": "string", "description": "hooray" } } } } }, "description": "Pet object that needs to be added to the store", "required": true }, "parameters": [ { "name": "Accept-Language", "in": "header", "description": "The language you prefer for messages. Supported values are en-AU, en-CA, en-GB, en-US", "example": "en-US", "required": false, "schema": { "type": "string", "default": "en-AU" } }, { "name": "cookieParam", "in": "cookie", "description": "Some cookie", "required": true, "schema": { "type": "integer", "format": "int64" } } ], "method": "post", "path": "/pet", "servers": [ { "url": "https://petstore.swagger.io/v2", "description": "Default server" }, { "url": "https://petstore.swagger.io/sandbox", "description": "Sandbox server" }, { "url": "http://127.0.0.1:4010", "description": "Prism Mock API (local)" } ], "securitySchemes": { "petstore_auth": { "description": "Get access to data while protecting your account credentials.\nOAuth2 is also a safer and more secure way to give you access.\n", "type": "oauth2", "flows": { "implicit": { "authorizationUrl": "http://petstore.swagger.io/api/oauth/dialog", "scopes": { "write:pets": "modify pets in your account", "read:pets": "read your pets" } } } }, "api_key": { "description": "For this sample, you can use the api key `special-key` to test the authorization filters.\n", "type": "apiKey", "name": "api_key", "in": "header" }, "BasicAuth": { "type": "http", "scheme": "basic" }, "BearerAuth": { "type": "http", "scheme": "bearer" }, "ApiKeyAuth": { "type": "apiKey", "in": "header", "name": "X-API-Key" }, "OpenID": { "type": "openIdConnect", "openIdConnectUrl": "https://example.com/.well-known/openid-configuration" }, "OAuth2": { "type": "oauth2", "flows": { "authorizationCode": { "authorizationUrl": "https://example.com/oauth/authorize", "tokenUrl": "https://example.com/oauth/token", "scopes": { "read": "Grants read access", "write": "Grants write access", "admin": "Grants access to admin operations" } } } } }, "jsonRequestBodyExample": { "category": { "name": "string", "sub": { "prop1": "string" } }, "name": "Guru", "photoUrls": [ "string" ], "friend": {}, "tags": [ { "name": "string" } ], "status": "available", "petType": { "huntingSkill": "adventurous" } }, "info": { "description": "This is a sample server Petstore server.\nYou can find out more about Swagger at\n[http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).\nFor this sample, you can use the api key `special-key` to test the authorization filters.\n\n## Introduction\nThis API is documented in **OpenAPI format** and is based on\n[Petstore sample](http://petstore.swagger.io/) provided by [swagger.io](http://swagger.io) team.\nIt was **extended** to illustrate features of [generator-openapi-repo](https://github.com/Rebilly/generator-openapi-repo)\ntool and [ReDoc](https://github.com/Redocly/redoc) documentation. In addition to standard\nOpenAPI syntax we use a few [vendor extensions](https://github.com/Redocly/redoc/blob/master/docs/redoc-vendor-extensions.md).\n\n## OpenAPI Specification\nThis API is documented in **OpenAPI format** and is based on\n[Petstore sample](http://petstore.swagger.io/) provided by [swagger.io](http://swagger.io) team.\nIt was **extended** to illustrate features of [generator-openapi-repo](https://github.com/Rebilly/generator-openapi-repo)\ntool and [ReDoc](https://github.com/Redocly/redoc) documentation. In addition to standard\nOpenAPI syntax we use a few [vendor extensions](https://github.com/Redocly/redoc/blob/master/docs/redoc-vendor-extensions.md).\n\n## Cross-Origin Resource Sharing\nThis API features Cross-Origin Resource Sharing (CORS) implemented in compliance with [W3C spec](https://www.w3.org/TR/cors/).\nAnd that allows cross-domain communication from the browser.\nAll responses have a wildcard same-origin which makes them completely public and accessible to everyone, including any code on any site.\n\n## Authentication\n\nPetstore offers two forms of authentication:\n - API Key\n - OAuth2\n \nOAuth2 - an open protocol to allow secure authorization in a simple\nand standard method from web, mobile and desktop applications.\n", "version": "2.0.0", "title": "Swagger Petstore YAML", "termsOfService": "http://swagger.io/terms/", "contact": { "name": "API Support", "email": "[email protected]", "url": "https://github.com/Redocly/redoc" }, "x-logo": { "url": "https://redocly.github.io/redoc/petstore-logo.png", "altText": "Petstore logo" }, "x-dark-logo": { "url": "/img/petstore-logo-dark.png", "altText": "Petstore dark logo" }, "license": { "name": "Apache 2.0", "url": "http://www.apache.org/licenses/LICENSE-2.0.html" } }, "postman": { "name": "Add a new pet to the store", "description": { "content": "Add new pet to the store inventory.", "type": "text/plain" }, "url": { "path": [ "pet" ], "host": [ "{{baseUrl}}" ], "query": [], "variable": [] }, "header": [ { "disabled": false, "description": { "content": "The language you prefer for messages. Supported values are en-AU, en-CA, en-GB, en-US", "type": "text/plain" }, "key": "Accept-Language", "value": "" }, { "key": "Content-Type", "value": "application/json" } ], "method": "POST", "body": { "mode": "raw", "raw": "\"\"", "options": { "raw": { "language": "json" } } }, "auth": { "type": "oauth2", "oauth2": [] } } }