Skip to content

Commit

Permalink
Add GitHub API version HTTP header
Browse files Browse the repository at this point in the history
  • Loading branch information
vtourraine committed Jan 16, 2024
1 parent aa992c2 commit c24c4a7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Sources/AcknowList/GitHubAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ open class GitHubAPI {
let path = pathWithoutExtension(for: repository)
let url = "https://api.github.com/repos\(path)/license"
var request = URLRequest(url: URL(string: url)!)
request.allHTTPHeaderFields = ["Accept": "application/vnd.github.raw"]
request.allHTTPHeaderFields = [
"Accept": "application/vnd.github.raw",
"X-GitHub-Api-Version": "2022-11-28"]
return request
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/AcknowListTests/GitHubAPITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class GitHubAPITests: XCTestCase {
let request = GitHubAPI.getLicenseRequest(for: repoURL)

XCTAssertEqual(request.url?.absoluteString, "https://api.github.com/repos/vtourraine/AcknowList/license")
XCTAssertEqual(request.allHTTPHeaderFields, ["Accept": "application/vnd.github.raw"])
XCTAssertEqual(request.allHTTPHeaderFields, ["Accept": "application/vnd.github.raw", "X-GitHub-Api-Version": "2022-11-28"])
XCTAssertEqual(request.httpMethod, "GET")
}
}

0 comments on commit c24c4a7

Please sign in to comment.