Class: Graphiti::OpenAPI::Relationship
- Inherits:
-
RelationshipData
- Object
- Dry::Struct
- Struct
- RelationshipData
- Graphiti::OpenAPI::Relationship
- Defined in:
- app/models/graphiti/open_api/relationship.rb
Instance Method Summary collapse
Instance Method Details
#jsonapi_relationship ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'app/models/graphiti/open_api/relationship.rb', line 42 def jsonapi_relationship case type when /belongs_to/, "has_one" "jsonapi_relationshipToOne" else "jsonapi_relationshipToMany" end end |
#resource ⇒ Object
18 19 20 21 |
# File 'app/models/graphiti/open_api/relationship.rb', line 18 def resource return unless __attributes__[:resource] schema.resources[__attributes__[:resource]] end |
#resources ⇒ Object
23 24 25 26 |
# File 'app/models/graphiti/open_api/relationship.rb', line 23 def resources return [resource] if __attributes__[:resources].empty? __attributes__[:resources].map { |resource| schema.resources[resource] } end |
#to_schema ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/models/graphiti/open_api/relationship.rb', line 28 def to_schema { name => { type: :object, properties: { links: {"$ref": "#/components/schemas/jsonapi_relationshipLinks"}, data: {'$ref': "#/components/schemas/#{jsonapi_relationship}"}, meta: {"$ref": "#/components/schemas/jsonapi_meta"}, }, }, } end |