-
-
Notifications
You must be signed in to change notification settings - Fork 72
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
Add publish_apidoc flag to SpecTree constructor #311
Open
AndreasBBS
wants to merge
2
commits into
0b01001001:master
Choose a base branch
from
AndreasBBS:feature/disable_publish_apidoc
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
register_route
is only used when we need to generate the OpenAPI doc.You don't have to call this method if all you need is the validation. The code changes to the other two files look good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can add this to the README HowTo part? I think this flag is not necessary unless we support more features like "only expose part of the doc". WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me that other parts rely on the self.app inside spectree so I kept the register part of the code that sets that variable. For example the starlette_plugin.py uses it in find_routes. Tracking down the implications of removing the self.app was too complex for the fix I was trying to do so for safety I decided to keep it. If you are confident that it be the same as omitting the register(app) step then it's fine with me adding it to the README.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your time. I have double-checked the code, all the
self.app
usages are related to generating the OpenAPI config. Without thespec.register()
, we should be safe to use the validation feature without binding the OpenAPI endpoints.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it also the case for the plugins?
Falcon uses self.spectree.app here:
spectree/spectree/plugins/falcon_plugin.py
Lines 87 to 101 in 7d585b6
Starlette uses self.spectree.app here:
spectree/spectree/plugins/starlette_plugin.py
Lines 143 to 179 in 7d585b6
Are this
find_routes
methods also only for generating the OpenAPI config? I refactored this two plugins because they were usingself.app
on themselves and theBasePlugin
does not have a self.app. I felt it wasn't very consistent across plugins and theapp
can still be accessed fromself.spectree.app
. This might be a change to keep.If you give me the confirmation these
find_routes
methods on the plugins are also strictly for OpenAPI generation I'll go ahead and remove the changes and add a new entry toREADME.md
documenting that omitting the register(app) will cause the OpenAPI routes to not be generated but the validation will still be enforced.Also let me know if you want me to keep the
self.app
->self.spectree.app
refactor.P.S.: No need to thank me for my time. It's my pleasure to be able to contribute to the tools I use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
find_routes
is only used to generate the OpenAPI config.self.app
since there is no such attribute.SpecTree
andBasePlugin
can access each other. Need to refactor this part.self.app
->self.spectree.app
refactor. To make it consistent, you can also choose to delete theapp
arg fromregister_root()
and useself.spectree.app
directly.