rest icon indicating copy to clipboard operation
rest copied to clipboard

Run-time error on models containing map[string]interface{}

Open Arc-Calem opened this issue 1 year ago • 0 comments

I encounter a runtime error whenever I try to document a model with a map[string]interface{} field:

In Main:

api.Get(apiV1PathPrefix+"/my-route"). HasRequestModel(rest.ModelOf[model.MyRouteRequest]()). HasResponseModel(http.StatusInternalServerError, rest.ModelOf[model.MyRouteRequest]()). HasResponseModel(http.StatusInternalServerError, rest.ModelOf[respond.Error]())

The model:

type MyRouteRequest struct { Id string json:"Id,omitempty" OtherField stringjson:"otherField,omitempty" Text stringjson:"text" binding:"required" Extra map[string]interface{}json:"-" // Field that results in runtime error }

Arc-Calem avatar Jun 26 '24 15:06 Arc-Calem