Can't get Swagger UI to provide interface for arbitrary query params
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- clojure, openapi
- 领域
- api, documentation
调研方向
从 GET "/find" 路由及其 :query 声明开始,然后检查 compojure-api 如何将任意查询 map 转换为 OpenAPI/Swagger 描述。完成标准是 Swagger UI 能够针对 requester 选择的键生成 ?a=1\u0026b=2,同时现有 handler 能接收到该 map;使用 curl 示例进行验证。
由索引模型根据 Issue 内容生成。
描述
Library Version(s)
2.0.0-alpha31
Problem
Swagger can display a UI for setting dynamic query parameters, but I can't figure out how to do it with compojure-api.
I have a /find endpoint which needs to receive arbitrary query parameters.
E.g., Given /api/find?x=1&y=2&z=3 I want to receive a map {:x 1, :y 2, :3} somewhere in my handler. The keys are chosen by the requester.
(ns myns (:require [schema.core :as scm]))
(def myapp
(api ...
(GET "/find" [& fields]
:return scm/Any
(ok fields))
This works:
curl 'localhost:8080/api/runs/find?a=1&b=2'
{"a":"1","b":"2"}%
But the Swagger UI does not provide a way to set the query parameters:

I've tried variants of the route, providing
:query [fields scm/Any]
And many other things. I can't seem to find documentation for the arguments to :query. (Also, does anyone understand what :- is for?)
If I use a schema that starts with schema.core/maybe...
(scm/defschema QueryArgs (scm/maybe (scm/cond-pre scm/Num scm/Str scm/Bool scm/Keyword scm/Uuid)))
and provide this to :query...
(GET "/find" [& fields]
:return scm/Any
:query [fields QueryArgs]
(ok))
Swagger at least shows a box that allows me to assign several values inside another parameter, but it's not the one I want:

It produces a URL like this:
curl -X GET --header 'Accept: application/json' 'http://localhost:8080/api/runs/find?schemas=a%3D1&schemas=b%3D2'
But I want
curl -X GET --header 'Accept: application/json' 'http://localhost:8080/api/runs/find?a=1&b=2'
- 主要语言
- Clojure
- 星标
- 1.1k
- 派生
- 145
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
metosin/compojure-api 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 45/100
metosin/compojure-api#489 ·
-
难度 5/5 一周以上 新手友好度 30/100
metosin/compojure-api#468 ·
-
难度 5/5 一周以上 新手友好度 20/100
metosin/compojure-api#467 ·
-
难度 5/5 一周以上 新手友好度 25/100
metosin/compojure-api#464 ·
-
难度 5/5 一周以上 新手友好度 30/100
metosin/compojure-api#463 · 3 条评论 ·
查看 metosin/compojure-api 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 64/100
维护者通常 1 天内回复
-
.Needs Triage .Run Repro Bot .Team/UXWest Priority:P3 Type:Bug
难度 2/5 1-3 小时 新手友好度 65/100
metabase/metabase#84325 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
NoahTheDuke/splint#56 ·
-
Permissioned transactions fetch each entity once per tx-step, producing huge permission-check queries可能已有人在做 @verveguy 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
难度 2/5 半天 新手友好度 84/100
clojure-lsp/clojure-lsp#2502 ·
维护者通常 1 天内回复