Skip to content

Commit

Permalink
Custom property attr (zircote#1466)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerManoMann authored Aug 16, 2023
1 parent f01574d commit 434cd0a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
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

0 comments on commit 434cd0a

Please sign in to comment.