// handleModel extracts data from the api:model markup func handleModel(swagDoc *specs.SwagDoc, docs []string) error { var def = make(map[string]specs.SwagSchema) for _, doc := range docs { var model map[string]specs.SwagSchema y := []byte(doc) // for some reason yaml.Unmarshal throws error: "panic: reflect: reflect.Value.Set using unaddressable value" // with structs that have nested pointers // as a workaround, convert yaml string to json string and unmarshal j, err := yaml.YAMLToJSON(y) err = json.Unmarshal(j, &model) if err != nil { return err } for k, v := range model { def[k] = v } } swagDoc.Definitions = &def return nil }