lib/cocina/generator/schema_base.rb in cocina-models-0.57.0 vs lib/cocina/generator/schema_base.rb in cocina-models-0.58.0

- old
+ new

@@ -19,13 +19,23 @@ def name key || schema_doc.name end + # Allows non-required values to not be provided. This allows smaller + # requests as not every field needs to be present. def omittable return '' if required '.meta(omittable: true)' + end + + # Allows non-required values to be set to nil. This is useful when doing + # an update and you want to clear out a value. + def optional + return '' if required + + '.optional' end def quote(item) return item unless schema_doc.type == 'string'