Class: Graphiti::OpenAPI::Endpoint
- Inherits:
-
EndpointData
- Object
- Dry::Struct
- Struct
- EndpointData
- Graphiti::OpenAPI::Endpoint
- Defined in:
- app/models/graphiti/open_api/endpoint.rb
Instance Method Summary collapse
- #collection_actions ⇒ Object
- #parameters ⇒ Object
- #paths ⇒ Object
- #resource ⇒ Object
- #resource_actions ⇒ Object
- #resource_path ⇒ Object
Methods inherited from EndpointData
Instance Method Details
#collection_actions ⇒ Object
58 59 60 |
# File 'app/models/graphiti/open_api/endpoint.rb', line 58 def collection_actions actions.select(&:collection?) end |
#parameters ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/models/graphiti/open_api/endpoint.rb', line 35 def parameters [].tap do |parameters| parameters << {'$ref': "#/components/parameters/#{type}_include"} if resource.relationships? parameters << {'$ref': "#/components/parameters/#{type}_sort"} parameters << {'$ref': "#/components/parameters/#{type}_fields"} resource.relationships.values.map do |relationship| relationship.resources.each do |resource| parameters << {'$ref': "#/components/parameters/#{resource.type}_fields"} end end end.uniq end |
#paths ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'app/models/graphiti/open_api/endpoint.rb', line 24 def paths { path => { parameters: parameters, }.merge(collection_actions.map(&:operation).inject(&:merge)), resource_path => { parameters: [{'$ref': "#/components/parameters/#{resource.type}_id"}] + parameters, }.merge(resource_actions.map(&:operation).inject(&:merge)), } end |
#resource ⇒ Object
48 49 50 |
# File 'app/models/graphiti/open_api/endpoint.rb', line 48 def resource resource_actions.first.resource end |
#resource_actions ⇒ Object
54 55 56 |
# File 'app/models/graphiti/open_api/endpoint.rb', line 54 def resource_actions actions.reject(&:collection?) end |
#resource_path ⇒ Object
20 21 22 |
# File 'app/models/graphiti/open_api/endpoint.rb', line 20 def resource_path File.join(path.to_s, "{id}") end |