Skip to content

Commit

Permalink
test scalar properties
Browse files Browse the repository at this point in the history
  • Loading branch information
DjordyKoert committed Jan 8, 2025
1 parent bea1021 commit dd54133
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 8 deletions.
22 changes: 22 additions & 0 deletions tests/Functional/ModelDescriber/Fixtures/NullableScalar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"properties": {
"int": {
"type": "integer",
"nullable": true
},
"float": {
"type": "number",
"format": "float",
"nullable": true
},
"string": {
"type": "string",
"nullable": true
},
"bool": {
"type": "boolean",
"nullable": true
}
},
"type": "object"
}
20 changes: 20 additions & 0 deletions tests/Functional/ModelDescriber/Fixtures/NullableScalar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/*
* This file is part of the NelmioApiDocBundle package.
*
* (c) Nelmio
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Nelmio\ApiDocBundle\Tests\Functional\ModelDescriber\Fixtures;

class NullableScalar
{
public ?int $int;
public ?float $float;
public ?string $string;
public ?bool $bool;
}
24 changes: 24 additions & 0 deletions tests/Functional/ModelDescriber/Fixtures/ScalarTypes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"required": [
"int",
"float",
"string",
"bool"
],
"properties": {
"int": {
"type": "integer"
},
"float": {
"type": "number",
"format": "float"
},
"string": {
"type": "string"
},
"bool": {
"type": "boolean"
}
},
"type": "object"
}
20 changes: 20 additions & 0 deletions tests/Functional/ModelDescriber/Fixtures/ScalarTypes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/*
* This file is part of the NelmioApiDocBundle package.
*
* (c) Nelmio
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Nelmio\ApiDocBundle\Tests\Functional\ModelDescriber\Fixtures;

class ScalarTypes
{
public int $int;
public float $float;
public string $string;
public bool $bool;
}
20 changes: 12 additions & 8 deletions tests/Functional/ModelDescriber/ObjectModelDescriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
use Nelmio\ApiDocBundle\Model\ModelRegistry;
use Nelmio\ApiDocBundle\ModelDescriber\ObjectModelDescriber;
use Nelmio\ApiDocBundle\OpenApiPhp\Util;
use Nelmio\ApiDocBundle\Tests\Functional\ModelDescriber\Fixtures\ArrayOfInt;
use Nelmio\ApiDocBundle\Tests\Functional\ModelDescriber\Fixtures\ArrayOfString;
use Nelmio\ApiDocBundle\Tests\Functional\ModelDescriber\Fixtures\ComplexArray;
use Nelmio\ApiDocBundle\Tests\Functional\ModelDescriber\Fixtures\SimpleClass;
use Nelmio\ApiDocBundle\Tests\Functional\WebTestCase;
use OpenApi\Annotations as OA;
use OpenApi\Annotations\OpenApi;
Expand Down Expand Up @@ -68,19 +64,27 @@ public function testItDescribes(string $class, ?string $fixtureDir = null): void
public static function provideFixtures(): \Generator
{
yield [
SimpleClass::class,
Fixtures\SimpleClass::class,
];

yield [
ArrayOfInt::class,
Fixtures\ArrayOfInt::class,
];

yield [
ArrayOfString::class,
Fixtures\ArrayOfString::class,
];

yield [
ComplexArray::class
Fixtures\ComplexArray::class
];

yield [
Fixtures\ScalarTypes::class
];

yield [
Fixtures\NullableScalar::class
];
}

Expand Down

0 comments on commit dd54133

Please sign in to comment.