Parameters in OpenAPI
Parameters are used to describe inputs to an operation. Parameters can be defined at the path or operation level and are merged with any duplicates at the operation level, overriding any defined at the path level.
Each parameter needs to be uniquely identified by a combination of its name
and in
fields in an operation.
A parameter in the list can either be a Parameter Object or a Reference to a Parameter Object defined in the Components Object under the parameters
field.
Parameters can represent a number of different input types, including:
- Path Parameters
- Query Parameters
- Headers
- Cookies
Example:
Parameter Object
Parameter Object Fields
- - A templated parameter defined within the path.
- - A query parameter passed via the URL.
- - A header parameter passed via HTTP headers.
- - A cookie parameter passed via HTTP cookies.
The order of fields above is recommended for defining fields in the document.
Parameter Serialization
Depending on the parameter’s in
, style
, and explode
fields and schema type, the parameter value will be serialized in different ways. Some combinations of schema type and parameter serialization are not valid and should be avoided.
The content
field can be used instead to define complex serialization scenarios for a parameter such as serializing an object to a JSON string for including in a query parameter in the URL.
Last updated on