-
-
Notifications
You must be signed in to change notification settings - Fork 135
Integrate Requests library #24
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b86a15d
Add RequestsOpenAPIRequest to wrappers.py to integrate requests pytho…
andyceo 4d24006
Add RequestsOpenAPIResponse to wrappers.py to integrate requests pyth…
andyceo d97df12
Cleanup for Request object
andyceo 375aeed
Bugfix for RequestsOpenAPIRequest.parameters(): path and query now co…
andyceo 05a844d
Add implementation of RequestsOpenAPIRequest.body and RequestsOpenAPI…
andyceo 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 hidden or 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.
I don't think your implementation for the path_pattern is going to work for routes that have path parameters. The library does a dictionary lookup where it expects the path_pattern to equal the path in the spec. For example, consider the path '/pets/{petId}'. Your implementation will cause the library to try to look up something like '/pets/123' in the paths dict, which will cause the validation to fail because that's not the way the path is defined in the OAS spec.
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.
I'll be pushing a PR sometime today that should deal with the path_pattern problem. If accepted then your implementation will likely work correctly with my addition.
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.
Actually, it's more complicated than I thought. I have something that would work for the path_pattern but it doesn't account for the path and query parameters.
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.
Yes, if we have route pattern, this would not work. I think we should add route pattern when creating RequestsOpenAPIRequest object:
Currently I am working on it, could not say when it would ready...
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.
I'm wondering if this should actually be a part of the library. Consider this.
We already have a regex-like pattern in the route:
/pets/{petId})
If we convert this into a true regex then we should be able to match against every possible pattern that this path can have:
/pets/(.*)
It makes sense to do this in the spec object rather than the request object because the spec contains the patterns of every possible path in the API. Thus we merely match the url against all possible paths, which is O(n) though n should be small, and pick the pattern that matches the raw url.
The problem then (and this is where I am at the moment) is that we must also extract the path path and query parameters. The query params should be able to be parsed easily. The path params require a bit more work since this is part of the validators, but it's definitely doable.
A second option is to pass the spec to the request object and let it figure out everything there. However, I feel it would be far more user friendly to simply be able to have the core library extract this information from a simpler request object since there are plenty or url parsing tools and it would make implementing request wrappers much easier in the future.