Fork me on GitHub
#reitit
<
2020-04-07
>
eric.shao02:04:47

Hello. How to setup retitit-swagger to group APIs under different group names? Is there a piece of code sample? THX!😊

eric.shao05:04:21

@ikitommi 😀Thank you for your reply. I don’t describe clear, Is there a way to have a Two-level Group? A big group contains many secondary groups.

ikitommi05:04:46

uthere is no such thing in swagger, but we have used tag names like admin, admin.users, admin.products etc. Flat, but looks nested.

ikitommi06:04:04

You could post an issue asking this into swagger-ui repo, if there would be such a grouping available nowadays, please paste the result here too.

eric.shao06:04:48

Maybe gen many swagger spec?

eric.shao06:04:21

😀Thank you @ikitommi for your reply.

ikitommi06:04:44

e.g. you can easily groups the apis into separate swagger specs too.

eric.shao06:04:23

:hugging_face: Thank you!!!

sudakatux12:04:17

I cant seem to get this example to work

sudakatux12:04:21

["/upload"
    {:post {:summary "upload a file"
            :parameters {:multipart [:map [:file reitit.ring.malli/temp-file-part]]}
            :responses {200 {:body [:map [:name string?] [:size int?]]}}
            :handler (fn [{{{:keys [file]} :multipart} :parameters}]
                       {:status 200
                        :body {:name (:filename file)
                               :size (:size file)}})}}]

sudakatux12:04:38

im using

[metosin/reitit "0.4.2"]

ikitommi12:04:53

do you have the multipart-middleware mounted?

sudakatux12:04:55

The middleware seems to be "the problem"

sudakatux12:04:15

{:middleware [;; query-params & form-params
                 parameters/parameters-middleware
                 ;; content-negotiation
                 muuntaja/format-negotiate-middleware
                 ;; encoding response body
                 muuntaja/format-response-middleware
                 ;; exception handling
                 exception/exception-middleware
                 ;; decoding request body
                 muuntaja/format-request-middleware
                 ;; coercing response bodys
                 coercion/coerce-response-middleware
                 ;; coercing request parameters
                 coercion/coerce-request-middleware
                 ;; multipart params
                 multipart/multipart-middleware]
    :muuntaja   formats/instance

ikitommi12:04:21

that is directly from the example project?

sudakatux12:04:26

["/api"
   {:middleware [;; query-params & form-params
                 parameters/parameters-middleware
                 ;; content-negotiation
                 muuntaja/format-negotiate-middleware
                 ;; encoding response body
                 muuntaja/format-response-middleware
                 ;; exception handling
                 exception/exception-middleware
                 ;; decoding request body
                 muuntaja/format-request-middleware
                 ;; coercing response bodys
                 coercion/coerce-response-middleware
                 ;; coercing request parameters
                 coercion/coerce-request-middleware
                 ;; multipart params
                 multipart/multipart-middleware]
    :muuntaja   formats/instance
    :coercion   malli-coercion/coercion

sudakatux12:04:45

just copied that endpoint

ikitommi12:04:01

will test the project

sudakatux12:04:41

it seems like the middleware is not adding the :multipart parameter

sudakatux12:04:17

because if i ignore the middleware and i hit :multipart-param directly I do see the file

ikitommi12:04:37

Just tested the example project and it works ok.

ikitommi13:04:50

try adding the :reitit.middleware/transform reitit.ring.middleware.dev/print-request-diffs router option

sudakatux11:04:45

Thanks this really helped me understand lots of things

ikitommi13:04:01

should print what’s going on.

sudakatux13:04:10

cool thanks will try