Skip to content
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

Incorrectly renders CamelCase in all views #156

Closed
glujan opened this issue Jul 2, 2018 · 4 comments
Closed

Incorrectly renders CamelCase in all views #156

glujan opened this issue Jul 2, 2018 · 4 comments
Milestone

Comments

@glujan
Copy link

glujan commented Jul 2, 2018

In my app I'm using djangorestframework-camel-case only for some subset of views by setting their parser and renderer classes to CamelCaseJSONParser and CamelCaseJSONRenderer respectively. My default parser and renderer classes are set to JSONParser and JSONRenderer in my project settings.

It looks like using camelCase for just one view is causing drf-yasg to use camelCase in all views.

@axnsan12
Copy link
Owner

axnsan12 commented Jul 2, 2018

As you can see form the demo project, this is not generally the case. Only views with the parser and renderer you mentioned are converted. Thus it must be something more particular to your project, so please provide some details.

You should note however that due to the nature of OpenAPI and the current implementation of drf-yasg, if you use the same serializer in multiple views, where only some of them are camelCased, the Swagger model associated with that serializer will be camelCased everywhere. See also the note here. You can work around this by not using named Swagger models (setting ref_name to None on the serializer).

@glujan
Copy link
Author

glujan commented Jul 3, 2018

Thank you for detailed response.

I'm indeed reusing some serializers and your note about ref_name was what I was missing - setting it to None or to string to not clash with original serializer solves the issue.

@glujan glujan closed this as completed Jul 3, 2018
@glujan
Copy link
Author

glujan commented Jul 3, 2018

Note: this also happens if I'm not reusing serializers but there is a name clash in across different Django applications. Setting different ref_name helps with those issues as well.

Maybe drf-yasg should show a warning about that or at least allow to prefix model name with app name.

@glujan glujan reopened this Jul 3, 2018
@axnsan12
Copy link
Owner

axnsan12 commented Jul 3, 2018

Maybe drf-yasg should show a warning about that or at least allow to prefix model name with app name.

Yeah, both of those seem reasonable.

@axnsan12 axnsan12 added this to the 1.10.0 milestone Aug 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants