-
Notifications
You must be signed in to change notification settings - Fork 76
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
Align search API with search page #656
base: main
Are you sure you want to change the base?
Conversation
5c315a0
to
ab6f480
Compare
cli: Boolean | ||
)(project: Project): SearchApi.Project = { | ||
val artifacts = if (cli) project.cliArtifacts.toList else project.artifacts | ||
SearchApi.Project( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also include defaultArtifact since search API under the hood redirects to it anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added the defaultArtifact
field coming from the Project
data class. You can try it here.
This field is not set automatically, it is set manually by the library maintainer. So it can be empty or completely nonsense.
@@ -10,29 +10,33 @@ package object routes { | |||
( | |||
"q" ? "*", | |||
"page".as[Int] ? 1, | |||
"total".as[Int] ? SearchParams.resultsPerPage, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we also include information about available pages? Currently one needs to call next page until the response is empty (but this is probably not in the scope of this PR).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added the currentPage
and pageTotal
fields: https://index-dev.scala-lang.org/api/search?q=*&scalaVersions=scala3&sort=stars&total=20&page=2
3f84d64
to
4d564b0
Compare
@@ -91,7 +104,8 @@ class SearchApi( | |||
val routes: Route = | |||
pathPrefix("api") { | |||
cors() { | |||
path("search") { | |||
// deprecated endpoint replaced by api/search endpoint | |||
path("search-old") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we instead keep this one and introduce a new endpoint api/search/v2
, to not break existing users?
This PR deprecates the current
api/search
endpoint by renaming itapi/search-old
.Then it introduces a new
api/search
endpoint whose query inputs, behavior and response are similar to thesearch
page enpoint.This new API can be tested on the dev environment: https://index-dev.scala-lang.org
Example:
https://index-dev.scala-lang.org/api/search?q=*&scalaVersions=scala3&sort=stars&total=20