ApiFilter - 别名参数名称
ApiFilter - Altername parameter name
是否可以为 URL 使用备用参数名称?
我有类似的东西
* @ApiFilter(SearchFilter::class, strategy="exact", properties={
* "appcountryref.countryname":"exact",
* "refyear":"exact"
* })
这导致 url 笑话
https://127.0.0.1:8000/api/exo/allowances?appcountryref.countryname=Belgium&page=1
我想要:
https://127.0.0.1:8000/api/exo/allowances?countryname=Belgium&page=1
在幕后将 "countryname" 链接到 "appcountryref.countryname" 的 API
可能吗?
谢谢!
来自 Grégoire Hébert 贡献者和导师的信息
It is not expected because it reflects the structure of your public data.
If you want to do it you need private property whose getter returns the value of the child object but this is not a good practice.
It's not trivial if it's done this way, it's to meet standards
是否可以为 URL 使用备用参数名称?
我有类似的东西
* @ApiFilter(SearchFilter::class, strategy="exact", properties={
* "appcountryref.countryname":"exact",
* "refyear":"exact"
* })
这导致 url 笑话 https://127.0.0.1:8000/api/exo/allowances?appcountryref.countryname=Belgium&page=1
我想要: https://127.0.0.1:8000/api/exo/allowances?countryname=Belgium&page=1
在幕后将 "countryname" 链接到 "appcountryref.countryname" 的 API
可能吗? 谢谢!
来自 Grégoire Hébert 贡献者和导师的信息
It is not expected because it reflects the structure of your public data. If you want to do it you need private property whose getter returns the value of the child object but this is not a good practice. It's not trivial if it's done this way, it's to meet standards