Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property level validation for Management API #15644

Merged
merged 25 commits into from Jan 31, 2024

Conversation

kjac
Copy link
Contributor

@kjac kjac commented Jan 27, 2024

Prerequisites

  • I have added steps to test this contribution in the description below

Description

Adds support for property level validation in the management API for document and media editing operations. Any validation errors are returned in an errors collection of the resulting problem details, thus mimicking how ASP.NET Core handles request model validation errors.

As content must always be saved despite property validation errors, the API cannot output the validation errors in the actual create and update responses:

  • Create must yield 201 Created and a location header pointing to the newly created resource.
  • Update must yield 200 OK without a response body.

To get around this, a new pair of "validation endpoints" have been introduced for create and update, respectively. These endpoints solely concerns themselves with property level validation.

The PR adds support for outputting an endpoint "operation status". This has been added for all document and media operations.

Testing this PR

Unstructured notes for test scenarios 😄

  • JSON path in problem details errors for complex editor validation errors
  • Create & update always succeeds despite property editor level validation errors
  • Can validate both create and update models (separate endpoints)
  • Publish performs re-validation and fails with appropriate property level validation errors
  • Validation works for both documents and media
  • Problem details response contains status code for all failure states when working with documents and media - not limited to property level validation

# Conflicts:
#	src/Umbraco.Cms.Api.Management/Controllers/Document/CreateDocumentController.cs
#	src/Umbraco.Cms.Api.Management/Controllers/Media/CreateMediaController.cs
# Conflicts:
#	src/Umbraco.Cms.Api.Management/Controllers/Document/CreateDocumentController.cs
#	src/Umbraco.Cms.Api.Management/Controllers/Document/UpdateDocumentController.cs
Copy link
Member

@Zeegaan Zeegaan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a few small nitpicky things 😊

Copy link
Member

@Zeegaan Zeegaan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay had a few more, just found out we could do this:

# Conflicts:
#	src/Umbraco.Cms.Api.Management/Content/ContentControllerBase.cs
#	src/Umbraco.Cms.Api.Management/Controllers/Document/CreateDocumentController.cs
#	src/Umbraco.Cms.Api.Management/Controllers/Media/CreateMediaController.cs
#	src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs
Copy link
Member

@Zeegaan Zeegaan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@Zeegaan Zeegaan merged commit aaf7075 into v14/dev Jan 31, 2024
14 of 15 checks passed
@Zeegaan Zeegaan deleted the v14/feature/property-validation branch January 31, 2024 09:41
@Zeegaan Zeegaan added the project/bellissima AKA "the new backoffice" label Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
project/bellissima AKA "the new backoffice" release/14.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants