Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Swagger slash basepath within Swagger UI Middleware #1835

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

nielsbox
Copy link
Collaborator

Fixes #1834 .

Changes proposed in this pull request:

  • Add slash before basePath

@coveralls
Copy link

coveralls commented Dec 11, 2023

Coverage Status

coverage: 94.214%. remained the same
when pulling 306d5ee on bugfix/swagger-slash-base-path
into 211bdb0 on main.

Copy link
Member

@RobbeSneyders RobbeSneyders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nielsbox! The fix looks good, but some comments on the tests.

tests/conftest.py Outdated Show resolved Hide resolved
tests/api/test_swagger_ui.py Show resolved Hide resolved
tests/api/conftest.py Outdated Show resolved Hide resolved
@@ -269,7 +269,7 @@ def base_path(self):

@base_path.setter
def base_path(self, base_path):
base_path = canonical_base_path(base_path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function seems to be fairly specific for this usecase, can we adjust it instead or create a different util function that adjust the behaviour of canonical_base_path in this way?

Then it's also easier to test because we can just write a unit test for that util function

@@ -269,7 +269,7 @@ def base_path(self):

@base_path.setter
def base_path(self, base_path):
base_path = canonical_base_path(base_path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit wider comment: the property itself still uses the canonical_base_path function, so the "getter" returns a different value, there's also the added complexity that the base path is used as Flask blueprint name, which has its own rules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BasePath doesn't get properly returned within SwaggerUI Middleware
4 participants