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

Fix for openapi.json location if another root directory #378

Merged
merged 4 commits into from
Oct 31, 2024

Conversation

Vlczech
Copy link
Contributor

@Vlczech Vlczech commented Oct 29, 2024

(for example /foo/bar -> /foo/bar/apidoc/openapi.json instead of /apidoc/openapi.json)

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Another root fix for starlette

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@@ -79,7 +79,7 @@ def register_route(self, app: Any):
f"/{self.config.path}/{ui}",
self.DOC_PAGE_ROUTE_CLASS(
self.config.page_templates[ui],
spec_url=self.config.spec_url,
spec_url=self.config.filename,
Copy link
Member

Choose a reason for hiding this comment

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

spec_url is f"/{self.path}/{self.filename}", I don't get why it should only contain the filename. Can you explain in detail?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I wrote to comment - absolute address is /apidoc/openapi.json ; so for example for:

But if there is some subdirectory for API, for example if multiple APIs is available, then absolute address is not good solution. For example base root dirs (basepaths) for APIs:

...If you have set some root directory for API, swagger and redoc try to find file absolutely on /apidoc/openapi.json (not relatively) so it show errors only. It is needed to search openapi.json in set subdirectory.

Copy link
Member

Choose a reason for hiding this comment

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

Got it. Thanks.

@kemingy kemingy merged commit 67c2684 into 0b01001001:master Oct 31, 2024
9 checks passed
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.

None yet

2 participants