-
-
Notifications
You must be signed in to change notification settings - Fork 762
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
Bad operationId to error status code #278
Merged
rafaelcaricio
merged 29 commits into
spec-first:master
from
jfinkhaeuser:bad-operation-id-to-5xx
Sep 13, 2016
Merged
Changes from 28 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
a0071d6
- Add test cases for bad and missing operationIds
jfinkhaeuser ad0a908
Add test cases for missing and bad operationIds - slightly different …
jfinkhaeuser 1648dd5
YAML file for the previous test case
jfinkhaeuser 1914e56
ImportError should also be translated into ResolverError
jfinkhaeuser 875efbf
Obviously, ImportError no longer falls through. That should have been
jfinkhaeuser 3cd04f8
Add test cases for the resolver_error flag. That's what it should do,
jfinkhaeuser d27264d
Add ability to add random string to endpoint names so that flask doesn't
jfinkhaeuser 7864a9d
Mhh, that change should not have been there.
jfinkhaeuser 2cae3b1
Fix flake8 complaints
jfinkhaeuser 44d4140
Add ability for Operation to randomize endpoint name (off by default)
jfinkhaeuser 92f51ea
Improve Api test cases
jfinkhaeuser 8c55654
Move ResolverError over to exceptions where it seems to be long.
jfinkhaeuser 4d706d5
Give the same string representation as other exception classes
jfinkhaeuser 1e786d9
If a ResolverError is raised during the addition of operations, and a
jfinkhaeuser eacfe47
Instead of making resolver_error_handler a magic dict, make it a
jfinkhaeuser 34ee0d1
Add ResolverErrorHandler, analogous to AuthErrorHandler
jfinkhaeuser 4203f4c
When adding an API, allow specifying an error code for turning
jfinkhaeuser f50da76
Add YAML for bad specs test
jfinkhaeuser 9196b38
Report more about the ResolverError details.
jfinkhaeuser 37154d3
Makes sure #250 is still working. This explicitly handles ImportError
jfinkhaeuser 70c5bb9
Merge branch 'reuse-endpoint-names' into bad-operation-id-to-5xx
jfinkhaeuser 328aa51
Fix isort errors. Some of these look like they're not from my branch to
jfinkhaeuser 9d4a40e
Merge branch 'fix-missing-operation-id' into bad-operation-id-to-5xx
jfinkhaeuser 0bc04c5
Merge branch 'master' into bad-operation-id-to-5xx
jfinkhaeuser ecd7d3a
Fix tests after merge
jfinkhaeuser 6476c03
Fix isort errors
jfinkhaeuser 7b7b11d
This file shouldn't have been added.
jfinkhaeuser 74cec24
Fixes after running & fixing `TOXENV=isort-check tox`
jfinkhaeuser fa328f7
Move bad_specs fixtures to its own fixtures folder
jfinkhaeuser 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ | |
|
||
import connexion | ||
from connexion import NoContent | ||
|
||
import orm | ||
|
||
db_session = None | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
swagger: "2.0" | ||
|
||
info: | ||
title: "{{title}}" | ||
version: "1.0" | ||
|
||
basePath: /v1.0 | ||
|
||
paths: | ||
/welcome: | ||
get: | ||
operationId: fakeapi.foo_bar.search | ||
parameters: | ||
# The default below validates, but is obviously the wrong type | ||
- name: foo | ||
in: query | ||
type: integer | ||
default: somestring | ||
responses: | ||
200: | ||
description: search | ||
schema: | ||
type: object |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
swagger: "2.0" | ||
|
||
info: | ||
title: "{{title}}" | ||
version: "1.0" | ||
|
||
basePath: /v1.0 | ||
|
||
paths: | ||
/welcome: | ||
get: | ||
operationId: no.module.or.function | ||
responses: | ||
200: | ||
description: greeting response | ||
schema: | ||
type: object | ||
put: | ||
# operationId: XXX completely missing | ||
responses: | ||
200: | ||
description: greeting response | ||
schema: | ||
type: object | ||
post: | ||
operationId: fakeapi.module_with_error.something | ||
responses: | ||
200: | ||
description: greeting response | ||
schema: | ||
type: object |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
import tempfile | ||
|
||
from connexion.api import Api | ||
from connexion.exceptions import ResolverError | ||
from connexion.exceptions import InvalidSpecification, ResolverError | ||
from swagger_spec_validator.common import SwaggerValidationError | ||
from yaml import YAMLError | ||
|
||
|
@@ -49,6 +49,10 @@ def test_invalid_operation_does_stop_application_to_setup(): | |
Api(TEST_FOLDER / "fixtures/user_module_loading_error/swagger.yaml", "/api/v1.0", | ||
{'title': 'OK'}) | ||
|
||
with pytest.raises(ResolverError): | ||
Api(TEST_FOLDER / "fixtures/missing_op_id/swagger.yaml", "/api/v1.0", | ||
{'title': 'OK'}) | ||
|
||
|
||
def test_invalid_operation_does_not_stop_application_in_debug_mode(): | ||
api = Api(TEST_FOLDER / "fixtures/op_error_api/swagger.yaml", "/api/v1.0", | ||
|
@@ -59,11 +63,28 @@ def test_invalid_operation_does_not_stop_application_in_debug_mode(): | |
{'title': 'OK'}, debug=True) | ||
assert api.specification['info']['title'] == 'OK' | ||
|
||
api = Api(TEST_FOLDER / "fixtures/module_not_implemented/swagger.yaml", "/api/v1.0", | ||
{'title': 'OK'}, debug=True) | ||
assert api.specification['info']['title'] == 'OK' | ||
|
||
api = Api(TEST_FOLDER / "fixtures/user_module_loading_error/swagger.yaml", "/api/v1.0", | ||
{'title': 'OK'}, debug=True) | ||
assert api.specification['info']['title'] == 'OK' | ||
|
||
api = Api(TEST_FOLDER / "fixtures/module_not_implemented/swagger.yaml", "/api/v1.0", | ||
api = Api(TEST_FOLDER / "fixtures/missing_op_id/swagger.yaml", "/api/v1.0", | ||
{'title': 'OK'}, debug=True) | ||
assert api.specification['info']['title'] == 'OK' | ||
|
||
|
||
def test_other_errors_stop_application_to_setup(): | ||
# The previous tests were just about operationId not being resolvable. | ||
# Other errors should still result exceptions! | ||
with pytest.raises(InvalidSpecification): | ||
Api(TEST_FOLDER / "fakeapi/bad_specs.yaml", "/api/v1.0", | ||
{'title': 'OK'}) | ||
|
||
# Debug mode should ignore the error | ||
api = Api(TEST_FOLDER / "fakeapi/bad_specs.yaml", "/api/v1.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please move those specs to a proper directory within There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, yeah, the bad specs I missed. One moment. |
||
{'title': 'OK'}, debug=True) | ||
assert api.specification['info']['title'] == 'OK' | ||
|
||
|
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.
It is not very clear that
resolver_error
is expected to be a HTTP status code. Would be nice to have a more friendly name here.