Skip to content

Add configure() support for issues #532

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 6 commits into from
Mar 27, 2017
Merged

Add configure() support for issues #532

merged 6 commits into from
Mar 27, 2017

Conversation

bobeagan
Copy link
Contributor

@bobeagan bobeagan commented Mar 3, 2017

Borrowed from issue comments, but changed the default bodyType to "raw" since the documentation indicates that is the default when no specific media type is passed: https://developer.github.com/v3/media/#comment-body-properties

Borrowed from issue comments, but changed the default bodyType to "raw" since the documentation indicates that is the default when no specific media type is passed: https://developer.github.com/v3/media/#comment-body-properties
@bobeagan
Copy link
Contributor Author

bobeagan commented Mar 4, 2017

There are others that should be updated too, this was just the first one that was causing me issue. If I get a chance on Monday, I can try to add the others to this PR (or if you merge before then, I'll make a separate).

- also fixes the Issue/Comments default configure value
- also adds support for polaris-preview in PullRequest
- also adds support for squirrel-girl-preview in PullRequest/Comments
- replaces switch case with in_array in Repository/Comments to standardize
@bobeagan
Copy link
Contributor Author

bobeagan commented Mar 6, 2017

I updated more places that used custom media types in the Accept header. I noticed what is likely a bug in Repository/Comments where Accept: was prefixed on the header value.

I also fixed a few places where the default value was not correct to what the API docs specified, which might be considered a breaking change if you version according to semver.

Copy link
Collaborator

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

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

Great. Thank you for this PR.

There was one BC break that I cannot merge but the rest looks good.

public function configure($bodyType = null)
{
switch ($bodyType) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice!

* @link https://developer.github.com/v3/pulls/#custom-media-types
* @param string|null $bodyType
*/
public function configure($apiVersion = null, $bodyType = null)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Tell me more about the api version here. That is just to enable preview features, right? You cannot change to an older version of the API.

Also why have you chosen this order of parameters?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct, this was to allow for setting the preview version of https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button

Looking now, the order doesn't make much sense as I did it, I'm guessing that I probably started on the PullRequest/Comments (since that is what I was looking to set a preview version for and then came back through later when I figured I would update all of the places that allow changing the bodyType of message responses. I'll update this to flip the order around (and also to add the missing @param that I forgot to include when copy/pasting the comment block)

@@ -23,8 +23,8 @@ class Comments extends AbstractApi
*/
public function configure($bodyType = null)
{
if (!in_array($bodyType, array('raw', 'text', 'html'))) {
$bodyType = 'full';
Copy link
Collaborator

Choose a reason for hiding this comment

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

You cannot change the default behavior. That is breaking BC

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I mentioned in the initial PR message and also further down in the last comment I left, I was recognizing that this was a breaking change but that as it was currently implemented here (and in Repository/Comments) the option that you have defaulting currently does not align with the default behavior that is described in the GitHub API documentation.

I would suggest aligning with the documentation, noting the breaking change in the release and bumping a major version.

If you aren't interested in doing that, then I would rather go through and change all of the places where I set the default value to raw and switch them to full but then I would suggest that information gets included somewhere that the default behavior of this library does not match the default behavior of the documentation, to avoid any potential for confusion of users of the library.

Let me know your preference and I'll update accordingly.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I saw your comments.

I think the best solution is to accept that we made a mistake before by keep the default body type to full for the comments API. In general we should align with the docs.

Making a new major release just for this fix is not a good solution. What we should do is to create a new issue suggesting this change and add that issue in a 3.0 milestone.

So in short: Just change this back to full and I'll be happy to merge.

@Nyholm Nyholm mentioned this pull request Mar 23, 2017
…ents

Users would more commonly be interested in changing the bodyType rather than apiVersion
Also, added missing @param values
@Nyholm Nyholm added this to the Release 2.2 milestone Mar 24, 2017
# Conflicts:
#	lib/Github/Api/Repository/Comments.php
…raw"

Per @Nyholm
"I think the best solution is to accept that we made a mistake before by keep the default body type to full for the comments API. In general we should align with the docs.
Making a new major release just for this fix is not a good solution. What we should do is to create a new issue suggesting this change and add that issue in a 3.0 milestone.
So in short: Just change this back to full and I'll be happy to merge."
@bobeagan
Copy link
Contributor Author

@Nyholm I reverted the two breaking changes and will submit a different PR for to change the default behavior of those instances to align with the GH docs. I also updated the newly added configure() methods to be chainable per a recently merged PR that introduced that functionality.

Copy link
Collaborator

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

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

Thank you!

@Nyholm Nyholm merged commit 8c5d3bb into KnpLabs:master Mar 27, 2017
@bobeagan bobeagan deleted the patch-2 branch March 27, 2017 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants