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

Issue with operation id names #1264

Closed
shermari opened this issue Jul 24, 2024 · 3 comments
Closed

Issue with operation id names #1264

shermari opened this issue Jul 24, 2024 · 3 comments

Comments

@shermari
Copy link

First of all thank you for such wonderful library, it generates spectacular openapi.

Description of bug:
We were using django rest framework built-in support for creating the openapi specification for our django project but that's deprecated now (https://www.django-rest-framework.org/topics/documenting-your-api/#built-in-openapi-schema-generation-deprecated), they also suggest to use drf-spectacular which we find very useful to use and extend.

But after testing it with Oracle Visual Builder we noticed that operationId's are generated in a different way than django rest framework operationId, like the operationId generated by drf-spectacular has underscores in it, e.g user_list, instead of camel case, but after reading the documentation we found "CAMELIZE_NAMES" option in setting, by setting it True, it does camelise the operationId's but in wrong order, like instead of listUser it says userList,
We could not find any setting to change this.

To Reproduce:
Take any django app with a model and generate openapi as defined by drf-spectacular
drf-spectacular==0.27.2
djangorestframework==3.15.1
Django==5.0.6
Steps followed to setup the drf-spectacular
https://drf-spectacular.readthedocs.io/en/latest/readme.html

Expected Behavior:
Looking the docs of https://spec.openapis.org/oas/v3.0.1#operation-object-example and https://swagger.io/specification/ (Operation Object Example) I can see that operationIds are defined in "updatePetWithForm" and "updatePetWithForm" which means "Operation+ModelName or unique attribute" but in drf-spectacular that's not that case.

Please is it possible to change it from some setting or we can receive any update in near future?
Looking forward to correction operationIds because its breaking change for us migrating from drf's default openapi generation to drf-spectacular.

kind regards,
Sher, Senior Backend developer at Innovation Gateway

@shermari
Copy link
Author

shermari commented Sep 6, 2024

Hi, May I ask is there any plans to provide such option to change the operation_id in near future.
kind regards,
Sher

tfranzel added a commit that referenced this issue Sep 7, 2024
make operation_id action position configurable #1264
@tfranzel
Copy link
Owner

tfranzel commented Sep 7, 2024

Hi, I thought a while about this. I usually reject requests where the variation is only subjective and everybody would like to have their own flavour leading to too many options and somebody always wanting version x+1 afterwards.

However, this was raised before and is in my opinion the most common variation, especially with camelize_names.

I'll allow it but any further customization needs to be done by the user, which is super easy by the way. You would just need to subclass AutoSchema, override get_operation_id(), and set that class in the settings.

cheers

@tfranzel tfranzel closed this as completed Sep 7, 2024
@shermari
Copy link
Author

shermari commented Sep 7, 2024

Thank you very much I really appreciate this. Actually we tried to follow the openapi specs from the provided links from official source and i found this to be little bit different that's-why I asked that may be I was missing something.
kind regards, Sher.

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