Module: Faraday::Openapi
- Defined in:
- lib/faraday/openapi.rb,
lib/faraday/openapi/errors.rb,
lib/faraday/openapi/request.rb,
lib/faraday/openapi/version.rb,
lib/faraday/openapi/response.rb,
lib/faraday/openapi/middleware.rb
Overview
This will be your middleware main module, though the actual middleware implementation will go into Faraday::Openapi::Middleware for the correct namespacing.
Defined Under Namespace
Modules: Base, RequestValidation, ResponseValidation Classes: AlreadyRegisteredError, Error, FileNotFoundError, Middleware, NotRegisteredError, RequestInvalidError, RequestMiddleware, ResponseInvalidError, ResponseMiddleware
Constant Summary collapse
- VERSION =
'0.6.0'
Class Attribute Summary collapse
-
.configurations ⇒ Object
readonly
Returns the value of attribute configurations.
-
.enabled ⇒ Object
Returns the value of attribute enabled.
-
.registry ⇒ Object
readonly
Returns the value of attribute registry.
Class Method Summary collapse
Class Attribute Details
.configurations ⇒ Object (readonly)
Returns the value of attribute configurations.
27 28 29 |
# File 'lib/faraday/openapi.rb', line 27 def configurations @configurations end |
.enabled ⇒ Object
Returns the value of attribute enabled.
28 29 30 |
# File 'lib/faraday/openapi.rb', line 28 def enabled @enabled end |
.registry ⇒ Object (readonly)
Returns the value of attribute registry.
27 28 29 |
# File 'lib/faraday/openapi.rb', line 27 def registry @registry end |
Class Method Details
.[](key) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/faraday/openapi.rb', line 41 def self.[](key) registry.fetch(key) do = if registry.empty? 'No API descriptions have been registered. Please register your API description via ' \ "Faraday::Openapi.register('myopenapi.yaml')" else "API description #{key.inspect} was not found. Please register your API description via " \ "Faraday::Openapi.register('myopenapi.yaml'#{key == :default ? '' : ", as: #{key.inspect}"})" end raise NotRegisteredError, end end |
.register(filepath, as: :default, allow_partial_responses: false) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/faraday/openapi.rb', line 31 def self.register(filepath, as: :default, allow_partial_responses: false) raise AlreadyRegisteredError, "API description #{as} is already registered" if registry.key?(as) oad = filepath.is_a?(Hash) ? OpenapiFirst.parse(filepath) : OpenapiFirst.load(filepath) registry[as] = oad configurations[as] = { allow_partial_responses: } rescue OpenapiFirst::FileNotFoundError => e raise Faraday::Openapi::FileNotFoundError, e. end |