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

Allow recursive nesting of AdditionalProperties in Attributes #1490

Conversation

rien-vroom-cquential
Copy link
Contributor

Since nested AdditionalProperties have been allowed for a while through #706 also allow it through Attributes and not only with annotations.

Copy link
Collaborator

@DerManoMann DerManoMann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great if you could add a simple example of the nesting in the tests/Fixtures/Scratch folder.

Something like this (still missing the nesting):

// NestedAdditionalProperties.php
<?php declare(strict_types=1);

/**
 * @license Apache 2.0
 */

namespace OpenApi\Tests\Fixtures\Scratch;

use OpenApi\Attributes as OAT;

#[OAT\Schema(
    additionalProperties: new OAT\AdditionalProperties(
        type: 'string',
        schema: new OAT\Schema(
            type: 'object',
        )
    )
)]
class NestedAdditionalPropertiesModel
{
}

#[OAT\Info(
    title: 'Nested Additional Properties',
    version: '1.0'
)]
#[OAT\Get(
    path: '/api/endpoint',
    description: 'An endpoint',
    responses: [new OAT\Response(response: 200, description: 'OK', ref: NestedAdditionalPropertiesEndpoint::class)]
)]
class NestedAdditionalPropertiesEndpoint
{
}

Running the scratch test will create the corresponding .yaml file which you should check for correctness.

src/Attributes/AdditionalProperties.php Outdated Show resolved Hide resolved
Copy link
Collaborator

@DerManoMann DerManoMann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just needs a code style fix then should be good to go.

Thanks.

@DerManoMann DerManoMann merged commit e67dfd9 into zircote:master Oct 26, 2023
@DerManoMann
Copy link
Collaborator

Thanks @rien-vroom-cquential

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

Successfully merging this pull request may close these issues.

2 participants