Class: Aho::Schema::Parser
- Inherits:
-
Object
- Object
- Aho::Schema::Parser
- Defined in:
- lib/aho/schema/parser.rb
Constant Summary collapse
- OPENAPI_FILE =
'openapi.yml'
Instance Attribute Summary collapse
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#openapi_paths ⇒ Object
readonly
Returns the value of attribute openapi_paths.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #action ⇒ Object
- #controller ⇒ Object
-
#initialize(method, path, destination) ⇒ Parser
constructor
A new instance of Parser.
- #schema ⇒ Object
Constructor Details
#initialize(method, path, destination) ⇒ Parser
Returns a new instance of Parser.
10 11 12 13 14 15 |
# File 'lib/aho/schema/parser.rb', line 10 def initialize(method, path, destination) @method = method @path = path @destination = destination @openapi_paths = YAML.load_file(File.join(Aho.root_path, OPENAPI_FILE))['paths'] end |
Instance Attribute Details
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
8 9 10 |
# File 'lib/aho/schema/parser.rb', line 8 def destination @destination end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
8 9 10 |
# File 'lib/aho/schema/parser.rb', line 8 def method @method end |
#openapi_paths ⇒ Object (readonly)
Returns the value of attribute openapi_paths.
8 9 10 |
# File 'lib/aho/schema/parser.rb', line 8 def openapi_paths @openapi_paths end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/aho/schema/parser.rb', line 8 def path @path end |
Instance Method Details
#action ⇒ Object
21 22 23 |
# File 'lib/aho/schema/parser.rb', line 21 def action destination.split('#').last end |
#controller ⇒ Object
17 18 19 |
# File 'lib/aho/schema/parser.rb', line 17 def controller "#{destination.split('#').first.split('/').map(&:capitalize).join('::')}Controller" end |
#schema ⇒ Object
25 26 27 |
# File 'lib/aho/schema/parser.rb', line 25 def schema remove_descriptions(openapi_paths.dig(path, method, 'requestBody', 'content', 'application/json', 'schema')) end |