From 213a265dddaaa2e4f6be7b3f99083b8b9e693f53 Mon Sep 17 00:00:00 2001 From: Muhammad Nawzad Date: Tue, 30 Jan 2024 13:15:16 +0300 Subject: [PATCH] Add nullable_relationships method to Schemable::Definition --- lib/schemable/definition.rb | 12 ++++++++++++ sig/schemable/definition.rbs | 1 + 2 files changed, 13 insertions(+) diff --git a/lib/schemable/definition.rb b/lib/schemable/definition.rb index 9fb2773..f25d1b1 100644 --- a/lib/schemable/definition.rb +++ b/lib/schemable/definition.rb @@ -125,6 +125,18 @@ module Schemable %i[] end + # Returns the relationships that are nullable in the response body. + # This means that they can be present in the response body but they can be null. + # They are not required to be present in the request body. + # + # @example + # ['users', 'applicant'] + # + # @return [Array] The attributes that are nullable in the response body. + def nullable_relationships + %w[] + end + # Returns the additional create request attributes that are not automatically generated. # These attributes are appended to the create request schema. # diff --git a/sig/schemable/definition.rbs b/sig/schemable/definition.rbs index 64ac8bd..a0b264d 100644 --- a/sig/schemable/definition.rbs +++ b/sig/schemable/definition.rbs @@ -13,6 +13,7 @@ module Schemable def array_types: -> Hash[Symbol, any] def relationships: -> Hash[Symbol, any] def nullable_attributes: -> Array[Symbol] + def nullable_relationships: -> Array[String] def serialized_instance: -> Hash[Symbol, any] def self.generate: -> Array[Hash[Symbol, any]] def excluded_response_included: -> Array[Symbol]