Skip to content

Generate API Platform operations from OpenAPI #440

@Pierstoval

Description

@Pierstoval

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:

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

Output:

/**
 * 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions