cocina-models 0.86.0 → 0.87.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/.rubocop.yml +52 -2
- data/.rubocop_todo.yml +49 -15
- data/Gemfile.lock +56 -52
- data/lib/cocina/generator/datatype.rb +1 -1
- data/lib/cocina/generator/generator.rb +19 -12
- data/lib/cocina/generator/schema.rb +4 -2
- data/lib/cocina/generator/schema_array.rb +1 -1
- data/lib/cocina/generator/schema_base.rb +36 -16
- data/lib/cocina/generator/schema_value.rb +2 -2
- data/lib/cocina/generator/union_type.rb +24 -0
- data/lib/cocina/models/admin_policy.rb +2 -2
- data/lib/cocina/models/admin_policy_administrative.rb +2 -2
- data/lib/cocina/models/admin_policy_with_metadata.rb +2 -2
- data/lib/cocina/models/administrative.rb +1 -1
- data/lib/cocina/models/barcode.rb +7 -0
- data/lib/cocina/models/business_barcode.rb +1 -1
- data/lib/cocina/models/catalog_link.rb +1 -10
- data/lib/cocina/models/catkey_barcode.rb +1 -1
- data/lib/cocina/models/cocina_version.rb +1 -1
- data/lib/cocina/models/collection.rb +2 -2
- data/lib/cocina/models/collection_identification.rb +1 -1
- data/lib/cocina/models/collection_with_metadata.rb +2 -2
- data/lib/cocina/models/created_in_folio_identifier.rb +9 -0
- data/lib/cocina/models/description.rb +2 -2
- data/lib/cocina/models/doi.rb +7 -0
- data/lib/cocina/models/doi_exceptions.rb +1 -1
- data/lib/cocina/models/doi_pattern.rb +1 -1
- data/lib/cocina/models/dro.rb +2 -2
- data/lib/cocina/models/dro_with_metadata.rb +2 -2
- data/lib/cocina/models/druid.rb +1 -1
- data/lib/cocina/models/folio_catalog_link.rb +16 -0
- data/lib/cocina/models/identification.rb +3 -3
- data/lib/cocina/models/lane_medical_barcode.rb +1 -1
- data/lib/cocina/models/mapping/from_mods/identifier.rb +1 -1
- data/lib/cocina/models/mapping/from_mods/identifier_builder.rb +1 -1
- data/lib/cocina/models/mapping/normalizers/mods_normalizer.rb +2 -2
- data/lib/cocina/models/migrated_from_symphony_identifier.rb +9 -0
- data/lib/cocina/models/migrated_from_voyager_identifier.rb +9 -0
- data/lib/cocina/models/purl.rb +1 -1
- data/lib/cocina/models/related_resource.rb +2 -2
- data/lib/cocina/models/request_admin_policy.rb +1 -1
- data/lib/cocina/models/request_administrative.rb +1 -1
- data/lib/cocina/models/request_collection.rb +1 -1
- data/lib/cocina/models/request_dro.rb +1 -1
- data/lib/cocina/models/request_identification.rb +2 -2
- data/lib/cocina/models/source_id.rb +1 -1
- data/lib/cocina/models/standard_barcode.rb +1 -1
- data/lib/cocina/models/symphony_catalog_link.rb +17 -0
- data/lib/cocina/models/version.rb +1 -1
- data/lib/cocina/models.rb +7 -3
- data/openapi.yml +366 -317
- metadata +14 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 272a5d8e2b026dc773452921e549241338c6c8cda4f21b3ae6da3b7511f7cec6
|
4
|
+
data.tar.gz: f3471e9e52d279444b8ef4bac802d116c71b23d5d937363c084f322204b9ce1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a44093101a258a2d88b83f82955dc81c81624419baf0cf55892eb976e04ac770ddf34d8c60e5649522c1c4b14687aed0715b14b92ede2a8858af839ff2bb6b8e
|
7
|
+
data.tar.gz: a95e82570f152ac1498d072c0ee7320c0da738a45b80949cb098c722838d9495cd4e6c6e74aa78cf40ba6f3b88ea846779cc2adbddd42d161929ae8bd79a7856
|
data/.circleci/config.yml
CHANGED
data/.rubocop.yml
CHANGED
@@ -20,6 +20,10 @@ Layout/LineLength:
|
|
20
20
|
Layout/SpaceAroundMethodCallOperator:
|
21
21
|
Enabled: true
|
22
22
|
|
23
|
+
# This cop throws an error in 1.37.1
|
24
|
+
Layout/SpaceInsideHashLiteralBraces:
|
25
|
+
Enabled: false
|
26
|
+
|
23
27
|
# ----- Lint ------
|
24
28
|
|
25
29
|
Lint/BinaryOperatorWithIdenticalOperands:
|
@@ -331,7 +335,7 @@ Style/MapCompactWithConditionalBlock: # new in 1.30
|
|
331
335
|
Enabled: true
|
332
336
|
RSpec/ChangeByZero: # new in 2.11.0
|
333
337
|
Enabled: true
|
334
|
-
|
338
|
+
Capybara/SpecificMatcher: # new in 2.12
|
335
339
|
Enabled: false
|
336
340
|
RSpec/Rails/HaveHttpStatus: # new in 2.12
|
337
341
|
Enabled: false
|
@@ -340,5 +344,51 @@ RSpec/ClassCheck: # new in 2.13
|
|
340
344
|
Enabled: true
|
341
345
|
RSpec/NoExpectationExample: # new in 2.13
|
342
346
|
Enabled: true
|
343
|
-
|
347
|
+
Capybara/SpecificFinders: # new in 2.13
|
348
|
+
Enabled: true
|
349
|
+
Gemspec/DevelopmentDependencies: # new in 1.44
|
350
|
+
Enabled: true
|
351
|
+
Lint/DuplicateMagicComment: # new in 1.37
|
352
|
+
Enabled: true
|
353
|
+
Lint/UselessRescue: # new in 1.43
|
354
|
+
Enabled: true
|
355
|
+
Style/ArrayIntersect: # new in 1.40
|
356
|
+
Enabled: true
|
357
|
+
Style/ComparableClamp: # new in 1.44
|
358
|
+
Enabled: true
|
359
|
+
Style/ConcatArrayLiterals: # new in 1.41
|
360
|
+
Enabled: true
|
361
|
+
Style/MapToSet: # new in 1.42
|
362
|
+
Enabled: true
|
363
|
+
Style/MinMaxComparison: # new in 1.42
|
364
|
+
Enabled: true
|
365
|
+
Style/OperatorMethodCall: # new in 1.37
|
366
|
+
Enabled: true
|
367
|
+
Style/RedundantConstantBase: # new in 1.40
|
368
|
+
Enabled: true
|
369
|
+
Style/RedundantDoubleSplatHashBraces: # new in 1.41
|
370
|
+
Enabled: true
|
371
|
+
Style/RedundantEach: # new in 1.38
|
372
|
+
Enabled: true
|
373
|
+
Style/RedundantStringEscape: # new in 1.37
|
374
|
+
Enabled: true
|
375
|
+
Capybara/MatchStyle: # new in <<next>>
|
376
|
+
Enabled: true
|
377
|
+
Capybara/NegationMatcher: # new in 2.14
|
378
|
+
Enabled: true
|
379
|
+
Capybara/SpecificActions: # new in 2.14
|
380
|
+
Enabled: true
|
381
|
+
RSpec/DuplicatedMetadata: # new in 2.16
|
382
|
+
Enabled: true
|
383
|
+
RSpec/PendingWithoutReason: # new in 2.16
|
384
|
+
Enabled: true
|
385
|
+
RSpec/SortMetadata: # new in 2.14
|
386
|
+
Enabled: true
|
387
|
+
RSpec/FactoryBot/ConsistentParenthesesStyle: # new in 2.14
|
388
|
+
Enabled: true
|
389
|
+
RSpec/FactoryBot/FactoryNameStyle: # new in 2.16
|
390
|
+
Enabled: true
|
391
|
+
RSpec/Rails/InferredSpecType: # new in 2.14
|
392
|
+
Enabled: true
|
393
|
+
RSpec/Rails/MinitestAssertions: # new in 2.17
|
344
394
|
Enabled: true
|
data/.rubocop_todo.yml
CHANGED
@@ -1,17 +1,27 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config --auto-gen-only-exclude`
|
3
|
-
# on
|
3
|
+
# on 2023-02-07 01:43:53 UTC using RuboCop version 1.44.1.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
+
# Offense count: 3
|
10
|
+
# Configuration parameters: EnforcedStyle, AllowedGems, Include.
|
11
|
+
# SupportedStyles: Gemfile, gems.rb, gemspec
|
12
|
+
# AllowedGems: bundler
|
13
|
+
# Include: **/*.gemspec, **/Gemfile, **/gems.rb
|
14
|
+
Gemspec/DevelopmentDependencies:
|
15
|
+
Exclude:
|
16
|
+
- 'cocina-models.gemspec'
|
17
|
+
|
9
18
|
# Offense count: 1
|
10
19
|
Lint/NoReturnInBeginEndBlocks:
|
11
20
|
Exclude:
|
12
21
|
- 'lib/cocina/models/mapping/to_mods/description.rb'
|
13
22
|
|
14
|
-
# Offense count:
|
23
|
+
# Offense count: 2
|
24
|
+
# This cop supports safe autocorrection (--autocorrect).
|
15
25
|
# Configuration parameters: AllowedMethods.
|
16
26
|
# AllowedMethods: present?, blank?, presence, try, try!, in?
|
17
27
|
Lint/SafeNavigationChain:
|
@@ -19,7 +29,7 @@ Lint/SafeNavigationChain:
|
|
19
29
|
- 'lib/cocina/generator/schema_base.rb'
|
20
30
|
|
21
31
|
# Offense count: 13
|
22
|
-
# This cop supports safe
|
32
|
+
# This cop supports safe autocorrection (--autocorrect).
|
23
33
|
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
|
24
34
|
Lint/UnusedMethodArgument:
|
25
35
|
Exclude:
|
@@ -35,16 +45,30 @@ Lint/UnusedMethodArgument:
|
|
35
45
|
- 'lib/cocina/models/mapping/from_mods/subject.rb'
|
36
46
|
- 'lib/cocina/models/mapping/to_mods/event.rb'
|
37
47
|
|
38
|
-
# Offense count:
|
39
|
-
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
|
48
|
+
# Offense count: 95
|
49
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
|
40
50
|
Metrics/AbcSize:
|
41
51
|
Max: 40
|
42
52
|
|
43
|
-
# Offense count:
|
44
|
-
# Configuration parameters: IgnoredMethods.
|
53
|
+
# Offense count: 43
|
54
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
|
45
55
|
Metrics/CyclomaticComplexity:
|
46
56
|
Max: 12
|
47
57
|
|
58
|
+
# Offense count: 1
|
59
|
+
# Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
|
60
|
+
Metrics/MethodLength:
|
61
|
+
Exclude:
|
62
|
+
- 'spec/cocina/models/file_access_spec.rb'
|
63
|
+
- 'spec/cocina/models/dro_access_spec.rb'
|
64
|
+
- 'lib/cocina/rspec/factories.rb'
|
65
|
+
- 'lib/cocina/models/mapping/to_mods/*'
|
66
|
+
- 'lib/cocina/models/mapping/from_mods/*'
|
67
|
+
- 'lib/cocina/models/mapping/normalizers/mods/origin_info_normalizer.rb'
|
68
|
+
- 'lib/cocina/models/mapping/normalizers/mods/subject_normalizer.rb'
|
69
|
+
- 'lib/cocina/models/mapping/normalizers/mods_normalizer.rb'
|
70
|
+
- 'lib/cocina/generator/schema_base.rb'
|
71
|
+
|
48
72
|
# Offense count: 1
|
49
73
|
# Configuration parameters: Max, CountKeywordArgs, MaxOptionalParameters.
|
50
74
|
Metrics/ParameterLists:
|
@@ -62,20 +86,30 @@ RSpec/ExampleLength:
|
|
62
86
|
Max: 128
|
63
87
|
|
64
88
|
# Offense count: 10
|
65
|
-
# Configuration parameters: Max.
|
89
|
+
# Configuration parameters: Max, AllowedGroups.
|
66
90
|
RSpec/NestedGroups:
|
67
91
|
Exclude:
|
68
92
|
- 'spec/cocina/models/mapping/normalizers/mods/origin_info_normalizer_spec.rb'
|
69
93
|
- 'spec/cocina/models/validators/date_time_validator_spec.rb'
|
70
94
|
|
71
|
-
# Offense count:
|
72
|
-
|
73
|
-
Style/GuardClause:
|
95
|
+
# Offense count: 19
|
96
|
+
RSpec/PendingWithoutReason:
|
74
97
|
Exclude:
|
75
|
-
- '
|
98
|
+
- 'spec/cocina/models/mapping/descriptive/mods/name_spec.rb'
|
99
|
+
- 'spec/cocina/models/mapping/descriptive/mods/origin_info_place_spec.rb'
|
100
|
+
- 'spec/cocina/models/mapping/descriptive/mods/physical_description_spec.rb'
|
101
|
+
- 'spec/cocina/models/mapping/descriptive/mods/record_info_spec.rb'
|
102
|
+
- 'spec/cocina/models/mapping/descriptive/mods/subject_classification_spec.rb'
|
103
|
+
- 'spec/cocina/models/mapping/descriptive/mods/subject_genre_spec.rb'
|
104
|
+
- 'spec/cocina/models/mapping/descriptive/mods/subject_geographic_spec.rb'
|
105
|
+
- 'spec/cocina/models/mapping/descriptive/mods/subject_name_spec.rb'
|
106
|
+
- 'spec/cocina/models/mapping/descriptive/mods/subject_spec.rb'
|
107
|
+
- 'spec/cocina/models/mapping/descriptive/mods/subject_title_spec.rb'
|
108
|
+
- 'spec/cocina/models/mapping/descriptive/mods/title_info_spec.rb'
|
109
|
+
- 'spec/cocina/models/mapping/descriptive/mods/type_of_resource_spec.rb'
|
76
110
|
|
77
111
|
# Offense count: 1
|
78
|
-
# This cop supports safe
|
112
|
+
# This cop supports safe autocorrection (--autocorrect).
|
79
113
|
Style/IfUnlessModifier:
|
80
114
|
Exclude:
|
81
115
|
- 'lib/cocina/models/validators/open_api_validator.rb'
|
@@ -88,8 +122,8 @@ Style/MultilineBlockChain:
|
|
88
122
|
- 'lib/cocina/models/mapping/to_mods/form.rb'
|
89
123
|
- 'lib/cocina/models/mapping/to_mods/subject.rb'
|
90
124
|
|
91
|
-
# Offense count:
|
92
|
-
# This cop supports safe
|
125
|
+
# Offense count: 225
|
126
|
+
# This cop supports safe autocorrection (--autocorrect).
|
93
127
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
|
94
128
|
# URISchemes: http, https
|
95
129
|
Layout/LineLength:
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cocina-models (0.
|
4
|
+
cocina-models (0.87.0)
|
5
5
|
activesupport
|
6
6
|
deprecation
|
7
7
|
dry-struct (~> 1.0)
|
@@ -20,57 +20,58 @@ PATH
|
|
20
20
|
GEM
|
21
21
|
remote: https://rubygems.org/
|
22
22
|
specs:
|
23
|
-
activesupport (7.0.4)
|
23
|
+
activesupport (7.0.4.2)
|
24
24
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
25
25
|
i18n (>= 1.6, < 2)
|
26
26
|
minitest (>= 5.1)
|
27
27
|
tzinfo (~> 2.0)
|
28
28
|
ast (2.4.2)
|
29
|
-
attr_extras (
|
29
|
+
attr_extras (7.1.0)
|
30
30
|
byebug (11.1.3)
|
31
|
-
committee (4.
|
31
|
+
committee (4.99.1)
|
32
32
|
json_schema (~> 0.14, >= 0.14.3)
|
33
33
|
openapi_parser (>= 0.11.1, < 1.0)
|
34
34
|
rack (>= 1.5)
|
35
|
-
commonmarker (0.23.
|
36
|
-
concurrent-ruby (1.
|
35
|
+
commonmarker (0.23.8)
|
36
|
+
concurrent-ruby (1.2.0)
|
37
37
|
deprecation (1.1.0)
|
38
38
|
activesupport
|
39
39
|
diff-lcs (1.5.0)
|
40
40
|
docile (1.4.0)
|
41
|
-
dry-
|
41
|
+
dry-core (1.0.0)
|
42
42
|
concurrent-ruby (~> 1.0)
|
43
|
-
|
43
|
+
zeitwerk (~> 2.6)
|
44
|
+
dry-inflector (1.0.0)
|
45
|
+
dry-logic (1.5.0)
|
44
46
|
concurrent-ruby (~> 1.0)
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
dry-core (~> 0
|
49
|
-
|
50
|
-
dry-core (~> 0.5, >= 0.5)
|
51
|
-
dry-types (~> 1.5)
|
47
|
+
dry-core (~> 1.0, < 2)
|
48
|
+
zeitwerk (~> 2.6)
|
49
|
+
dry-struct (1.6.0)
|
50
|
+
dry-core (~> 1.0, < 2)
|
51
|
+
dry-types (>= 1.7, < 2)
|
52
52
|
ice_nine (~> 0.11)
|
53
|
-
|
53
|
+
zeitwerk (~> 2.6)
|
54
|
+
dry-types (1.7.0)
|
54
55
|
concurrent-ruby (~> 1.0)
|
55
|
-
dry-
|
56
|
-
dry-
|
57
|
-
dry-
|
58
|
-
|
59
|
-
edtf (3.1.
|
56
|
+
dry-core (~> 1.0, < 2)
|
57
|
+
dry-inflector (~> 1.0, < 2)
|
58
|
+
dry-logic (>= 1.4, < 2)
|
59
|
+
zeitwerk (~> 2.6)
|
60
|
+
edtf (3.1.1)
|
60
61
|
activesupport (>= 3.0, < 8.0)
|
61
62
|
equivalent-xml (0.6.0)
|
62
63
|
nokogiri (>= 1.4.3)
|
63
64
|
i18n (1.12.0)
|
64
65
|
concurrent-ruby (~> 1.0)
|
65
66
|
ice_nine (0.11.2)
|
66
|
-
json (2.6.
|
67
|
+
json (2.6.3)
|
67
68
|
json_schema (0.21.0)
|
68
69
|
jsonpath (1.1.2)
|
69
70
|
multi_json
|
70
|
-
mini_portile2 (2.8.
|
71
|
-
minitest (5.
|
71
|
+
mini_portile2 (2.8.1)
|
72
|
+
minitest (5.17.0)
|
72
73
|
multi_json (1.15.0)
|
73
|
-
nokogiri (1.
|
74
|
+
nokogiri (1.14.2)
|
74
75
|
mini_portile2 (~> 2.8.0)
|
75
76
|
racc (~> 1.4)
|
76
77
|
openapi3_parser (0.9.2)
|
@@ -78,51 +79,54 @@ GEM
|
|
78
79
|
openapi_parser (0.15.0)
|
79
80
|
optimist (3.0.1)
|
80
81
|
parallel (1.22.1)
|
81
|
-
parser (3.
|
82
|
+
parser (3.2.1.0)
|
82
83
|
ast (~> 2.4.1)
|
83
84
|
patience_diff (1.2.0)
|
84
85
|
optimist (~> 3.0)
|
85
|
-
racc (1.6.
|
86
|
-
rack (3.0.
|
86
|
+
racc (1.6.2)
|
87
|
+
rack (3.0.4.1)
|
87
88
|
rainbow (3.1.1)
|
88
89
|
rake (13.0.6)
|
89
|
-
regexp_parser (2.
|
90
|
+
regexp_parser (2.7.0)
|
90
91
|
rexml (3.2.5)
|
91
|
-
rspec (3.
|
92
|
-
rspec-core (~> 3.
|
93
|
-
rspec-expectations (~> 3.
|
94
|
-
rspec-mocks (~> 3.
|
95
|
-
rspec-core (3.
|
96
|
-
rspec-support (~> 3.
|
97
|
-
rspec-expectations (3.
|
92
|
+
rspec (3.12.0)
|
93
|
+
rspec-core (~> 3.12.0)
|
94
|
+
rspec-expectations (~> 3.12.0)
|
95
|
+
rspec-mocks (~> 3.12.0)
|
96
|
+
rspec-core (3.12.1)
|
97
|
+
rspec-support (~> 3.12.0)
|
98
|
+
rspec-expectations (3.12.2)
|
98
99
|
diff-lcs (>= 1.2.0, < 2.0)
|
99
|
-
rspec-support (~> 3.
|
100
|
-
rspec-mocks (3.
|
100
|
+
rspec-support (~> 3.12.0)
|
101
|
+
rspec-mocks (3.12.3)
|
101
102
|
diff-lcs (>= 1.2.0, < 2.0)
|
102
|
-
rspec-support (~> 3.
|
103
|
-
rspec-support (3.
|
104
|
-
rspec_junit_formatter (0.
|
103
|
+
rspec-support (~> 3.12.0)
|
104
|
+
rspec-support (3.12.0)
|
105
|
+
rspec_junit_formatter (0.6.0)
|
105
106
|
rspec-core (>= 2, < 4, != 2.12.0)
|
106
107
|
rss (0.2.9)
|
107
108
|
rexml
|
108
|
-
rubocop (1.
|
109
|
+
rubocop (1.45.1)
|
109
110
|
json (~> 2.3)
|
110
111
|
parallel (~> 1.10)
|
111
|
-
parser (>= 3.
|
112
|
+
parser (>= 3.2.0.0)
|
112
113
|
rainbow (>= 2.2.2, < 4.0)
|
113
114
|
regexp_parser (>= 1.8, < 3.0)
|
114
115
|
rexml (>= 3.2.5, < 4.0)
|
115
|
-
rubocop-ast (>= 1.
|
116
|
+
rubocop-ast (>= 1.24.1, < 2.0)
|
116
117
|
ruby-progressbar (~> 1.7)
|
117
|
-
unicode-display_width (>=
|
118
|
-
rubocop-ast (1.
|
119
|
-
parser (>= 3.
|
118
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
119
|
+
rubocop-ast (1.26.0)
|
120
|
+
parser (>= 3.2.1.0)
|
121
|
+
rubocop-capybara (2.17.0)
|
122
|
+
rubocop (~> 1.41)
|
120
123
|
rubocop-rake (0.6.0)
|
121
124
|
rubocop (~> 1.0)
|
122
|
-
rubocop-rspec (2.
|
125
|
+
rubocop-rspec (2.18.1)
|
123
126
|
rubocop (~> 1.33)
|
127
|
+
rubocop-capybara (~> 2.17)
|
124
128
|
ruby-progressbar (1.11.0)
|
125
|
-
simplecov (0.
|
129
|
+
simplecov (0.22.0)
|
126
130
|
docile (~> 1.1)
|
127
131
|
simplecov-html (~> 0.11)
|
128
132
|
simplecov_json_formatter (~> 0.1)
|
@@ -133,10 +137,10 @@ GEM
|
|
133
137
|
diff-lcs
|
134
138
|
patience_diff
|
135
139
|
thor (1.2.1)
|
136
|
-
tzinfo (2.0.
|
140
|
+
tzinfo (2.0.6)
|
137
141
|
concurrent-ruby (~> 1.0)
|
138
|
-
unicode-display_width (2.
|
139
|
-
zeitwerk (2.6.
|
142
|
+
unicode-display_width (2.4.2)
|
143
|
+
zeitwerk (2.6.7)
|
140
144
|
|
141
145
|
PLATFORMS
|
142
146
|
ruby
|
@@ -5,7 +5,7 @@ require 'fileutils'
|
|
5
5
|
module Cocina
|
6
6
|
module Generator
|
7
7
|
# Class for generating Cocina models from openapi.
|
8
|
-
class Generator < Thor
|
8
|
+
class Generator < Thor # rubocop:disable Metrics/ClassLength
|
9
9
|
include Thor::Actions
|
10
10
|
|
11
11
|
class_option :openapi, desc: 'Path of openapi.yml', default: 'openapi.yml'
|
@@ -19,14 +19,12 @@ module Cocina
|
|
19
19
|
def generate
|
20
20
|
clean_output
|
21
21
|
|
22
|
-
|
23
|
-
# This is not a Hash
|
24
|
-
schemas.keys.each do |schema_name|
|
22
|
+
filepaths = schemas.keys.filter_map do |schema_name|
|
25
23
|
schema = schema_for(schema_name)
|
26
24
|
generate_for(schema) if schema
|
27
25
|
end
|
28
|
-
# rubocop:enable Style/HashEachMethods
|
29
26
|
|
27
|
+
auto_format(filepaths)
|
30
28
|
generate_vocab
|
31
29
|
generate_descriptive_docs
|
32
30
|
end
|
@@ -38,7 +36,8 @@ module Cocina
|
|
38
36
|
|
39
37
|
FileUtils.mkdir_p(options[:output])
|
40
38
|
|
41
|
-
generate_for(schema)
|
39
|
+
filepath = generate_for(schema)
|
40
|
+
auto_format(filepath)
|
42
41
|
end
|
43
42
|
|
44
43
|
desc 'generate_vocab', 'generate vocab'
|
@@ -101,18 +100,26 @@ module Cocina
|
|
101
100
|
|
102
101
|
case schema_doc.type
|
103
102
|
when 'object'
|
104
|
-
Schema.new(schema_doc)
|
103
|
+
Schema.new(schema_doc, schemas: schemas.keys)
|
105
104
|
when 'string'
|
106
|
-
Datatype.new(schema_doc)
|
105
|
+
Datatype.new(schema_doc, schemas: schemas.keys)
|
106
|
+
when NilClass
|
107
|
+
return unless schema_doc.one_of.map(&:name).all? { |ref_schema_name| schemas.keys.include?(ref_schema_name) }
|
108
|
+
|
109
|
+
UnionType.new(schema_doc)
|
107
110
|
end
|
108
111
|
end
|
109
112
|
|
110
113
|
def generate_for(schema)
|
111
|
-
|
112
|
-
|
114
|
+
"#{options[:output]}/#{schema.filename}".tap do |filepath|
|
115
|
+
FileUtils.rm_f(filepath)
|
116
|
+
|
117
|
+
create_file filepath, schema.generate
|
118
|
+
end
|
119
|
+
end
|
113
120
|
|
114
|
-
|
115
|
-
run("rubocop -a #{
|
121
|
+
def auto_format(*filepaths)
|
122
|
+
run("rubocop -a #{filepaths.join(' ')} > /dev/null")
|
116
123
|
end
|
117
124
|
|
118
125
|
NO_CLEAN = [
|
@@ -111,7 +111,8 @@ module Cocina
|
|
111
111
|
# different oneOf schemas. Validation is still performed
|
112
112
|
# by openAPI.
|
113
113
|
relaxed: true,
|
114
|
-
parent: self
|
114
|
+
parent: self,
|
115
|
+
schemas: schemas)
|
115
116
|
end
|
116
117
|
end
|
117
118
|
end
|
@@ -122,7 +123,8 @@ module Cocina
|
|
122
123
|
key: key,
|
123
124
|
required: doc.requires?(key),
|
124
125
|
nullable: properties_doc.nullable?,
|
125
|
-
parent: self
|
126
|
+
parent: self,
|
127
|
+
schemas: schemas)
|
126
128
|
end
|
127
129
|
end
|
128
130
|
end
|
@@ -4,15 +4,16 @@ module Cocina
|
|
4
4
|
module Generator
|
5
5
|
# Base class for generating from openapi
|
6
6
|
class SchemaBase
|
7
|
-
attr_reader :schema_doc, :key, :required, :nullable, :parent, :relaxed
|
7
|
+
attr_reader :schema_doc, :key, :required, :nullable, :parent, :relaxed, :schemas
|
8
8
|
|
9
|
-
def initialize(schema_doc, key: nil, required: false, nullable: false, parent: nil, relaxed: false)
|
9
|
+
def initialize(schema_doc, key: nil, required: false, nullable: false, parent: nil, relaxed: false, schemas: [])
|
10
10
|
@schema_doc = schema_doc
|
11
11
|
@key = key
|
12
12
|
@required = required
|
13
13
|
@nullable = nullable
|
14
14
|
@parent = parent
|
15
15
|
@relaxed = relaxed
|
16
|
+
@schemas = schemas
|
16
17
|
end
|
17
18
|
|
18
19
|
def filename
|
@@ -60,33 +61,52 @@ module Cocina
|
|
60
61
|
end
|
61
62
|
|
62
63
|
def dry_datatype(doc)
|
64
|
+
return doc.name if doc.name.present? && schemas.include?(doc.name)
|
65
|
+
|
66
|
+
datatype_from_doc_names(doc) ||
|
67
|
+
datatype_from_doc_type(doc) ||
|
68
|
+
raise("#{doc.type} not supported")
|
69
|
+
end
|
70
|
+
|
71
|
+
def datatype_from_doc_type(doc)
|
63
72
|
case doc.type
|
64
73
|
when 'integer'
|
65
|
-
'Strict::Integer'
|
74
|
+
'Types::Strict::Integer'
|
66
75
|
when 'string'
|
67
76
|
string_dry_datatype(doc)
|
68
77
|
when 'boolean'
|
69
|
-
'Strict::Bool'
|
78
|
+
'Types::Strict::Bool'
|
70
79
|
else
|
71
|
-
if any_datatype?(doc)
|
72
|
-
|
73
|
-
|
74
|
-
raise "#{schema_doc.type} not supported"
|
75
|
-
end
|
80
|
+
return 'Types::Nominal::Any' if any_datatype?(doc)
|
81
|
+
|
82
|
+
raise "#{schema_doc.type} not supported"
|
76
83
|
end
|
77
84
|
end
|
78
85
|
|
86
|
+
def datatype_from_doc_names(doc)
|
87
|
+
return unless defined_datatypes?(doc)
|
88
|
+
|
89
|
+
doc.one_of.map(&:name).join(' | ')
|
90
|
+
end
|
91
|
+
|
92
|
+
def defined_datatypes?(doc)
|
93
|
+
doc.one_of&.map(&:name)&.all? { |name| name.present? && schemas.include?(name) }
|
94
|
+
end
|
95
|
+
|
79
96
|
def any_datatype?(doc)
|
80
|
-
relaxed || doc.one_of&.map(&:type)
|
97
|
+
relaxed || doc.one_of&.map(&:type)&.all? { |o| %w[integer string].include?(o) }
|
81
98
|
end
|
82
99
|
|
83
100
|
def string_dry_datatype(doc)
|
84
|
-
case doc.format
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
101
|
+
format = case doc.format
|
102
|
+
when 'date-time'
|
103
|
+
'Types::Params::DateTime'
|
104
|
+
else
|
105
|
+
'Types::Strict::String'
|
106
|
+
end
|
107
|
+
return format unless doc.pattern
|
108
|
+
|
109
|
+
"Types::Strict::String.constrained(format: /#{doc.pattern}/)"
|
90
110
|
end
|
91
111
|
|
92
112
|
def preamble
|
@@ -16,7 +16,7 @@ module Cocina
|
|
16
16
|
private
|
17
17
|
|
18
18
|
def type
|
19
|
-
"
|
19
|
+
"#{dry_datatype(schema_doc)}#{optional}#{default}#{enum}"
|
20
20
|
end
|
21
21
|
|
22
22
|
def enum
|
@@ -33,7 +33,7 @@ module Cocina
|
|
33
33
|
|
34
34
|
def default
|
35
35
|
# Provide version as default for cocinaVersion
|
36
|
-
return '.default(
|
36
|
+
return '.default(VERSION)' if name == 'cocinaVersion'
|
37
37
|
|
38
38
|
# If type is boolean and default is false, erroneously getting a nil.
|
39
39
|
# Assuming that if required, then default is false.
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cocina
|
4
|
+
module Generator
|
5
|
+
# Class for generating a union type
|
6
|
+
class UnionType < SchemaBase
|
7
|
+
def generate
|
8
|
+
<<~RUBY
|
9
|
+
# frozen_string_literal: true
|
10
|
+
|
11
|
+
module Cocina
|
12
|
+
module Models
|
13
|
+
#{name} = #{type_names}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
RUBY
|
17
|
+
end
|
18
|
+
|
19
|
+
def type_names
|
20
|
+
schema_doc.one_of.map(&:name).join(' | ')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -11,10 +11,10 @@ module Cocina
|
|
11
11
|
|
12
12
|
# The version of Cocina with which this object conforms.
|
13
13
|
# example: 1.2.3
|
14
|
-
attribute :cocinaVersion,
|
14
|
+
attribute :cocinaVersion, CocinaVersion.default(VERSION)
|
15
15
|
attribute :type, Types::Strict::String.enum(*AdminPolicy::TYPES)
|
16
16
|
# example: druid:bc123df4567
|
17
|
-
attribute :externalIdentifier,
|
17
|
+
attribute :externalIdentifier, Druid
|
18
18
|
attribute :label, Types::Strict::String
|
19
19
|
attribute :version, Types::Strict::Integer
|
20
20
|
attribute(:administrative, AdminPolicyAdministrative.default { AdminPolicyAdministrative.new })
|
@@ -11,9 +11,9 @@ module Cocina
|
|
11
11
|
attribute? :disseminationWorkflow, Types::Strict::String
|
12
12
|
attribute :collectionsForRegistration, Types::Strict::Array.of(Types::Strict::String).default([].freeze)
|
13
13
|
# example: druid:bc123df4567
|
14
|
-
attribute :hasAdminPolicy,
|
14
|
+
attribute :hasAdminPolicy, Druid
|
15
15
|
# example: druid:bc123df4567
|
16
|
-
attribute :hasAgreement,
|
16
|
+
attribute :hasAgreement, Druid
|
17
17
|
attribute :roles, Types::Strict::Array.of(AccessRole).default([].freeze)
|
18
18
|
end
|
19
19
|
end
|