lib/cocina/generator/schema_value.rb in cocina-models-0.57.0 vs lib/cocina/generator/schema_value.rb in cocina-models-0.58.0
- old
+ new
@@ -4,10 +4,11 @@
module Generator
# Class for generating from an openapi value
class SchemaValue < SchemaBase
# rubocop:disable Layout/LineLength
def generate
- "#{description}#{example}attribute :#{name.camelize(:lower)}, Types::#{dry_datatype(schema_doc)}#{default}#{enum}#{omittable}"
+ # optional has to come before default or the default value that gets set will be nil.
+ "#{description}#{example}attribute :#{name.camelize(:lower)}, Types::#{dry_datatype(schema_doc)}#{optional}#{default}#{enum}#{omittable}"
end
# rubocop:enable Layout/LineLength
private