From c24c4a76fd66b56016b094455831f5d32fca7ecc Mon Sep 17 00:00:00 2001 From: Vincent Tourraine Date: Tue, 16 Jan 2024 17:12:06 +0100 Subject: [PATCH] Add GitHub API version HTTP header --- Sources/AcknowList/GitHubAPI.swift | 4 +++- Tests/AcknowListTests/GitHubAPITests.swift | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/AcknowList/GitHubAPI.swift b/Sources/AcknowList/GitHubAPI.swift index feea5a2..4157a81 100644 --- a/Sources/AcknowList/GitHubAPI.swift +++ b/Sources/AcknowList/GitHubAPI.swift @@ -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 } diff --git a/Tests/AcknowListTests/GitHubAPITests.swift b/Tests/AcknowListTests/GitHubAPITests.swift index 3822013..ec94078 100644 --- a/Tests/AcknowListTests/GitHubAPITests.swift +++ b/Tests/AcknowListTests/GitHubAPITests.swift @@ -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") } }