Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OpenAPI] Allow using (more) objects instead of arrays in openapiContext #6173

Open
JarJak opened this issue Feb 21, 2024 · 3 comments
Open

Comments

@JarJak
Copy link

JarJak commented Feb 21, 2024

Description

Hello! I'm in the middle of transforming my old API to the API Platform one.

One thing I noticed is that when changing OpenAPI attributes to Api Platform attributes I can no longer use item references as class names or generally OpenAPI/Nelmio Model objects deeper under openapiContext property.

Am I missing something to make it work properly or is this feature not implemented yet?

Example
My old attribute:

use OpenApi\Attributes as OA;
use Nelmio\ApiDocBundle\Annotation\Model;

    #[OA\Property(
        description: 'the list of order items',
        type: 'array',
        items: new OA\Items(
            ref: new Model(type: OrderItem::class),
        )
    )]
    public array $items;

The new one:

    #[ApiProperty(
        description: 'the list of order items',
        openapiContext: [
            'type' => 'array',
            'items' => [
                '$ref' => '#/components/schemas/OrderItem'
            ],
        ],
    )]
    public array $items;
@soyuka
Copy link
Member

soyuka commented Mar 5, 2024

I wish it'd be something like:

#[ApiProperty(openapi: new Schema)]

from where do use OpenApi\Attributes as OA; come from?

@JarJak
Copy link
Author

JarJak commented Mar 5, 2024

@soyuka
Copy link
Member

soyuka commented Mar 15, 2024

Sorry we're not compatible with swagger-php for now it's not supported, marking this as an enhancement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants