Swagger::AbstractParameterObject Class Referenceabstract

Describes a single operation parameter. More...

Inheritance diagram for Swagger::AbstractParameterObject:
[legend]

## Public Member Functions

abstract | check (bool serialize, bool request, string path, string method, string name, reference value)
| verifies the parameter in an actual REST API call
| constructor (hash oh)
| Constructor. More...
auto | getDefaultValue ()
| returns the default value of the parameter (default: NOTHING)
Public Member Functions inherited from Swagger::ObjectBase
| constructor ()
| Constructor.
| constructor (hash oh)
| Constructor. More...
| constructor (ObjectBase other)
| copy constructor
| initialize (hash oh)
| Initialize. More...

## Static Public Member Functions

static AbstractParameterObject | newParameter (string name, hash oh, SwaggerSchema swagger)
| gets a concrete instance of an AbstractParameterObject

## Public Attributes

*string | desc
| A brief description of the parameter. This could contain examples of use. GFM syntax can be used for rich text representation.
string | inLoc
| Required. The location of the parameter. More...
string | name
| Required. The name of the parameter. Parameter names are case sensitive. More...
bool | required = False
| Determines whether this parameter is mandatory. More...
Public Attributes inherited from Swagger::ObjectBase
hash | vendorExtensions
| Allows extensions to the Swagger Schema. More...

## Detailed Description

Describes a single operation parameter.

A unique parameter is defined by a combination of a name and location.

There are five possible parameter types:

- Path: Used together with Path Templating, where the parameter value is actually part of the operation's URL. This does not include the host or base path of the API. For example, in `/items/{itemId}`, the path parameter is `itemId`.
- Query: Parameters that are appended to the URL. For example, in `/items?id=###`, the query parameter is `id`.
- Header: Custom headers that are expected as part of the request.
- Body: The payload that's appended to the HTTP request. Since there can only be one payload, there can only be one body parameter. The name of the body parameter has no effect on the parameter itself and is used for documentation purposes only. Since Form parameters are also in the payload, body and form parameters cannot exist together for the same operation.
- Form: Used to describe the payload of an HTTP request when either `application/x-www-form-urlencoded`, `multipart/form-data` or both are used as the content type of the request (in Swagger's definition, the `consumes` property of an operation). This is the only parameter type that can be used to send files, thus supporting the file type. Since form parameters are sent in the payload, they cannot be declared together with a body parameter for the same operation. Form parameters have a different format based on the content-type used (for further details, consult http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4):
  - `application/x-www-form-urlencoded` - Similar to the format of Query parameters but as a payload. For example, `foo=1&bar=swagger` - both foo and bar are form parameters. This is normally used for simple parameters that are being transferred.
  - `multipart/form-data` - each parameter takes a section in the payload with an internal header. For example, for the header `Content-Disposition: form-data; name="submit-name"` the name of the parameter is `submit-name`. This type of form parameters is more commonly used for file transfers.

## Member Function Documentation

## constructor()

Swagger::AbstractParameterObject::constructor | ( | hash | oh | ) |

Constructor.

Parameters

  oh | deserialized hash from the source schema description decscribing a single parameter

Exceptions

  INVALID-FIELD-TYPE | field has invalid type
  INVALID-FIELD-VALUE | field has invalid value
  REQUIRED-FIELD-MISSING | required field is missing

## Member Data Documentation

## inLoc

string Swagger::AbstractParameterObject::inLoc

Required. The location of the parameter.

Possible values are `"query"`, `"header"`, `"path"`, `"formData"` or `"body"`.

## name

string Swagger::AbstractParameterObject::name

Required. The name of the parameter. Parameter names are case sensitive.

- If inLoc is `"path"`, the `name` field MUST correspond to the associated path segment from the `"path"` field in the Swagger::PathsObject.
- For all other cases, the name corresponds to the parameter name used based on the inLoc property.

## required

bool Swagger::AbstractParameterObject::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`.