Skip to content

Commit

Permalink
Hidden properties take precedence in being hidden (#547)
Browse files Browse the repository at this point in the history
Hidden properties were correctly not showing in operation response sample, but still displaying in schema sample. This hides them always.
  • Loading branch information
cnizzardini authored May 11, 2024
1 parent d3e741f commit cbb7f7c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Lib/Schema/SchemaFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ private function getProperties(Model $model, int $propertyType, ?DocBlock $docBl
$factory = new SchemaPropertyFactory($this->validator, $docBlock);

foreach ($model->getProperties() as $property) {
$return[$property->getName()] = $factory->create($property);
if (!$property->isHidden()) {
$return[$property->getName()] = $factory->create($property);
}
}

$return = array_merge($return, $this->getPropertyAnnotations($model));
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Lib/SwaggerSchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function test_employee_table_properties(): void
$this->assertEquals('date', $employee['properties']['hire_date']['format']);

$this->assertTrue($employee['properties']['read']['readOnly']);
$this->assertTrue($employee['properties']['write']['writeOnly']);
$this->assertArrayNotHasKey('write', $employee['properties']);
$this->assertArrayNotHasKey('hide', $employee['properties']);

foreach (['birth_date', 'first_name', 'last_name', 'gender', 'hire_date',] as $property) {
Expand Down

0 comments on commit cbb7f7c

Please sign in to comment.