api-platform / api-platform/schema-generator

Generate API Platform operations from OpenAPI

Open
#440 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
PHP
Stars
474
Forks
107
PR merge metrics
No merged PRs in 30d

Description

For now, we can create operations with the `generate` command manually by customizing the `yml` config file.

My request is the following:

If the generation is done from an OpenApi file, there is a way to add operations directly in the ApiResource.

Example:

```yaml
# openapi.yaml
paths:
/books:
get:
operationId: getBookCollection
tags:
- Book
# ...
/books/{id}:
get:
operationId: getBookItem
tags:
- Book
# ...
```

Output:

```php
/**
* A book.
*
* @see https://schema.org/Book
*/
#[ORM\Entity]
#[ApiResource(
types: ['https://schema.org/Book'],
operations: [
new GetCollection(
uriTemplate: '/books',
name: 'getBookCollection',
),
new Get(
uriTemplate: '/books/{id}',
name: 'getBookItem',
),
],
)]
class Book
{
// ...
}
```

WDYT?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.