-
Notifications
You must be signed in to change notification settings - Fork 505
Add add_specs to api #553
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
base: master
Are you sure you want to change the base?
Add add_specs to api #553
Conversation
Wrong PR. |
What is status on this? |
@casparjespersen the code is working, but it is pending to be reviewed/accepted by a maintainer. Note that this is basically #465 including the unit test. |
I've approved, and will send it to the core team for a final check. Going through the ticket, it looks like @noirbizarre approved the general addition already. Code and tests look good to me. Sorry for not responding / checking earlier. Quite a backlog accumulated before more maintainers were added, and we're still going through things. |
@j5awry no problems, thans for taking care of this. |
The Swagger UI can already be disabled using import flask
from flask_restplus import Api, Resource
app = flask.Flask(__name__)
api = Api(app, version='1.0',
title='test', doc=False)
ns1 = api.namespace('api/v1', description='test')
@ns1.route('/my-resource')
class MyResource(Resource):
def get(self):
return {"message": "hello"}
if __name__ == "__main__":
app.run(debug=True) Requesting However, {
"swagger": "2.0",
"basePath": "/",
"paths": {
"/api/v1/my-resource": {
"get": {
"responses": {
"200": {
"description": "Success"
}
},
"operationId": "get_my_resource",
"tags": [
"api/v1"
]
}
},
"/api/v2/my-resource": {
"get": {
"responses": {
"200": {
"description": "Success"
}
},
"operationId": "get_my_new_resource",
"tags": [
"api/v2"
]
}
}
},
"info": {
"title": "test",
"version": "1.0"
},
"produces": [
"application/json"
],
"consumes": [
"application/json"
],
"tags": [
{
"name": "api/v1",
"description": "test"
},
{
"name": "api/v2",
"description": "test"
}
],
"responses": {
"ParseError": {
"description": "When a mask can't be parsed"
},
"MaskError": {
"description": "When any error occurs on mask"
}
}
} Instead of adding another Also it would be worth adding this change to the documentation -https://flask-restplus.readthedocs.io/en/stable/swagger.html#disabling-the-documentation |
@SteadBytes from my point of view the Swagger UI and the specs (i.e. |
d426f82
to
1ca98c6
Compare
I agree with @alvarolopez on this. While the swagger GUI uses the generated swagger.json, they are distinct entities as far as end user cases. In that vein, I think we should ensure the other cases around
|
46795b3
to
b64b9a3
Compare
@j5awry @alvarolopez , yes that's a good point. On second thoughts I agree with that. @j5awry, I can answer 2 for you; yes, the Swagger UI is not available if |
@SteadBytes well, I guess this is a side-effect of removing the |
Yes, removing However I think @j5awry was also asking whether we should support a possible use case of showing the Swagger UI but not directly exposing |
This flag allows to select if specs are added into the API or not. Fixes noirbizarre#464
So, I have added the documentation and also disabled spec generation. |
This PR is basically #465 without the removal of the test.
Implements #464