-
Notifications
You must be signed in to change notification settings - Fork 440
[WIP] Merge in features from DRF core #461
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
Open
kevin-brown
wants to merge
58
commits into
axnsan12:master
Choose a base branch
from
kevin-brown:merge-drf-core
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
ca7b624
to
4c0eced
Compare
Removal of `as_cached_view` in favor of just making all `as_view` calls use the cache. Subclassing the DRF-profvided SchemaView to start the merge with the YASG SchemaView. get_schema_view to be API-compatible with DRF.
This makes it now match the standard formats used by DRF which should help compatibility with the existing DRF renderers for mixing and matching.
This required defining a `with_validators` method that is a no-op in order to still work with how "validators" are injected into renderers at the time that the schema view is built. All tests are still passing after this was swapped out, so it appears as though validators were not tested with this view.
This still does custom rendering of the YAML because we are using custom classes that aren't natively compatible with the YAML dumper. The eventual goal would be to do this without a custom renderer, or to allow DRF to have a custom dumper for YAML like it does for JSON. This also needs the `with_validators` override because the schema view expects this to always be defined. Once again, it looks like we don't have any actual tests which use the validators.
We were special casing the URL patterns for the generator for the UI views, but instead of looking for the UI views we were looking for any of the schema renderers. Since we are switching the base classes for the schema renderers, we should be instead looking for the common UI rendering subclass.
Instead of requiring a middleware to do the rendering, we can instead just use the built-in error handling provided by DRF. All this required was for us to subclass `APIException` and to set the `detail` property on the exception itself.
This brings us further away from the DRF-provided SchemaView, but hopefully we can get a hook in DRF that would allow for this validation to be provided. Right now DRF throws an error if the generated schema is empty, so this is basically another check that would occur around that time. The logger for validations has changed as a result of it now occurring in a different file.
This is used in the tests and it will make it easier when we are figuring out what needs to be split back out from the DRF SchemaView in the future.
This has been replaced by `yaml_sane_dump` which serves the same purpose
This method was unused now that we are running validators within the view instead of within the renderer as a part of rendering. This should make it easier to use DRF renderers since they are now API compatible.
This is unused now that we no longer have the custom JSON and YAML codecs to deal with.
These are very basic but they should get the job done enough.
4c0eced
to
b98a8e9
Compare
5c17f9c
to
838d3df
Compare
fix map source mapping
[readme] Fix missing re_path import
Add utf-8 support for generated formats
Remove universal wheel, python 2 is unsupported
Fix old spelling errors and add a cspell configuration.
…-arbitrary-references Allow specifying response as a reference
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is a proof of concept to see if it's even possible. If this ends up being possible, the intention is to layer in smaller pull requests which are targeted instead of a massive one (so, not using this branch).