Skip to content

fix/openapi/general #678

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

Merged
merged 3 commits into from
Jul 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/phar-manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

$tag = @exec('git describe --tags 2>&1');

if (strpos($tag, '-') === false && strpos($tag, 'No names found') === false) {
if (!str_contains($tag, '-') && !str_contains($tag, 'No names found')) {
print $tag;
} else {
$branch = @exec('git rev-parse --abbrev-ref HEAD');
Expand Down
2 changes: 1 addition & 1 deletion src/PHPDraft/Model/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function parse(object $object): self
$struct->deps = $deps;
$struct->parse($item->content, $deps);

if (isset($item->content->content) && is_array($item->content->content) && isset($item->content->content[0]->meta->id)) {
if (isset($item->content->content[0]->meta->id)) {
$this->structures[$item->content->content[0]->meta->id] = $struct;
} elseif (isset($item->content->meta->id->content)) {
$this->structures[$item->content->meta->id->content] = $struct;
Expand Down
2 changes: 1 addition & 1 deletion src/PHPDraft/Model/Elements/ObjectStructureElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,6 @@ protected function construct_string_return(string $value): string
}

$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>";
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>";
}
}
2 changes: 1 addition & 1 deletion src/PHPDraft/Model/HTTPResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,6 @@ public function is_equal_to(object $b): bool
*/
public function __toString(): string
{
return "{$this->statuscode}_{$this->description}";
return "{$this->statuscode}_$this->description";
}
}
10 changes: 6 additions & 4 deletions src/PHPDraft/Model/HierarchyElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ abstract class HierarchyElement
*
* @param object $object an object to parse
*
* @return void
* @return self
*/
public function parse(object $object)
public function parse(object $object): self
{
if (isset($object->meta) && isset($object->meta->title)) {
if (isset($object->meta->title)) {
$this->title = $object->meta->title->content ?? $object->meta->title;
}

if (!isset($object->content) || !is_array($object->content)) {
return;
return $this;
}

foreach ($object->content as $key => $item) {
Expand All @@ -72,6 +72,8 @@ public function parse(object $object)
if ($object->content !== null && $object->content !== []) {
$object->content = array_slice($object->content, 0);
}

return $this;
}

/**
Expand Down
15 changes: 7 additions & 8 deletions src/PHPDraft/Out/OpenAPI/OpenApiRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,25 +456,24 @@ private function getSchemaProperty(BasicStructureElement|ElementStructureElement

if ($value->type === 'enum') {
$propery_data['type'] = in_array('nullable', $value->status, true) ? [ $value->type, 'null' ] : $value->type;
$options = [];
$options = [];
if (!is_iterable($value->value->value)) {
return $propery_data;
}
foreach ($value->value->value as $option) {
if ($option instanceof ElementStructureElement) {
$options[] = ['const' => $option->value, 'title' => $option->value];
$options[] = [ 'const' => $option->value, 'title' => $option->value ];
}
}
$propery_data['oneOf'] = $options;

return $propery_data;
}

if ($value->type === 'array') {
} elseif ($value->type === 'array') {
$propery_data['type'] = array_unique(array_map(fn($item) => $item->type, $value->value->value));
$propery_data['example'] = array_merge(array_filter(array_map(fn($item) => $item->value, $value->value->value)));

return $propery_data;
}

if ($value->type === 'object') {
} elseif ($value->type === 'object') {
$propery_data['type'] = $value->type;
$propery_data['properties'] = $this->getComponent($value->value)['properties'];

Expand Down
Loading