Skip to content

fix baseUrl and an simple fix for multiple types in an param (in v2\explorer) #653

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

Closed
wants to merge 6 commits into from
Closed
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
29 changes: 23 additions & 6 deletions src/Explorer/v2/Explorer.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,11 @@ public function get()
) {
$filename .= '.js';
}
PassThrough::file(__DIR__ . '/client/' . (empty($filename) ? 'index.html' : $filename), false,
0); //60 * 60 * 24);
PassThrough::file(
__DIR__ . '/client/' . (empty($filename) ? 'index.html' : $filename),
false,
0
); //60 * 60 * 24);
}

/**
Expand All @@ -190,7 +193,10 @@ public function swagger()
$r->swagger = static::SWAGGER;

$info = parse_url($this->restler->getBaseUrl());
$r->host = $info['host'];
$r->host = '';
if (isset($info['host'])) {
$r->host = $info['host'];
}
if (isset($info['port'])) {
$r->host .= ':' . $info['port'];
}
Expand Down Expand Up @@ -456,8 +462,17 @@ private function model($type, array $children)

private function setType(&$object, ValidationInfo $info)
{
// TEMP FIX: for multiple types, pick first one if not null
$type = $info->type;
if (is_array($info->type)) {
foreach ($info->type as $type) {
if (strtolower($type) != 'null') {
break;
}
}
}
//TODO: proper type management
$type = Util::getShortName($info->type);
$type = Util::getShortName($type);
if ($info->type === 'array') {
$object->type = 'array';
if ($info->children) {
Expand All @@ -478,8 +493,10 @@ private function setType(&$object, ValidationInfo $info)
)
));
} elseif ($info->contentType && $info->contentType != 'indexed') {
if (is_string($info->contentType) && $t = Util::nestedValue(static::$dataTypeAlias,
strtolower($info->contentType))) {
if (is_string($info->contentType) && $t = Util::nestedValue(
static::$dataTypeAlias,
strtolower($info->contentType)
)) {
if (is_array($t)) {
$object->items = (object)array(
'type' => $t[0],
Expand Down
Loading