Templates: remove deprecated params from api (#15020)

This commit is contained in:
andig 2024-07-24 16:24:46 +02:00 • committed by GitHub
parent 972259f706
commit 5e608fb656
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -33,7 +33,20 @@ func templatesHandler(w http.ResponseWriter, r *http.Request) {
return
}
jsonResult(w, templates.ByClass(class))
// filter deprecated properties
res := make([]templates.Template, 0)
for _, t := range templates.ByClass(class) {
params := make([]templates.Param, 0, len(t.Params))
for _, p := range t.Params {
if p.Deprecated == nil || !*p.Deprecated {
params = append(params, p)
}
}
t.Params = params
res = append(res, t)
}
jsonResult(w, res)
}
// productsHandler returns the list of products by class