Sha256: 199db3dcbfdeecccf37c84e767c918fd3ceffd646a4f1ca39e9380f98ea874b1
Contents?: true
Size: 664 Bytes
Versions: 21
Compression:
Stored size: 664 Bytes
Contents
# frozen_string_literal: true module Cocina module Generator # Class for generating from an openapi schema class Datatype < SchemaBase def generate <<~RUBY # frozen_string_literal: true module Cocina module Models #{name} = Types::String#{pattern}#{enum} end end RUBY end def pattern return unless schema_doc.pattern ".constrained(format: /#{schema_doc.pattern}/)" end def enum return unless schema_doc.enum ".enum(#{schema_doc.enum.map { |item| quote(item) }.join(', ')})" end end end end
Version data entries
21 entries across 21 versions & 1 rubygems
Version | Path |
---|---|
cocina-models-0.89.0 | lib/cocina/generator/datatype.rb |