Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add oneOf schema support #103

Merged
merged 12 commits into from
Jan 2, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,8 @@

class GetExampleResponseBodyMapper implements SchemaMapperInterface
{
private AnimalMapper $animalMapper;

private MachineMapper $machineMapper;

public function __construct(AnimalMapper $animalMapper, MachineMapper $machineMapper)
public function __construct(private AnimalMapper $animalMapper, private MachineMapper $machineMapper)
{
$this->animalMapper = $animalMapper;
$this->machineMapper = $machineMapper;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,8 @@

class GetExampleResponseBodyMapper implements SchemaMapperInterface
{
private AnimalMapper $animalMapper;

private MachineMapper $machineMapper;

public function __construct(AnimalMapper $animalMapper, MachineMapper $machineMapper)
public function __construct(private AnimalMapper $animalMapper, private MachineMapper $machineMapper)
{
$this->animalMapper = $animalMapper;
$this->machineMapper = $machineMapper;
}

public function toSchema(array $payload): GetExampleResponseBody
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,8 @@

class GetExampleResponseBodyMapper implements SchemaMapperInterface
{
private AnimalMapper $animalMapper;

private MachineMapper $machineMapper;

public function __construct(AnimalMapper $animalMapper, MachineMapper $machineMapper)
public function __construct(private AnimalMapper $animalMapper, private MachineMapper $machineMapper)
{
$this->animalMapper = $animalMapper;
$this->machineMapper = $machineMapper;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions test/suite/functional/Generator/SchemaMapperGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,19 @@ public function exampleProvider(): array
'/SchemaMapper/oneOf.yaml',
'/SchemaMapper/OneOfResponseBodyMapper.php',
self::BASE_NAMESPACE . SchemaMapperGenerator::NAMESPACE_SUBPATH . '\\GetExampleResponseBodyMapper',
ConfigurationBuilder::fake()->build(),
ConfigurationBuilder::fake()->withPhpVersion(PhpVersion::VERSION_PHP80)->build(),
],
'OneOf response without discriminator' => [
'/SchemaMapper/oneOfWithoutDiscriminator.yaml',
'/SchemaMapper/OneOfResponseBodyMapperWithoutDiscriminator.php',
self::BASE_NAMESPACE . SchemaMapperGenerator::NAMESPACE_SUBPATH . '\\GetExampleResponseBodyMapper',
ConfigurationBuilder::fake()->build(),
ConfigurationBuilder::fake()->withPhpVersion(PhpVersion::VERSION_PHP80)->build(),
vsouz4 marked this conversation as resolved.
Show resolved Hide resolved
],
'AnyOf response' => [
'/SchemaMapper/anyOf.yaml',
'/SchemaMapper/AnyOfResponseBodyMapper.php',
self::BASE_NAMESPACE . SchemaMapperGenerator::NAMESPACE_SUBPATH . '\\GetExampleResponseBodyMapper',
ConfigurationBuilder::fake()->build(),
ConfigurationBuilder::fake()->withPhpVersion(PhpVersion::VERSION_PHP80)->build(),
],
];
}
Expand Down
Loading