Application uses kabab-case key formatting for schema like below
(s/defschema User
{:first-name s/Str
:last-name s/Str})
But for swagger docs I want the schema in camelCase like below
(s/defschema User
{:firstName s/Str
:lastName s/Str})
Is there any way of implementing middleware for swagger so that I can transform schema from kabab-case to camelCase? Please suggest how can I achieve this.
My current code looks like this below for dynamic swagger docs generation for the api
(api {:format {:formats [:transit-json :json]
:params-opts {:transit-json {:handlers transit/transit-read-handlers}}
:response-opts {:transit-json {:handlers transit/transit-write-handlers}}}
:coercion coercions/default-coercions
:swagger {:ui "/swagger"
:spec "/swagger.json"
:data {:info {:title "API Docs"}
:securityDefinitions
{:api_key
{:type "apiKey"
:name "Authorization"
:in "header"}}
:tags [{:name "User" :description "/api/v1/user"}]
:consumes ["application/json"]
:produces ["application/json"]}
}
:api {:invalid-routes-fn (constantly nil)}}
(create-api-routes web-server-config :middleware default-middleware))
I am using swagger provided by compojure-api for routing.
We can implement my requirement using reitit and there is also a sample project rest-api using reitit how to achieve this. But I want to achieve similar thing using compojure-api as i don't want to upgrade to new library for routing now.