lib/cocina/generator/schema_base.rb in cocina-models-0.90.0 vs lib/cocina/generator/schema_base.rb in cocina-models-0.91.0
- old
+ new
@@ -2,27 +2,28 @@
module Cocina
module Generator
# Base class for generating from openapi
class SchemaBase
- attr_reader :schema_doc, :key, :required, :nullable, :parent, :relaxed, :schemas
+ attr_reader :schema_doc, :key, :required, :nullable, :parent, :relaxed, :schemas, :lite
- def initialize(schema_doc, key: nil, required: false, nullable: false, parent: nil, relaxed: false, schemas: [])
+ def initialize(schema_doc, key: nil, required: false, nullable: false, parent: nil, relaxed: false, schemas: [], lite: false)
@schema_doc = schema_doc
@key = key
@required = required
@nullable = nullable
@parent = parent
@relaxed = relaxed
@schemas = schemas
+ @lite = lite
end
def filename
"#{name.underscore}.rb"
end
def name
- key || schema_doc.name
+ "#{key || schema_doc.name}#{lite ? 'Lite' : ''}"
end
# Allows nullable values to be set to nil. This is useful when doing an
# update and you want to clear out a value. The logic also permits custom
# types (e.g., `Barcode`, `SourceId`) to be nullable if they are not