-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Wrong type bad request #260
Conversation
Codecov Report
@@ Coverage Diff @@
## 1.x #260 +/- ##
===========================================
Coverage 100.00% 100.00%
- Complexity 518 520 +2
===========================================
Files 83 83
Lines 1315 1319 +4
===========================================
+ Hits 1315 1319 +4
Continue to review full report at Codecov.
|
ご対応ありがとうございます! status code 400ではなく、0が返りました。 composer config repositories.koriym/BEAR.Resource vcs https://github.com/koriym/BEAR.Resource
composer require "bear/resource":"dev-wrong_type_bad_request as 1.17.0"
mkdir -p src/Resource/App
$(cat << 'EOF' > src/Resource/App/Weekday.php
<?php
declare(strict_types=1);
namespace MyVendor\Weekday\Resource\App;
use BEAR\Resource\ResourceObject;
use DateTimeImmutable;
class Weekday extends ResourceObject
{
public function onGet(int $year, int $month, int $day): static
{
$dateTime = DateTimeImmutable::createFromFormat('Y-m-d', "$year-$month-$day");
$weekday = $dateTime->format('D');
$this->body = ['weekday' => $weekday];
return $this;
}
}
EOF
)
# BadRequestException(Invalid parameter type)が返りましたが、400ではなく0でした
php bin/app.php get '/weekday?year=2001&month=1&day='
|
@yuki777 再現例ありがとうございます。再現手順は最初から全部書いてあるorどこかにpushしてあるともっと嬉しいですね! |
src/Invoker.php
Outdated
$response = call_user_func_array($callable, $params); | ||
} catch (Throwable $e) { | ||
if (get_class($e) === 'TypeError') { | ||
throw new BadRequestException('Invalid parameter type', 0, $e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0ではなく
400 Bad Requestが返ることを確認できました! # MyVendor.Weekdayで作成
composer create-project bear/skeleton MyVendor.Weekday
cd MyVendor.Weekday
composer config repositories.koriym/BEAR.Resource vcs https://github.com/koriym/BEAR.Resource
composer require "bear/resource":"dev-wrong_type_bad_request as 1.17.0"
mkdir -p src/Resource/App
$(cat << 'EOF' > src/Resource/App/Weekday.php
<?php
declare(strict_types=1);
namespace MyVendor\Weekday\Resource\App;
use BEAR\Resource\ResourceObject;
use DateTimeImmutable;
class Weekday extends ResourceObject
{
public function onGet(int $year, int $month, int $day): static
{
$dateTime = DateTimeImmutable::createFromFormat('Y-m-d', "$year-$month-$day");
$weekday = $dateTime->format('D');
$this->body = ['weekday' => $weekday];
return $this;
}
}
EOF
)
# 400 Bad Requestを確認できました :)
php bin/app.php get '/weekday?year=2001&month=1&day='
400 Bad Request
content-type: application/vnd.error+json
{
"message": "Bad Request",
"logref": "7952cf74",
"request": "get app://self/weekday?year=2001&month=1&day=",
"exceptions": "BEAR\\Resource\\Exception\\BadRequestException(Invalid parameter type)",
"file": "/Users/adachi/tmp/MyVendor.Weekday/vendor/bear/resource/src/Invoker.php(46)"
} |
Closes #259