Skip to content

Commit

Permalink
Automatically set attribute fixed value if it is required but no valu…
Browse files Browse the repository at this point in the history
…e is explicitly provided
  • Loading branch information
ekzobrain committed Nov 13, 2023
1 parent 2fe364b commit 6c34812
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## [Unreleased]

## [2.4.0] - 2023-11-13

- Fixed reading of SimpleType in List
- Add support for Restriction without base
- Support Any generation in simple scenarios

## [2.3.0] - 2023-09-06

- Fixed reading of SimpleType in List
Expand Down
4 changes: 4 additions & 0 deletions lib/xsd/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ def build_element(xml, element, data, namespaces = {})
value = item["@#{attribute.name}"]
if value
attributes[attribute.name] = value
elsif attribute.required?
raise Error, "Attribute #{attribute.name} is required, but no data in provided for it" if attribute.fixed.nil?

attributes[attribute.name] = attribute.fixed
else
attributes.delete(attribute.name)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/xsd/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module XSD
VERSION = '2.3.0'
VERSION = '2.4.0'
end

0 comments on commit 6c34812

Please sign in to comment.