-
Notifications
You must be signed in to change notification settings - Fork 154
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 option to exclude OPTIONS requests #123
Conversation
d0cbe1a
to
03d0d78
Compare
These changes add a new optional parameter called `document_options` to the FlaskApiSpec constructor that will exclude OPTIONS requests from the swagger specification if set to `False`. Flask automatically generates OPTIONS requests for each route. There are cases, such as when using CORS, where one would want these OPTIONS requests to be generated but do not want to have them in their swagger docs. My line of reasoning for wanting to exclude these is: My API users will never explicitly make an OPTIONS request. The browser will automatically send a pre-flight OPTIONS request when making a cross-origin request, and I want to have OPTIONS endpoints in order to support that, but I don't want to have this functionality adding a bunch of endpoints to my swagger docs which will largely be ignored by users.
03d0d78
to
203800d
Compare
Codecov Report
@@ Coverage Diff @@
## master #123 +/- ##
==========================================
- Coverage 97.64% 97.38% -0.26%
==========================================
Files 8 8
Lines 339 344 +5
==========================================
+ Hits 331 335 +4
- Misses 8 9 +1
Continue to review full report at Codecov.
|
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.
Just like APISPEC_SPEC
is set as a config option, maybe FlaskApiSpec.document_options
should be as well? Otherwise it looks good to me, hope it'll get merged 👍
This would be handy for me right now. Thanks for working on it. |
Without meaning to drag up old issues, did this ever get anywhere? It looks to me like it wasn't implemented but I would say it's useful for many users who do not conciously need to make use of pre-flight/ |
Codecov Report
@@ Coverage Diff @@
## master #123 +/- ##
==========================================
- Coverage 97.82% 97.58% -0.24%
==========================================
Files 8 8
Lines 367 372 +5
==========================================
+ Hits 359 363 +4
- Misses 8 9 +1
Continue to review full report at Codecov.
|
Sorry for the long delay on this. This is released in 0.9.0 |
Fixes #111.
See #112 for prior discussion.
These changes add a new optional parameter called
document_options
to the FlaskApiSpec constructor that will exclude OPTIONS requests from the swagger specification if set toFalse
.Flask automatically generates OPTIONS requests for each route. There are cases, such as when using CORS, where one would want these OPTIONS requests to be generated but do not want to have them in their swagger docs.
My line of reasoning for wanting to exclude these is: My API users will never explicitly make an OPTIONS request. The browser will automatically send a pre-flight OPTIONS request when making a cross-origin request, and I want to have OPTIONS endpoints in order to support that, but I don't want to have this functionality adding a bunch of endpoints to my swagger docs which will largely be ignored by users.