You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<?php
/**
* @file ATTENTION!!! The code below was carefully crafted by a mean machine.
* Please consider to NOT put any emotional human-generated modifications as the splendid AI will throw them away with no mercy.
*/
use Swaggest\JsonSchema\Constraint\Properties;
use Swaggest\JsonSchema\Schema;
use Swaggest\JsonSchema\Structure\ClassStructure;
class Test extends ClassStructure
{
/** @var string */
public $foo;
/** @var string */
public $bar;
/**
* @param Properties|static $properties
* @param Schema $ownerSchema
*/
public static function setUpProperties($properties, Schema $ownerSchema)
{
$properties->foo = Schema::string();
$properties->bar = Schema::string();
$ownerSchema->type = Schema::OBJECT;
$ownerSchema->required = array(
self::names()->foo,
);
}
/**
* @return string
* @codeCoverageIgnoreStart
*/
public function getFoo()
{
return $this->foo;
}
/** @codeCoverageIgnoreEnd */
/**
* @return string
* @codeCoverageIgnoreStart
*/
public function getBar()
{
return $this->bar;
}
/** @codeCoverageIgnoreEnd */
}
Expected
<?php
/**
* @file ATTENTION!!! The code below was carefully crafted by a mean machine.
* Please consider to NOT put any emotional human-generated modifications as the splendid AI will throw them away with no mercy.
*/
use Swaggest\JsonSchema\Constraint\Properties;
use Swaggest\JsonSchema\Schema;
use Swaggest\JsonSchema\Structure\ClassStructure;
class Test extends ClassStructure
{
/** @var string */
public $foo;
/** @var string | null */
public $bar;
/**
* @param Properties|static $properties
* @param Schema $ownerSchema
*/
public static function setUpProperties($properties, Schema $ownerSchema)
{
$properties->foo = Schema::string();
$properties->bar = Schema::string();
$ownerSchema->type = Schema::OBJECT;
$ownerSchema->required = array(
self::names()->foo,
);
}
/**
* @return string
* @codeCoverageIgnoreStart
*/
public function getFoo()
{
return $this->foo;
}
/** @codeCoverageIgnoreEnd */
/**
* @return string | null
* @codeCoverageIgnoreStart
*/
public function getBar()
{
return $this->bar;
}
/** @codeCoverageIgnoreEnd */
}
The text was updated successfully, but these errors were encountered:
Non required properties could be missing and can return null. The generated classes do not reflect this is the phpdoc, For example, the schema:
Creates a class with:
When validating
The schema will be validated as valid, but
getBar()
will returnnull
, even though the phpdoc suggests it will always return a stringTest case
Actual
Expected
The text was updated successfully, but these errors were encountered: