Add ical action on MealPlanViewSet to expose filterable ical API in restful manner #3038
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Seems that the django style support for APIs with optional parameters (https://docs.djangoproject.com/en/5.0/topics/http/urls/#specifying-defaults-for-view-arguments) doesn't play nicely with openapi. In particular, it seems that if you use the same function for multiple URLs, they all get the same operation id which has to be unique.
I took a step back and I actually don't like the API design for ical as it isn't really properly formatted as a restful API. Search/filter parameters should generally be query parameters, not part of the URL itself. We already do this for the MealPlan apis; the to/from dates are query parameters for those APIs. I looked and with a bit of refactoring, its actually pretty simple to put the ical API in with the rest of the meal plan APIs, which seems like the more logical place for it to live. Benefit of putting it with the MealPlanViewSet as a new action is that you don't end up with conflicting operation ids. Also, if there are future changes to allow more advanced filtering of meal plans, the ical API gets it all for free.
This time, I made sure to take the extra step of generating the openapi client, and it seems to generate without error. I also took a look at the feature/vue3 branch, and it seems that this way will also work for that, but I didn't actually verify.
I left the original ical API as I wouldn't be surprised if someone somewhere is using it, and didn't want to immediately break them. But we should probably consider deprecating that at some point.