This repository has been archived by the owner on Jan 15, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding more complex types found in spec
- Loading branch information
Showing
3 changed files
with
89 additions
and
1 deletion.
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
44 changes: 44 additions & 0 deletions
44
tests/Description/Builder/OpenApi/DefinitionsBuilderTest.php
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,44 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of the KleijnWeb\PhpApi\Descriptions package. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace KleijnWeb\PhpApi\Descriptions\Tests\Description\Builder\OpenApi; | ||
|
||
use KleijnWeb\PhpApi\Descriptions\Description\ComplexType; | ||
use KleijnWeb\PhpApi\Descriptions\Tests\Description\Builder\OpenApiBuilderTest; | ||
|
||
/** | ||
* @author John Kleijn <john@kleijnweb.nl> | ||
*/ | ||
class DefinitionsBuilderTest extends OpenApiBuilderTest | ||
{ | ||
protected function setUp() | ||
{ | ||
$this->setUpDescription(__DIR__ . '/../../../definitions/openapi/definitions.yml'); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function willAddAllSchemaUnderDefinitionsAsComplexTypes() | ||
{ | ||
$typeNames = array_map(function (ComplexType $type) { | ||
return $type->getName(); | ||
}, $this->description->getComplexTypes()); | ||
|
||
sort($typeNames); | ||
|
||
$expected = [ | ||
'Bar', | ||
'Baz', | ||
'Foo', | ||
'UnusedDefinition', | ||
]; | ||
|
||
$this->assertSame($expected, $typeNames); | ||
} | ||
} |
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,35 @@ | ||
swagger: '2.0' | ||
info: | ||
description: 'Data api' | ||
version: 1.0.0 | ||
basePath: /data/v1 | ||
paths: | ||
/baz: | ||
get: | ||
responses: | ||
'200': | ||
schema: { $ref: '#/definitions/Baz' } | ||
|
||
definitions: | ||
Foo: | ||
type: object | ||
properties: | ||
fooProperty: { type: string } | ||
Bar: | ||
type: object | ||
properties: | ||
barProperty: { type: string } | ||
|
||
Baz: | ||
allOf: | ||
- { $ref: '#/definitions/Foo' } | ||
- { $ref: '#/definitions/Bar' } | ||
- properties: | ||
bazProperty: { type: string } | ||
|
||
StringDefinition: | ||
type: string | ||
|
||
UnusedDefinition: | ||
properties: | ||
barProperty: { type: string } |