cocina-models 0.99.2 → 0.99.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 359f5d4b2c40c778c96778e6595b629d62713b78ea933da12227cf6ece72d9c1
4
- data.tar.gz: 8492b6d7101cae1c53c4854fa390f7a1d3812a87328b364f0ebb9466edb12d4b
3
+ metadata.gz: 7084352ad6644805e589d4326dc33d8fa24bf552e2477388f214a631787a6c1c
4
+ data.tar.gz: 9f79866b2045957d92b106951c56d1b9921c5f73e0c402cace570bfc5b1d1b8b
5
5
  SHA512:
6
- metadata.gz: 424c7c15cb8ecd2e0831ce12c0fadf7bc40e99603213ff337fbd35a14252f58f33a248e1954eed55a1be253ee77be9f411517cb89537b9edc19c4d00941e0639
7
- data.tar.gz: d7a01272dfad0e8dc7660af2db1ac9e50c784d91d870a0af5c71c0a02463dd7b4bc49b406e8f79725e1fe5294c6887b8a711dae5f00b233d58fc3f6c0dc61fe3
6
+ metadata.gz: 10d995ae9c4e178cab0217cda005fd017f94c07f46430e9e0553adbcc58f143602b7cf8c12c180c3d1f571be44f1acb27f045360a3dc0615158c3b794e4b1b5d
7
+ data.tar.gz: 172a116805b32a6ee40a1a14fde6e4f87b95359e59d1ee0604c0205bb33b19e3ff7fe20ce262742803b88e80794055c2aaeaa947767cb10cc6bde6ab8ba03c7c
data/Gemfile.lock CHANGED
@@ -1,9 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cocina-models (0.99.2)
4
+ cocina-models (0.99.3)
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,8 +42,6 @@ GEM
44
42
  json_schema (~> 0.14, >= 0.14.3)
45
43
  openapi_parser (~> 1.0)
46
44
  rack (>= 1.5)
47
- commonmarker (2.0.1)
48
- rb_sys (~> 0.9)
49
45
  concurrent-ruby (1.3.4)
50
46
  connection_pool (2.4.1)
51
47
  deprecation (1.1.0)
@@ -53,14 +49,15 @@ GEM
53
49
  diff-lcs (1.5.1)
54
50
  docile (1.4.1)
55
51
  drb (2.2.1)
56
- dry-core (1.0.2)
52
+ dry-core (1.1.0)
57
53
  concurrent-ruby (~> 1.0)
58
54
  logger
59
55
  zeitwerk (~> 2.6)
60
- dry-inflector (1.1.0)
61
- dry-logic (1.5.0)
56
+ dry-inflector (1.2.0)
57
+ dry-logic (1.6.0)
58
+ bigdecimal
62
59
  concurrent-ruby (~> 1.0)
63
- dry-core (~> 1.0, < 2)
60
+ dry-core (~> 1.1)
64
61
  zeitwerk (~> 2.6)
65
62
  dry-struct (1.6.0)
66
63
  dry-core (~> 1.0, < 2)
@@ -93,8 +90,6 @@ GEM
93
90
  nokogiri (1.18.1)
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)
@@ -107,7 +102,6 @@ GEM
107
102
  rack (3.1.8)
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)
@@ -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'
@@ -96,7 +96,9 @@ module Cocina
96
96
  end
97
97
 
98
98
  def schemas
99
- @schemas ||= Openapi3Parser.load_file(options[:openapi]).components.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.node_context.document.paths["/validate/#{schema_doc.name}"].nil? && !lite
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.requires?(key),
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 || dry_datatype(schema_doc.items)
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
@@ -50,7 +50,7 @@ module Cocina
50
50
  end
51
51
 
52
52
  def deprecation
53
- return '' unless schema_doc.deprecated?
53
+ return '' unless schema_doc.deprecated
54
54
 
55
55
  "# DEPRECATED\n"
56
56
  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'] }.compact
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- VERSION = '0.99.2'
5
+ VERSION = '0.99.3'
6
6
  end
7
7
  end
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 = Openapi3Parser.load_file('openapi.yml').components.schemas['Druid'].pattern
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.2
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: 2024-12-30 00:00:00.000000000 Z
11
+ date: 2025-01-08 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
@@ -564,7 +536,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
564
536
  - !ruby/object:Gem::Version
565
537
  version: '0'
566
538
  requirements: []
567
- rubygems_version: 3.5.16
539
+ rubygems_version: 3.5.22
568
540
  signing_key:
569
541
  specification_version: 4
570
542
  summary: Data models for the SDR