Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Fixing issue 109 - Allow requests with empty body #114

Merged
merged 1 commit into from
May 1, 2018
Merged

Fixing issue 109 - Allow requests with empty body #114

merged 1 commit into from
May 1, 2018

Conversation

jefferson-lima
Copy link
Contributor

Here's a fix for the problem described in the issue 109.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.5%) to 89.655% when pulling 290c76c on jefferson-lima:issue109 into 2f85b8d on alecsammon:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.5%) to 89.655% when pulling 290c76c on jefferson-lima:issue109 into 2f85b8d on alecsammon:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.06%) to 89.142% when pulling 53588a4 on jefferson-lima:issue109 into 2f85b8d on alecsammon:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.06%) to 89.142% when pulling 53588a4 on jefferson-lima:issue109 into 2f85b8d on alecsammon:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.06%) to 89.142% when pulling 53588a4 on jefferson-lima:issue109 into 2f85b8d on alecsammon:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.06%) to 89.142% when pulling 7961d7c on jefferson-lima:issue109 into 2f85b8d on alecsammon:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.06%) to 89.142% when pulling 7961d7c on jefferson-lima:issue109 into 2f85b8d on alecsammon:master.

@coveralls
Copy link

coveralls commented Nov 17, 2017

Coverage Status

Coverage decreased (-0.06%) to 89.142% when pulling 7961d7c on jefferson-lima:issue109 into 2f85b8d on alecsammon:master.

@martin-georgiev martin-georgiev self-requested a review April 3, 2018 16:26
Copy link
Collaborator

@martin-georgiev martin-georgiev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, lgtm with minor comments above that should be easy to address. Thank you for the contribution.


} catch(EmptyBodyException $e) {
throw new EmptyBodyException($e->getMessage());
}catch (\Exception $exception) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you fix the spacing here and on line 139?

src/Method.php Outdated
@@ -13,7 +15,7 @@ class Method implements ArrayInstantiationInterface, MessageSchemaInterface
* - Currently missing OPTIONS as this is unlikely to be specified in RAML
* @var array
*/
public static $validMethods = ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'PATCH'];
public static $validMethods = ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a unit test with OPTIONS as method?

<?php
namespace Raml\Exception;


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the extra new line here.

src/Method.php Outdated
@@ -381,8 +383,12 @@ public function addQueryParameter(NamedParameter $queryParameter)
*/
public function getBodyByType($type)
{
if(empty($this->getBodies())){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please apply the correct spacing style.

$schemaBody->getSchema()->validate($body);

}catch (EmptyBodyException $exception) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spacing style is slightly off in this newly added line.

@jefferson-lima
Copy link
Contributor Author

Thanks for the review, I will be making the corrections soon.

@martin-georgiev
Copy link
Collaborator

@jefferson-lima would you be able to address the code review changes?
There is a momentum for moving the repository to RAML.org and it will be nice to clean up the pile of MR before that. Thank you!

} catch (Exception $exception) {

} catch(EmptyBodyException $e) {
throw new EmptyBodyException($e->getMessage());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look right that the exception is throwing a new instance of the same exception here (EmptyBodyException).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that what's not quite right is catching an Exception in such a low level of the code, instead of catching a more specific exception. In this case, I need the EmptyBodyException to be propagated, but if it weren't for that piece of code, it would be caught and rethrown as a ValidatorSchemaException. I understand that this is a workaround and it's not straightforward.

@jefferson-lima
Copy link
Contributor Author

Hi @martin-georgiev, I believe I fixed the issues you pointed out. Would you please give it another look? Note that I squashed my previous commits into a single one to don't mess up the history, I hope this is not a problem.

@martin-georgiev martin-georgiev merged commit 4d7a777 into raml-org:master May 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants