Documentation ¶
Index ¶
- func CreateAPISpec(b []byte) (*spec.Swagger, error)
- func Import(path string) (*spec.Swagger, string, error)
- type APISpec
- type DefinitionName
- type GroupName
- type Items
- type ObjectKind
- type ObjectRef
- type Package
- type ParsedDefinitionName
- type Properties
- type Property
- type PropertyName
- type SchemaDefinition
- type SchemaDefinitions
- type SchemaInfo
- type SchemaType
- type TopLevelSpec
- type TopLevelSpecs
- type VersionString
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateAPISpec ¶
CreateAPISpec a swagger file into a *spec.Swagger.
Types ¶
type APISpec ¶
type APISpec struct { SwaggerVersion string `json:"swagger"` Info *SchemaInfo `json:"info"` Definitions SchemaDefinitions `json:"definitions"` // Not part of the OpenAPI spec. Filled in later. FilePath string Text []byte }
APISpec represents an OpenAPI specification of an API.
type DefinitionName ¶
type DefinitionName string
DefinitionName represents the name of a definition. For example, `v1.APIGroup`.
func (DefinitionName) AsObjectRef ¶
func (dn DefinitionName) AsObjectRef() *ObjectRef
func (*DefinitionName) Parse ¶
func (dn *DefinitionName) Parse() (*ParsedDefinitionName, error)
Parse will parse a `DefinitionName` into a structured `ParsedDefinitionName`.
func (DefinitionName) String ¶
func (dn DefinitionName) String() string
type GroupName ¶
type GroupName string
GroupName represetents a Kubernetes group name (e.g., apps, extensions, etc.)
type Items ¶
type Items struct {
Ref *ObjectRef `json:"$ref"`
}
Items represents the type of an element in an array. Usually this is used to fully specify a `Property` object whose `type` field is `"array"`.
type ObjectKind ¶
type ObjectKind string
ObjectKind represents the `kind` of a Kubernetes API object (e.g., Service, Deployment, etc.)
func (ObjectKind) String ¶
func (ok ObjectKind) String() string
type ObjectRef ¶
type ObjectRef string
ObjectRef represents a reference to some API object. For example, `#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta`
func (*ObjectRef) IsMixinRef ¶
IsMixinRef will check whether a `ObjectRef` refers to an API object that can be turned into a mixin. This should be true of the vast majority of non-nil `ObjectRef`s. The most common exception is `IntOrString`, which should not be turned into a mixin, and should instead by transformed into a property method that behaves identically to one taking an int or a ref as argument.
func (*ObjectRef) Name ¶
func (or *ObjectRef) Name() *DefinitionName
Name parses a `DefinitionName` from an `ObjectRef`. `ObjectRef`s that refer to a definition contain two parts: (1) a special prefix, and (2) a `DefinitionName`, so this function simply strips the prefix off.
type Package ¶
type Package int
Package represents the type of the definition, either `APIs`, which have API groups (e.g., extensions, apps, meta, and so on), or `Core`, which does not.
const ( // Core is a package that contains the Kubernetes Core objects. Core Package = iota // APIs is a set of non-core packages grouped loosely by semantic // functionality (e.g., apps, extensions, and so on). APIs // Util is a package that contains utilities used for both testing // and running Kubernetes. Util // Runtime is a package that contains various utilities used in the // Kubernetes runtime. Runtime // Version is a package that supplies version information collected // at build time. Version )
type ParsedDefinitionName ¶
type ParsedDefinitionName struct { PackageType Package Codebase string Group *GroupName // Pointer because it's optional. Version *VersionString // Pointer because it's optional. Kind ObjectKind }
ParsedDefinitionName is a parsed version of a fully-qualified OpenAPI spec name. For example, `io.k8s.kubernetes.pkg.api.v1.Container` would parse into an instance of the struct below.
func (*ParsedDefinitionName) Unparse ¶
func (p *ParsedDefinitionName) Unparse(isLegacySchema bool) (DefinitionName, error)
Unparse transforms a `ParsedDefinitionName` back into its corresponding string, e.g., `io.k8s.kubernetes.pkg.api.v1.Container`.
type Properties ¶
type Properties map[PropertyName]*Property
Properties is a named collection of `Properties`s, represented as a collection mapping definition name -> `Properties`.
type Property ¶
type Property struct { Description string `json:"description"` Type *SchemaType `json:"type"` Ref *ObjectRef `json:"$ref"` Items Items `json:"items"` // nil unless Type == "array". }
Property represents an object property for some API object. For example, `v1.APIGroup` might contain a property called `apiVersion`, which would be specifid by a `Property`.
type PropertyName ¶
type PropertyName string
PropertyName represents the name of a property. For example, `apiVersion` or `kind`.
func (PropertyName) String ¶
func (pn PropertyName) String() string
type SchemaDefinition ¶
type SchemaDefinition struct { Type *SchemaType `json:"type"` Description string `json:"description"` // nullable. Required []string `json:"required"` // nullable. Properties Properties `json:"properties"` // nullable. TopLevelSpecs TopLevelSpecs `json:"x-kubernetes-group-version-kind"` Ref string `json:"$ref,omitempty"` }
SchemaDefinition is an API object definition. For example, this might contain a name (e.g., `v1.APIGroup`), a set of properties (e.g., `apiVersion`, `kind`, and so on), and the names of required properties.
func (*SchemaDefinition) IsCRD ¶
func (sd *SchemaDefinition) IsCRD() bool
IsCRD returns true if the definition represents a CRD.
func (*SchemaDefinition) IsDeprecated ¶
func (sd *SchemaDefinition) IsDeprecated() bool
IsDeprecated returns true if the definition has a description that starts with "Deprecated" and a $ref that is not empty.
func (*SchemaDefinition) QualifiedGroupName ¶
func (sd *SchemaDefinition) QualifiedGroupName(groupName string) string
QualifiedGroupName is the qualified group name. It is retrieved from the x-kubernetes-group-version-kind field. If it doesn't exist, the group name is returned.
type SchemaDefinitions ¶
type SchemaDefinitions map[DefinitionName]*SchemaDefinition
SchemaDefinitions is a named collection of `SchemaDefinition`s, represented as a collection mapping definition name -> `SchemaDefinition`.
type SchemaInfo ¶
SchemaInfo contains information about the the API represented with `APISpec`. For example, `title` might be `"Kubernetes"`, and `version` might be `"v1.7.0"`.
type SchemaType ¶
type SchemaType string
SchemaType represents the type of some object in an API spec. For example, a property might have type `string`.
func (SchemaType) String ¶
func (st SchemaType) String() string
type TopLevelSpec ¶
type TopLevelSpec struct { Group GroupName `json:"Group"` Version VersionString `json:"Version"` Kind ObjectKind `json:"Kind"` }
TopLevelSpec is a property that exists on `SchemaDefinition`s for top-level API objects.
type TopLevelSpecs ¶
type TopLevelSpecs []*TopLevelSpec
type VersionString ¶
type VersionString string
VersionString is the string representation of an API version (e.g., v1, v1beta1, etc.)
func (VersionString) String ¶
func (vs VersionString) String() string