Skip to content

Commit ccc8f10

Browse files
committed
test: openapi fixes
note that the test in docs.feature has been moved to phpunit
1 parent a742dbe commit ccc8f10

File tree

4 files changed

+7
-110
lines changed

4 files changed

+7
-110
lines changed

features/jsonapi/related-resouces-inclusion.feature

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ Feature: JSON API Inclusion of Related Resources
5454
}
5555
"""
5656

57+
@createSchema
5758
Scenario: Request inclusion of a non existing related resource
59+
Given there are 3 dummy property objects
5860
When I send a "GET" request to "/dummy_properties/1?include=foo"
5961
Then the response status code should be 200
6062
And the response should be in JSON
@@ -87,7 +89,9 @@ Feature: JSON API Inclusion of Related Resources
8789
}
8890
"""
8991

92+
@createSchema
9093
Scenario: Request inclusion of a related resource keeping main object properties unfiltered
94+
Given there are 3 dummy property objects
9195
When I send a "GET" request to "/dummy_properties/1?include=group&fields[group]=id,foo&fields[DummyProperty]=bar,baz"
9296
Then the response status code should be 200
9397
And the response should be in JSON

features/openapi/docs.feature

Lines changed: 1 addition & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,9 @@ Feature: Documentation support
153153
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters" should have 6 elements
154154

155155
# Subcollection - check schema
156-
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.responses.200.content.application/ld+json.schema.properties.hydra:member.items.$ref" should be equal to "#/components/schemas/RelatedToDummyFriend.jsonld-fakemanytomany"
156+
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.responses.200.content.application/ld+json.schema.allOf[1].properties.hydra:member.items.$ref" should be equal to "#/components/schemas/RelatedToDummyFriend.jsonld-fakemanytomany"
157157

158158
# Deprecations
159-
And the JSON node "paths./dummies.get.deprecated" should be false
160159
And the JSON node "paths./deprecated_resources.get.deprecated" should be true
161160
And the JSON node "paths./deprecated_resources.post.deprecated" should be true
162161
And the JSON node "paths./deprecated_resources/{id}.get.deprecated" should be true
@@ -166,111 +165,6 @@ Feature: Documentation support
166165

167166
# Formats
168167
And the OpenAPI class "Dummy.jsonld" exists
169-
And the "@id" property exists for the OpenAPI class "Dummy.jsonld"
170-
And the JSON node "paths./dummies.get.responses.200.content.application/ld+json" should be equal to:
171-
"""
172-
{
173-
"schema": {
174-
"type": "object",
175-
"properties": {
176-
"hydra:member": {
177-
"type": "array",
178-
"items": {
179-
"$ref": "#/components/schemas/Dummy.jsonld"
180-
}
181-
},
182-
"hydra:totalItems": {
183-
"type": "integer",
184-
"minimum": 0
185-
},
186-
"hydra:view": {
187-
"type": "object",
188-
"properties": {
189-
"@id": {
190-
"type": "string",
191-
"format": "iri-reference"
192-
},
193-
"@type": {
194-
"type": "string"
195-
},
196-
"hydra:first": {
197-
"type": "string",
198-
"format": "iri-reference"
199-
},
200-
"hydra:last": {
201-
"type": "string",
202-
"format": "iri-reference"
203-
},
204-
"hydra:previous": {
205-
"type": "string",
206-
"format": "iri-reference"
207-
},
208-
"hydra:next": {
209-
"type": "string",
210-
"format": "iri-reference"
211-
}
212-
},
213-
"example": {
214-
"@id": "string",
215-
"type": "string",
216-
"hydra:first": "string",
217-
"hydra:last": "string",
218-
"hydra:previous": "string",
219-
"hydra:next": "string"
220-
}
221-
},
222-
"hydra:search": {
223-
"type": "object",
224-
"properties": {
225-
"@type": {
226-
"type": "string"
227-
},
228-
"hydra:template": {
229-
"type": "string"
230-
},
231-
"hydra:variableRepresentation": {
232-
"type": "string"
233-
},
234-
"hydra:mapping": {
235-
"type": "array",
236-
"items": {
237-
"type": "object",
238-
"properties": {
239-
"@type": {
240-
"type": "string"
241-
},
242-
"variable": {
243-
"type": "string"
244-
},
245-
"property": {
246-
"type": ["string", "null"]
247-
},
248-
"required": {
249-
"type": "boolean"
250-
}
251-
}
252-
}
253-
}
254-
}
255-
}
256-
},
257-
"required": [
258-
"hydra:member"
259-
]
260-
}
261-
}
262-
"""
263-
And the JSON node "paths./dummies.get.responses.200.content.application/json" should be equal to:
264-
"""
265-
{
266-
"schema": {
267-
"type": "array",
268-
"items": {
269-
"$ref": "#/components/schemas/Dummy"
270-
}
271-
}
272-
}
273-
"""
274168
And the JSON node "paths./override_open_api_responses.post.responses" should be equal to:
275169
"""
276170
{
@@ -322,7 +216,6 @@ Feature: Documentation support
322216
And the "resourceRelated" property for the OpenAPI class "Resource" should be equal to:
323217
"""
324218
{
325-
"readOnly": true,
326219
"anyOf": [
327220
{
328221
"$ref": "#/components/schemas/ResourceRelated"

tests/Fixtures/TestBundle/Document/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* @author Théo FIDRY <theo.fidry@gmail.com>
3535
* @author Kévin Dunglas <dunglas@gmail.com>
3636
*/
37-
#[ApiResource(operations: [new Get(), new Put(), new Delete(), new Put(input: RecoverPasswordInput::class, output: RecoverPasswordOutput::class, uriTemplate: 'users/recover/{id}'), new Post(), new GetCollection(), new Post(uriTemplate: '/users/password_reset_request', messenger: 'input', input: PasswordResetRequest::class, output: PasswordResetRequestResult::class, normalizationContext: ['groups' => ['user_password_reset_request']], denormalizationContext: ['groups' => ['user_password_reset_request']])], normalizationContext: ['groups' => ['user', 'user-read']], denormalizationContext: ['groups' => ['user', 'user-write']])]
37+
#[ApiResource(openapi: false, operations: [new Get(), new Put(), new Delete(), new Put(input: RecoverPasswordInput::class, output: RecoverPasswordOutput::class, uriTemplate: 'users/recover/{id}'), new Post(), new GetCollection(), new Post(uriTemplate: '/users/password_reset_request', messenger: 'input', input: PasswordResetRequest::class, output: PasswordResetRequestResult::class, normalizationContext: ['groups' => ['user_password_reset_request']], denormalizationContext: ['groups' => ['user_password_reset_request']])], normalizationContext: ['groups' => ['user', 'user-read']], denormalizationContext: ['groups' => ['user', 'user-write']])]
3838
#[ODM\Document(collection: 'user_test')]
3939
class User implements UserInterface, PasswordAuthenticatedUserInterface
4040
{

tests/Fixtures/TestBundle/Entity/Issue5793/BagOfTests.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class BagOfTests
4949
#[Groups(['read', 'write'])]
5050
private Collection $nonResourceTests;
5151

52-
#[ORM\ManyToOne(targetEntity: TestEntity::class)]
52+
#[ORM\ManyToOne(targetEntity: TestEntity::class, cascade: ['persist'])]
5353
#[ORM\JoinColumn(name: 'type', referencedColumnName: 'id', nullable: false)]
5454
#[Groups(['read', 'write'])]
5555
protected ?TestEntity $type = null;

0 commit comments

Comments
 (0)