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

Document endpoint /api/player/autocomplete (fix #847) #848

Merged
merged 2 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ GET /player controllers.User.list
GET /player/top/:nb/:perfKey controllers.User.topNb(nb: Int, perfKey: String)
GET /player/top/week controllers.User.topWeek
GET /player/online controllers.User.online
GET /player/autocomplete controllers.User.autocomplete
GET /api/player/autocomplete controllers.User.autocomplete

GET /dasher controllers.Dasher.get

Expand Down
63 changes: 60 additions & 3 deletions public/doc/lishogi-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2364,6 +2364,60 @@ paths:
schema:
$ref: '#/components/schemas/Crosstable'

/api/player/autocomplete:
get:
operationId: apiPlayerAutocomplete
summary: Autocomplete usernames
description: |
Provides autocompletion options for an incomplete username.
tags:
- Users
security: []
parameters:
- in: query
name: term
description: The beginning of a username
schema:
type: string
minLength: 3
required: true
- in: query
name: object
description: |
- `false` returns an array of usernames
- `true` returns an object with matching users
schema:
type: boolean
default: false
- in: query
name: friend
description: |
Returns followed players matching `term` if any, else returns other players.
Requires [OAuth](#tag/OAuth).
schema:
type: boolean
responses:
"200":
description: An array of players which usernames start with the provided term.
headers:
Access-Control-Allow-Origin:
schema:
type: string
default: "'*'"
content:
application/json:
schema:
oneOf:
- type: array
items:
type: string
- type: object
properties:
result:
type: array
items:
$ref: '#/components/schemas/LightUser'

/api/stream/event:
get:
operationId: apiStreamEvent
Expand Down Expand Up @@ -4328,6 +4382,9 @@ components:
LightUser:
type: object
properties:
id:
type: string
example: "shogi_harbour"
name:
type: string
example: "Shogi_Harbour"
Expand All @@ -4338,9 +4395,9 @@ components:
patron:
type: boolean
example: true
id:
type: string
example: "shogi_harbour"
online:
type: boolean
example: true

Perf:
type: object
Expand Down
2 changes: 1 addition & 1 deletion public/javascripts/forum-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ $(function () {
// We fall back to every site user after 3 letters of the username have been entered
// and there are no matches in the forum thread participants
$.ajax({
url: '/player/autocomplete',
url: '/api/player/autocomplete',
data: {
term: term,
},
Expand Down
2 changes: 1 addition & 1 deletion public/javascripts/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $(function () {
if (name.length >= 3)
$.ajax({
method: 'GET',
url: '/player/autocomplete',
url: '/api/player/autocomplete',
data: {
term: name,
exists: 1,
Expand Down
2 changes: 1 addition & 1 deletion public/javascripts/team-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ $(() => {
// show loading animation and hide the suggestions dropdown
tagify.loading(true).dropdown.hide.call(tagify);

fetch(`/player/autocomplete?term=${encodeURIComponent(term)}&names=1`, {
fetch(`/api/player/autocomplete?term=${encodeURIComponent(term)}&names=1`, {
signal: abortCtrl.signal,
})
.then(r => r.json())
Expand Down
2 changes: 1 addition & 1 deletion ui/site/src/clas.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ $(function () {
if (term.length < 2) callback([]);
else
$.ajax({
url: '/player/autocomplete?object=1&teacher=1',
url: '/api/player/autocomplete?object=1&teacher=1',
data: {
term: term,
},
Expand Down
2 changes: 1 addition & 1 deletion ui/site/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
source: function (query, _, runAsync) {
if (query.trim().match(/^[a-z0-9][\w-]{2,29}$/i))
$.ajax({
url: '/player/autocomplete',
url: '/api/player/autocomplete',
cache: true,
data: {
term: query,
Expand Down
Loading