Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix(metadata): handle union/intersect types * review * try to move SchemaFactory onto SchemaPropertyMetadataFactory * complete property schema on SchemaFactory * Apply suggestions from code review Co-authored-by: Antoine Bluchet <soyuka@users.noreply.github.com> * fix: review * fix: cs * fix: phpunit * fix: cs * fix: tests about maker * fix: JsonSchema::SchemaFactory * fix: behat tests * fix deprec * tests --------- Co-authored-by: Antoine Bluchet <soyuka@users.noreply.github.com>
- Loading branch information
1 parent
6babb3d
commit d793ffb
Showing
52 changed files
with
1,548 additions
and
484 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
Feature: Union/Intersect types | ||
|
||
Scenario Outline: Create a resource with union type | ||
When I add "Content-Type" header equal to "application/ld+json" | ||
And I add "Accept" header equal to "application/ld+json" | ||
And I send a "POST" request to "/issue-5452/books" with body: | ||
""" | ||
{ | ||
"number": <number>, | ||
"isbn": "978-3-16-148410-0" | ||
} | ||
""" | ||
Then the response status code should be 201 | ||
And the response should be in JSON | ||
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" | ||
And the JSON should be valid according to this schema: | ||
""" | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"@type": { | ||
"type": "string", | ||
"pattern": "^Book$" | ||
}, | ||
"@context": { | ||
"type": "string", | ||
"pattern": "^/contexts/Book$" | ||
}, | ||
"@id": { | ||
"type": "string", | ||
"pattern": "^/.well-known/genid/.+$" | ||
}, | ||
"number": { | ||
"type": "<type>" | ||
}, | ||
"isbn": { | ||
"type": "string", | ||
"pattern": "^978-3-16-148410-0$" | ||
} | ||
}, | ||
"required": [ | ||
"@type", | ||
"@context", | ||
"@id", | ||
"number", | ||
"isbn" | ||
] | ||
} | ||
""" | ||
Examples: | ||
| number | type | | ||
| "1" | string | | ||
| 1 | integer | | ||
|
||
Scenario: Create a resource with valid intersect type | ||
When I add "Content-Type" header equal to "application/ld+json" | ||
And I send a "POST" request to "/issue-5452/books" with body: | ||
""" | ||
{ | ||
"number": 1, | ||
"isbn": "978-3-16-148410-0", | ||
"author": "/issue-5452/authors/1" | ||
} | ||
""" | ||
Then the response status code should be 201 | ||
And the response should be in JSON | ||
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" | ||
And the JSON should be valid according to this schema: | ||
""" | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"@type": { | ||
"type": "string", | ||
"pattern": "^Book$" | ||
}, | ||
"@context": { | ||
"type": "string", | ||
"pattern": "^/contexts/Book$" | ||
}, | ||
"@id": { | ||
"type": "string", | ||
"pattern": "^/.well-known/genid/.+$" | ||
}, | ||
"number": { | ||
"type": "integer" | ||
}, | ||
"isbn": { | ||
"type": "string", | ||
"pattern": "^978-3-16-148410-0$" | ||
}, | ||
"author": { | ||
"type": "string", | ||
"pattern": "^/issue-5452/authors/1$" | ||
} | ||
}, | ||
"required": [ | ||
"@type", | ||
"@context", | ||
"@id", | ||
"number", | ||
"isbn", | ||
"author" | ||
] | ||
} | ||
""" | ||
|
||
Scenario: Create a resource with invalid intersect type | ||
When I add "Content-Type" header equal to "application/ld+json" | ||
And I send a "POST" request to "/issue-5452/books" with body: | ||
""" | ||
{ | ||
"number": 1, | ||
"isbn": "978-3-16-148410-0", | ||
"library": "/issue-5452/libraries/1" | ||
} | ||
""" | ||
Then the response status code should be 400 | ||
And the response should be in JSON | ||
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" | ||
And the JSON node "hydra:description" should be equal to 'Could not denormalize object of type "ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue5452\ActivableInterface", no supporting normalizer found.' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.