Merged in feature/s3integration (pull request #47)

Set Up S3 integration

* cfginterfaceandfirsts3funcs

* addlocalstack

* generallypassesfullsuite

* addedmultipleattemptedpings

* cleanup

* stabiliseplusskip
This commit is contained in:
Michael McGuinness
2025-02-05 12:52:41 +00:00
parent 9254b91d45
commit 92334ad1dd
838 changed files with 139249 additions and 6671 deletions
+76
View File
@@ -0,0 +1,76 @@
package openapi3
import "encoding/json"
// StringMap is a map[string]string that ignores the origin in the underlying json representation.
type StringMap map[string]string
// UnmarshalJSON sets StringMap to a copy of data.
func (stringMap *StringMap) UnmarshalJSON(data []byte) (err error) {
*stringMap, _, err = unmarshalStringMap[string](data)
return
}
// unmarshalStringMapP unmarshals given json into a map[string]*V
func unmarshalStringMapP[V any](data []byte) (map[string]*V, *Origin, error) {
var m map[string]any
if err := json.Unmarshal(data, &m); err != nil {
return nil, nil, err
}
origin, err := deepCast[Origin](m[originKey])
if err != nil {
return nil, nil, err
}
delete(m, originKey)
result := make(map[string]*V, len(m))
for k, v := range m {
value, err := deepCast[V](v)
if err != nil {
return nil, nil, err
}
result[k] = value
}
return result, origin, nil
}
// unmarshalStringMap unmarshals given json into a map[string]V
func unmarshalStringMap[V any](data []byte) (map[string]V, *Origin, error) {
var m map[string]any
if err := json.Unmarshal(data, &m); err != nil {
return nil, nil, err
}
origin, err := deepCast[Origin](m[originKey])
if err != nil {
return nil, nil, err
}
delete(m, originKey)
result := make(map[string]V, len(m))
for k, v := range m {
value, err := deepCast[V](v)
if err != nil {
return nil, nil, err
}
result[k] = *value
}
return result, origin, nil
}
// deepCast casts any value to a value of type V.
func deepCast[V any](value any) (*V, error) {
data, err := json.Marshal(value)
if err != nil {
return nil, err
}
var result V
if err = json.Unmarshal(data, &result); err != nil {
return nil, err
}
return &result, nil
}