Skip to content

Instantly share code, notes, and snippets.

@jerzyn
Created July 1, 2015 15:58
Show Gist options
  • Save jerzyn/ce791dc9fb65280eac02 to your computer and use it in GitHub Desktop.
Save jerzyn/ce791dc9fb65280eac02 to your computer and use it in GitHub Desktop.
Paths Object Schema with comments
{
// Path is a relative path to an individual endpoint. The field name MUST begin with a slash. The path is appended to the basePath in order to construct the full URL. Path templating is allowed.
"/pets": {
"get": {
// A definition of a GET operation on this path.
"description": "Returns all pets from the system that the user has access to\nNam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia.\n\nSed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien.\n",
// A verbose explanation of the operation behavior. GFM syntax can be used for rich text representation.
"operationId": "findPets",
// A friendly name for the operation. The id MUST be unique among all operations described in the API. Tools and libraries MAY use the operation id to uniquely identify an operation.
"parameters": [
// A list of parameters that are applicable for this operation. If a parameter is already defined at the Path Item, the new definition will override it, but can never remove it. The list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of a name and location. The list can use the Reference Object to link to parameters that are defined at the Swagger Object's parameters. There can be one "body" parameter at most.
{
"name": "tags",
// Required. The name of the parameter. Parameter names are case sensitive. If in is "path", the name field MUST correspond to the associated path segment from the path field in the Paths Object. See Path Templating for further information. For all other cases, the name corresponds to the parameter name used based on the in property.
"in": "query",
// Required. The location of the parameter. Possible values are "query", "header", "path", "formData" or "body".
"description": "tags to filter by",
// A brief description of the parameter. This could contain examples of use. GFM syntax can be used for rich text representation.
"required": false,
// Determines whether this parameter is mandatory. If the parameter is in "path", this property is required and its value MUST be true. Otherwise, the property MAY be included and its default value is false.
"type": "array",
// g Required. The type of the parameter. Since the parameter is not located at the request body, it is limited to simple types (that is, not an object). The value MUST be one of "string", "number", "integer", "boolean", "array" or "file". If type is "file", the consumes MUST be either "multipart/form-data" or " application/x-www-form-urlencoded" and the parameter MUST be in "formData".
"collectionFormat": "csv",
// Determines the format of the array if type array is used. Possible values are: csv - comma separated values foo,bar; ssv - space separated values foo bar; tsv - tab separated values foo\tbar; pipes - pipe separated values foo|bar. multi - corresponds to multiple parameter instances instead of multiple values for a single instance foo=bar&foo=baz. This is valid only for parameters in "query" or "formData". Default value is csv.
"items": {
// Required if type is "array". Describes the type of items in the array. An limited subset of JSON-Schema's items object. It is used by parameter definitions that are not located in "body".
"type": "string"
// Full documentation on Items Object: https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#itemsObject
}
// If in is "body" there will be one more required field named "schema" defining the type used for the body parameter.
// Full reference of the Parameter object can be found here: https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#parameter-object
},
{
"name": "limit",
"in": "query",
"description": "maximum number of results to return",
"required": false,
"type": "integer",
"format": "int32"
},
{
"name": "user_key",
"in": "header",
"description": "User Key Authentication Parameter",
"required": true,
"type": "string"
}
],
"responses": {
// Required. The list of possible responses as they are returned from executing this operation.
// Full documentation on the Response Object can be found here: https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#responsesObject
"200": {
"description": "pet response",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
},
"403": {
"description": "Authentication failed",
"schema": {
"$ref": "#/definitions/AuthenticationFailed"
}
},
"default": {
// The documentation of responses other than the ones declared for specific HTTP response codes. It can be used to cover undeclared responses. Reference Object can be used to link to a response that is defined at the Swagger Object's responses section.
"description": "unexpected error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
},
"post": {
// A definition of a POST operation on this path.
"description": "Creates a new pet in the store. Duplicates are allowed",
"operationId": "addPet",
"parameters": [
{
"name": "pet",
"in": "body",
"description": "Pet to add to the store",
"required": true,
"schema": {
"$ref": "#/definitions/NewPet"
}
},
{
"name": "user_key",
"in": "header",
"description": "User Key Authentication Parameter",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "pet response",
"schema": {
"$ref": "#/definitions/Pet"
}
},
"403": {
"description": "Authentication failed",
"schema": {
"$ref": "#/definitions/AuthenticationFailed"
}
},
"default": {
"description": "unexpected error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
},
"/pets/{id}": {
"get": {
"description": "Returns a user based on a single ID, if the user does not have access to the pet",
"operationId": "find pet by id",
"parameters": [
{
"name": "id",
"in": "path",
"description": "ID of pet to fetch",
"required": true,
"type": "integer",
"format": "int64"
},
{
"name": "user_key",
"in": "header",
"description": "User Key Authentication Parameter",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "pet response",
"schema": {
"$ref": "#/definitions/Pet"
}
},
"403": {
"description": "Authentication failed",
"schema": {
"$ref": "#/definitions/AuthenticationFailed"
}
},
"default": {
"description": "unexpected error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
},
"delete": {
// A definition of a DELETE operation on this path.
"description": "deletes a single pet based on the ID supplied",
"operationId": "deletePet",
"parameters": [
{
"name": "id",
"in": "path",
"description": "ID of pet to delete",
"required": true,
"type": "integer",
"format": "int64"
},
{
"name": "user_key",
"in": "header",
"description": "User Key Authentication Parameter",
"required": true,
"type": "string"
}
],
"responses": {
"204": {
"description": "pet deleted"
},
"403": {
"description": "Authentication failed",
"schema": {
"$ref": "#/definitions/AuthenticationFailed"
}
},
"default": {
"description": "unexpected error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
// NOT COVERED IN THIS EXAMPLE
"put": {
// A definition of a PUT operation on this path.
"tags": ["string"],
// A list of tags for API documentation control. Tags can be used for logical grouping of operations by resources or any other qualifier.
"summary": "string",
// A short summary of what the operation does. For maximum readability in the swagger-ui, this field SHOULD be less than 120 characters.
"externalDocs": {},
// Additional external documentation for this operation.
"consumes": ["string"]
// A list of MIME types the operation can consume. This overrides the consumes definition at the Swagger Object. An empty value MAY be used to clear the global definition. Value MUST be as described under Mime Types.
"produces": ["string"]
// A list of MIME types the operation can produce. This overrides the consumes definition at the Swagger Object. An empty value MAY be used to clear the global definition. Value MUST be as described under Mime Types.
"schemes": ["string"]
// The transfer protocol for the operation. Values MUST be from the list: "http", "https", "ws", "wss". The value overrides the Swagger Object schemes definition.
"deprecated": boolean
// Declares this operation to be deprecated. Usage of the declared operation should be refrained. Default value is false.
"security": [{}]
// A declaration of which security schemes are applied for this operation. The list of values describes alternative security schemes that can be used (that is, there is a logical OR between the security requirements). This definition overrides any declared top-level security. To remove a top-level security declaration, an empty array can be used.
},
"options": {},
// A definition of a OPTIONS operation on this path.
"head": {},
// A definition of a HEAD operation on this path.
"patch": {},
// A definition of a PATCH operation on this path.
"$ref": "string",
// Allows for an external definition of this path item. The referenced structure MUST be in the format of a Path Item Object. If there are conflicts between the referenced definition and this Path Item's definition, the behavior is undefined.
"parameters": [{}]
// A list of parameters that are applicable for all the operations described under this path. These parameters can be overridden at the operation level, but cannot be removed there. The list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of a name and location. The list can use the Reference Object to link to parameters that are defined at the Swagger Object's parameters. There can be one "body" parameter at most.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment