Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Can't get Swagger UI to provide interface for arbitrary query params

未关闭
#455 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 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:
image

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:
image

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 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

metosin/compojure-api 的其他 Issue

查看 metosin/compojure-api 的全部 Issue

相似的 Issue

更多 Clojure Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。