cocina-models 0.99.1 → 0.99.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +27 -28
- data/cocina-models.gemspec +0 -1
- data/lib/cocina/generator/generator.rb +3 -1
- data/lib/cocina/generator/schema.rb +4 -4
- data/lib/cocina/generator/schema_array.rb +6 -1
- data/lib/cocina/generator/schema_base.rb +1 -1
- data/lib/cocina/generator/vocab.rb +1 -1
- data/lib/cocina/models/version.rb +1 -1
- data/lib/cocina/models.rb +15 -2
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7084352ad6644805e589d4326dc33d8fa24bf552e2477388f214a631787a6c1c
|
4
|
+
data.tar.gz: 9f79866b2045957d92b106951c56d1b9921c5f73e0c402cace570bfc5b1d1b8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10d995ae9c4e178cab0217cda005fd017f94c07f46430e9e0553adbcc58f143602b7cf8c12c180c3d1f571be44f1acb27f045360a3dc0615158c3b794e4b1b5d
|
7
|
+
data.tar.gz: 172a116805b32a6ee40a1a14fde6e4f87b95359e59d1ee0604c0205bb33b19e3ff7fe20ce262742803b88e80794055c2aaeaa947767cb10cc6bde6ab8ba03c7c
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cocina-models (0.99.
|
4
|
+
cocina-models (0.99.3)
|
5
5
|
activesupport
|
6
6
|
deprecation
|
7
7
|
dry-struct (~> 1.0)
|
@@ -11,7 +11,6 @@ PATH
|
|
11
11
|
i18n
|
12
12
|
jsonpath
|
13
13
|
nokogiri
|
14
|
-
openapi3_parser
|
15
14
|
openapi_parser (~> 1.0)
|
16
15
|
super_diff
|
17
16
|
thor
|
@@ -20,7 +19,7 @@ PATH
|
|
20
19
|
GEM
|
21
20
|
remote: https://rubygems.org/
|
22
21
|
specs:
|
23
|
-
activesupport (
|
22
|
+
activesupport (8.0.1)
|
24
23
|
base64
|
25
24
|
benchmark (>= 0.3)
|
26
25
|
bigdecimal
|
@@ -32,18 +31,17 @@ GEM
|
|
32
31
|
minitest (>= 5.1)
|
33
32
|
securerandom (>= 0.3)
|
34
33
|
tzinfo (~> 2.0, >= 2.0.5)
|
34
|
+
uri (>= 0.13.1)
|
35
35
|
ast (2.4.2)
|
36
36
|
attr_extras (7.1.0)
|
37
37
|
base64 (0.2.0)
|
38
38
|
benchmark (0.4.0)
|
39
|
-
bigdecimal (3.1.
|
39
|
+
bigdecimal (3.1.9)
|
40
40
|
byebug (11.1.3)
|
41
41
|
committee (5.0.0)
|
42
42
|
json_schema (~> 0.14, >= 0.14.3)
|
43
43
|
openapi_parser (~> 1.0)
|
44
44
|
rack (>= 1.5)
|
45
|
-
commonmarker (1.1.5)
|
46
|
-
rb_sys (~> 0.9)
|
47
45
|
concurrent-ruby (1.3.4)
|
48
46
|
connection_pool (2.4.1)
|
49
47
|
deprecation (1.1.0)
|
@@ -51,14 +49,15 @@ GEM
|
|
51
49
|
diff-lcs (1.5.1)
|
52
50
|
docile (1.4.1)
|
53
51
|
drb (2.2.1)
|
54
|
-
dry-core (1.0
|
52
|
+
dry-core (1.1.0)
|
55
53
|
concurrent-ruby (~> 1.0)
|
56
54
|
logger
|
57
55
|
zeitwerk (~> 2.6)
|
58
|
-
dry-inflector (1.
|
59
|
-
dry-logic (1.
|
56
|
+
dry-inflector (1.2.0)
|
57
|
+
dry-logic (1.6.0)
|
58
|
+
bigdecimal
|
60
59
|
concurrent-ruby (~> 1.0)
|
61
|
-
dry-core (~> 1.
|
60
|
+
dry-core (~> 1.1)
|
62
61
|
zeitwerk (~> 2.6)
|
63
62
|
dry-struct (1.6.0)
|
64
63
|
dry-core (~> 1.0, < 2)
|
@@ -72,27 +71,25 @@ GEM
|
|
72
71
|
dry-inflector (~> 1.0)
|
73
72
|
dry-logic (~> 1.4)
|
74
73
|
zeitwerk (~> 2.6)
|
75
|
-
edtf (3.
|
76
|
-
activesupport (>= 3.0, <
|
74
|
+
edtf (3.2.0)
|
75
|
+
activesupport (>= 3.0, < 9.0)
|
77
76
|
equivalent-xml (0.6.0)
|
78
77
|
nokogiri (>= 1.4.3)
|
79
78
|
i18n (1.14.6)
|
80
79
|
concurrent-ruby (~> 1.0)
|
81
80
|
ice_nine (0.11.2)
|
82
|
-
json (2.
|
81
|
+
json (2.9.1)
|
83
82
|
json_schema (0.21.0)
|
84
83
|
jsonpath (1.1.5)
|
85
84
|
multi_json
|
86
85
|
language_server-protocol (3.17.0.3)
|
87
|
-
logger (1.6.
|
86
|
+
logger (1.6.4)
|
88
87
|
mini_portile2 (2.8.8)
|
89
|
-
minitest (5.25.
|
88
|
+
minitest (5.25.4)
|
90
89
|
multi_json (1.15.0)
|
91
|
-
nokogiri (1.
|
90
|
+
nokogiri (1.18.1)
|
92
91
|
mini_portile2 (~> 2.8.2)
|
93
92
|
racc (~> 1.4)
|
94
|
-
openapi3_parser (0.10.0)
|
95
|
-
commonmarker (>= 1.0)
|
96
93
|
openapi_parser (1.0.0)
|
97
94
|
optimist (3.2.0)
|
98
95
|
parallel (1.26.3)
|
@@ -105,8 +102,7 @@ GEM
|
|
105
102
|
rack (3.1.8)
|
106
103
|
rainbow (3.1.1)
|
107
104
|
rake (13.2.1)
|
108
|
-
|
109
|
-
regexp_parser (2.9.2)
|
105
|
+
regexp_parser (2.10.0)
|
110
106
|
rspec (3.13.0)
|
111
107
|
rspec-core (~> 3.13.0)
|
112
108
|
rspec-expectations (~> 3.13.0)
|
@@ -119,20 +115,20 @@ GEM
|
|
119
115
|
rspec-mocks (3.13.2)
|
120
116
|
diff-lcs (>= 1.2.0, < 2.0)
|
121
117
|
rspec-support (~> 3.13.0)
|
122
|
-
rspec-support (3.13.
|
118
|
+
rspec-support (3.13.2)
|
123
119
|
rspec_junit_formatter (0.6.0)
|
124
120
|
rspec-core (>= 2, < 4, != 2.12.0)
|
125
|
-
rubocop (1.
|
121
|
+
rubocop (1.69.2)
|
126
122
|
json (~> 2.3)
|
127
123
|
language_server-protocol (>= 3.17.0)
|
128
124
|
parallel (~> 1.10)
|
129
125
|
parser (>= 3.3.0.2)
|
130
126
|
rainbow (>= 2.2.2, < 4.0)
|
131
|
-
regexp_parser (>= 2.
|
132
|
-
rubocop-ast (>= 1.
|
127
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
128
|
+
rubocop-ast (>= 1.36.2, < 2.0)
|
133
129
|
ruby-progressbar (~> 1.7)
|
134
|
-
unicode-display_width (>= 2.4.0, <
|
135
|
-
rubocop-ast (1.
|
130
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
131
|
+
rubocop-ast (1.37.0)
|
136
132
|
parser (>= 3.3.1.0)
|
137
133
|
rubocop-capybara (2.21.0)
|
138
134
|
rubocop (~> 1.41)
|
@@ -148,7 +144,7 @@ GEM
|
|
148
144
|
rubocop-rspec_rails (2.29.1)
|
149
145
|
rubocop (~> 1.61)
|
150
146
|
ruby-progressbar (1.13.0)
|
151
|
-
securerandom (0.
|
147
|
+
securerandom (0.4.1)
|
152
148
|
simplecov (0.22.0)
|
153
149
|
docile (~> 1.1)
|
154
150
|
simplecov-html (~> 0.11)
|
@@ -162,7 +158,10 @@ GEM
|
|
162
158
|
thor (1.3.2)
|
163
159
|
tzinfo (2.0.6)
|
164
160
|
concurrent-ruby (~> 1.0)
|
165
|
-
unicode-display_width (
|
161
|
+
unicode-display_width (3.1.3)
|
162
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
163
|
+
unicode-emoji (4.0.4)
|
164
|
+
uri (1.0.2)
|
166
165
|
zeitwerk (2.7.1)
|
167
166
|
|
168
167
|
PLATFORMS
|
data/cocina-models.gemspec
CHANGED
@@ -33,7 +33,6 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_dependency 'i18n' # for validating BCP 47 language tags, according to RFC 4646
|
34
34
|
spec.add_dependency 'jsonpath' # used for date/time validation
|
35
35
|
spec.add_dependency 'nokogiri'
|
36
|
-
spec.add_dependency 'openapi3_parser' # Parsing openapi doc
|
37
36
|
# Match these version requirements to what committee wants,
|
38
37
|
# so that our client (non-committee) users have the same dependencies.
|
39
38
|
spec.add_dependency 'openapi_parser', '~> 1.0'
|
@@ -96,7 +96,9 @@ module Cocina
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def schemas
|
99
|
-
@schemas ||=
|
99
|
+
@schemas ||= OpenAPIParser.parse(YAML.load_file(options[:openapi]), strict_reference_validation: true)
|
100
|
+
.find_object('#/components')
|
101
|
+
.schemas
|
100
102
|
end
|
101
103
|
|
102
104
|
def schema_for(schema_name, lite: false)
|
@@ -71,7 +71,7 @@ module Cocina
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def validatable?
|
74
|
-
!schema_doc.
|
74
|
+
!schema_doc.root.paths.path["/validate/#{schema_doc.name}"].nil? && !lite
|
75
75
|
end
|
76
76
|
|
77
77
|
def properties
|
@@ -118,13 +118,13 @@ module Cocina
|
|
118
118
|
end
|
119
119
|
|
120
120
|
def schema_properties_for(doc)
|
121
|
-
doc.properties.map do |key, properties_doc|
|
121
|
+
Array(doc.properties).map do |key, properties_doc|
|
122
122
|
clazz = property_class_for(properties_doc)
|
123
123
|
clazz.new(properties_doc,
|
124
124
|
key: key,
|
125
|
-
required: doc.
|
125
|
+
required: doc.required&.include?(key),
|
126
126
|
relaxed: lite && clazz != SchemaValue,
|
127
|
-
nullable: properties_doc.nullable
|
127
|
+
nullable: properties_doc.nullable,
|
128
128
|
parent: self,
|
129
129
|
schemas: schemas)
|
130
130
|
end
|
@@ -4,12 +4,17 @@ module Cocina
|
|
4
4
|
module Generator
|
5
5
|
# Class for generating from an openapi array
|
6
6
|
class SchemaArray < SchemaBase
|
7
|
+
GENERIC_ITEMS_NAME = 'items'
|
8
|
+
|
7
9
|
def generate
|
8
10
|
"attribute :#{name.camelize(:lower)}, Types::Strict::Array.of(#{array_of_type}).default([].freeze)"
|
9
11
|
end
|
10
12
|
|
11
13
|
def array_of_type
|
12
|
-
schema_doc.items.name
|
14
|
+
items_name = schema_doc.items.name
|
15
|
+
return items_name unless items_name == GENERIC_ITEMS_NAME
|
16
|
+
|
17
|
+
dry_datatype(schema_doc.items)
|
13
18
|
end
|
14
19
|
end
|
15
20
|
end
|
@@ -51,7 +51,7 @@ module Cocina
|
|
51
51
|
}.freeze
|
52
52
|
|
53
53
|
def vocabs
|
54
|
-
type_properties = schemas.values.map { |schema| schema.properties['type'
|
54
|
+
type_properties = schemas.values.map { |schema| schema.properties&.[]('type') }.compact
|
55
55
|
type_properties.map(&:enum).flat_map(&:to_a)
|
56
56
|
.filter { |vocab| vocab.start_with?(BASE) }
|
57
57
|
.uniq
|
data/lib/cocina/models.rb
CHANGED
@@ -7,7 +7,6 @@ require 'dry-types'
|
|
7
7
|
require 'json'
|
8
8
|
require 'yaml'
|
9
9
|
require 'openapi_parser'
|
10
|
-
require 'openapi3_parser'
|
11
10
|
require 'active_support'
|
12
11
|
require 'active_support/core_ext'
|
13
12
|
require 'thor'
|
@@ -40,6 +39,17 @@ loader.ignore("#{__dir__}/rspec.rb")
|
|
40
39
|
loader.ignore("#{__dir__}/rspec")
|
41
40
|
loader.setup
|
42
41
|
|
42
|
+
module OpenAPIParser
|
43
|
+
module Schemas
|
44
|
+
# Patch OpenAPIParser::Schemas::Schema so it can tell us its name, the way Openapi3Parser schemas do.
|
45
|
+
class Schema
|
46
|
+
def name
|
47
|
+
object_reference.split('/').last
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
43
53
|
module Cocina
|
44
54
|
# Provides Ruby objects for the repository and serializing them to/from JSON.
|
45
55
|
module Models
|
@@ -191,7 +201,10 @@ module Cocina
|
|
191
201
|
|
192
202
|
def self.druid_regex
|
193
203
|
@druid_regex ||= begin
|
194
|
-
str =
|
204
|
+
str = OpenAPIParser.parse(YAML.load_file('openapi.yml'), strict_reference_validation: true)
|
205
|
+
.find_object('#/components')
|
206
|
+
.schemas['Druid']
|
207
|
+
.pattern
|
195
208
|
Regexp.new(str)
|
196
209
|
end
|
197
210
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocina-models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.99.
|
4
|
+
version: 0.99.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -136,20 +136,6 @@ dependencies:
|
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: openapi3_parser
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - ">="
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '0'
|
146
|
-
type: :runtime
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - ">="
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '0'
|
153
139
|
- !ruby/object:Gem::Dependency
|
154
140
|
name: openapi_parser
|
155
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -550,7 +536,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
550
536
|
- !ruby/object:Gem::Version
|
551
537
|
version: '0'
|
552
538
|
requirements: []
|
553
|
-
rubygems_version: 3.5.
|
539
|
+
rubygems_version: 3.5.22
|
554
540
|
signing_key:
|
555
541
|
specification_version: 4
|
556
542
|
summary: Data models for the SDR
|