Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion app/commands/v2/patch_link_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class PatchLinkSet < BaseCommand
def call
raise_unless_links_hash_is_provided
check_bulk_publishing_present
validate_schema
validate_schema if validate_schema?
link_set = LinkSet.find_or_create_locked(content_id:)
check_version_and_raise_if_conflicting(link_set, previous_version_number)

Expand Down Expand Up @@ -140,6 +140,12 @@ def downstream_live(content_id, locale, orphaned_content_ids, update_dependencie
)
end

def validate_schema?
return true unless payload.key?(:validate_schema)

payload[:validate_schema]
end

def validate_schema
# We allow setting links before the document actually exists.
# This means we blindly accept anything regardless of what the schema says.
Expand Down
14 changes: 9 additions & 5 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ presented edition and [warnings](#warnings).
- `update_type` *(optional)*
- Accepts: "major", "minor", "republish"
- It is acceptable to send a "minor" update for the first ever draft
- `bulk_publishing` *(optional, default: false)*
- `bulk_publishing` *(required)*
- Set this to true when making multiple requests. Publishing API will use a
lower priority queue to avoid delays to standard publishing activity.

Expand Down Expand Up @@ -464,7 +464,7 @@ it wants to defer to a reusable piece of content, such as an email address.

- [`content_id`](model.md#content_id)
- Identifies the target document for the reusable piece of content

### Query parameters

- `order` *(optional, default: "unique_pageviews")*
Expand All @@ -476,7 +476,7 @@ it wants to defer to a reusable piece of content, such as an email address.

## `GET /v2/content/:content_id/host-content/:host_content_id`

Returns metadata for a single item of content with ID `:host_content_id` that has an embedded reference to
Returns metadata for a single item of content with ID `:host_content_id` that has an embedded reference to
the target `:content_id`.

### Path parameters
Expand Down Expand Up @@ -525,10 +525,14 @@ in the request is preserved.
}
}
```
- `bulk_publishing` *(required)*
- Set this to true when making multiple requests. Publishing API will use a lower priority queue to avoid delays to standard publishing activity.
- `previous_version` *(optional, recommended)*
- Used to ensure that we are updating the current version of the link set.
- `bulk_publishing` *(optional, default: false)*
- Set this to true when making multiple requests. Publishing API will use a lower priority queue to avoid delays to standard publishing activity.
- `validate_schema` *(optional, default: true)*
- Set to false to skip validation of links against the content schema for
the current payload. After changing a document's document type, allows
for removal of links of types unsupported.

### State changes

Expand Down
29 changes: 29 additions & 0 deletions spec/commands/v2/patch_link_set_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -501,5 +501,34 @@
end
end

context "when an edition exists for the content_id" do
before do
create(
:edition,
document: create(:document, content_id:),
base_path: "/some-path",
title: "Some Title",
)
end

context "when called with validate: false in the payload" do
before { payload[:validate_schema] = false }

it "skips validation" do
expect_any_instance_of(described_class).not_to receive(:validate_schema)

described_class.call(payload)
end
end

context "when called without :validate in the payload" do
it "validates the payload against the schema" do
expect_any_instance_of(described_class).to receive(:validate_schema)

described_class.call(payload)
end
end
end

it_behaves_like TransactionalCommand
end
Loading