sortref

package
v0.24.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DepthFirst

func DepthFirst(in any) []string

DepthFirst sorts a map of anything. It groups keys by category (shared params, op param, statuscode response, default response, definitions) sort groups internally by number of parts in the key and lexical names flatten groups into a single list of keys.

func ReverseIndex

func ReverseIndex(schemas map[string]spec.Ref, basePath string) map[string]RefRevIdx

ReverseIndex builds a reverse index for references in schemas.

func TopmostFirst

func TopmostFirst(refs []string) []string

TopmostFirst sorts references by depth.

Types

type Key

type Key struct {
	Segments int
	Key      string
}

Key represent a key item constructed from /-separated segments.

type Keys

type Keys []Key

Keys is a sortable collable collection of Keys.

func (Keys) Len

func (k Keys) Len() int

func (Keys) Less

func (k Keys) Less(i, j int) bool

func (Keys) Swap

func (k Keys) Swap(i, j int)

type PartAdder

type PartAdder func(string) []string

PartAdder know how to construct the components of a new name.

type RefRevIdx

type RefRevIdx struct {
	Ref  spec.Ref
	Keys []string
}

RefRevIdx is a reverse index for references.

type SplitKey

type SplitKey []string

SplitKey holds of the parts of a /-separated key, so that their location may be determined.

func KeyParts

func KeyParts(key string) SplitKey

KeyParts construct a SplitKey with all its /-separated segments decomposed. It is sortable.

func (SplitKey) BuildName

func (s SplitKey) BuildName(segments []string, startIndex int, adder PartAdder) string

BuildName builds a name from segments.

func (SplitKey) DefinitionName

func (s SplitKey) DefinitionName() string

DefinitionName yields the name of the definition.

func (SplitKey) IsDefaultResponse

func (s SplitKey) IsDefaultResponse() bool

IsDefaultResponse is true when the split key is the default response for an operation.

func (SplitKey) IsDefinition

func (s SplitKey) IsDefinition() bool

IsDefinition is true when the split key is in the #/definitions section of a spec.

func (SplitKey) IsOperation

func (s SplitKey) IsOperation() bool

IsOperation is true when the split key is in the operations section.

func (SplitKey) IsOperationParam

func (s SplitKey) IsOperationParam() bool

IsOperationParam is true when the split key is in the parameters section of an operation.

func (SplitKey) IsOperationResponse

func (s SplitKey) IsOperationResponse() bool

IsOperationResponse is true when the split key is in the responses section of an operation.

func (SplitKey) IsSharedOperationParam

func (s SplitKey) IsSharedOperationParam() bool

IsSharedOperationParam is true when the split key is in the parameters section of a path.

func (SplitKey) IsSharedParam

func (s SplitKey) IsSharedParam() bool

IsSharedParam is true when the split key is in the #/parameters section of a spec.

func (SplitKey) IsSharedResponse

func (s SplitKey) IsSharedResponse() bool

IsSharedResponse is true when the split key is in the #/responses section of a spec.

func (SplitKey) IsStatusCodeResponse

func (s SplitKey) IsStatusCodeResponse() bool

IsStatusCodeResponse is true when the split key is an operation response with a status code.

func (SplitKey) PathItemRef

func (s SplitKey) PathItemRef() spec.Ref

PathItemRef constructs a $ref object from a split key of the form /{path}/{method}.

func (SplitKey) PathRef

func (s SplitKey) PathRef() spec.Ref

PathRef constructs a $ref object from a split key of the form /paths/{reference}.

func (SplitKey) ResponseName

func (s SplitKey) ResponseName() string

ResponseName yields either the status code or "Default" for a response.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL