mirror of
https://github.com/slimtoolkit/slim.git
synced 2025-06-03 04:00:23 +00:00
![dependabot[bot]](/assets/img/avatar_default.png)
Bumps [github.com/getkin/kin-openapi](https://github.com/getkin/kin-openapi) from 0.76.0 to 0.131.0. - [Release notes](https://github.com/getkin/kin-openapi/releases) - [Commits](https://github.com/getkin/kin-openapi/compare/v0.76.0...v0.131.0) --- updated-dependencies: - dependency-name: github.com/getkin/kin-openapi dependency-version: 0.131.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com>
35 lines
1009 B
Go
35 lines
1009 B
Go
package openapi3
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/oasdiff/yaml"
|
|
)
|
|
|
|
func unmarshalError(jsonUnmarshalErr error) error {
|
|
if before, after, found := strings.Cut(jsonUnmarshalErr.Error(), "Bis"); found && before != "" && after != "" {
|
|
before = strings.ReplaceAll(before, " Go struct ", " ")
|
|
return fmt.Errorf("%s%s", before, strings.ReplaceAll(after, "Bis", ""))
|
|
}
|
|
return jsonUnmarshalErr
|
|
}
|
|
|
|
func unmarshal(data []byte, v any, includeOrigin bool) error {
|
|
var jsonErr, yamlErr error
|
|
|
|
// See https://github.com/getkin/kin-openapi/issues/680
|
|
if jsonErr = json.Unmarshal(data, v); jsonErr == nil {
|
|
return nil
|
|
}
|
|
|
|
// UnmarshalStrict(data, v) TODO: investigate how ymlv3 handles duplicate map keys
|
|
if yamlErr = yaml.UnmarshalWithOrigin(data, v, includeOrigin); yamlErr == nil {
|
|
return nil
|
|
}
|
|
|
|
// If both unmarshaling attempts fail, return a new error that includes both errors
|
|
return fmt.Errorf("failed to unmarshal data: json error: %v, yaml error: %v", jsonErr, yamlErr)
|
|
}
|