Skip to content

Commit

Permalink
Deprecate previews
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwiseman committed Jun 20, 2024
1 parent c3ba272 commit f191180
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/kohsuke/github/GHRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -2468,7 +2468,7 @@ public PagedIterable<GHUser> listStargazers() {
*/
public PagedIterable<GHStargazer> listStargazers2() {
return root().createRequest()
.withPreview("application/vnd.github.v3.star+json")
.withAccept("application/vnd.github.star+json")
.withUrlPath(getApiTailUrl("stargazers"))
.toIterable(GHStargazer[].class, item -> item.wrapUp(this));
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/kohsuke/github/GitHubClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -619,10 +619,12 @@ private static GitHubConnectorRequest prepareConnectorRequest(GitHubRequest requ
}
}
if (request.header("Accept") == null) {
builder.setHeader("Accept", "application/vnd.github.v3+json");
builder.setHeader("Accept", "application/vnd.github+json");
}
builder.setHeader("Accept-Encoding", "gzip");

builder.setHeader("X-GitHub-Api-Version", "2022-11-28");

if (request.hasBody()) {
if (request.body() != null) {
builder.contentType(defaultString(request.contentType(), "application/x-www-form-urlencoded"));
Expand Down
15 changes: 14 additions & 1 deletion src/main/java/org/kohsuke/github/GitHubRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,9 @@ public B injectMappingValue(@NonNull String name, Object value) {
* the name
* @return the b
*/
@Deprecated
public B withPreview(String name) {
return withHeader("Accept", name);
return withAccept(name);
}

/**
Expand All @@ -518,10 +519,22 @@ public B withPreview(String name) {
* the preview
* @return the b
*/
@Deprecated
public B withPreview(Previews preview) {
return withPreview(preview.mediaType());
}

/**
* With accept header.
*
* @param name
* the name
* @return the b
*/
public B withAccept(String name) {
return withHeader("Accept", name);
}

/**
* With requester.
*
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/kohsuke/github/internal/Previews.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package org.kohsuke.github.internal;

import java.lang.Deprecated;

/**
* Provides the media type strings for GitHub API previews
*
* https://developer.github.com/v3/previews/
*
* @author Kohsuke Kawaguchi
*/
@Deprecated
public enum Previews {

/**
Expand Down

0 comments on commit f191180

Please sign in to comment.