Class: SoberSwag::Reporting::Compiler::Schema
- Inherits:
-
Object
- Object
- SoberSwag::Reporting::Compiler::Schema
- Defined in:
- lib/sober_swag/reporting/compiler.rb
Overview
Compile component schemas.
Instance Attribute Summary collapse
-
#references ⇒ Object
readonly
Hash of references to type definitions.
Instance Method Summary collapse
- #compile(value) ⇒ Object
- #compile_inner(value) ⇒ Object
-
#initialize ⇒ Schema
constructor
A new instance of Schema.
- #merge_found(found) ⇒ Object
Constructor Details
#initialize ⇒ Schema
Returns a new instance of Schema.
7 8 9 10 |
# File 'lib/sober_swag/reporting/compiler.rb', line 7 def initialize @references = {} @referenced_schemas = Set.new end |
Instance Attribute Details
#references ⇒ Object (readonly)
Hash of references to type definitions. Suitable for us as the components hash.
15 16 17 |
# File 'lib/sober_swag/reporting/compiler.rb', line 15 def references @references end |
Instance Method Details
#compile(value) ⇒ Object
17 18 19 |
# File 'lib/sober_swag/reporting/compiler.rb', line 17 def compile(value) compile_inner(value.swagger_schema) end |
#compile_inner(value) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/sober_swag/reporting/compiler.rb', line 21 def compile_inner(value) initial, found = value merge_found(found) initial end |
#merge_found(found) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/sober_swag/reporting/compiler.rb', line 29 def merge_found(found) found.each do |k, v| next unless @referenced_schemas.add?(k) @references[k] = compile_inner(v.call) end end |