-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
A required request body will not fail tests, if no body is given #3
Comments
Hi, FIrst of all, thank you :) I believe you are right. I'll found some time to touch in the code this week and fix it. Meanwhile, If you have some idea or piece of code it will welcome. |
Thanks for the fast reply. My workaround at the moment: $bodyRequestDef = $this->swaggerSchema->getRequestParameters($expectedResponse->path, $expectedResponse->method);
try {
$bodyRequestDef->match($requestBody);
} catch (InvalidDefinitionException $e) {
if ('There is no body for match' !== $e->getMessage()) {
// throw exception if not the body exception
throw $e;
}
if ('There is no body for match' === $e->getMessage() && !empty($content)) {
// throw exception if there is no body in swagger, but a body given
throw $e;
}
} But I really think there is a better solution ;) |
Yeah, I'll figure it out a way inside the library.
Probably today at night I'll have a draft solution,
…On Tue, Sep 19, 2017 at 11:12 AM, Andreas Nölke ***@***.***> wrote:
Thanks for the fast reply.
My workaround at the moment:
$bodyRequestDef = $this->swaggerSchema->getRequestParameters($expectedResponse->path, $expectedResponse->method);try { $bodyRequestDef->match($requestBody);} catch (InvalidDefinitionException $e) { if ('There is no body for match' !== $e->getMessage()) { // throw exception if not the body exception throw $e; } if ('There is no body for match' === $e->getMessage() && !empty($content)) { // throw exception if there is no body in swagger, but a body given throw $e; }}
But I really think there is a better solution ;)
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA77pKoGNWCGp26ag1hrs6dECgZyZR_8ks5sj8qzgaJpZM4PcCBG>
.
|
I did a fix. I'd like you test if before I merge it . In your composer.json do it:
|
That's perfect. Thanks for this fast fix! |
I published a new release. |
Hello there, thanks for this great package.
I have the following problem: If I have a required request body (defined in swagger), but non is given in my test, then the test does not fail.
I expected that the test will fail.
This seems to be a bug:
https://github.com/byjg/php-swagger-test/blob/master/src/SwaggerTestCase.php#L80-L82
I think in
SwaggerRequestBody
the exception should only be thrown if$body
is not empty and no parameter body is found.The text was updated successfully, but these errors were encountered: