Skip to content

[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
wants to merge 58 commits into
base: master
Choose a base branch
from

Conversation

kevin-brown
Copy link

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).

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.
@JoelLefkowitz JoelLefkowitz changed the base branch from master to 1.21.x July 17, 2022 17:20
@JoelLefkowitz JoelLefkowitz added 1.21.x Release target in 1.21.x Incomplete labels Jul 17, 2022
@JoelLefkowitz JoelLefkowitz added 1.22.x Release target in 1.22.x and removed 1.21.x Release target in 1.21.x labels Jul 17, 2022
@JoelLefkowitz JoelLefkowitz deleted the branch axnsan12:master October 17, 2024 11:55
@JoelLefkowitz JoelLefkowitz reopened this Oct 17, 2024
@JoelLefkowitz JoelLefkowitz changed the base branch from 1.21.x to master October 17, 2024 12:08
@JoelLefkowitz JoelLefkowitz added the enhancement Enhancement label Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.22.x Release target in 1.22.x enhancement Enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants