Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#455 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
clojure, openapi
Lĩnh vực
api, documentation

Hướng nghiên cứu

Bắt đầu với route GET "/find" và khai báo :query của nó, sau đó kiểm tra cách compojure-api chuyển các query map tùy ý thành mô tả OpenAPI/Swagger. Công việc được xem là hoàn tất khi Swagger UI có thể tạo ?a=1\u0026b=2 cho các key do requester chọn, trong khi handler hiện tại nhận được map; hãy xác minh bằng các ví dụ curl.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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'
Ngôn ngữ chính
Clojure
Star
1.1k
Fork
145
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của metosin/compojure-api

Tất cả issue của metosin/compojure-api

Issue tương tự

Thêm issue về Clojure

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.