Documentation
¶
Overview ¶
Package allof merges allOf schema compositions into single unified schemas.
Overview ¶
The allof package flattens allOf compositions by merging all subschemas into one. This improves breaking change detection accuracy because changes to individual allOf members can be properly compared as property-level changes rather than as entire schema replacements.
Usage ¶
Merge allOf in a spec:
mergedSpec, err := allof.MergeSpec(spec)
Or use via the load package option:
specInfo, err := load.NewSpecInfo(loader, source, load.WithFlattenAllOf())
Merge Rules ¶
The merge process combines schema properties following these rules:
- Properties from all subschemas are combined
- Required fields are merged (union)
- Numeric constraints use the most restrictive values (e.g., max of minimums)
- Type and format must be identical across subschemas or an error is returned
- Enum values are intersected
- Nested allOf compositions are recursively merged
Example ¶
Before:
allOf:
- type: object
properties:
name: { type: string }
- type: object
properties:
age: { type: integer }
After:
type: object
properties:
name: { type: string }
age: { type: integer }
Index ¶
Constants ¶
View Source
const ( FormatErrorMessage = "unable to resolve Format conflict using default resolver: all Format values must be identical" TypeErrorMessage = "unable to resolve Type conflict: all Type values must be identical" DefaultErrorMessage = "unable to resolve Default conflict: all Default values must be identical" ConstErrorMessage = "unable to resolve Const conflict: all Const values must be identical" ContentMediaTypeErrorMessage = "unable to resolve ContentMediaType conflict: all ContentMediaType values must be identical" ContentEncodingErrorMessage = "unable to resolve ContentEncoding conflict: all ContentEncoding values must be identical" FormatInt32 = "int32" FormatInt64 = "int64" FormatFloat = "float" FormatDouble = "double" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type SchemaCollection ¶
type SchemaCollection struct {
Not []*openapi3.SchemaRef
OneOf []openapi3.SchemaRefs
AnyOf []openapi3.SchemaRefs
Title []string
Type []openapi3.Types
Format []string
Description []string
Enum [][]any
UniqueItems []bool
ExclusiveMin []openapi3.ExclusiveBound
ExclusiveMax []openapi3.ExclusiveBound
Min []*float64
Max []*float64
MultipleOf []*float64
MinLength []uint64
MaxLength []*uint64
Pattern []string
MinItems []uint64
MaxItems []*uint64
Items []*openapi3.SchemaRef
Required [][]string
Properties []openapi3.Schemas
MinProps []uint64
MaxProps []*uint64
AdditionalProperties []openapi3.BoolSchema
Nullable []bool
ReadOnly []bool
WriteOnly []bool
Default []any
Const []any
MinContains []*uint64
MaxContains []*uint64
Contains []*openapi3.SchemaRef
PropertyNames []*openapi3.SchemaRef
ContentMediaType []string
ContentEncoding []string
DependentRequired []map[string][]string
}
Click to show internal directories.
Click to hide internal directories.