Class: Apiwork::Introspection::API
- Inherits:
-
Object
- Object
- Apiwork::Introspection::API
- Defined in:
- lib/apiwork/introspection/api.rb,
lib/apiwork/introspection/api/info.rb,
lib/apiwork/introspection/api/resource.rb,
lib/apiwork/introspection/api/info/server.rb,
lib/apiwork/introspection/api/info/contact.rb,
lib/apiwork/introspection/api/info/license.rb
Overview
Facade for introspected API data.
Entry point for accessing all API data. Access resources via #resources, types via #types, enums via #enums.
Defined Under Namespace
Instance Method Summary collapse
-
#base_path ⇒ String?
The base path for this API.
-
#enums ⇒ Hash{Symbol => Enum}
The enums for this API.
-
#error_codes ⇒ Hash{Symbol => ErrorCode}
The error codes for this API.
-
#fingerprint ⇒ String
The fingerprint for this API.
-
#info ⇒ API::Info?
The info for this API.
-
#initialize(dump) ⇒ API
constructor
A new instance of API.
-
#locales ⇒ Array<Symbol>
The supported locales for this API.
-
#resources ⇒ Hash{Symbol => API::Resource}
The resources for this API.
-
#to_h ⇒ Hash
Converts this API to a hash.
-
#types ⇒ Hash{Symbol => Type}
The types for this API.
Constructor Details
#initialize(dump) ⇒ API
Returns a new instance of API.
24 25 26 |
# File 'lib/apiwork/introspection/api.rb', line 24 def initialize(dump) @dump = dump end |
Instance Method Details
#base_path ⇒ String?
The base path for this API.
32 33 34 |
# File 'lib/apiwork/introspection/api.rb', line 32 def base_path @dump[:base_path] end |
#enums ⇒ Hash{Symbol => Enum}
The enums for this API.
72 73 74 |
# File 'lib/apiwork/introspection/api.rb', line 72 def enums @enums ||= @dump[:enums].transform_values { |dump| Enum.new(dump) } end |
#error_codes ⇒ Hash{Symbol => ErrorCode}
The error codes for this API.
88 89 90 |
# File 'lib/apiwork/introspection/api.rb', line 88 def error_codes @error_codes ||= @dump[:error_codes].transform_values { |dump| ErrorCode.new(dump) } end |
#fingerprint ⇒ String
The fingerprint for this API.
40 41 42 |
# File 'lib/apiwork/introspection/api.rb', line 40 def fingerprint @dump[:fingerprint] end |
#info ⇒ API::Info?
The info for this API.
48 49 50 |
# File 'lib/apiwork/introspection/api.rb', line 48 def info @info ||= @dump[:info] ? Info.new(@dump[:info]) : nil end |
#locales ⇒ Array<Symbol>
The supported locales for this API.
80 81 82 |
# File 'lib/apiwork/introspection/api.rb', line 80 def locales @dump[:locales] end |
#resources ⇒ Hash{Symbol => API::Resource}
The resources for this API.
56 57 58 |
# File 'lib/apiwork/introspection/api.rb', line 56 def resources @resources ||= @dump[:resources].transform_values { |dump| Resource.new(dump) } end |
#to_h ⇒ Hash
Converts this API to a hash.
96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/apiwork/introspection/api.rb', line 96 def to_h { base_path:, fingerprint:, locales:, enums: enums.transform_values(&:to_h), error_codes: error_codes.transform_values(&:to_h), info: info&.to_h, resources: resources.transform_values(&:to_h), types: types.transform_values(&:to_h), } end |