...

Package sortref

import "github.com/go-openapi/analysis/internal/flatten/sortref"
Overview
Index

Overview ▾

func DepthFirst

func DepthFirst(in interface{}) []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

type Key

Key represent a key item constructed from /-separated segments

type Key struct {
    Segments int
    Key      string
}

type Keys

Keys is a sortable collable collection of Keys

type Keys []Key

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

PartAdder know how to construct the components of a new name

type PartAdder func(string) []string

type RefRevIdx

RefRevIdx is a reverse index for references

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

type SplitKey

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

type SplitKey []string

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