DeanWay / fastapi-versioning

api versioning for fastapi web applications
MIT License
642 stars 63 forks source link

root_path is not propagated to versioned apps properly, breaking openapi docs #50

Closed kosz85 closed 3 years ago

kosz85 commented 3 years ago

My app is behind some proxy so it's url is smth like http://abc.cd/some/path/v1_0/ to support it properly I'm adding root_path="/some/path", and in general everything is working ok as in most cases this param is just ignored, except openapidocs, where it's used to generate path to openapi.json:

http://abc.cd/some/path/v1_0/docs

    const ui = SwaggerUIBundle({
        url: '/v1_0/openapi.json',

should be:

    const ui = SwaggerUIBundle({
        url: '/some/path/v1_0/openapi.json',
DeanWay commented 3 years ago

fixed in version 0.10.0

nierw commented 3 years ago

Still experiencing this in 0.10.0

DeanWay commented 3 years ago

@nierw can you include steps to reproduce? And specifically how this is different in a real world scenario than in https://github.com/DeanWay/fastapi-versioning/tree/master/example/proxy Thanks

nierw commented 2 years ago

@DeanWay So it looks as if I misread the changes, apologies - I fixed my end. However the core problem is that root_path has to be passed directly to VersionedFastAPI instead of being propagated from the underlying FastAPI object. This is a bit unclear without directly reading the examples. Additionally this is a breaking change for certain codebases that rely on operations prior to creation of VersionedFastAPI instances.

Defining root_path from the root FastAPI object should be a possible, if not the preferred way to deal with this param. https://github.com/DeanWay/fastapi-versioning/blob/master/example/proxy/app.py#L5