Page MenuHomePhabricator

Cannot override basePath in the Swagger spec
Open, LowPublic


The base path for the Swagger spec is set dynamically; there doesn't seem to be any way to override it. This is a problem on vagrant which rewrites URLs on the web server level, so the public URL prefix is<vagrant port>/api/rest_v1/ which gets internally rewritten into http://localhost:<restbase port>/ and since the current logic autogenerates basePath from the URL it will end up with the latter.

Even if getDocBasePath honored an explicit basePath, it's not very clear where to set it. The data for match.value.specRoot seems to be the object defined in one of the projects/wmf_*.yaml files, which is not a great place for vagrant-specific overrides. There should be a way to set basePath somewhere in config.*.yaml and get it merged into the Swagger spec.

Event Timeline

Tgr created this task.Sep 26 2017, 1:16 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 26 2017, 1:16 AM
Tgr added a comment.Sep 26 2017, 5:02 PM

F9823771 is a workaround for local testing.

Pchelolo added a subscriber: Pchelolo.

There should be a way to set basePath somewhere in config.*.yaml and get it merged into the Swagger spec.

This is pretty easy to do and I agree that should be done.

However, that's not all we need here because of this check. As I understand this was done precisely for local testing and inability to set the x-host-basePath in the config so that both local dev and production worked.

In production, we set the Host header to the requested wiki domain, while in both vagrant and just local installation the Host header is just localhost. With vanilla installation it all works - we do not do any rewrites, however in vagrant, it breaks - even though the do a rewrite, the Host header is still being set to localhost - the check doesn't pass.

I have tried to reset the Host header in apache for requests routed to RESTBase, but for some reason never could make it change the host header.


  1. Use 'X-Forwarded-Host` header instead of the Host header.
  2. Remove the check and rely entirely on the presence/absence for the x-host-basePath in the config.
  3. EPIC: reconsider all of these rewrites etc and rely entirely on the Host header coming to RESTBase for everything. Varnish team would be pretty happy about that, but it's a huge amount of work and I'm not sure we could undertake it.

I like option number 2 the most.

Pchelolo triaged this task as Low priority.Aug 13 2019, 6:10 PM