-
-
Notifications
You must be signed in to change notification settings - Fork 381
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
Camel case serialization/deserialization for Schema #33
Comments
I've basically solved this myself without library additions, the solution isn't perfect but I'm pretty happy with it. I'm using the
And then I just use It's a little funky, and I'm ignoring the
This method allows me to serialize directly to a Django Model and the schema shows up in the Swagger documentation correctly. I personally think adding this to the library would be beneficial. I'm happy to submit a PR and update the Ninja docs to highlight this use case @vitalik. If you reopen the issue, I can throw this and the docs together and submit a PR within a day or so. |
Thanks @fletcheaston , very useful! |
I'm currently using DRF and a third-party package called djangorestframework-camel-case (DRFCC). DRFCC provides "Camel case JSON support for Django REST framework", which simply outputs snake case to camel case, and vice versa for input. This is really helpful for my counterpart on the front-end/React side of our application, so he doesn't need to camel case fields himself. DRFCC has 348 stars at this point, so I believe this is a fairly popular use case.
An implementation of this seems fairly straightforward using Pydantic's alias generators, and I see that you've already configured some specific Pydantic Config options for your Schema class.
Is this something you'd be interested in having included as an option to your Schema class? I'll be implementing this myself regardless, but I'm happy to discuss this in greater detail and submit a PR, I can also document this addition to the PR.
The text was updated successfully, but these errors were encountered: