You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having a look at the new Autopatch functionality.
I send something like this: [{"op":"replace","path":"/description","value":"MouthPieceApp123"}]
In my GET Operation, I return a model with a number of fields Marked ReadOnly, but description is not:
type appGetResponse struct {
ID int `doc:"ID of the Application" readOnly:"true" json:"id"`
Name string `doc:"Name of the Application" pattern:"^[a-zA-Z0-9_]+$" minLength:"3" maxLength:"32" json:"name"`
Description string `doc:"Description of the Application" pattern:"^[a-zA-Z0-9_]+$" minLength:"0" maxLength:"255" json:"description,omitempty"`
Filters []appFiltersResponse `doc:"Filters of the Application" json:"filters,omitempty" readOnly:"true"`
Groups []appGroupResponse `doc:"Groups of the Application" json:"groups,omitempty" readOnly:"true"`
}
and my PUT operation input model is:
type appPutRequest struct {
ID int `doc:"ID of the Application" readOnly:"true" path:"id"`
Body struct {
appGetResponse
}
}
Before hitting the actual PUT Operation, Huma rejects a json-patch operation with errors such as:
{
"title": "Unprocessable Entity",
"status": 422,
"detail": "Error while processing input parameters",
"errors": [
{
"message": "Additional property id is not allowed",
"location": "body",
"value": 1
},
{
"message": "Additional property groups is not allowed",
"location": "body",
"value": [
{
"Description": "Default MouthPiece App Group",
"ID": 8589934593,
"Name": "MouthPiece"
}
]
}
]
}
if I change the Body struct for my appPutRequest struct to just the mutable fields, I still get errors about additional fields - those copied from the internal GET request.
I'm guessing readonly fields should be dropped from the final request sent internally to the PUT handler, but looking over the patch code, I see we basically just copy the result of the GET operation into the json-patch library without any filtering at all. (
I'm having a look at the new Autopatch functionality.
I send something like this:
[{"op":"replace","path":"/description","value":"MouthPieceApp123"}]
In my GET Operation, I return a model with a number of fields Marked ReadOnly, but description is not:
and my PUT operation input model is:
Before hitting the actual PUT Operation, Huma rejects a json-patch operation with errors such as:
if I change the Body struct for my appPutRequest struct to just the mutable fields, I still get errors about additional fields - those copied from the internal GET request.
I'm guessing readonly fields should be dropped from the final request sent internally to the PUT handler, but looking over the patch code, I see we basically just copy the result of the GET operation into the json-patch library without any filtering at all. (
huma/patch.go
Line 225 in 1519e49
The text was updated successfully, but these errors were encountered: