jhthorsen / mojolicious-plugin-openapi

OpenAPI / Swagger plugin for Mojolicious
54 stars 44 forks source link

url_for problem in Mojolicious::Plugin::OpenAPI::SpecRenderer V5.09 -> _render_spec with haproxy replace-path #250

Closed opawilly closed 2 months ago

opawilly commented 5 months ago

we use a haproxy with replace-path to manage multiple backend http-request replace-path /app(/)?(.*) /\2

  "openapi": "3.0.0",
  "servers": [
    {
      "url": "/api"
    }
  ], ...

after server restart the json looks ok

    "servers": [
        {
            "url": "http://localhost/app/api"
        }
    ],

after site refresh

    "servers": [
        {
            "url": "http://localhost/app/app/api"
        }
    ],

if i change
$validator->base_url($c->req->url->to_abs->path($c->url_for($validator->base_url->path))); to $validator->base_url($c->req->url->to_abs->path($c->url_for($openapi->validator->base_url->path))); all work fine

jhthorsen commented 3 months ago

Would you mind opening a pull request for this?