JuliaComputing/OpenAPI.jl

Escape path parameters

Closed this issue · 2 comments

For path parameters we need an uriescape. This could be done with

julia> HTTP.escapeuri(":/?#[]@!\$&'()*+,;=")
"%3A%2F%3F%23%5B%5D%40%21%24%26%27%28%29%2A%2B%2C%3B%3D"

but this needs to be placed in in the openapi generator here

In my use case I would also like to escape dots . -> %2E. Unsure how to go about this. I thought I'll add

    function f(ctx)
        for (k, v) in ctx.path
            ctx.path[k] = replace(v, "." => "%2E")
        end
        for (k, v) in ctx.query
            ctx.query[k] = replace(v, "." => "%2E")
        end
        ctx
    end
    function f(rp, bd, he)
        return rp, bd, he
    end

And set f to pre_request_hook of the client. However, now it's converting to %252E (hook converts to %2E, code converts % to %25). Maybe it's fine to document this and ask users to do this in their own pre-request hook as this logic may vary upon implementation.

Closing as we discussed that it is not required for the client.