Issue with enum query parameter with a default value
还没有人认领这个 Issue。
评估
调研方向
首先跟踪 issue 中所示 enum 查询参数的 Swagger 参数生成过程。检查默认值和 required 标志的派生方式,然后验证生成的 JSON 包含默认值 "published_at" 和 required true,且 UI 中没有 nil 选项。
由索引模型根据 Issue 内容生成。
描述
If a query parameter is of type enum and has a default value, the swagger parameter for default should be appropriately set and required should be set to true.
Here is an example below.
what's happening
(GET "/all/" request
:description "Return a list of articles."
:return [(dissoc t/Article :is_html :text)]
:responses default-responses
:query-params [{sort :- (describe (s/enum :published_at :last_processed_at) "The sort type. Defaults to published_at.") "published_at"}]
(return (domain/get-all-articles db (org request) :days 1)))
The sort parameter above can be either published_at or last_processed_at where it defaults to the former.
The JSON output for the route above is:
"parameters": [
{
"in": "query",
"name": "sort",
"description": "The sort type. Defaults to published_at.",
"required": false,
"type": "string",
"enum": [
"last_processed_at",
"published_at"
]
}
]
And the UI renders like this:

expectation
I would expect the select box in the UI to start off with the published_at pre-selected and not allow a nil option.
I would expect the json output to have required set to true and a default value set to published_at.
Thanks for your time!
- 主要语言
- 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 小时 新手友好度 72/100
NoahTheDuke/splint#56 ·
-
Permissioned transactions fetch each entity once per tx-step, producing huge permission-check queries可能已有人在做 @verveguy 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
难度 2/5 半天 新手友好度 84/100
clojure-lsp/clojure-lsp#2502 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 72/100