lib/cocina/generator/schema_value.rb in cocina-models-0.87.0 vs lib/cocina/generator/schema_value.rb in cocina-models-0.87.1
- old
+ new
@@ -3,20 +3,20 @@
module Cocina
module Generator
# Class for generating from an openapi value
class SchemaValue < SchemaBase
def generate
- # optional has to come before default or the default value that gets set will be nil.
if required && !relaxed
"#{preamble}attribute :#{name.camelize(:lower)}, #{type}"
else
"#{preamble}attribute? :#{name.camelize(:lower)}, #{type}"
end
end
private
def type
+ # optional has to come before default or the default value that gets set will be nil.
"#{dry_datatype(schema_doc)}#{optional}#{default}#{enum}"
end
def enum
return '' if !schema_doc.enum || relaxed