Skip to content

Commit 994f393

Browse files
committed
Fix form submit response @id returning /submit suffix instead of canonical IRI
AP4 4.x uses the current operation's uriTemplate to generate @id, so POST/PATCH to /forms/{id}/submit was returning @id with the /submit suffix. Adding normalizationContext: ['item_uri_template' => '/forms/{id}'] on both submit operations forces the IRI converter to use the canonical Get template instead.
1 parent 6a70a94 commit 994f393

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

features/form/form.feature

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,25 @@ Feature: Form component that defines a form type created in the application
4040
| | 422 |
4141

4242

43+
Scenario: The @id in the submit response is the canonical form IRI, not the /submit endpoint
44+
Given there is a "test" form
45+
And I add "Content-Type" header equal to "application/merge-patch+json"
46+
When I send a "PATCH" request to the resource "test_form" and the postfix "/submit" with body:
47+
"""
48+
{"test": {"name": "John Smith"}}
49+
"""
50+
Then the response status code should be 200
51+
And the JSON node "@id" should be equal to the IRI of the resource "test_form"
52+
53+
Scenario: The @id in the POST submit response is the canonical form IRI, not the /submit endpoint
54+
Given there is a "test" form
55+
When I send a "POST" request to the resource "test_form" and the postfix "/submit" with body:
56+
"""
57+
{"test": {"name": "John Smith"}}
58+
"""
59+
Then the response status code should be 201
60+
And the JSON node "@id" should be equal to the IRI of the resource "test_form"
61+
4362
# PATCH
4463

4564
Scenario Outline: I send a PATCH request to the form with multiple fields

src/Entity/Component/Form.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
write: false,
5353
serialize: true,
5454
requirements: ['id' => '[^/]+'],
55+
normalizationContext: ['item_uri_template' => '/forms/{id}{._format}'],
5556
),
5657
new Post(
5758
name: '_api_/forms/{id}/submit{._format}_post',
@@ -62,6 +63,7 @@
6263
write: false,
6364
serialize: true,
6465
requirements: ['id' => '[^/]+'],
66+
normalizationContext: ['item_uri_template' => '/forms/{id}{._format}'],
6567
),
6668
]
6769
)]

0 commit comments

Comments
 (0)