diff --git a/app/json_schemas/customer_schema.rb b/app/json_schemas/customer_schema.rb index 5e7cb94e21..4652ae3bbf 100644 --- a/app/json_schemas/customer_schema.rb +++ b/app/json_schemas/customer_schema.rb @@ -19,4 +19,8 @@ class CustomerSchema < JsonApiSchema def self.required_attributes [:enterprise_id, :email] end + + def self.relationships + [:enterprise] + end end diff --git a/app/json_schemas/json_api_schema.rb b/app/json_schemas/json_api_schema.rb index db12a1c425..9551becccc 100644 --- a/app/json_schemas/json_api_schema.rb +++ b/app/json_schemas/json_api_schema.rb @@ -10,6 +10,10 @@ class JsonApiSchema [] end + def relationships + [] + end + def all_attributes attributes.keys end @@ -83,7 +87,12 @@ class JsonApiSchema properties: attributes, required: required }, - relationships: { type: :object } + relationships: { + type: :object, + properties: relationships.to_h do |name| + [name, { "$ref" => "#/components/schemas/relationship" }] + end + } } end end diff --git a/app/json_schemas/relationship_schema.rb b/app/json_schemas/relationship_schema.rb new file mode 100644 index 0000000000..5b31dcf630 --- /dev/null +++ b/app/json_schemas/relationship_schema.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class RelationshipSchema + def self.schema + { + type: :object, + properties: { + data: { + type: [:object, :array] + }, + links: { + type: :object, + properties: { + related: { type: :string } + } + } + } + } + end +end