Skip to content

[Question] Use Swagger servers for version prefix and leave the paths as is #44

@OlegZv

Description

@OlegZv

Subject of the issue

I am trying to figure out how to make Swagger display the version prefix, like /api/latest in the servers list, and the API route excludes that prefix. This way, the swagger UI paths contain only the base paths. So my two questions are:

  1. Can this be achieved with the current implementation?
  2. Would you consider changing the API to add this functionality?

Your environment

Python 3.11.4
Ubuntu 22.04

Steps to reproduce

Running custom docs example from here: https://github.com/alexschimpf/fastapi-versionizer/blob/main/examples/docs_customization.py

Desired behavior

I'd love to get this as a result. The server contains /v1_0, and all the paths are "base."
image

I achieved this by changing the _build_version_router to router = APIRouter() (no prefix) and in the versionize changed self._app.include_router(router=version_router, prefix=version_prefix).

Actual behavior

Each version path repeatedly starts with the version prefix /v1_0
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions