diff --git a/lib/suma/express_schema.rb b/lib/suma/express_schema.rb index e6f7f06..9c1ef89 100644 --- a/lib/suma/express_schema.rb +++ b/lib/suma/express_schema.rb @@ -8,12 +8,9 @@ module Suma class ExpressSchema attr_accessor :path, :id, :parsed, :output_path - def initialize(path:, output_path:) + def initialize(id:, path:, output_path:) @path = Pathname.new(path).expand_path - @parsed = Expressir::Express::Parser.from_file(@path.to_s) - Utils.log "Loaded EXPRESS schema: #{path}" - - @id = @parsed.schemas.first.id + @id = id @output_path = output_path end @@ -28,8 +25,17 @@ def type end end + def parsed + return @parsed if @parsed + + @parsed = Expressir::Express::Parser.from_file(@path.to_s) + Utils.log "Loaded EXPRESS schema: #{path}" + @id = @parsed.schemas.first.id + @parsed + end + def to_plain - @parsed.to_s(no_remarks: true) + parsed.to_s(no_remarks: true) end def filename_plain diff --git a/lib/suma/schema_collection.rb b/lib/suma/schema_collection.rb index a3754b0..4e01c11 100644 --- a/lib/suma/schema_collection.rb +++ b/lib/suma/schema_collection.rb @@ -39,8 +39,9 @@ def doc_from_schema_name(schema_name) def finalize @config.schemas.each do |config_schema| s = ExpressSchema.new( - path: config_schema.path, - output_path: @output_path_schemas + id: config_schema.id, + path: config_schema.path.to_s, + output_path: @output_path_schemas.to_s ) klass = config_schema.schemas_only ? SchemaDocument : SchemaAttachment