kube-openapi: k8s.io/kube-openapi/pkg/util/proto Index | Files | Directories

package proto

import "k8s.io/kube-openapi/pkg/util/proto"

Package proto is a collection of libraries for parsing and indexing the type definitions. The openapi spec contains the object model definitions and extensions metadata.

Index

Package Files

doc.go document.go openapi.go

Constants

const (
    Integer = "integer"
    Number  = "number"
    String  = "string"
    Boolean = "boolean"
)

Defines openapi types.

func VendorExtensionToMap Uses

func VendorExtensionToMap(e []*openapi_v2.NamedAny) map[string]interface{}

VendorExtensionToMap converts openapi VendorExtension to a map.

type Arbitrary Uses

type Arbitrary struct {
    BaseSchema
}

Arbitrary is a value of any type (primitive, object or array)

func (*Arbitrary) Accept Uses

func (a *Arbitrary) Accept(v SchemaVisitor)

func (*Arbitrary) GetName Uses

func (a *Arbitrary) GetName() string

type Array Uses

type Array struct {
    BaseSchema

    SubType Schema
}

Array must have all its element of the same `SubType`.

func (*Array) Accept Uses

func (a *Array) Accept(v SchemaVisitor)

func (*Array) GetName Uses

func (a *Array) GetName() string

type BaseSchema Uses

type BaseSchema struct {
    Description string
    Extensions  map[string]interface{}

    Path Path
}

BaseSchema holds data used by each types of schema.

func (*BaseSchema) GetDescription Uses

func (b *BaseSchema) GetDescription() string

func (*BaseSchema) GetExtensions Uses

func (b *BaseSchema) GetExtensions() map[string]interface{}

func (*BaseSchema) GetPath Uses

func (b *BaseSchema) GetPath() *Path

type Definitions Uses

type Definitions struct {
    // contains filtered or unexported fields
}

Definitions is an implementation of `Models`. It looks for models in an openapi Schema.

func (*Definitions) ListModels Uses

func (d *Definitions) ListModels() []string

func (*Definitions) LookupModel Uses

func (d *Definitions) LookupModel(model string) Schema

LookupModel is public through the interface of Models. It returns a visitable schema from the given model name.

func (*Definitions) ParseSchema Uses

func (d *Definitions) ParseSchema(s *openapi_v2.Schema, path *Path) (Schema, error)

ParseSchema creates a walkable Schema from an openapi schema. While this function is public, it doesn't leak through the interface.

type Kind Uses

type Kind struct {
    BaseSchema

    // Lists names of required fields.
    RequiredFields []string
    // Maps field names to types.
    Fields map[string]Schema
    // FieldOrder reports the canonical order for the fields.
    FieldOrder []string
}

Kind is a complex object. It can have multiple different subtypes for each field, as defined in the `Fields` field. Mandatory fields are listed in `RequiredFields`. The key of the object is always of type `string`.

func (*Kind) Accept Uses

func (k *Kind) Accept(v SchemaVisitor)

func (*Kind) GetName Uses

func (k *Kind) GetName() string

func (*Kind) IsRequired Uses

func (k *Kind) IsRequired(field string) bool

IsRequired returns true if `field` is a required field for this type.

func (*Kind) Keys Uses

func (k *Kind) Keys() []string

Keys returns a alphabetically sorted list of keys.

type Map Uses

type Map struct {
    BaseSchema

    SubType Schema
}

Map is an object who values must all be of the same `SubType`. The key of the object is always of type `string`.

func (*Map) Accept Uses

func (m *Map) Accept(v SchemaVisitor)

func (*Map) GetName Uses

func (m *Map) GetName() string

type Models Uses

type Models interface {
    LookupModel(string) Schema
    ListModels() []string
}

Models interface describe a model provider. They can give you the schema for a specific model.

func NewOpenAPIData Uses

func NewOpenAPIData(doc *openapi_v2.Document) (Models, error)

NewOpenAPIData creates a new `Models` out of the openapi document.

type Path Uses

type Path struct {
    // contains filtered or unexported fields
}

Path helps us keep track of type paths

func NewPath Uses

func NewPath(key string) Path

func (*Path) ArrayPath Uses

func (p *Path) ArrayPath(i int) Path

ArrayPath appends an array index and creates a new path

func (*Path) FieldPath Uses

func (p *Path) FieldPath(field string) Path

FieldPath appends a field name and creates a new path

func (*Path) Get Uses

func (p *Path) Get() []string

func (*Path) Len Uses

func (p *Path) Len() int

func (*Path) String Uses

func (p *Path) String() string

type Primitive Uses

type Primitive struct {
    BaseSchema

    // Type of a primitive must be one of: integer, number, string, boolean.
    Type   string
    Format string
}

Primitive is a literal. There can be multiple types of primitives, and this subtype can be visited through the `subType` field.

func (*Primitive) Accept Uses

func (p *Primitive) Accept(v SchemaVisitor)

func (*Primitive) GetName Uses

func (p *Primitive) GetName() string

type Ref Uses

type Ref struct {
    BaseSchema
    // contains filtered or unexported fields
}

func (*Ref) Accept Uses

func (r *Ref) Accept(v SchemaVisitor)

func (*Ref) GetName Uses

func (r *Ref) GetName() string

func (*Ref) Reference Uses

func (r *Ref) Reference() string

func (*Ref) SubSchema Uses

func (r *Ref) SubSchema() Schema

type Reference Uses

type Reference interface {
    Schema

    Reference() string
    SubSchema() Schema
}

Reference implementation depends on the type of document.

type Schema Uses

type Schema interface {
    // Giving a visitor here will let you visit the actual type.
    Accept(SchemaVisitor)

    // Pretty print the name of the type.
    GetName() string
    // Describes how to access this field.
    GetPath() *Path
    // Describes the field.
    GetDescription() string
    // Returns type extensions.
    GetExtensions() map[string]interface{}
}

Schema is the base definition of an openapi type.

type SchemaVisitor Uses

type SchemaVisitor interface {
    VisitArray(*Array)
    VisitMap(*Map)
    VisitPrimitive(*Primitive)
    VisitKind(*Kind)
    VisitReference(Reference)
}

SchemaVisitor is an interface that you need to implement if you want to "visit" an openapi schema. A dispatch on the Schema type will call the appropriate function based on its actual type: - Array is a list of one and only one given subtype - Map is a map of string to one and only one given subtype - Primitive can be string, integer, number and boolean. - Kind is an object with specific fields mapping to specific types. - Reference is a link to another definition.

type SchemaVisitorArbitrary Uses

type SchemaVisitorArbitrary interface {
    SchemaVisitor
    VisitArbitrary(*Arbitrary)
}

SchemaVisitorArbitrary is an additional visitor interface which handles arbitrary types. For backwards compatibility, it's a separate interface which is checked for at runtime.

Directories

PathSynopsis
testing
validation

Package proto imports 5 packages (graph) and is imported by 56 packages. Updated 2019-04-04. Refresh now. Tools for package owners.