class Yori::Schema::V3::Responses

Responses:

A container for the expected responses of an operation.
The container maps a HTTP response code to the expected response.
The documentation is not necessarily expected to cover all possible HTTP response codes because they may not be known in advance.
However, documentation is expected to cover a successful operation response and any known errors.
The default MAY be used as a default response object for all HTTP codes that are not covered individually by the specification.
The Responses Object MUST contain at least one response code, and it SHOULD be the response for a successful operation call.

Public Instance Methods

http_status_code(status_code, &block)
Alias for: response
response(status_code, &block) click to toggle source

@!method response

Any HTTP status code can be used as the property name, but only one property per code, to describe the expected response for that HTTP status code.
A Reference Object can link to a response that is defined in the OpenAPI Object's components/responses section.
This field MUST be enclosed in quotation marks (for example, "200") for compatibility between JSON and YAML.
To define a range of response codes, this field MAY contain the uppercase wildcard character X.
For example, 2XX represents all response codes between [200-299]. The following range definitions are allowed: 1XX, 2XX, 3XX, 4XX, and 5XX.
If a response range is defined using an explicit code, the explicit code definition takes precedence over the range definition for that code.
# File lib/yori/schema/v3/responses.rb, line 28
def response(status_code, &block)
  self[status_code.to_s] = self.class.eval_class!(Yori::Schema::V3::Response, id, &block)
end
Also aliased as: status, http_status_code
status(status_code, &block)
Alias for: response
validate!() click to toggle source
# File lib/yori/schema/v3/responses.rb, line 35
def validate!
  status_keys = keys.reject { |x| x == 'default' }
  raise Yori::Errors::InvalidSchemaError, 'The Responses Object MUST contain at least one response code.' if status_keys.empty?
end