Skip to content
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

[BUG]: Missing TextMatches from SearchCodeResult #2747

Open
1 task done
rogerfar opened this issue Jul 12, 2023 · 2 comments
Open
1 task done

[BUG]: Missing TextMatches from SearchCodeResult #2747

rogerfar opened this issue Jul 12, 2023 · 2 comments
Labels
Status: Pinned A way to keep old or long lived issues around Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented

Comments

@rogerfar
Copy link

What happened?

When searching for code, you can request TextMatches by adding application/vnd.github.text-match+json to the Accept header:
https://docs.github.com/en/rest/search/search?apiVersion=2022-11-28#text-match-metadata

This will include text_matches in the response, currently they are not included in the response.

Versions

Tested on C# 7.0.1

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@rogerfar rogerfar added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Jul 12, 2023
@kfcampbell kfcampbell added Priority: Normal Status: Up for grabs Issues that are ready to be worked on by anyone and removed Status: Triage This is being looked at and prioritized labels Jul 13, 2023
@mitchcapper
Copy link
Contributor

While adding this with a PR isn't too hard if you want a quick hack around:

public class OurSearchCode {
	public class TextMatch {
		public string fragment { get; private set; }
	}
	public TextMatch[] text_matches { get; private set; }
	public string Name { get; private set; }
	public string Path { get; private set; }
	public string Sha { get; private set; }
	public string Url { get; private set; }
	public string GitUrl { get; private set; }
	public string HtmlUrl { get; private set; }
	public Repository Repository { get; private set; }
}
public class OurSearchCodeResult : SearchResult<OurSearchCode> {
	public OurSearchCodeResult() { }

	public OurSearchCodeResult(int totalCount, bool incompleteResults, IReadOnlyList<OurSearchCode> items)
		: base(totalCount, incompleteResults, items) {
	}
}
public async Task<OurSearchCodeResult> DoSearch(bool withProxy = false) {
	var client = GetClient(withProxy);
	var conn = (ApiConnection)typeof(ApiClient).InvokeMember("ApiConnection", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.GetProperty | BindingFlags.Instance, null, client.Search, new object[0]);
	var result = await conn.Get<OurSearchCodeResult>(ApiUrls.SearchCode(), request.Parameters, "application/vnd.github.text-match+json");
	return result;
}

you can add some of the other text search result args to the TextMatch class if desired as well

@nickfloyd nickfloyd added the hacktoberfest Issues for participation in Hacktoberfest label Sep 21, 2023
Copy link

👋 Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!

@github-actions github-actions bot added the Status: Stale Used by stalebot to clean house label Jun 18, 2024
@kfcampbell kfcampbell reopened this Jun 28, 2024
@kfcampbell kfcampbell added Status: Pinned A way to keep old or long lived issues around and removed Status: Stale Used by stalebot to clean house hacktoberfest Issues for participation in Hacktoberfest labels Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Pinned A way to keep old or long lived issues around Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented
Projects
Status: 🔥 Backlog
Development

No branches or pull requests

4 participants