Open zarembas opened 9 years ago
Moving the default_version line before the api_base_url seems to fix this.
This is a bug with how the base_url is stored on a per-version basis. This should be better documented, but config.api_base_url
sets the base_url for the default version, which is 1.0 when that command is executed. You can either change the default version before setting api_base_url
(which you discovered) or you can run config.api_base_url["0.6"] = "/"
to set it for version 0.6. Relevant function below:
# set base url for default version of API
# to set it for specific version use
# config.api_base_url[version] = url
def api_base_url=(url)
version = Apipie.configuration.default_version
@api_base_url[version] = url
end
For apipie maintainers, a possible fix would be to add the following to lib/apipie/configuration.rb
:
def default_version=(version)
old_default_version = Apipie.configuration.default_version
@default_version = version
@api_base_url[version] = @api_base_url[old_default_version] unless @api_base_url[version]
@app_info[version] = @app_info[old_default_version] unless @app_info[version]
end
The following code will add "api" at the beginning of every route:
If I change the default_version back to "1.0", the routes start with "/" again.