-
Notifications
You must be signed in to change notification settings - Fork 937
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reliably pick root schema in Analysis::getSchemaForSource() (#1028)
Flag annotations created by processors as `_aux`. Also pick schema from the end of a context's annotation list as the root annotation should be last (excluding annotations created during processing).
- Loading branch information
1 parent
db7c984
commit 31210d8
Showing
18 changed files
with
213 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace OpenApi\Examples\Polymorphism; | ||
|
||
use OpenApi\Annotations as OA; | ||
|
||
/** | ||
* @OA\Schema( | ||
* schema="Responsible", | ||
* @OA\Discriminator( | ||
* propertyName="type", | ||
* mapping={ | ||
* "fl": "#/components/schemas/FlResponsible", | ||
* "employee": "#/components/schemas/EmployeeResponsible" | ||
* } | ||
* ), | ||
* oneOf={ | ||
* @OA\Schema(ref="#/components/schemas/FlResponsible"), | ||
* @OA\Schema(ref="#/components/schemas/EmployeeResponsible") | ||
* } | ||
* ) | ||
*/ | ||
abstract class AbstractResponsible | ||
{ | ||
protected const TYPE = null; | ||
|
||
/** | ||
* @OA\Property(nullable=false, enum={"employee","assignee","fl"}) | ||
* | ||
* @var string | ||
*/ | ||
protected $type; | ||
|
||
public function __construct() | ||
{ | ||
$this->type = static::TYPE; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace OpenApi\Examples\Polymorphism; | ||
|
||
use OpenApi\Annotations as OA; | ||
|
||
class Controller | ||
{ | ||
|
||
/** | ||
* @OA\Info(title="Polymorphism",version="1") | ||
* | ||
* @OA\Get( | ||
* path="/test", | ||
* @OA\Response( | ||
* response="default", | ||
* description="Polymorphism", | ||
* @OA\JsonContent(ref="#/components/schemas/Request") | ||
* ) | ||
* ) | ||
*/ | ||
public function getProduct($id) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace OpenApi\Examples\Polymorphism; | ||
|
||
use OpenApi\Annotations as OA; | ||
|
||
/** | ||
* @OA\Schema(schema="EmployeeResponsible") | ||
*/ | ||
final class Employee extends AbstractResponsible | ||
{ | ||
protected const TYPE = 'employee'; | ||
|
||
/** | ||
* @OA\Property(nullable=false) | ||
* | ||
* @var string | ||
*/ | ||
public $property2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace OpenApi\Examples\Polymorphism; | ||
|
||
use OpenApi\Annotations as OA; | ||
|
||
/** | ||
* @OA\Schema(schema="FlResponsible") | ||
*/ | ||
final class Fl extends AbstractResponsible | ||
{ | ||
public const TYPE = 'fl'; | ||
|
||
/** | ||
* @OA\Property(nullable=false) | ||
* | ||
* @var string | ||
*/ | ||
public $property3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace OpenApi\Examples\Polymorphism; | ||
|
||
use OpenApi\Annotations as OA; | ||
|
||
/** | ||
* @OA\Schema(schema="Request") | ||
*/ | ||
final class Request | ||
{ | ||
protected const TYPE = 'employee'; | ||
|
||
/** | ||
* @OA\Property(nullable=false) | ||
* | ||
* @var AbstractResponsible | ||
*/ | ||
public $payload; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: Polymorphism | ||
version: '1' | ||
paths: | ||
/test: | ||
get: | ||
operationId: ef7f8a05d4ce52bae215869c1decc7c1 | ||
responses: | ||
default: | ||
description: Polymorphism | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Request' | ||
components: | ||
schemas: | ||
Responsible: | ||
properties: | ||
type: | ||
nullable: false | ||
type: string | ||
enum: | ||
- employee | ||
- assignee | ||
- fl | ||
type: object | ||
discriminator: | ||
propertyName: type | ||
mapping: | ||
fl: '#/components/schemas/FlResponsible' | ||
employee: '#/components/schemas/EmployeeResponsible' | ||
oneOf: | ||
- | ||
$ref: '#/components/schemas/FlResponsible' | ||
- | ||
$ref: '#/components/schemas/EmployeeResponsible' | ||
EmployeeResponsible: | ||
allOf: | ||
- | ||
properties: | ||
property2: | ||
nullable: false | ||
type: string | ||
- | ||
$ref: '#/components/schemas/Responsible' | ||
FlResponsible: | ||
allOf: | ||
- | ||
properties: | ||
property3: | ||
nullable: false | ||
type: string | ||
- | ||
$ref: '#/components/schemas/Responsible' | ||
Request: | ||
properties: | ||
payload: | ||
$ref: '#/components/schemas/Responsible' | ||
type: object | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters