cocina-models 0.99.2 → 0.99.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +3 -1
- data/.codecov.yml +4 -0
- data/Gemfile.lock +23 -29
- data/README.md +1 -2
- data/cocina-models.gemspec +0 -2
- data/description_types.yml +2 -0
- 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 +4 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41bd326d5fc785d050467a40c155db810ff7b9d639d314654ccab38d4496eb4f
|
4
|
+
data.tar.gz: 7af9ccf5082bb028c3af2b7a11e3a1bffc60e17d79d4ef7c296497c3fc3f8723
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f30cf1b9d9ebbbe8e98bcc489248841689518badbd047ba5647115d706a9c7716ed596dee81ebc8579843f89b2ffa513e98e2b82ca8e4d5d45781bbdc5f96574
|
7
|
+
data.tar.gz: 76d24ee0f27114027027cefaff3a2ff4ddc96b580da7979c873c6bce8a7d3f881b0c71515ae74dde98957136fa298feec2aab9f978cf0c9b128f5afc38e06c9a
|
data/.circleci/config.yml
CHANGED
data/.codecov.yml
ADDED
data/Gemfile.lock
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cocina-models (0.99.
|
4
|
+
cocina-models (0.99.4)
|
5
5
|
activesupport
|
6
|
-
commonmarker (= 2.0.1)
|
7
6
|
deprecation
|
8
7
|
dry-struct (~> 1.0)
|
9
8
|
dry-types (~> 1.1)
|
@@ -12,7 +11,6 @@ PATH
|
|
12
11
|
i18n
|
13
12
|
jsonpath
|
14
13
|
nokogiri
|
15
|
-
openapi3_parser
|
16
14
|
openapi_parser (~> 1.0)
|
17
15
|
super_diff
|
18
16
|
thor
|
@@ -44,30 +42,29 @@ GEM
|
|
44
42
|
json_schema (~> 0.14, >= 0.14.3)
|
45
43
|
openapi_parser (~> 1.0)
|
46
44
|
rack (>= 1.5)
|
47
|
-
|
48
|
-
|
49
|
-
concurrent-ruby (1.3.4)
|
50
|
-
connection_pool (2.4.1)
|
45
|
+
concurrent-ruby (1.3.5)
|
46
|
+
connection_pool (2.5.0)
|
51
47
|
deprecation (1.1.0)
|
52
48
|
activesupport
|
53
49
|
diff-lcs (1.5.1)
|
54
50
|
docile (1.4.1)
|
55
51
|
drb (2.2.1)
|
56
|
-
dry-core (1.0
|
52
|
+
dry-core (1.1.0)
|
57
53
|
concurrent-ruby (~> 1.0)
|
58
54
|
logger
|
59
55
|
zeitwerk (~> 2.6)
|
60
|
-
dry-inflector (1.
|
61
|
-
dry-logic (1.
|
56
|
+
dry-inflector (1.2.0)
|
57
|
+
dry-logic (1.6.0)
|
58
|
+
bigdecimal
|
62
59
|
concurrent-ruby (~> 1.0)
|
63
|
-
dry-core (~> 1.
|
60
|
+
dry-core (~> 1.1)
|
64
61
|
zeitwerk (~> 2.6)
|
65
|
-
dry-struct (1.
|
66
|
-
dry-core (~> 1.
|
67
|
-
dry-types (
|
62
|
+
dry-struct (1.7.1)
|
63
|
+
dry-core (~> 1.1)
|
64
|
+
dry-types (~> 1.8, >= 1.8.2)
|
68
65
|
ice_nine (~> 0.11)
|
69
66
|
zeitwerk (~> 2.6)
|
70
|
-
dry-types (1.
|
67
|
+
dry-types (1.8.2)
|
71
68
|
bigdecimal (~> 3.0)
|
72
69
|
concurrent-ruby (~> 1.0)
|
73
70
|
dry-core (~> 1.0)
|
@@ -78,36 +75,33 @@ GEM
|
|
78
75
|
activesupport (>= 3.0, < 9.0)
|
79
76
|
equivalent-xml (0.6.0)
|
80
77
|
nokogiri (>= 1.4.3)
|
81
|
-
i18n (1.14.
|
78
|
+
i18n (1.14.7)
|
82
79
|
concurrent-ruby (~> 1.0)
|
83
80
|
ice_nine (0.11.2)
|
84
81
|
json (2.9.1)
|
85
82
|
json_schema (0.21.0)
|
86
83
|
jsonpath (1.1.5)
|
87
84
|
multi_json
|
88
|
-
language_server-protocol (3.17.0.
|
89
|
-
logger (1.6.
|
85
|
+
language_server-protocol (3.17.0.4)
|
86
|
+
logger (1.6.5)
|
90
87
|
mini_portile2 (2.8.8)
|
91
88
|
minitest (5.25.4)
|
92
89
|
multi_json (1.15.0)
|
93
|
-
nokogiri (1.18.
|
90
|
+
nokogiri (1.18.2)
|
94
91
|
mini_portile2 (~> 2.8.2)
|
95
92
|
racc (~> 1.4)
|
96
|
-
openapi3_parser (0.10.0)
|
97
|
-
commonmarker (>= 1.0)
|
98
93
|
openapi_parser (1.0.0)
|
99
94
|
optimist (3.2.0)
|
100
95
|
parallel (1.26.3)
|
101
|
-
parser (3.3.
|
96
|
+
parser (3.3.7.0)
|
102
97
|
ast (~> 2.4.1)
|
103
98
|
racc
|
104
99
|
patience_diff (1.2.0)
|
105
100
|
optimist (~> 3.0)
|
106
101
|
racc (1.8.1)
|
107
|
-
rack (3.1.
|
102
|
+
rack (3.1.9)
|
108
103
|
rainbow (3.1.1)
|
109
104
|
rake (13.2.1)
|
110
|
-
rb_sys (0.9.105)
|
111
105
|
regexp_parser (2.10.0)
|
112
106
|
rspec (3.13.0)
|
113
107
|
rspec-core (~> 3.13.0)
|
@@ -124,17 +118,17 @@ GEM
|
|
124
118
|
rspec-support (3.13.2)
|
125
119
|
rspec_junit_formatter (0.6.0)
|
126
120
|
rspec-core (>= 2, < 4, != 2.12.0)
|
127
|
-
rubocop (1.
|
121
|
+
rubocop (1.71.1)
|
128
122
|
json (~> 2.3)
|
129
123
|
language_server-protocol (>= 3.17.0)
|
130
124
|
parallel (~> 1.10)
|
131
125
|
parser (>= 3.3.0.2)
|
132
126
|
rainbow (>= 2.2.2, < 4.0)
|
133
127
|
regexp_parser (>= 2.9.3, < 3.0)
|
134
|
-
rubocop-ast (>= 1.
|
128
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
135
129
|
ruby-progressbar (~> 1.7)
|
136
130
|
unicode-display_width (>= 2.4.0, < 4.0)
|
137
|
-
rubocop-ast (1.
|
131
|
+
rubocop-ast (1.38.0)
|
138
132
|
parser (>= 3.3.1.0)
|
139
133
|
rubocop-capybara (2.21.0)
|
140
134
|
rubocop (~> 1.41)
|
@@ -157,14 +151,14 @@ GEM
|
|
157
151
|
simplecov_json_formatter (~> 0.1)
|
158
152
|
simplecov-html (0.13.1)
|
159
153
|
simplecov_json_formatter (0.1.4)
|
160
|
-
super_diff (0.
|
154
|
+
super_diff (0.15.0)
|
161
155
|
attr_extras (>= 6.2.4)
|
162
156
|
diff-lcs
|
163
157
|
patience_diff
|
164
158
|
thor (1.3.2)
|
165
159
|
tzinfo (2.0.6)
|
166
160
|
concurrent-ruby (~> 1.0)
|
167
|
-
unicode-display_width (3.1.
|
161
|
+
unicode-display_width (3.1.4)
|
168
162
|
unicode-emoji (~> 4.0, >= 4.0.4)
|
169
163
|
unicode-emoji (4.0.4)
|
170
164
|
uri (1.0.2)
|
data/README.md
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
[![CircleCI](https://circleci.com/gh/sul-dlss/cocina-models.svg?style=svg)](https://circleci.com/gh/sul-dlss/cocina-models)
|
2
|
-
[![Test Coverage](https://
|
3
|
-
[![Maintainability](https://api.codeclimate.com/v1/badges/472273351516ac01dce1/maintainability)](https://codeclimate.com/github/sul-dlss/cocina-models/maintainability)
|
2
|
+
[![Test Coverage](https://codecov.io/github/sul-dlss/cocina-models/graph/badge.svg?token=FG1SRYCME2)](https://codecov.io/github/sul-dlss/cocina-models)
|
4
3
|
[![Gem Version](https://badge.fury.io/rb/cocina-models.svg)](https://badge.fury.io/rb/cocina-models)
|
5
4
|
[![OpenAPI Validator](http://validator.swagger.io/validator?url=https://raw.githubusercontent.com/sul-dlss/cocina-models/main/openapi.yml)](http://validator.swagger.io/validator/debug?url=https://raw.githubusercontent.com/sul-dlss/cocina-models/main/openapi.yml)
|
6
5
|
|
data/cocina-models.gemspec
CHANGED
@@ -25,7 +25,6 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.required_ruby_version = '>= 3.0'
|
26
26
|
|
27
27
|
spec.add_dependency 'activesupport'
|
28
|
-
spec.add_dependency 'commonmarker', '2.0.1' # There is a breaking change in 2.0.2 with openapi3_parser
|
29
28
|
spec.add_dependency 'deprecation'
|
30
29
|
spec.add_dependency 'dry-struct', '~> 1.0'
|
31
30
|
spec.add_dependency 'dry-types', '~> 1.1'
|
@@ -34,7 +33,6 @@ Gem::Specification.new do |spec|
|
|
34
33
|
spec.add_dependency 'i18n' # for validating BCP 47 language tags, according to RFC 4646
|
35
34
|
spec.add_dependency 'jsonpath' # used for date/time validation
|
36
35
|
spec.add_dependency 'nokogiri'
|
37
|
-
spec.add_dependency 'openapi3_parser' # Parsing openapi doc
|
38
36
|
# Match these version requirements to what committee wants,
|
39
37
|
# so that our client (non-committee) users have the same dependencies.
|
40
38
|
spec.add_dependency 'openapi_parser', '~> 1.0'
|
data/description_types.yml
CHANGED
@@ -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.4
|
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-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: commonmarker
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 2.0.1
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - '='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 2.0.1
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: deprecation
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,20 +136,6 @@ dependencies:
|
|
150
136
|
- - ">="
|
151
137
|
- !ruby/object:Gem::Version
|
152
138
|
version: '0'
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: openapi3_parser
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - ">="
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '0'
|
160
|
-
type: :runtime
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - ">="
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: '0'
|
167
139
|
- !ruby/object:Gem::Dependency
|
168
140
|
name: openapi_parser
|
169
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -341,6 +313,7 @@ extensions: []
|
|
341
313
|
extra_rdoc_files: []
|
342
314
|
files:
|
343
315
|
- ".circleci/config.yml"
|
316
|
+
- ".codecov.yml"
|
344
317
|
- ".github/pull_request_template.md"
|
345
318
|
- ".gitignore"
|
346
319
|
- ".rspec"
|
@@ -564,7 +537,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
564
537
|
- !ruby/object:Gem::Version
|
565
538
|
version: '0'
|
566
539
|
requirements: []
|
567
|
-
rubygems_version: 3.5.
|
540
|
+
rubygems_version: 3.5.11
|
568
541
|
signing_key:
|
569
542
|
specification_version: 4
|
570
543
|
summary: Data models for the SDR
|