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

Exclude OPTIONS method from operation list #112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ruathudo
Copy link

I have the problem with every endpoint, the OPTIONS method is auto created and showing in Swagger UI.
Options method is rarely used for creating REST API so it is good to ignore this.
Flask endpoint always gives (HEAD, OPTIONS) method by default.

@codecov-io
Copy link

codecov-io commented Jul 19, 2018

Codecov Report

Merging #112 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #112   +/-   ##
=======================================
  Coverage   97.64%   97.64%           
=======================================
  Files           8        8           
  Lines         339      339           
=======================================
  Hits          331      331           
  Misses          8        8
Impacted Files Coverage Δ
flask_apispec/apidoc.py 97.05% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 535fc9d...32f810d. Read the comment docs.

@euri10
Copy link

euri10 commented Aug 10, 2018

“OPTIONS is a promising idea that nobody uses.”

maybe a slightly "better" option would be to add a configuration option to exclude it, some people may indeed like the idea of having it enabled as a self referencing tool.

@euri10
Copy link

euri10 commented Aug 11, 2018

as per Flask doc in routes registration:

provide_automatic_options: if this attribute is set Flask will either force enable or disable the automatic implementation of the HTTP OPTIONS response. This can be useful when working with decorators that want to customize the OPTIONS response on a per-view basis.

you just pass provide_automatic_options=False in your route and options disappear

@henryfjordan
Copy link
Contributor

OPTIONS endpoints are absolutely valid to have in a spec. This would be a breaking change and should be avoided. Adding an option to the flask-apispec constructor would be better.

@Brcrwilliams
Copy link
Contributor

Brcrwilliams commented Oct 21, 2018

I think CORS gives people a legitimate reason for excluding OPTIONS requests from the swagger specification while still having Flask automatically generate them. I have taken a stab at implementing this as an optional feature by adding a parameter to the FlaskApiSpec constructor. Take a look at my PR #123, where I have also elaborated further on my reasoning.

@vpassapera
Copy link

Any issues merging this?

@caarmen
Copy link

caarmen commented Nov 11, 2024

Hello from multiple years in the future!

Looks like this was addressed (and merged) in #123

Now, it's possible to pass an argument document_options=False to the FlaskApiSpec constructor.

Perhaps this issue can be closed now?

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.

7 participants