Class: Starter::Importer::Specification
- Inherits:
-
Object
- Object
- Starter::Importer::Specification
- Defined in:
- lib/starter/importer/specification.rb
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#components ⇒ Object
Returns the value of attribute components.
-
#info ⇒ Object
Returns the value of attribute info.
-
#openapi ⇒ Object
Returns the value of attribute openapi.
-
#paths ⇒ Object
Returns the value of attribute paths.
-
#webhooks ⇒ Object
Returns the value of attribute webhooks.
Instance Method Summary collapse
-
#initialize(spec:) ⇒ Specification
constructor
A new instance of Specification.
- #namespaces ⇒ Object
Constructor Details
#initialize(spec:) ⇒ Specification
Returns a new instance of Specification.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/starter/importer/specification.rb', line 11 def initialize(spec:) # mandatory @openapi = spec.fetch('openapi') @info = spec.fetch('info') # in contrast to the spec, paths are required @paths = spec.fetch('paths').except('/').sort.to_h # optional -> not used atm @components = spec.fetch('components', false) @webhooks = spec.fetch('webhooks', false) end |
Instance Attribute Details
#components ⇒ Object
Returns the value of attribute components.
8 9 10 |
# File 'lib/starter/importer/specification.rb', line 8 def components @components end |
#info ⇒ Object
Returns the value of attribute info.
8 9 10 |
# File 'lib/starter/importer/specification.rb', line 8 def info @info end |
#openapi ⇒ Object
Returns the value of attribute openapi.
8 9 10 |
# File 'lib/starter/importer/specification.rb', line 8 def openapi @openapi end |
#paths ⇒ Object
Returns the value of attribute paths.
8 9 10 |
# File 'lib/starter/importer/specification.rb', line 8 def paths @paths end |
#webhooks ⇒ Object
Returns the value of attribute webhooks.
8 9 10 |
# File 'lib/starter/importer/specification.rb', line 8 def webhooks @webhooks end |
Instance Method Details
#namespaces ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/starter/importer/specification.rb', line 24 def namespaces validate_paths @namespaces ||= paths.keys.each_with_object({}) do |path, memo| namespace, rest_path = segmentize(path) memo[namespace] ||= {} memo[namespace][rest_path] = prepare_verbs(paths[path]) end end |