Skip to content

Commit 3692bbb

Browse files
committed
fix: add OpenAPI fields
1 parent cf72033 commit 3692bbb

File tree

8 files changed

+261
-72
lines changed

8 files changed

+261
-72
lines changed

.editorconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[*.html]
2+
indent_size = 2
3+
indent_style = space
4+
5+
[*.php]
6+
indent_size = 2
7+
tab_width = 2
8+
indent_style = space

src/PHPDraft/Model/Elements/BasicStructureElement.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ abstract class BasicStructureElement implements StructureElement
4545
/**
4646
* Object status (required|optional).
4747
*
48-
* @var string|null
48+
* @var string[]
4949
*/
50-
public ?string $status = '';
50+
public array $status = [];
5151
/**
5252
* Parent structure.
5353
*
@@ -130,14 +130,13 @@ protected function parse_common(object $object, array &$dependencies): void
130130

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

133-
$this->status = null;
134133
if (isset($object->attributes->typeAttributes->content)) {
135134
$data = array_map(function ($item) {
136135
return $item->content;
137136
}, $object->attributes->typeAttributes->content);
138-
$this->status = join(', ', $data);
137+
$this->status = $data;
139138
} elseif (isset($object->attributes->typeAttributes)) {
140-
$this->status = join(', ', $object->attributes->typeAttributes);
139+
$this->status = $object->attributes->typeAttributes;
141140
}
142141

143142
if (!in_array($this->type, self::DEFAULTS, true) && $this->type !== null) {

src/PHPDraft/Model/Elements/ObjectStructureElement.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ protected function construct_string_return(string $value): string
214214
$desc = MarkdownExtra::defaultTransform($this->description);
215215
}
216216

217-
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>";
217+
$status_string = join(', ', $this->status);
218+
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>";
218219
}
219220
}

src/PHPDraft/Model/HierarchyElement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ abstract class HierarchyElement
2727
/**
2828
* Description of the element.
2929
*
30-
* @var string
30+
* @var string|null
3131
*/
32-
public string $description;
32+
public ?string $description = NULL;
3333

3434
/**
3535
* Child elements.

src/PHPDraft/Model/Tests/ObjectElementTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function testValueSetup(): void
8383
*/
8484
public function testStatusSetup(): void
8585
{
86-
$this->assertSame('', $this->class->status);
86+
$this->assertSame([], $this->class->status);
8787
}
8888

8989
/**

0 commit comments

Comments
 (0)