surface_v1

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

README

API Code Surface

This directory contains a Protocol Buffer-language model suitable for generating support code for calling and implementing an API.

It can be generated from other formats read by gnostic and passed to code generator plugins to assist them by providing a preprocessed API description that is easier to generate.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FieldKind_name = map[int32]string{
		0: "SCALAR",
		1: "MAP",
		2: "ARRAY",
		3: "REFERENCE",
		4: "ANY",
	}
	FieldKind_value = map[string]int32{
		"SCALAR":    0,
		"MAP":       1,
		"ARRAY":     2,
		"REFERENCE": 3,
		"ANY":       4,
	}
)

Enum value maps for FieldKind.

View Source
var (
	TypeKind_name = map[int32]string{
		0: "STRUCT",
		1: "OBJECT",
	}
	TypeKind_value = map[string]int32{
		"STRUCT": 0,
		"OBJECT": 1,
	}
)

Enum value maps for TypeKind.

View Source
var (
	Position_name = map[int32]string{
		0: "BODY",
		1: "HEADER",
		2: "FORMDATA",
		3: "QUERY",
		4: "PATH",
	}
	Position_value = map[string]int32{
		"BODY":     0,
		"HEADER":   1,
		"FORMDATA": 2,
		"QUERY":    3,
		"PATH":     4,
	}
)

Enum value maps for Position.

View Source
var File_surface_surface_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Field

type Field struct {
	Name string    `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`                            // the name as specified in the API description
	Type string    `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"`                            // the specified content type of the field
	Kind FieldKind `protobuf:"varint,3,opt,name=kind,proto3,enum=surface.v1.FieldKind" json:"kind,omitempty"` // what kind of thing is this field? scalar, reference,
	// array, map of strings to the specified type
	Format        string   `protobuf:"bytes,4,opt,name=format,proto3" json:"format,omitempty"`                                    // the specified format of the field
	Position      Position `protobuf:"varint,5,opt,name=position,proto3,enum=surface.v1.Position" json:"position,omitempty"`      // "body", "header", "formdata", "query", or "path"
	NativeType    string   `protobuf:"bytes,6,opt,name=native_type,json=nativeType,proto3" json:"native_type,omitempty"`          // the programming-language native type of the field
	FieldName     string   `protobuf:"bytes,7,opt,name=field_name,json=fieldName,proto3" json:"field_name,omitempty"`             // the name to use for a data structure field
	ParameterName string   `protobuf:"bytes,8,opt,name=parameter_name,json=parameterName,proto3" json:"parameter_name,omitempty"` // the name to use for a function parameter
	Serialize     bool     `protobuf:"varint,9,opt,name=serialize,proto3" json:"serialize,omitempty"`                             // true if this field should be serialized (to JSON, etc)
	EnumValues    []string `protobuf:"bytes,10,rep,name=enum_values,json=enumValues,proto3" json:"enum_values,omitempty"`         // enum values as specified in the API description
	// contains filtered or unexported fields
}

Field is a field in a definition and can be associated with a position in a request structure.

func (*Field) Descriptor deprecated

func (*Field) Descriptor() ([]byte, []int)

Deprecated: Use Field.ProtoReflect.Descriptor instead.

func (*Field) GetEnumValues added in v0.4.2

func (x *Field) GetEnumValues() []string

func (*Field) GetFieldName

func (x *Field) GetFieldName() string

func (*Field) GetFormat

func (x *Field) GetFormat() string

func (*Field) GetKind

func (x *Field) GetKind() FieldKind

func (*Field) GetName

func (x *Field) GetName() string

func (*Field) GetNativeType

func (x *Field) GetNativeType() string

func (*Field) GetParameterName

func (x *Field) GetParameterName() string

func (*Field) GetPosition

func (x *Field) GetPosition() Position

func (*Field) GetSerialize

func (x *Field) GetSerialize() bool

func (*Field) GetType

func (x *Field) GetType() string

func (*Field) ProtoMessage

func (*Field) ProtoMessage()

func (*Field) ProtoReflect added in v0.4.2

func (x *Field) ProtoReflect() protoreflect.Message

func (*Field) Reset

func (x *Field) Reset()

func (*Field) ServiceType

func (f *Field) ServiceType(m *Model) *Type

ServiceType returns the Type associated with a field.

func (*Field) String

func (x *Field) String() string

type FieldInfo added in v0.3.1

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

The structure to transport information during the recursive calls inside model_openapiv2.go and model_openapiv3.go

type FieldKind

type FieldKind int32
const (
	FieldKind_SCALAR    FieldKind = 0
	FieldKind_MAP       FieldKind = 1
	FieldKind_ARRAY     FieldKind = 2
	FieldKind_REFERENCE FieldKind = 3
	FieldKind_ANY       FieldKind = 4
)

func (FieldKind) Descriptor added in v0.4.2

func (FieldKind) Descriptor() protoreflect.EnumDescriptor

func (FieldKind) Enum added in v0.4.2

func (x FieldKind) Enum() *FieldKind

func (FieldKind) EnumDescriptor deprecated

func (FieldKind) EnumDescriptor() ([]byte, []int)

Deprecated: Use FieldKind.Descriptor instead.

func (FieldKind) Number added in v0.4.2

func (x FieldKind) Number() protoreflect.EnumNumber

func (FieldKind) String

func (x FieldKind) String() string

func (FieldKind) Type added in v0.4.2

type Method

type Method struct {
	Operation          string `protobuf:"bytes,1,opt,name=operation,proto3" json:"operation,omitempty"`                                               // Operation ID
	Path               string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"`                                                         // HTTP path
	Method             string `protobuf:"bytes,3,opt,name=method,proto3" json:"method,omitempty"`                                                     // HTTP method name
	Description        string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"`                                           // description of method
	Name               string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"`                                                         // Operation name, possibly generated from method and path
	HandlerName        string `protobuf:"bytes,6,opt,name=handler_name,json=handlerName,proto3" json:"handler_name,omitempty"`                        // name of the generated handler
	ProcessorName      string `protobuf:"bytes,7,opt,name=processor_name,json=processorName,proto3" json:"processor_name,omitempty"`                  // name of the processing function in the service interface
	ClientName         string `protobuf:"bytes,8,opt,name=client_name,json=clientName,proto3" json:"client_name,omitempty"`                           // name of client
	ParametersTypeName string `protobuf:"bytes,9,opt,name=parameters_type_name,json=parametersTypeName,proto3" json:"parameters_type_name,omitempty"` // parameters (input), with fields corresponding to input parameters
	ResponsesTypeName  string `protobuf:"bytes,10,opt,name=responses_type_name,json=responsesTypeName,proto3" json:"responses_type_name,omitempty"`   // responses (output), with fields
	// contains filtered or unexported fields
}

Method is an operation of an API and typically has associated client and server code.

func (*Method) Descriptor deprecated

func (*Method) Descriptor() ([]byte, []int)

Deprecated: Use Method.ProtoReflect.Descriptor instead.

func (*Method) GetClientName

func (x *Method) GetClientName() string

func (*Method) GetDescription

func (x *Method) GetDescription() string

func (*Method) GetHandlerName

func (x *Method) GetHandlerName() string

func (*Method) GetMethod

func (x *Method) GetMethod() string

func (*Method) GetName

func (x *Method) GetName() string

func (*Method) GetOperation

func (x *Method) GetOperation() string

func (*Method) GetParametersTypeName

func (x *Method) GetParametersTypeName() string

func (*Method) GetPath

func (x *Method) GetPath() string

func (*Method) GetProcessorName

func (x *Method) GetProcessorName() string

func (*Method) GetResponsesTypeName

func (x *Method) GetResponsesTypeName() string

func (*Method) ProtoMessage

func (*Method) ProtoMessage()

func (*Method) ProtoReflect added in v0.4.2

func (x *Method) ProtoReflect() protoreflect.Message

func (*Method) Reset

func (x *Method) Reset()

func (*Method) String

func (x *Method) String() string

type Model

type Model struct {
	Name               string    `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`                                                       // a free-form title for the API
	Types              []*Type   `protobuf:"bytes,2,rep,name=types,proto3" json:"types,omitempty"`                                                     // the types used by the API
	Methods            []*Method `protobuf:"bytes,3,rep,name=methods,proto3" json:"methods,omitempty"`                                                 // the methods (functions) of the API
	SymbolicReferences []string  `protobuf:"bytes,4,rep,name=symbolic_references,json=symbolicReferences,proto3" json:"symbolic_references,omitempty"` // references to other OpenAPI files. Currently only supported for
	// contains filtered or unexported fields
}

Model represents an API for code generation.

func NewModelFromOpenAPI2

func NewModelFromOpenAPI2(document *openapiv2.Document, sourceName string) (*Model, error)

NewModelFromOpenAPI2 builds a model of an API service for use in code generation.

func NewModelFromOpenAPI3

func NewModelFromOpenAPI3(document *openapiv3.Document, sourceName string) (*Model, error)

NewModelFromOpenAPIv3 builds a model of an API service for use in code generation.

func (*Model) Descriptor deprecated

func (*Model) Descriptor() ([]byte, []int)

Deprecated: Use Model.ProtoReflect.Descriptor instead.

func (*Model) GetMethods

func (x *Model) GetMethods() []*Method

func (*Model) GetName

func (x *Model) GetName() string

func (*Model) GetSymbolicReferences added in v0.3.1

func (x *Model) GetSymbolicReferences() []string

func (*Model) GetTypes

func (x *Model) GetTypes() []*Type

func (*Model) ProtoMessage

func (*Model) ProtoMessage()

func (*Model) ProtoReflect added in v0.4.2

func (x *Model) ProtoReflect() protoreflect.Message

func (*Model) Reset

func (x *Model) Reset()

func (*Model) String

func (x *Model) String() string

func (*Model) TypeWithTypeName

func (m *Model) TypeWithTypeName(name string) *Type

type OpenAPI2Builder

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

type OpenAPI3Builder

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

type Position

type Position int32
const (
	Position_BODY     Position = 0
	Position_HEADER   Position = 1
	Position_FORMDATA Position = 2
	Position_QUERY    Position = 3
	Position_PATH     Position = 4
)

func (Position) Descriptor added in v0.4.2

func (Position) Descriptor() protoreflect.EnumDescriptor

func (Position) Enum added in v0.4.2

func (x Position) Enum() *Position

func (Position) EnumDescriptor deprecated

func (Position) EnumDescriptor() ([]byte, []int)

Deprecated: Use Position.Descriptor instead.

func (Position) Number added in v0.4.2

func (x Position) Number() protoreflect.EnumNumber

func (Position) String

func (x Position) String() string

func (Position) Type added in v0.4.2

type Type

type Type struct {
	Name        string   `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`                                  // the name to use for the type
	Kind        TypeKind `protobuf:"varint,2,opt,name=kind,proto3,enum=surface.v1.TypeKind" json:"kind,omitempty"`        // a meta-description of the type (struct, map, etc)
	Description string   `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"`                    // a comment describing the type
	ContentType string   `protobuf:"bytes,4,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"` // if the type is a map, this is its content type
	Fields      []*Field `protobuf:"bytes,5,rep,name=fields,proto3" json:"fields,omitempty"`                              // the fields of the type
	TypeName    string   `protobuf:"bytes,6,opt,name=type_name,json=typeName,proto3" json:"type_name,omitempty"`          // language-specific type name
	// contains filtered or unexported fields
}

Type typically corresponds to a definition, parameter, or response in an API and is represented by a type in generated code.

func (*Type) Descriptor deprecated

func (*Type) Descriptor() ([]byte, []int)

Deprecated: Use Type.ProtoReflect.Descriptor instead.

func (*Type) FieldWithName

func (s *Type) FieldWithName(name string) *Field

func (*Type) FieldWithPosition

func (s *Type) FieldWithPosition(position Position) *Field

func (*Type) GetContentType

func (x *Type) GetContentType() string

func (*Type) GetDescription

func (x *Type) GetDescription() string

func (*Type) GetFields

func (x *Type) GetFields() []*Field

func (*Type) GetKind

func (x *Type) GetKind() TypeKind

func (*Type) GetName

func (x *Type) GetName() string

func (*Type) GetTypeName

func (x *Type) GetTypeName() string

func (*Type) HasFieldWithName

func (s *Type) HasFieldWithName(name string) bool

func (*Type) HasFieldWithPosition

func (s *Type) HasFieldWithPosition(position Position) bool

func (*Type) ProtoMessage

func (*Type) ProtoMessage()

func (*Type) ProtoReflect added in v0.4.2

func (x *Type) ProtoReflect() protoreflect.Message

func (*Type) Reset

func (x *Type) Reset()

func (*Type) String

func (x *Type) String() string

type TypeKind

type TypeKind int32
const (
	TypeKind_STRUCT TypeKind = 0 // implement with named fields
	TypeKind_OBJECT TypeKind = 1 // implement with a map
)

func (TypeKind) Descriptor added in v0.4.2

func (TypeKind) Descriptor() protoreflect.EnumDescriptor

func (TypeKind) Enum added in v0.4.2

func (x TypeKind) Enum() *TypeKind

func (TypeKind) EnumDescriptor deprecated

func (TypeKind) EnumDescriptor() ([]byte, []int)

Deprecated: Use TypeKind.Descriptor instead.

func (TypeKind) Number added in v0.4.2

func (x TypeKind) Number() protoreflect.EnumNumber

func (TypeKind) String

func (x TypeKind) String() string

func (TypeKind) Type added in v0.4.2

Jump to

Keyboard shortcuts

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