logto-io / logto

🧑‍🚀 The better identity infrastructure for developers and the open-source alternative to Auth0.
https://logto.io
Mozilla Public License 2.0
8.36k stars 409 forks source link

feat: add advanced search params to all supported endpoints #6358

Closed mostafa closed 1 month ago

mostafa commented 1 month ago

Summary

The /api/users (GET) endpoint (and many others) returns a list of users and supports advanced search queries. However, the OpenAPI spec documentation currently does not include any URL search (query) parameters for this functionality. This PR introduces a new dynamic parameter called search_params, defined as an object with string keys and values. This object will not appear in the generated OpenAPI client. Instead, users can pass a map of strings, which will append these keys and values to the URLSearchParams, thereby enabling advanced user search capabilities.

Testing

Query parameter

api-search-params

Swagger UI

swagger-ui

URL

image

Go API Client

user, _, err := client.UsersAPI.ListUsers(ctx).SearchParams(map[string]string{
  "search.primaryEmail": "test@example.com",
  "mode": "exact"
}).Execute()

Checklist

github-actions[bot] commented 1 month ago

COMPARE TO master

Total Size Diff :chart_with_upwards_trend: +692 Bytes

Diff by File |Name|Diff| |---|---| |packages/core/src/routes/swagger/index.ts|:chart_with_upwards_trend: +414 Bytes| |packages/core/src/routes/swagger/utils/parameters.ts|:chart_with_upwards_trend: +278 Bytes|