go.mod: Update oapi-codegen and kin-openapi

This commit is contained in:
sanne 2022-01-11 19:00:14 +01:00 committed by Sanne Raymaekers
parent add17bba45
commit a83cf95d5b
156 changed files with 29663 additions and 2248 deletions

View file

@ -8,7 +8,9 @@ import (
)
const (
extPropGoType = "x-go-type"
extPropGoType = "x-go-type"
extPropOmitEmpty = "x-omitempty"
extPropExtraTags = "x-oapi-codegen-extra-tags"
)
func extTypeName(extPropValue interface{}) (string, error) {
@ -23,3 +25,29 @@ func extTypeName(extPropValue interface{}) (string, error) {
return name, nil
}
func extParseOmitEmpty(extPropValue interface{}) (bool, error) {
raw, ok := extPropValue.(json.RawMessage)
if !ok {
return false, fmt.Errorf("failed to convert type: %T", extPropValue)
}
var omitEmpty bool
if err := json.Unmarshal(raw, &omitEmpty); err != nil {
return false, errors.Wrap(err, "failed to unmarshal json")
}
return omitEmpty, nil
}
func extExtraTags(extPropValue interface{}) (map[string]string, error) {
raw, ok := extPropValue.(json.RawMessage)
if !ok {
return nil, fmt.Errorf("failed to convert type: %T", extPropValue)
}
var tags map[string]string
if err := json.Unmarshal(raw, &tags); err != nil {
return nil, errors.Wrap(err, "failed to unmarshal json")
}
return tags, nil
}