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

overriding methods does not work #79

Closed
rule88 opened this issue Sep 30, 2020 · 2 comments
Closed

overriding methods does not work #79

rule88 opened this issue Sep 30, 2020 · 2 comments

Comments

@rule88
Copy link

rule88 commented Sep 30, 2020

Hi,

overriding methods doesn't seem to work, even not in the provided example:

python demo_http_method.py 
/venv/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py:793: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it to True or False to suppress this warning.
  warnings.warn(FSADeprecationWarning(
[2020-09-30 10:07:21,345] INFO: Exposing method User.send_mail on /users/<string:UserId>/send_mail, endpoint: api.users.send_mail
[2020-09-30 10:07:21,359] INFO: Exposing User on /users/, endpoint: api.User
[2020-09-30 10:07:21,360] ERROR: Invalid response object. Missing field "description"
Traceback (most recent call last):
  File "/venv/lib/python3.8/site-packages/flask_restful_swagger_2/swagger.py", line 336, in validate_responses_object
    validate_reference_object(v)
  File "/venv/lib/python3.8/site-packages/flask_restful_swagger_2/swagger.py", line 324, in validate_reference_object
    raise ValidationError('Invalid reference object. It may only contain key "$ref"')
flask_restful_swagger_2.swagger.ValidationError: Invalid reference object. It may only contain key "$ref"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/venv/lib/python3.8/site-packages/safrs/safrs_api.py", line 411, in add_resource
    validate_path_item_object(path_item)
  File "/venv/lib/python3.8/site-packages/flask_restful_swagger_2/swagger.py", line 232, in validate_path_item_object
    validate_operation_object(v)
  File "/venv/lib/python3.8/site-packages/flask_restful_swagger_2/swagger.py", line 273, in validate_operation_object
    validate_responses_object(v)
  File "/venv/lib/python3.8/site-packages/flask_restful_swagger_2/swagger.py", line 338, in validate_responses_object
    validate_response_object(v)
  File "/venv/lib/python3.8/site-packages/flask_restful_swagger_2/swagger.py", line 360, in validate_response_object
    raise ValidationError('Invalid response object. Missing field "description"')
flask_restful_swagger_2.swagger.ValidationError: Invalid response object. Missing field "description"
[2020-09-30 10:07:21,360] CRITICAL: Validation failed for OrderedDict([('get', {'tags': ['users'], 'summary': 'Retrieve a collection of User objects', 'parameters': [{'default': '', 'type': 'string', 'name': 'include', 'in': 'query', 'format': 'string', 'required': False, 'description': 'User relationships to include (csv)'}, {'default': 'name,email', 'type': 'string', 'name': 'fields[User]', 'in': 'query', 'format': 'string', 'required': False, 'description': 'User fields to include (csv)'}, {'default': 0, 'type': 'integer', 'name': 'page[offset]', 'in': 'query', 'format': 'int64', 'required': False, 'description': 'Page offset'}, {'default': 10, 'type': 'integer', 'name': 'page[limit]', 'in': 'query', 'format': 'int64', 'required': False, 'description': 'Max number of items'}, {'default': 'name,email,id', 'type': 'string', 'name': 'sort', 'in': 'query', 'format': 'string', 'required': False, 'description': 'Sort order'}, {'default': '', 'type': 'string', 'name': 'filter[name]', 'in': 'query', 'format': 'string', 'required': False, 'description': 'name attribute filter (csv)'}, {'default': '', 'type': 'string', 'name': 'filter[email]', 'in': 'query', 'format': 'string', 'required': False, 'description': 'email attribute filter (csv)'}, {'default': '', 'type': 'string', 'name': 'filter[id]', 'in': 'query', 'format': 'string', 'required': False, 'description': 'id attribute filter (csv)'}, {'default': '', 'type': 'string', 'name': 'filter', 'in': 'query', 'format': 'string', 'required': False, 'description': 'Custom User filter'}, {'name': 'Content-Type', 'in': 'header', 'type': 'string', 'default': 'application/vnd.api+json', 'enum': ['application/vnd.api+json', 'application/json'], 'required': True}], 'responses': {'429': {'description': 'Too many requests'}, '404': {'description': 'Nothing matches the given URI'}, '200': {'schema': {'$ref': '#/definitions/User_get_coll'}}, '405': {'description': 'Specified method is invalid for this resource'}, '400': {'description': 'Bad request syntax or unsupported method'}, '500': {'description': 'Server got itself in trouble'}}, 'produces': ['application/vnd.api+json'], 'description': 'Get something', 'operationId': 'Usergetsummary_0'}), ('post', {'tags': ['users'], 'summary': 'Create User', 'parameters': [{'name': 'UserId', 'in': 'path', 'type': 'string', 'default': 'addbb3f2-e356-470c-8f5f-c0965d23561f', 'required': True}, {'name': 'Content-Type', 'in': 'header', 'type': 'string', 'default': 'application/vnd.api+json', 'enum': ['application/vnd.api+json', 'application/json'], 'required': True}, {'name': 'POST body', 'in': 'body', 'description': 'User attributes', 'schema': {'$ref': '#/definitions/User_post_inst1'}, 'required': True}], 'responses': {'403': {'description': 'Forbidden'}, '202': {'description': 'Accepted'}, '404': {'description': 'Not Found'}, '409': {'description': 'Conflict'}, '201': {'description': 'Created'}, '405': {'description': 'Specified method is invalid for this resource'}, '400': {'description': 'Bad request syntax or unsupported method'}, '500': {'description': 'Server got itself in trouble'}}, 'produces': ['application/vnd.api+json']})])

This is an important feature as it will greatly enable the flexibility of an API.

@thomaxxl
Copy link
Owner

From the error it looks like the swagger in the method docstring is invalid.
Did you specify a docstring? Can you paste your method code?

@thomaxxl
Copy link
Owner

thomaxxl commented Oct 2, 2020

Can you check if de7ee82 works for you?

@thomaxxl thomaxxl reopened this Oct 2, 2020
@thomaxxl thomaxxl closed this as completed Oct 4, 2020
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

No branches or pull requests

2 participants