Documentation
¶
Index ¶
- Variables
- func CatesianProduct[T any](params ...[]T) [][]T
- func CatesianProductMap[T any](params map[string][]T) []map[string]T
- func FlattenJSONValueObjectByAddr(obj JSONObject) map[string]JSONValue
- func JSONValueValueMap(l ...JSONValue) (map[string]*JSONValuePos, error)
- func SchemaIsArray(schema *spec.Schema) bool
- func SchemaIsEmptyObject(schema *spec.Schema) bool
- func SchemaIsMap(schema *spec.Schema) bool
- func SchemaIsObject(schema *spec.Schema) bool
- type Expander
- type ExpanderCache
- type ExpanderOption
- type JSONArray
- type JSONObject
- type JSONPrimitive
- type JSONValue
- type JSONValuePos
- type PropWalkFunc
- type Property
- type PropertyAddr
- type PropertyAddrStep
- type PropertyAddrStepType
- type PropertyName
- type RequestDescriptor
- type Rnd
- type RndOption
- type RootModelInfo
- type SynthDuplicateElement
- type Synthesizer
- type SynthesizerOption
- type VariantInfo
- type VariantMap
Constants ¶
This section is empty.
Variables ¶
var RootAddr = PropertyAddr{}
Functions ¶
func CatesianProduct ¶
func CatesianProduct[T any](params ...[]T) [][]T
func CatesianProductMap ¶
func FlattenJSONValueObjectByAddr ¶
func FlattenJSONValueObjectByAddr(obj JSONObject) map[string]JSONValue
func JSONValueValueMap ¶
func JSONValueValueMap(l ...JSONValue) (map[string]*JSONValuePos, error)
JSONValueValueMap merges one or more JSONValue into a map whose key is the un-ambiguous leaf value of the input JSONValue(s). For the ambiguous leaf value (i.e. multiple properties among the JSONValue(s) have the same value), they are not included in the returning map.
func SchemaIsArray ¶
func SchemaIsEmptyObject ¶
func SchemaIsMap ¶
func SchemaIsObject ¶
Types ¶
type Expander ¶
type Expander struct {
// contains filtered or unexported fields
}
func NewExpander ¶
func NewExpander(ref spec.Ref, opt *ExpanderOption) (*Expander, error)
NewExpander create a expander for the schema referenced by the input json reference. The reference must be a normalized reference.
func NewExpanderFromOpRef ¶
func NewExpanderFromOpRef(ref spec.Ref, opt *ExpanderOption) (*Expander, error)
NewExpanderFromOpRef create a expander for the successful response schema of an operation referenced by the input json reference. The reference must be a normalized reference to the operation.
type ExpanderCache ¶
type ExpanderCache struct {
// contains filtered or unexported fields
}
func NewExpanderCache ¶
func NewExpanderCache() *ExpanderCache
type ExpanderOption ¶
type ExpanderOption struct { EmptyObjAsStr bool Cache *ExpanderCache }
type JSONArray ¶
type JSONArray struct {
// contains filtered or unexported fields
}
func (JSONArray) JSONValuePos ¶
func (arr JSONArray) JSONValuePos() *JSONValuePos
type JSONObject ¶
type JSONObject struct {
// contains filtered or unexported fields
}
func (JSONObject) JSONValue ¶
func (obj JSONObject) JSONValue() interface{}
func (JSONObject) JSONValuePos ¶
func (obj JSONObject) JSONValuePos() *JSONValuePos
type JSONPrimitive ¶
type JSONPrimitive[T primitiveType] struct {
// contains filtered or unexported fields
}
func (JSONPrimitive[T]) JSONValue ¶
func (p JSONPrimitive[T]) JSONValue() interface{}
func (JSONPrimitive[T]) JSONValuePos ¶
func (p JSONPrimitive[T]) JSONValuePos() *JSONValuePos
type JSONValue ¶
type JSONValue interface { JSONValue() interface{} // Only JSONPrimitive returns non-nil JSONValuePos() *JSONValuePos }
type JSONValuePos ¶
type JSONValuePos struct { RootModel RootModelInfo `json:"root_model"` Ref jsonreference.Ref `json:"ref"` Addr PropertyAddr `json:"addr"` LinkLocal string `json:"link_local,omitempty"` LinkGithub string `json:"link_github,omitempty"` }
func (JSONValuePos) MarshalJSON ¶
func (pos JSONValuePos) MarshalJSON() ([]byte, error)
func (JSONValuePos) String ¶
func (pos JSONValuePos) String() string
func (*JSONValuePos) UnmarshalJSON ¶
func (pos *JSONValuePos) UnmarshalJSON(b []byte) error
type PropWalkFunc ¶
PropWalkFunc is invoked during the property tree walking. If it returns false, it will stop walking at that property.
type Property ¶
type Property struct { Schema *spec.Schema // The root model information that holds this property. RootModel RootModelInfo // Discriminator indicates the property name of the parent base schema's discriminator. // This only applies to property that is a variant schema. Discriminator string // DiscriminatorValue indicates the discriminator value. // This only applies to property that is a variant schema. DiscriminatorValue string // Children represents the child properties of an object // At most one of Children, Element and Variant is non nil Children map[string]*Property // Element represents the element property of an array or a map (additionalProperties of an object) // At most one of Children, Element and Variant is non nil Element *Property // Variant represents the current property is a polymorphic schema, which is then expanded to multiple variant schemas // At most one of Children, Element and Variant is non nil Variant map[string]*Property // contains filtered or unexported fields }
func Monomorphization ¶
func (Property) SchemaName ¶
func (*Property) Walk ¶
func (prop *Property) Walk(fn PropWalkFunc)
Walk walks the property tree in depth first order
type PropertyAddr ¶
type PropertyAddr []PropertyAddrStep
func MustParseAddr ¶
func MustParseAddr(input string) PropertyAddr
func ParseAddr ¶
func ParseAddr(input string) (*PropertyAddr, error)
func (PropertyAddr) Copy ¶
func (addr PropertyAddr) Copy() PropertyAddr
func (PropertyAddr) Equal ¶
func (addr PropertyAddr) Equal(oaddr PropertyAddr) bool
func (PropertyAddr) String ¶
func (addr PropertyAddr) String() string
func (PropertyAddr) ToPointer ¶
func (addr PropertyAddr) ToPointer() (jsonpointer.Pointer, error)
type PropertyAddrStep ¶
type PropertyAddrStep struct { Type PropertyAddrStepType Value string Variant string }
func (PropertyAddrStep) String ¶
func (step PropertyAddrStep) String() string
type PropertyAddrStepType ¶
type PropertyAddrStepType int
const ( PropertyAddrStepTypeProp PropertyAddrStepType = iota PropertyAddrStepTypeIndex )
type PropertyName ¶
type RequestDescriptor ¶
type Rnd ¶
type Rnd struct {
// contains filtered or unexported fields
}
func (*Rnd) NextInteger ¶
func (*Rnd) NextNumber ¶
func (*Rnd) NextString ¶
type RootModelInfo ¶
type RootModelInfo struct { PathRef jsonreference.Ref `json:"path_ref"` Operation string `json:"operation"` Version string `json:"version"` }
func (RootModelInfo) MarshalJSON ¶
func (model RootModelInfo) MarshalJSON() ([]byte, error)
func (RootModelInfo) String ¶
func (info RootModelInfo) String() string
func (*RootModelInfo) UnmarshalJSON ¶
func (model *RootModelInfo) UnmarshalJSON(b []byte) error
type SynthDuplicateElement ¶
type SynthDuplicateElement struct { Cnt int Addr PropertyAddr }
type Synthesizer ¶
type Synthesizer struct {
// contains filtered or unexported fields
}
func NewSynthesizer ¶
func NewSynthesizer(root *Property, rnd *Rnd, opt *SynthesizerOption) (*Synthesizer, error)
func (*Synthesizer) Synthesize ¶
func (syn *Synthesizer) Synthesize() (interface{}, bool)
type SynthesizerOption ¶
type SynthesizerOption struct { UseEnumValues bool DuplicateElements []SynthDuplicateElement }
type VariantInfo ¶
type VariantMap ¶
type VariantMap map[string]VariantInfo
VariantMap maps the x-ms-discriminator-value to the model name in "/definitions". Note that the variant map is the plain translation of the swagger inheritance strucutre, it doesn't take cascaded variants into consideration. So always ensure use `Get()` to get the complete variant set of a model.
func NewVariantMap ¶
func NewVariantMap(path string) (VariantMap, error)
func (VariantMap) Get ¶
func (m VariantMap) Get(modelName string) (*VariantInfo, bool)