Class: OpenAPIRest::ApiParameters
- Inherits:
-
Object
- Object
- OpenAPIRest::ApiParameters
- Defined in:
- lib/openapi_rest/api_parameters.rb
Overview
Rest Api Parameters
Instance Attribute Summary collapse
-
#allowed_params ⇒ Object
readonly
Returns the value of attribute allowed_params.
-
#validation_errors ⇒ Object
readonly
Returns the value of attribute validation_errors.
Instance Method Summary collapse
-
#initialize(args) ⇒ ApiParameters
constructor
A new instance of ApiParameters.
- #response_permitted_params ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(args) ⇒ ApiParameters
Returns a new instance of ApiParameters.
8 9 10 11 12 |
# File 'lib/openapi_rest/api_parameters.rb', line 8 def initialize(args) @params = args.fetch(:params, {}) @model_class = args.fetch(:api_model).model @doc_parser = OpenAPIRest::ApiDocParser.new(args.fetch(:openapi_path, {})) end |
Instance Attribute Details
#allowed_params ⇒ Object (readonly)
Returns the value of attribute allowed_params.
6 7 8 |
# File 'lib/openapi_rest/api_parameters.rb', line 6 def allowed_params @allowed_params end |
#validation_errors ⇒ Object (readonly)
Returns the value of attribute validation_errors.
6 7 8 |
# File 'lib/openapi_rest/api_parameters.rb', line 6 def validation_errors @validation_errors end |
Instance Method Details
#response_permitted_params ⇒ Object
22 23 24 |
# File 'lib/openapi_rest/api_parameters.rb', line 22 def response_permitted_params @doc_parser.find_path.responses.find(response_code).schema.properties.keys.collect(&:to_sym) end |
#valid? ⇒ Boolean
14 15 16 17 18 19 20 |
# File 'lib/openapi_rest/api_parameters.rb', line 14 def valid? @validation_errors = [] validate @validation_errors.empty? end |