Documentation
¶
Index ¶
- Variables
- func AsSecuritySource(security interface{}) func(context.Context) (interface{}, error)
- func CalculateJSONSize(v interface{}) int
- func ConsumeRawBody(res *http.Response) ([]byte, error)
- func Contains(slice []string, item string) bool
- func GenerateURL(_ context.Context, serverURL, path string, pathParams interface{}, ...) (string, error)
- func GetEnv(name, defaultValue string) string
- func MarshalJSON(v interface{}, tag reflect.StructTag, topLevel bool) ([]byte, error)
- func MatchContentType(contentType string, pattern string) bool
- func MatchStatusCodes(expectedCodes []string, statusCode int) bool
- func PopulateHeaders(_ context.Context, req *http.Request, headers interface{}, globals interface{})
- func PopulateQueryParams(_ context.Context, req *http.Request, queryParams interface{}, ...) error
- func PopulateSecurity(ctx context.Context, req *http.Request, ...) error
- func PopulateSecurityFromEnv(security interface{}) bool
- func ReplaceParameters(stringWithParams string, params map[string]string) string
- func Retry(ctx context.Context, r Retries, operation func() (*http.Response, error)) (*http.Response, error)
- func SerializeRequestBody(_ context.Context, request interface{}, nullable, optional bool, ...) (io.Reader, string, error)
- func UnmarshalJSON(b []byte, v interface{}, tag reflect.StructTag, topLevel bool, ...) error
- func UnmarshalJsonFromResponseBody(body io.Reader, out interface{}, tag string) error
- func ValueFromEnvVar(envVar string, field interface{}) interface{}
- type BackoffStrategydeprecated
- type FieldCounts
- type Retries
- type RetryConfigdeprecated
- type Timer
- type UnionCandidate
Constants ¶
This section is empty.
Variables ¶
var (
SerializationMethodToContentType = map[string]string{
"json": "application/json",
"form": "application/x-www-form-urlencoded",
"multipart": "multipart/form-data",
"raw": "application/octet-stream",
"string": "text/plain",
}
)
Functions ¶
func AsSecuritySource ¶
func CalculateJSONSize ¶ added in v0.7.0
func CalculateJSONSize(v interface{}) int
CalculateJSONSize returns the byte size of the JSON representation of a value. This is used to determine which union type variant has the most data.
func GenerateURL ¶
func GetEnv ¶
GetEnv returns the value of the environment variable named by the key or the defaultValue if the environment variable is not set.
func MarshalJSON ¶
func MatchContentType ¶
func MatchStatusCodes ¶
func PopulateHeaders ¶
func PopulateQueryParams ¶
func PopulateSecurity ¶
func PopulateSecurityFromEnv ¶
func PopulateSecurityFromEnv(security interface{}) bool
func ReplaceParameters ¶
func SerializeRequestBody ¶
func UnmarshalJSON ¶
func ValueFromEnvVar ¶
func ValueFromEnvVar(envVar string, field interface{}) interface{}
Types ¶
type BackoffStrategy
deprecated
type BackoffStrategy = retry.BackoffStrategy
Deprecated: Use retry.BackoffStrategy instead.
type FieldCounts ¶ added in v0.8.8
type FieldCounts struct {
Total int // Total number of populated fields
Inexact int // Number of fields with unknown/unrecognized open enum values
}
FieldCounts holds the result of counting fields in a value
func CountFieldsWithInexact ¶ added in v0.8.8
func CountFieldsWithInexact(v interface{}) FieldCounts
CountFieldsWithInexact recursively counts fields and tracks inexact matches (unknown open enum values).
type RetryConfig
deprecated
type UnionCandidate ¶ added in v0.7.0
type UnionCandidate struct {
FieldCount int
InexactCount int // Count of fields with unknown/unrecognized enum values
Size int
Type any // The union type enum value
Value any // The unmarshaled value
}
UnionCandidate represents a candidate type during union deserialization
func PickBestCandidate ¶ added in v0.7.0
func PickBestCandidate(candidates []UnionCandidate) *UnionCandidate
PickBestCandidate selects the best union type candidate using a multi-stage filtering approach: 1. If multiple candidates, filter by field count (keep only those with max field count) 2. If still multiple, filter by inexact count (keep only those with min inexact count) 3. If still multiple, filter by JSON size (keep only those with max size) 4. Return the first remaining candidate