Skip to content

Commit

Permalink
Merge pull request #117 from sul-dlss/sourceid-required
Browse files Browse the repository at this point in the history
Require sourceId when requesting a new DRO
  • Loading branch information
justinlittman authored May 26, 2020
2 parents 6e61625 + 8f6de0a commit 8666874
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/cocina/models/request_dro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class RequestDRO < Struct
attribute :access, DROAccess.optional.meta(omittable: true)
attribute :administrative, Administrative.optional.meta(omittable: true)
attribute :description, Description.optional.meta(omittable: true)
attribute :identification, Identification.optional.meta(omittable: true)
attribute(:identification, RequestIdentification.default { RequestIdentification.new })
attribute :structural, RequestDROStructural.optional.meta(omittable: true)
attribute :geographic, Geographic.optional.meta(omittable: true)

Expand Down
11 changes: 11 additions & 0 deletions lib/cocina/models/request_identification.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

module Cocina
module Models
class RequestIdentification < Struct
# example: sul:PC0170_s3_Fiesta_Bowl_2012-01-02_210609_2026
attribute :sourceId, Types::Strict::String
attribute :catalogLinks, Types::Strict::Array.of(CatalogLink).meta(omittable: true)
end
end
end
18 changes: 16 additions & 2 deletions openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,6 @@ components:
type: array
items:
$ref: "#/components/schemas/DescriptiveValue"

File:
description: Binaries that are the basis of what our domain manages. Binaries here do not include metadata files generated for the domain's own management purposes.
type: object
Expand Down Expand Up @@ -861,7 +860,7 @@ components:
description:
$ref: '#/components/schemas/Description'
identification:
$ref: '#/components/schemas/Identification'
$ref: '#/components/schemas/RequestIdentification'
structural:
$ref: '#/components/schemas/RequestDROStructural'
geographic:
Expand All @@ -870,6 +869,7 @@ components:
- label
- type
- version
- identification
RequestDROStructural:
description: Structural metadata
type: object
Expand Down Expand Up @@ -955,6 +955,20 @@ components:
type: array
items:
$ref: '#/components/schemas/RequestFile'
RequestIdentification:
description: Same as a Identification, but requires a sourceId.
type: object
additionalProperties: false
properties:
sourceId:
type: string
example: 'sul:PC0170_s3_Fiesta_Bowl_2012-01-02_210609_2026'
catalogLinks:
type: array
items:
$ref: '#/components/schemas/CatalogLink'
required:
- sourceId
Sequence:
description: A sequence or ordering of resources within a Collection or Object.
type: object
Expand Down
6 changes: 4 additions & 2 deletions spec/cocina/generator/schema_value_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
Cocina::Models::RequestDRO.new({
label: 'The Prince',
type: Cocina::Models::Vocab.book,
version: 5
version: 5,
identification: { sourceId: 'sul:123' }
}, false, false)
end

Expand All @@ -26,7 +27,8 @@
Cocina::Models::RequestDRO.new({
label: 'The Blue and Brown Books',
type: Cocina::Models::Vocab.book,
version: 5
version: 5,
identification: { sourceId: 'sul:123' }
}, false, false)
end

Expand Down
3 changes: 2 additions & 1 deletion spec/cocina/models_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@
'type' => 'http://cocina.sul.stanford.edu/models/image.jsonld',
'label' => 'bar',
'version' => 5,
'access' => {}
'access' => {},
'identification' => { 'sourceId' => 'sul:123' }
}
end

Expand Down

0 comments on commit 8666874

Please sign in to comment.