Documentation
¶
Index ¶
- Variables
- func DetectGroupsFromSpec(specs []*loads.Document) (map[string]string, []string)
- func EscapeAsterisks(des string) string
- func GetDefinitionVersionKind(s spec.Schema) (string, string, string)
- func GetDefinitionVersionKindFromString(s string) (string, string, string)
- func GetTypeName(s spec.Schema) string
- func GuessGVK(name string) (group, version, kind string)
- func IsArray(s spec.Schema) bool
- func IsBlacklistedOperation(o *spec.Operation) bool
- func IsComplex(schema spec.Schema) bool
- func IsDefinition(s spec.Schema) bool
- func LoadDefinitions(config *Config, specs []*loads.Document, s *Definitions) error
- func LoadOpenApiSpec() ([]*loads.Document, error)
- func ParseSpecInfo(specs []*loads.Document, cfg *Config)
- func VisitOperations(specs []*loads.Document, fn func(operation Operation))
- type ApiGroup
- type ApiGroups
- type ApiKind
- type ApiVersion
- type ApiVersions
- type Config
- type CurlExample
- func (ce CurlExample) GetRequest(o *Operation) string
- func (ce CurlExample) GetRequestMessage() string
- func (ce CurlExample) GetRequestType() string
- func (ce CurlExample) GetResponse(o *Operation) string
- func (ce CurlExample) GetResponseMessage() string
- func (ce CurlExample) GetResponseType() string
- func (ce CurlExample) GetSample(d *Definition) string
- func (ce CurlExample) GetSampleType() string
- func (ce CurlExample) GetTab() string
- type Definition
- func (d *Definition) Description() string
- func (d *Definition) FullHrefLink() string
- func (d *Definition) GetResourceName() string
- func (d *Definition) GetSamples() []ExampleText
- func (d *Definition) GoImportPath() string
- func (d *Definition) GroupDisplayName() string
- func (d *Definition) HrefLink() string
- func (d *Definition) IsTopLevelResource() bool
- func (d *Definition) Key() string
- func (d *Definition) LinkID() string
- func (d *Definition) MdLink() string
- func (d *Definition) RequiredFields() []string
- func (d *Definition) VersionLink() string
- type DefinitionList
- type Definitions
- type EmptyExample
- func (ce EmptyExample) GetRequest(o *Operation) string
- func (ce EmptyExample) GetRequestMessage() string
- func (ce EmptyExample) GetRequestType() string
- func (ce EmptyExample) GetResponse(o *Operation) string
- func (ce EmptyExample) GetResponseMessage() string
- func (ce EmptyExample) GetResponseType() string
- func (ce EmptyExample) GetSample(d *Definition) string
- func (ce EmptyExample) GetSampleType() string
- func (ce EmptyExample) GetTab() string
- type ExampleConfig
- type ExampleProvider
- type ExampleText
- type Field
- type Fields
- type GroupVersions
- type HttpResponse
- type HttpResponses
- type KubectlExample
- func (ke KubectlExample) GetRequest(o *Operation) string
- func (ke KubectlExample) GetRequestMessage() string
- func (ke KubectlExample) GetRequestType() string
- func (ke KubectlExample) GetResponse(o *Operation) string
- func (ke KubectlExample) GetResponseMessage() string
- func (ke KubectlExample) GetResponseType() string
- func (ke KubectlExample) GetSample(d *Definition) string
- func (ke KubectlExample) GetSampleType() string
- func (ke KubectlExample) GetTab() string
- type Operation
- func (o *Operation) Description() string
- func (o *Operation) GetDisplayHttp() string
- func (o *Operation) GetExampleRequests() []ExampleText
- func (o *Operation) GetExampleResponses() []ExampleText
- func (o *Operation) GetGroupVersionKindSub() (string, string, string, string)
- func (o *Operation) GetMethod() string
- type OperationCategory
- type OperationType
- type Operations
- type Resource
- type ResourceCategory
- type ResourceVisitor
- type Resources
- type SampleConfig
- type SortDefinitionsByName
- type SortDefinitionsByVersion
Constants ¶
This section is empty.
Variables ¶
var AllowErrors = flag.Bool("allow-errors", false, "If true, don't fail on errors.")
var AutoDetect = flag.Bool("auto-detect", false, "If true, auto-detect API groups and versions from swagger.json.")
var Backend = flag.String("backend", "html", "Output format for the generator. Supported values: 'html', 'markdown', or 'hugo-md'.")
var BuildDir string
Directory for backend output files
var BuildOps = flag.Bool("build-operations", true, "If true build operations in the docs.")
var ConfigDir string
Directory for configuration and data files
var EmptyExampleProviders = []ExampleProvider{ EmptyExample{}, }
var ExampleProviders = []ExampleProvider{ KubectlExample{}, CurlExample{}, }
var IncludesDir string
Directory for temporary files that will eventually get merged into the HTML output file.
var KubernetesRelease = flag.String("kubernetes-release", "", "Kubernetes release version.")
var SectionsDir string
Directory for static sections
var UseTags = flag.Bool("use-tags", false, "If true, use the openapi tags instead of the config yaml.")
var VersionedConfigDir string
Directory for versioned configuration file and swagger.json
var WorkDir = flag.String("work-dir", "", "Working directory for the generator.")
Functions ¶
func DetectGroupsFromSpec ¶
func EscapeAsterisks ¶
handle '*', 'a/*', '*/b', '*/*' cases
func GetDefinitionVersionKind ¶
GetDefinitionVersionKind returns the api version and kind for the spec. This is the primary key of a Definition.
func GetTypeName ¶
GetTypeName returns the display name of a Schema. This is the api kind for definitions and the type for primitive types. Arrays of objects have "array" appended.
func GuessGVK ¶
GuessGVK makes a guess about the (Group, Version, Kind) tuple based on resource name TODO: Rework this function because it is ugly
func IsBlacklistedOperation ¶
func IsDefinition ¶
IsDefinition returns true if Schema is a complex type that should have a Definition.
func LoadDefinitions ¶
func LoadDefinitions(config *Config, specs []*loads.Document, s *Definitions) error
func LoadOpenApiSpec ¶
Loads all of the open-api documents
func ParseSpecInfo ¶
func VisitOperations ¶
VisitOperations calls fn once for each operation found in the collection of Documents VisitOperations calls fn once for each operation found in the collection of Documents
Types ¶
type ApiVersion ¶
type ApiVersion string
func (ApiVersion) LessThan ¶
func (ver ApiVersion) LessThan(that ApiVersion) bool
func (ApiVersion) String ¶
func (a ApiVersion) String() string
type ApiVersions ¶
type ApiVersions []ApiVersion
func (ApiVersions) Len ¶
func (a ApiVersions) Len() int
func (ApiVersions) Less ¶
func (a ApiVersions) Less(i, j int) bool
func (ApiVersions) Swap ¶
func (a ApiVersions) Swap(i, j int)
type Config ¶
type Config struct {
ApiGroups []ApiGroup `yaml:"api_groups,omitempty"`
ExampleLocation string `yaml:"example_location,omitempty"`
OperationCategories []OperationCategory `yaml:"operation_categories,omitempty"`
ResourceCategories []ResourceCategory `yaml:"resource_categories,omitempty"`
ExcludedOperations []string `yaml:"excluded_operations,omitempty"`
// Used to map the group as the resource sees it to the group as the operation sees it
OperationGroupMap map[string]string `yaml:"operation_group_map,omitempty"`
GroupFullNames map[string]string `yaml:"group_full_names,omitempty"`
Definitions Definitions
Operations Operations
SpecTitle string
SpecVersion string
}
func LoadConfigFromYAML ¶
LoadConfigFromYAML reads the config yaml file into a struct
func (*Config) OpExcluded ¶
type CurlExample ¶
type CurlExample struct{}
func (CurlExample) GetRequest ¶
func (ce CurlExample) GetRequest(o *Operation) string
func (CurlExample) GetRequestMessage ¶
func (ce CurlExample) GetRequestMessage() string
func (CurlExample) GetRequestType ¶
func (ce CurlExample) GetRequestType() string
func (CurlExample) GetResponse ¶
func (ce CurlExample) GetResponse(o *Operation) string
func (CurlExample) GetResponseMessage ¶
func (ce CurlExample) GetResponseMessage() string
func (CurlExample) GetResponseType ¶
func (ce CurlExample) GetResponseType() string
func (CurlExample) GetSample ¶
func (ce CurlExample) GetSample(d *Definition) string
func (CurlExample) GetSampleType ¶
func (ce CurlExample) GetSampleType() string
func (CurlExample) GetTab ¶
func (ce CurlExample) GetTab() string
type Definition ¶
type Definition struct {
// Display name of the definition (e.g. Deployment)
Name string
Group ApiGroup
ShowGroup bool
// Api version of the definition (e.g. v1beta1)
Version ApiVersion
Kind ApiKind
DescriptionWithEntities string
GroupFullName string
// InToc is true if this definition should appear in the table of contents
InToc bool
IsInlined bool
IsOldVersion bool
FoundInField bool
FoundInOperation bool
// Inline is a list of definitions that should appear inlined with this one in the documentations
Inline SortDefinitionsByName
// AppearsIn is a list of definition that this one appears in - e.g. PodSpec in Pod
AppearsIn SortDefinitionsByName
OperationCategories []*OperationCategory
// Fields is a list of fields in this definition
Fields Fields
OtherVersions SortDefinitionsByName
NewerVersions SortDefinitionsByName
Sample SampleConfig
FullName string
Resource string
// SwaggerKey is the raw, domain-reversed key under which this
// definition appeared in the OpenAPI spec — e.g.
// "io.k8s.api.apps.v1.Deployment". Preserved so downstream writers
// can derive artefacts like Go import paths without re-parsing.
SwaggerKey string
// contains filtered or unexported fields
}
func (*Definition) Description ¶
func (d *Definition) Description() string
func (*Definition) FullHrefLink ¶
func (d *Definition) FullHrefLink() string
func (*Definition) GetResourceName ¶
func (d *Definition) GetResourceName() string
func (*Definition) GetSamples ¶
func (d *Definition) GetSamples() []ExampleText
func (*Definition) GoImportPath ¶
func (d *Definition) GoImportPath() string
GoImportPath returns the Go import path this definition's type lives at, derived from the swagger key. Returns "" when the key was not preserved (e.g. old specs parsed before SwaggerKey existed).
The swagger key is a domain-reversed, dotted identifier such as "io.k8s.api.apps.v1.Deployment". The transform swaps the first two segments into a slash-joined hostname ("io.k8s" -> "k8s.io") and joins the middle segments as path components, dropping the trailing kind. For the example above, the result is "k8s.io/api/apps/v1".
func (*Definition) GroupDisplayName ¶
func (d *Definition) GroupDisplayName() string
func (*Definition) HrefLink ¶
func (d *Definition) HrefLink() string
func (*Definition) IsTopLevelResource ¶
func (d *Definition) IsTopLevelResource() bool
IsTopLevelResource returns true if this definition represents a top-level API resource (one that has its own List endpoint), as opposed to a subresource (Scale, Eviction) or utility type (Status, WatchEvent).
func (*Definition) Key ¶
func (d *Definition) Key() string
func (*Definition) LinkID ¶
func (d *Definition) LinkID() string
func (*Definition) MdLink ¶
func (d *Definition) MdLink() string
func (*Definition) RequiredFields ¶
func (d *Definition) RequiredFields() []string
RequiredFields returns the names of required properties on this definition, sourced from the underlying OpenAPI schema. Used by writers that need to flag required fields on a per-name basis.
func (*Definition) VersionLink ¶
func (d *Definition) VersionLink() string
type DefinitionList ¶
type DefinitionList []*Definition
func (DefinitionList) Len ¶
func (a DefinitionList) Len() int
func (DefinitionList) Less ¶
func (a DefinitionList) Less(i, j int) bool
func (DefinitionList) Swap ¶
func (a DefinitionList) Swap(i, j int)
type Definitions ¶
type Definitions struct {
All map[string]*Definition
ByKind map[byKindKey]SortDefinitionsByVersion
GroupVersions GroupVersions
}
Definitions indexes open-api definitions
func NewDefinitions ¶
func NewDefinitions(config *Config, specs []*loads.Document) (*Definitions, error)
func (*Definitions) FindNewestVersion ¶
func (s *Definitions) FindNewestVersion(group, kind string) string
FindNewestVersion returns the newest known version for the given group/kind. Returns an empty string if no matching definition is found.
func (*Definitions) GetByVersionKind ¶
func (s *Definitions) GetByVersionKind(group, version, kind string) (*Definition, bool)
GetByVersionKind looks up a definition using its primary key (version,kind)
func (*Definitions) GetForSchema ¶
func (s *Definitions) GetForSchema(schema spec.Schema) (*Definition, bool)
func (*Definitions) InitializeFields ¶
func (s *Definitions) InitializeFields(d *Definition)
Initializes the fields for a definition
type EmptyExample ¶
type EmptyExample struct{}
func (EmptyExample) GetRequest ¶
func (ce EmptyExample) GetRequest(o *Operation) string
func (EmptyExample) GetRequestMessage ¶
func (ce EmptyExample) GetRequestMessage() string
func (EmptyExample) GetRequestType ¶
func (ce EmptyExample) GetRequestType() string
func (EmptyExample) GetResponse ¶
func (ce EmptyExample) GetResponse(o *Operation) string
func (EmptyExample) GetResponseMessage ¶
func (ce EmptyExample) GetResponseMessage() string
func (EmptyExample) GetResponseType ¶
func (ce EmptyExample) GetResponseType() string
func (EmptyExample) GetSample ¶
func (ce EmptyExample) GetSample(d *Definition) string
func (EmptyExample) GetSampleType ¶
func (ce EmptyExample) GetSampleType() string
func (EmptyExample) GetTab ¶
func (ce EmptyExample) GetTab() string
type ExampleConfig ¶
type ExampleProvider ¶
type ExampleProvider interface {
GetTab() string
GetRequestMessage() string
GetResponseMessage() string
GetRequestType() string
GetResponseType() string
GetSampleType() string
GetSample(d *Definition) string
GetRequest(o *Operation) string
GetResponse(o *Operation) string
}
func GetExampleProviders ¶
func GetExampleProviders() []ExampleProvider
type Field ¶
type GroupVersions ¶
type GroupVersions map[string]ApiVersions
type HttpResponse ¶
type HttpResponses ¶
type HttpResponses []*HttpResponse
func (HttpResponses) Len ¶
func (a HttpResponses) Len() int
func (HttpResponses) Less ¶
func (a HttpResponses) Less(i, j int) bool
func (HttpResponses) Swap ¶
func (a HttpResponses) Swap(i, j int)
type KubectlExample ¶
type KubectlExample struct{}
func (KubectlExample) GetRequest ¶
func (ke KubectlExample) GetRequest(o *Operation) string
func (KubectlExample) GetRequestMessage ¶
func (ke KubectlExample) GetRequestMessage() string
func (KubectlExample) GetRequestType ¶
func (ke KubectlExample) GetRequestType() string
func (KubectlExample) GetResponse ¶
func (ke KubectlExample) GetResponse(o *Operation) string
func (KubectlExample) GetResponseMessage ¶
func (ke KubectlExample) GetResponseMessage() string
func (KubectlExample) GetResponseType ¶
func (ke KubectlExample) GetResponseType() string
func (KubectlExample) GetSample ¶
func (ke KubectlExample) GetSample(d *Definition) string
func (KubectlExample) GetSampleType ¶
func (ke KubectlExample) GetSampleType() string
func (KubectlExample) GetTab ¶
func (ke KubectlExample) GetTab() string
type Operation ¶
type Operation struct {
ID string
Type OperationType
Path string
HttpMethod string
Definition *Definition
BodyParams Fields
QueryParams Fields
PathParams Fields
HttpResponses HttpResponses
ExampleConfig ExampleConfig
// contains filtered or unexported fields
}
func (*Operation) Description ¶
func (*Operation) GetDisplayHttp ¶
func (*Operation) GetExampleRequests ¶
func (o *Operation) GetExampleRequests() []ExampleText
func (*Operation) GetExampleResponses ¶
func (o *Operation) GetExampleResponses() []ExampleText
func (*Operation) GetGroupVersionKindSub ¶
type OperationCategory ¶
type OperationCategory struct {
// Name is the display name of this group
Name string `yaml:",omitempty"`
// Operations are the collection of Operations in this group
OperationTypes []OperationType `yaml:"operation_types,omitempty"`
// Default is true if this is the default operation group for operations that do not match any other groups
Default bool `yaml:",omitempty"`
Operations []*Operation
}
OperationCategory defines a group of related operations
type OperationType ¶
type OperationType struct {
// Name is the display name of this operation
Name string `yaml:",omitempty"`
// Match is the regular expression of operation IDs that match this group where '${resource}' matches the resource name.
Match string `yaml:",omitempty"`
}
Operation defines a highlevel operation type such as Read, Replace, Patch
func (OperationType) GetOperationId ¶
func (ot OperationType) GetOperationId(d string) string
GetOperationId returns the ID of the operation for the given definition
type Operations ¶
type Resource ¶
type Resource struct {
// Name is the display name of this Resource
Name string `yaml:",omitempty"`
Version string `yaml:",omitempty"`
Group string `yaml:",omitempty"`
// DescriptionWarning is a warning message to show along side this resource when displaying it
DescriptionWarning string `yaml:"description_warning,omitempty"`
// DescriptionNote is a note message to show along side this resource when displaying it
DescriptionNote string `yaml:"description_note,omitempty"`
// ConceptGuide is a link to the concept guide for this resource if it exists
ConceptGuide string `yaml:"concept_guide,omitempty"`
// RelatedTasks is as list of tasks related to this concept
RelatedTasks []string `yaml:"related_tasks,omitempty"`
// Definition of the object
Definition *Definition
}
type ResourceCategory ¶
type ResourceCategory struct {
// Name is the display name of this group
Name string `yaml:",omitempty"`
// Include is the name of the _<resource_category>.html file to include in the index.html
Include string `yaml:",omitempty"`
// Resources are the collection of Resources in this group
Resources Resources `yaml:",omitempty"`
}
ResourceCategory defines a category of Concepts
type ResourceVisitor ¶
type ResourceVisitor func(resource *Resource, d *Definition)
type SampleConfig ¶
type SortDefinitionsByName ¶
type SortDefinitionsByName []*Definition
func (SortDefinitionsByName) Len ¶
func (a SortDefinitionsByName) Len() int
func (SortDefinitionsByName) Less ¶
func (a SortDefinitionsByName) Less(i, j int) bool
func (SortDefinitionsByName) Swap ¶
func (a SortDefinitionsByName) Swap(i, j int)
type SortDefinitionsByVersion ¶
type SortDefinitionsByVersion []*Definition
func (SortDefinitionsByVersion) Len ¶
func (a SortDefinitionsByVersion) Len() int
func (SortDefinitionsByVersion) Less ¶
func (a SortDefinitionsByVersion) Less(i, j int) bool
func (SortDefinitionsByVersion) Swap ¶
func (a SortDefinitionsByVersion) Swap(i, j int)