Skip to content

Add configurable write method policies - #92

Merged
eviltester merged 2 commits into
masterfrom
codex/configurable-write-method-policies
Jul 30, 2026
Merged

Add configurable write method policies#92
eviltester merged 2 commits into
masterfrom
codex/configurable-write-method-policies

Conversation

@eviltester

Copy link
Copy Markdown
Owner

Summary

  • Add configurable entity write method policies for POST and PUT using CREATE/UPDATE capability sets.
  • Add explicit PATCH update styles: PARTIAL_JSON_UPDATE, JSON_MERGE_PATCH_RFC7396, and JSON_PATCH_RFC6902.
  • Require PATCH Content-Type to select the patch format and expose Accept-Patch when PATCH is available.
  • Add JSON Merge Patch and JSON Patch application support, including raw-body handling for JSON Patch arrays.
  • Expand docs, Swagger, OPTIONS, and sample API coverage for the configured write methods.
  • Add the configured write methods standalone sample API and split its tests by surface area.
  • Move the existing AI/dev markdown note into docs/ai.

Validation

  • mvn test
  • mvn spotless:check

Refs #88

Copilot AI review requested due to automatic review settings July 30, 2026 12:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@eviltester
eviltester merged commit 64e2113 into master Jul 30, 2026
3 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: da82708858

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +212 to +214
case PATCH:
apiResponse = thingifier.api().patch(envelope);
break;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Enforce request entity views for PATCH

When a PATCH route is configured with requestEntityView(...) or entityView(...), this newly added dispatch executes the patch even though validateEntityViewInput returns immediately for every verb except POST and PUT. A client can therefore modify fields that the route's input view marks as disallowed, while equivalent POST/PUT requests receive 422; PATCH must validate the submitted operations or resulting document against the configured input view before dispatch.

Useful? React with 👍 / 👎.

if (verb == ThingifierHttpApi.HttpVerb.POST
|| verb == ThingifierHttpApi.HttpVerb.PUT
|| verb == ThingifierHttpApi.HttpVerb.PATCH) {
if (verb == ThingifierHttpApi.HttpVerb.POST || verb == ThingifierHttpApi.HttpVerb.PUT) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve configured content-type checks for PATCH

When setApiToAllowJsonForContentType(false) is configured, an enabled application/json PATCH now bypasses ContentTypeHeaderValidator and is accepted by RestApiPatchHandler, whereas POST and PUT still return the configured unsupported-content response. Removing PATCH from this condition makes the global request-content policy ineffective specifically for the new write path; PATCH media-type selection should retain the configuration checks while allowing the configured patch media types.

Useful? React with 👍 / 👎.

Comment on lines +275 to +279
RelationshipWriteOperation operation =
verb == blockedVerb
? blockedOperation
: relationshipOperationFor(verb, route, ApiBodyFields.empty());
return operation != null && relationshipOperationsFor(verb, route).contains(operation);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep POST in Allow when another relationship operation is enabled

When relationship POST is configured for only one operation (for example CREATE_AND_CONNECT) and a request attempts the other operation (CONNECT_EXISTING), the 405 response tests only the blocked operation here and omits POST from Allow. The same relationship collection still supports POST with a creation body—and generated OPTIONS advertises it whenever either POST operation is enabled—so clients receive a contradictory capability header; determine method availability from whether any POST operation is enabled rather than from the rejected body's operation.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants