Skip to content
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
1d53e3a
test
svogt0511 Oct 30, 2025
8efb138
Implements JSON Schema for titles
codycooperross May 21, 2025
2ce744c
Array.wrap titles attribute
codycooperross May 21, 2025
20e175b
Linting
codycooperross May 21, 2025
19213ec
Addressed issue where a string submitted in the titles attribute woul…
codycooperross May 22, 2025
1360a4c
Fix title data structure in test
codycooperross May 22, 2025
04497cd
Fix data structure
codycooperross May 23, 2025
853dd15
test
svogt0511 Oct 30, 2025
77e6295
Update activerecord_json_validator to the latest version.
svogt0511 Oct 31, 2025
71143ae
Appease rubocop.
svogt0511 Oct 31, 2025
a5ca110
Merge remote-tracking branch 'origin/pb325-json-metadata-validation' …
svogt0511 Oct 31, 2025
bdb6327
Update titles.json to use the latest schema and a couple more checks.
svogt0511 Nov 7, 2025
42f9f59
Fix test
svogt0511 Nov 7, 2025
b4b3451
fix titles schema
svogt0511 Nov 10, 2025
c5e8678
Merge pull request #1341 from datacite/titles
svogt0511 Nov 10, 2025
8a4a38b
JSON schema for publicationYear.
svogt0511 Nov 10, 2025
49c5ff3
JSON schema for publication_year.
svogt0511 Nov 10, 2025
e90e088
Add creators schema
svogt0511 Nov 11, 2025
3337cc2
Update schema in title_type
svogt0511 Nov 11, 2025
1f8dee6
Merge remote-tracking branch 'origin/master' into pb325-json-metadata…
svogt0511 Nov 12, 2025
ac4864c
Creators test should have failed.
svogt0511 Nov 12, 2025
0c343ad
Temporarily comment out test.
svogt0511 Nov 12, 2025
c6d150f
Temporarily comment out test.
svogt0511 Nov 12, 2025
19a710c
Fix test - creator missing name
svogt0511 Nov 12, 2025
da0e51d
Fix test. Creator.affiliation was not an array.
svogt0511 Nov 12, 2025
d3d118b
Don't validate json on /dois/validate enpoint. Fix a couple of tests.
svogt0511 Nov 13, 2025
d9c046e
Fix some test data - errors detected by validating with json schema.
svogt0511 Nov 13, 2025
e5f7e96
Fix test data
svogt0511 Nov 13, 2025
0351dc2
Add contributors schema.
svogt0511 Nov 13, 2025
9107c7d
Create shared schemas.
svogt0511 Nov 13, 2025
2833a4d
Add subjects schema.
svogt0511 Nov 14, 2025
e3b1429
Fix test data
svogt0511 Nov 14, 2025
de18655
Fix test data.
svogt0511 Nov 14, 2025
15c2f2f
Fix test data.
svogt0511 Nov 14, 2025
156e56f
Dates schema
svogt0511 Nov 17, 2025
c431f7b
Update validation qualifier to only valid schemas.
svogt0511 Nov 19, 2025
9036ca7
Appease rubocop.
svogt0511 Nov 19, 2025
9663a76
Appease rubocop.
svogt0511 Nov 19, 2025
cdd8419
Backing out dates to string rather than verification using regular ex…
svogt0511 Dec 1, 2025
a08363c
Remove validations for dates. Date to remain validated as string onl…
svogt0511 Dec 1, 2025
d545e4b
Merge remote-tracking branch 'origin/master' into pb325-json-metadata…
svogt0511 Dec 1, 2025
225deae
Add json-schema validation for resourceType.
svogt0511 Dec 1, 2025
c2bba5b
Revert test.
svogt0511 Dec 1, 2025
3f6606c
Add json-schema validation for alternageIdentifiers.
svogt0511 Dec 1, 2025
6315505
add json-schema validation for relatedIdentifiers.
svogt0511 Dec 2, 2025
4bb4b5b
Add json-schema validation for sizes.
svogt0511 Dec 2, 2025
2d87449
Add json-schema validation for formats.
svogt0511 Dec 2, 2025
329ee8f
Mods.
svogt0511 Dec 2, 2025
04de852
Add json-schema validation for version.
svogt0511 Dec 2, 2025
44fb68e
Add json-schema validation for descriptions.
svogt0511 Dec 2, 2025
598906b
Fix some errors.
svogt0511 Dec 3, 2025
acb17d4
More fixes.
svogt0511 Dec 3, 2025
ad28046
More fixes.
svogt0511 Dec 3, 2025
c6e093f
Fix a test.
svogt0511 Dec 3, 2025
da5f9e8
Corrections plus new controlled vocabularies.
svogt0511 Dec 4, 2025
111ec55
Restructuring and corrections.
svogt0511 Dec 8, 2025
c917c85
Add language validation, make sure it is used in all references to la…
svogt0511 Dec 8, 2025
e44889b
Appease rubocop.
svogt0511 Dec 8, 2025
743ac08
Fix a test - description.
svogt0511 Dec 8, 2025
235c3f9
Fixes - code and test.
svogt0511 Dec 8, 2025
fae0e97
Fix errors.
svogt0511 Dec 8, 2025
d430aee
Temporarily commenting out some tests having to do with language.
svogt0511 Dec 8, 2025
05b301e
Comment out language validation. There is a problem with it.
svogt0511 Dec 8, 2025
7a96090
Appease rubocop.
svogt0511 Dec 8, 2025
2148812
Fix tests.
svogt0511 Dec 8, 2025
8e953cd
Add fundingReference validation.
svogt0511 Dec 9, 2025
091b665
Fix test.
svogt0511 Dec 9, 2025
f27dcee
geoLocation validation.
svogt0511 Dec 9, 2025
fe15778
Add json schema validation for geoLocations.
svogt0511 Dec 10, 2025
a0b91fe
Merge remote-tracking branch 'origin/master' into pb325-json-metadata…
svogt0511 Dec 10, 2025
5e831a9
Fix
svogt0511 Dec 10, 2025
d719846
Fixes.
svogt0511 Dec 11, 2025
e945040
Fix errors.
svogt0511 Dec 11, 2025
f428d24
Fixes.
svogt0511 Dec 11, 2025
3c9ee96
Merge remote-tracking branch 'origin/master' into pb325-json-metadata…
svogt0511 Dec 16, 2025
bb141dc
fixes
svogt0511 Dec 16, 2025
681654a
Appease rubocop
svogt0511 Dec 16, 2025
7a1071e
Fixes - language
svogt0511 Dec 16, 2025
bb739f4
Fix
svogt0511 Dec 16, 2025
cf14588
Merge remote-tracking branch 'origin/master' into pb325-json-metadata…
svogt0511 Dec 17, 2025
74d0375
Fix language validation - add raw_language.
svogt0511 Dec 22, 2025
86c22a7
Appease rubocop
svogt0511 Dec 22, 2025
d3f2056
Add test.
svogt0511 Jan 6, 2026
64206c3
Review comment - fix
svogt0511 Jan 6, 2026
1162d93
Types/resourceType validation
svogt0511 Jan 6, 2026
3232373
Appease rubocop.
svogt0511 Jan 6, 2026
38f9fbd
Merge remote-tracking branch 'origin/master' into pb325-json-metadata…
svogt0511 Mar 2, 2026
466de93
Merge remote-tracking branch 'origin/master' into pb325-json-metadata…
svogt0511 Mar 3, 2026
fa2327b
JSON-SCHEMA - metadata-4.7 support.
svogt0511 Mar 4, 2026
0cc8590
Use the latest JSON-schema definition in schemas/client/subjects.json…
svogt0511 Mar 4, 2026
30cf06e
Remove null from the controlled vocabs.
svogt0511 Mar 4, 2026
401d91d
Remove null from the controlled vocabs.
svogt0511 Mar 4, 2026
13e2288
Reverse coderabbit comment. Allowing null as alternative to a contro…
svogt0511 Mar 5, 2026
95f1c99
Address review comment on affiliation.json - removed field dependency.
svogt0511 Mar 5, 2026
9fca65c
Affiliation: require nonempty string in name, as specified in DC meta…
svogt0511 Mar 5, 2026
ccda29d
Address review comment: Should both alternateIdentifier and alternate…
svogt0511 Mar 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ source "https://rubygems.org"

gem "aasm", "~> 5.0", ">= 5.0.1"
gem "active_model_serializers", "~> 0.10.0"
gem "activerecord_json_validator", "~> 2.1", ">= 2.1.5"
gem "activerecord_json_validator", "~> 3.1"
gem "apollo-federation", "1.1.3"
gem "audited", "~> 5.4", ">= 5.4.3"
gem "aws-sdk-s3"
Expand Down
16 changes: 6 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ GEM
activemodel (= 7.1.3.2)
activesupport (= 7.1.3.2)
timeout (>= 0.4.0)
activerecord_json_validator (2.1.5)
activerecord (>= 4.2.0, < 8)
json_schemer (~> 0.2.18)
activerecord_json_validator (3.1.0)
activerecord (>= 4.2.0, < 9)
json_schemer (~> 2.2)
activestorage (7.1.3.2)
actionpack (= 7.1.3.2)
activejob (= 7.1.3.2)
Expand Down Expand Up @@ -278,8 +278,6 @@ GEM
scanf (~> 1.0)
sxp (~> 1.2)
unicode-types (~> 1.7)
ecma-re-validator (0.4.0)
regexp_parser (~> 2.2)
edtf (3.2.0)
activesupport (>= 3.0, < 9.0)
elasticsearch (7.17.10)
Expand Down Expand Up @@ -390,12 +388,11 @@ GEM
json-ld-preloaded (3.2.2)
json-ld (~> 3.2)
rdf (~> 3.2)
json_schemer (0.2.25)
ecma-re-validator (~> 0.3)
json_schemer (2.4.0)
bigdecimal
hana (~> 1.3)
regexp_parser (~> 2.0)
simpleidn (~> 0.2)
uri_template (~> 0.7)
jsonapi-renderer (0.2.2)
jsonapi-serializer (2.2.0)
activesupport (>= 4.2)
Expand Down Expand Up @@ -771,7 +768,6 @@ GEM
unicode_utils (1.4.0)
uniform_notifier (1.16.0)
uri (0.13.2)
uri_template (0.7.0)
uuid (2.3.9)
macaddr (~> 1.0)
uuidtools (2.2.0)
Expand Down Expand Up @@ -799,7 +795,7 @@ PLATFORMS
DEPENDENCIES
aasm (~> 5.0, >= 5.0.1)
active_model_serializers (~> 0.10.0)
activerecord_json_validator (~> 2.1, >= 2.1.5)
activerecord_json_validator (~> 3.1)
apollo-federation (= 1.1.3)
audited (~> 5.4, >= 5.4.3)
aws-sdk-s3
Expand Down
16 changes: 10 additions & 6 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,19 @@ class Doi < ApplicationRecord
validates_presence_of :doi
validates_presence_of :url, if: Proc.new { |doi| doi.is_registered_or_findable? }

json_schema_validation = {
message: ->(errors) { errors },
schema: PUBLISHER_JSON_SCHEMA
}

def validate_publisher_obj?(doi)
doi.validatable? && doi.publisher_obj? && !(doi.publisher_obj.blank? || doi.publisher_obj.all?(nil))
end

validates :publisher_obj, if: ->(doi) { validate_publisher_obj?(doi) }, json: json_schema_validation
def validate_json_attribute?(attribute)
validatable? && !self[attribute].nil?
end

def schema_file_path(schema_name)
Rails.root.join("app", "models", "schemas", "doi", "#{schema_name}.json")
end

validates :publisher_obj, if: ->(doi) { validate_publisher_obj?(doi) }, json: { message: ->(errors) { errors }, schema: lambda { schema_file_path("publisher") } }

# from https://www.crossref.org/blog/dois-and-matching-regular-expressions/ but using uppercase
validates_format_of :doi, with: /\A10\.\d{4,5}\/[-._;()\/:a-zA-Z0-9*~$=]+\z/, on: :create
Expand All @@ -131,6 +134,7 @@ def validate_publisher_obj?(doi)
validate :check_dates, if: :dates?
validate :check_rights_list, if: :rights_list?
validate :check_titles, if: :titles?
validates :titles, if: proc { |doi| doi.validate_json_attribute?(:titles) }, json: { message: ->(errors) { errors }, schema: lambda { schema_file_path("titles") } }
validate :check_descriptions, if: :descriptions?
validate :check_types, if: :types?
validate :check_container, if: :container?
Expand Down
13 changes: 13 additions & 0 deletions app/models/schemas/doi/controlled_vocabularies/title_type.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"type": ["string", "null"],
"$schema": "http://json-schema.org/draft-04/schema#",
"anyOf": [
{
"type": "string",
"enum": ["AlternativeTitle", "Subtitle", "TranslatedTitle", "Other"]
},
{
"type": "null"
}
]
}
19 changes: 19 additions & 0 deletions app/models/schemas/doi/titles.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"type": "array",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"items": {
"type": "object",
"properties": {
"title": {
"type": "string"
},
"titleType": { "$ref": "controlled_vocabularies/title_type.json" },
"lang": { "type": ["string", "null"] }
},
"required": [
"title"
],
"additionalProperties": false
},
"minitems": 1
}
2 changes: 1 addition & 1 deletion spec/concerns/indexable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
let!(:doi) do
create(
:doi,
titles: { title: "Soil investigations" },
titles: [ { title: "Soil investigations" } ],
publisher: "Pangaea",
descriptions: { description: "this is a description" },
aasm_state: "findable",
Expand Down
6 changes: 4 additions & 2 deletions spec/fixtures/files/nasa_error.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
"familyName":"Ramasubramanian"
}
],
"titles":{
"titles": [
{
"title":"Tropical Cyclone Satellite Imagery and Wind Speed Dataset"
},
}
],
"publisher": "Radiant MLHub",
"publicationYear": 2020,
"types":{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion spec/requests/datacite_dois/patch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@
patch "/dois/#{doi.doi}", valid_attributes, headers

expect(last_response.status).to eq(422)
expect(json["errors"]).to eq([{ "source" => "titles", "title" => "Title 'Submitted chemical data for InChIKey=YAPQBXQYLJRXSA-UHFFFAOYSA-N' should be an object instead of a string.", "uid" => "10.14454/4k3m-nyvg" }])
expect(json["errors"]).to eq([{ "source" => "titles", "title" => "Value at root is not an array", "uid" => "10.14454/4k3m-nyvg" }])
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/requests/datacite_dois/post_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@
end

context "when the title changes" do
let(:titles) { { "title" => "Referee report. For: RESEARCH-3482 [version 5; referees: 1 approved, 1 approved with reservations]" } }
let(:titles) { [ { "title" => "Referee report. For: RESEARCH-3482 [version 5; referees: 1 approved, 1 approved with reservations]" } ] }
let(:xml) { Base64.strict_encode64(file_fixture("datacite.xml").read) }
let(:valid_attributes) do
{
Expand Down