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

Custom property attr #1466

Merged
merged 3 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions tests/Fixtures/Scratch/CustomPropertyAttribute.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php declare(strict_types=1);

/**
* @license Apache 2.0
*/

namespace OpenApi\Tests\Fixtures\Scratch;

use OpenApi\Attributes as OAT;

#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY | \Attribute::TARGET_PARAMETER | \Attribute::TARGET_CLASS_CONSTANT | \Attribute::IS_REPEATABLE)]
final class CustomOpenApiProperty extends OAT\Property
{
}

#[OAT\Info(title: 'Api', version: '1.0.0')]
#[OAT\Get(path: '/api')]
#[OAT\Response(response: 200, description: 'All good')]
class Controller
{
}

#[OAT\Schema]
class CustomPropertyAttribute
{
public function __construct(
#[CustomOpenApiProperty()]
public ?int $number,
) {
}
}
18 changes: 18 additions & 0 deletions tests/Fixtures/Scratch/CustomPropertyAttribute.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
openapi: 3.0.0
info:
title: Api
version: 1.0.0
paths:
/api:
get:
responses:
'200':
description: 'All good'
components:
schemas:
CustomPropertyAttribute:
properties:
number:
type: integer
nullable: true
type: object
Loading