-
-
Notifications
You must be signed in to change notification settings - Fork 536
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
Support custom JSON decoders for views #3709
Support custom JSON decoders for views #3709
Conversation
Reviewer's Guide by SourceryThis PR introduces a new Class diagram for the new decode_json methodclassDiagram
class BaseView {
+decode_json(data: Union<str, bytes>) object
+encode_json(data: object) str
}
class AsyncBaseHTTPView {
+decode_json(data: Union<str, bytes>) object
+encode_json(data: object) str
}
class GraphQLView {
+decode_json(data: Union<str, bytes>) object
+encode_json(data: object) str
}
class AsyncGraphQLView {
+decode_json(data: Union<str, bytes>) object
+encode_json(data: object) str
}
class GraphQLRouter {
+decode_json(data: Union<str, bytes>) object
+encode_json(data: object) str
}
class MyGraphQLView {
+decode_json(data: Union<str, bytes>) object
}
class MyGraphQLRouter {
+decode_json(data: Union<str, bytes>) object
}
BaseView <|-- AsyncBaseHTTPView
BaseView <|-- GraphQLView
BaseView <|-- AsyncGraphQLView
BaseView <|-- GraphQLRouter
GraphQLView <|-- MyGraphQLView
GraphQLRouter <|-- MyGraphQLRouter
note for BaseView "Base class for views with JSON encoding/decoding"
note for MyGraphQLView "Example subclass overriding decode_json"
note for MyGraphQLRouter "Example subclass overriding decode_json"
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @DoctorJohn - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 3 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Thanks for adding the Here's a preview of the changelog: The view classes of all integrations now have a This is useful if you want to use a different JSON decoder, for example, to Here's the tweet text:
|
CodSpeed Performance ReportMerging #3709 will not alter performanceComparing Summary
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3709 +/- ##
==========================================
- Coverage 97.01% 97.00% -0.02%
==========================================
Files 500 500
Lines 33454 33483 +29
Branches 5591 5593 +2
==========================================
+ Hits 32457 32479 +22
Misses 793 793
- Partials 204 211 +7
|
Description
This PR introduces a
decode_json
method which allows users to customize decoding of HTTP JSON requests and WebSocket messages. This is similar to theencode_json
method which we already had for a while.Since this is a new method, this PR also includes docs and tests making sure HTTP, Multipart, and WebSocket protocols all use this new method.
Types of Changes
Summary by Sourcery
Introduce a
decode_json
method to allow custom JSON decoding in HTTP and WebSocket protocols, update documentation with usage examples, and add tests to verify the new functionality.New Features:
decode_json
method in view classes to allow customization of JSON decoding for HTTP requests and WebSocket messages.Documentation:
decode_json
method across various integrations, explaining its usage and providing examples.Tests:
decode_json
method is used in HTTP, Multipart, and WebSocket protocols.