reitit

Sardtok 2024-10-29T14:16:26.277809Z

This summer I upgraded Reitit in an app and switched to OpenAPI 3. However, I apparently didn't test it enough in Swagger UI, as now I have an issue with certain schemas where the parameter list ends up empty.

{:query [:and [:map
               [:x int?]
               [:y int?]]
         [:fn #(< (:x %) (:y %))]]}
This applies to body parameters as well. Removing the :and and just using the map, makes it work like it did with OpenAPI 2, aka Swagger. For now, I've switched out the create-openapi-handler with create-swagger-handler and registered an issue on Github. But I'm just wondering if anyone knows if this is intentional? If so I'll have to move some of the validation into a different layer (either the handler or make an additional middleware).

opqdonut 2024-10-30T08:01:17.880329Z

commenting here as well as on github: the problem is that the :query parameter spec should be an actual :map, because the OpenAPI spec generation needs to iterate through the children. Supporting :and in general would be tricky, and I don't like the idea of adding a special case for [:and :map :fn]. I've added a warning that triggers when the :query spec isn't a :map.

👍 1
opqdonut 2024-10-29T14:40:25.123539Z

hmm

opqdonut 2024-10-29T14:40:57.069799Z

so :and maps to :allOf in json-schema, and :fn maps to an empty schema

opqdonut 2024-10-29T14:41:21.342999Z

I'll need to dig into this... I'm not sure what the right way to handle :and would be in general

opqdonut 2024-10-29T14:43:22.347059Z

note to self, this is the issue: https://github.com/metosin/reitit/issues/705