Skip to content

Subclass SchemaGenerator instead of defining a new one#470

Open
kevin-brown wants to merge 20 commits intoaxnsan12:masterfrom
kevin-brown:GH-461-schemagenerator-subclass
Open

Subclass SchemaGenerator instead of defining a new one#470
kevin-brown wants to merge 20 commits intoaxnsan12:masterfrom
kevin-brown:GH-461-schemagenerator-subclass

Conversation

@kevin-brown
Copy link

While the SchemaGenerator provided by DRF-YASG is not API-compatible with the one used by DRF, it does use a lot of the methods and even generates a DRF one internally. Given that this required quite a bit of extra code to be written to do the wrapping, it makes sense to instead just subclass it and get those additional benefits.

This should make it easier to migrate from the CoreAPISchemaGenerator, which is what is currently being used, to the DRF-provided OpenAPISchemaGenerator for the internal serialization. That was not done here because there is still a lot of work that needs to be done in order to enable that.

While the SchemaGenerator provided by DRF-YASG is not API-compatible
with the one used by DRF, it does use a lot of the methods and even
generates a DRF one internally. Given that this required quite a
bit of extra code to be written to do the wrapping, it makes sense
to instead just subclass it and get those additional benefits.

This should make it eaiser to migrate from the CoreAPISchemaGenerator,
which is what is currently being used, to the DRF-provided
OpenAPISchemaGenerator for the internal serialization. That was not
done here because there is still a lot of work that needs to be done
in order to enable that.
Copy link
Contributor

@PaulWay PaulWay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good idea.

@kevin-brown kevin-brown force-pushed the GH-461-schemagenerator-subclass branch from 1e013f0 to 1920a81 Compare December 4, 2019 00:33
@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 enhancement 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

Comments