Skip to content

Commit

Permalink
fix: add OpenAPI fields
Browse files Browse the repository at this point in the history
  • Loading branch information
SMillerDev committed Oct 21, 2024
1 parent cf72033 commit 3692bbb
Show file tree
Hide file tree
Showing 8 changed files with 261 additions and 72 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[*.html]
indent_size = 2
indent_style = space

[*.php]
indent_size = 2
tab_width = 2
indent_style = space
9 changes: 4 additions & 5 deletions src/PHPDraft/Model/Elements/BasicStructureElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ abstract class BasicStructureElement implements StructureElement
/**
* Object status (required|optional).
*
* @var string|null
* @var string[]
*/
public ?string $status = '';
public array $status = [];
/**
* Parent structure.
*
Expand Down Expand Up @@ -130,14 +130,13 @@ protected function parse_common(object $object, array &$dependencies): void

$this->is_variable = $object->attributes->variable->content ?? false;

$this->status = null;
if (isset($object->attributes->typeAttributes->content)) {
$data = array_map(function ($item) {
return $item->content;
}, $object->attributes->typeAttributes->content);
$this->status = join(', ', $data);
$this->status = $data;
} elseif (isset($object->attributes->typeAttributes)) {
$this->status = join(', ', $object->attributes->typeAttributes);
$this->status = $object->attributes->typeAttributes;
}

if (!in_array($this->type, self::DEFAULTS, true) && $this->type !== null) {
Expand Down
3 changes: 2 additions & 1 deletion src/PHPDraft/Model/Elements/ObjectStructureElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ protected function construct_string_return(string $value): string
$desc = MarkdownExtra::defaultTransform($this->description);
}

return "<tr><td><span>{$this->key->value}</span>{$variable}</td><td>{$type}</td><td> <span class=\"status\">{$this->status}</span></td><td>{$desc}</td><td>{$value}</td></tr>";
$status_string = join(', ', $this->status);
return "<tr><td><span>{$this->key->value}</span>{$variable}</td><td>{$type}</td><td> <span class=\"status\">{$status_string}</span></td><td>{$desc}</td><td>{$value}</td></tr>";
}
}
4 changes: 2 additions & 2 deletions src/PHPDraft/Model/HierarchyElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ abstract class HierarchyElement
/**
* Description of the element.
*
* @var string
* @var string|null
*/
public string $description;
public ?string $description = NULL;

/**
* Child elements.
Expand Down
2 changes: 1 addition & 1 deletion src/PHPDraft/Model/Tests/ObjectElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function testValueSetup(): void
*/
public function testStatusSetup(): void
{
$this->assertSame('', $this->class->status);
$this->assertSame([], $this->class->status);
}

/**
Expand Down
Loading

0 comments on commit 3692bbb

Please sign in to comment.