Closed vincentchalamon closed 1 year ago
API Platform version(s) affected: ^3.1
Description It's not possible to declare multiple operations using the same class:
operations: Post: uriTemplate: /books/{bookId}/borrow Post: uriTemplate: /books/{bookId}/return
In API Platform 3.*, to prevent this limitation, it is possible to declare the operations as following:
operations: - class: ApiPlatform\Metadata\Post uriTemplate: /books/{bookId}/borrow - class: ApiPlatform\Metadata\Post uriTemplate: /books/{bookId}/return
But the code generated by the Schema Generator is invalid:
#[ApiResource( operations: [ new 0(class: 'ApiPlatform\Metadata\Post', uriTemplate: '/books/{bookId}/borrow'), new 1(class: 'ApiPlatform\Metadata\Post', uriTemplate: '/books/{bookId}/return'),
How to reproduce Declare the following configuration in the schema.yaml file:
schema.yaml
types: BookOffer: guessFrom: "Book" attributes: - ApiResource: types: [ "https://schema.org/Book" ] operations: - class: "ApiPlatform\\Metadata\\GetCollection" - class: "ApiPlatform\\Metadata\\Get"
Then, run the Schema Generator: vendor/bin/schema generate src/ config/schema.yaml -vv
vendor/bin/schema generate src/ config/schema.yaml -vv
Possible Solution Support both formats declared above.
Additional Context
The code to modify is here: https://github.com/api-platform/schema-generator/blob/2f7098733d9d111d171730a1f412068db738d272/src/AttributeGenerator/ApiPlatformCoreAttributeGenerator.php#L83-L86
API Platform version(s) affected: ^3.1
Description
It's not possible to declare multiple operations using the same class:
In API Platform 3.*, to prevent this limitation, it is possible to declare the operations as following:
But the code generated by the Schema Generator is invalid:
How to reproduce
Declare the following configuration in the
schema.yaml
file:Then, run the Schema Generator:
vendor/bin/schema generate src/ config/schema.yaml -vv
Possible Solution
Support both formats declared above.
Additional Context