Documentation
¶
Overview ¶
Package converter provides utilities for converting between different function descriptor formats
Index ¶
- func ExtractExtension(extensions map[string]interface{}, key string) (interface{}, bool)
- func GetBoolExtension(extensions map[string]interface{}, key string) (bool, bool)
- func GetStringExtension(extensions map[string]interface{}, key string) (string, bool)
- func ToOpenAPIOperation(descriptor LocalFunctionDescriptorDesc) (*openapi3.Operation, error)
- type LocalFunctionDescriptorDesc
- type OpenAPIConverter
- type PackConverter
- type PackEntity
- type PackEntityOperation
- type PackFunction
- type PackManifest
- type ProtoConverter
- type ProtoMethodInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractExtension ¶
ExtractExtension extracts an extension value without the x- prefix
func GetBoolExtension ¶
GetBoolExtension extracts a boolean extension value
func GetStringExtension ¶
GetStringExtension extracts a string extension value
func ToOpenAPIOperation ¶
func ToOpenAPIOperation(descriptor LocalFunctionDescriptorDesc) (*openapi3.Operation, error)
ToOpenAPIOperation converts a LocalFunctionDescriptor to an OpenAPI 3.0.3 Operation object
Types ¶
type LocalFunctionDescriptorDesc ¶
type LocalFunctionDescriptorDesc struct {
ID string
Version string
Tags []string
Summary string
Description string
OperationID string
Deprecated bool
InputSchema string
OutputSchema string
Category string
Risk string
Entity string
Operation string
}
LocalFunctionDescriptorDesc represents a LocalFunctionDescriptor for conversion
type OpenAPIConverter ¶
type OpenAPIConverter struct{}
OpenAPIConverter handles OpenAPI 3.0.3 to JSON Schema conversions
func NewOpenAPIConverter ¶
func NewOpenAPIConverter() *OpenAPIConverter
NewOpenAPIConverter creates a new OpenAPI converter instance
func (*OpenAPIConverter) ToJSONSchema ¶
func (c *OpenAPIConverter) ToJSONSchema(schema *openapi3.Schema) (map[string]interface{}, error)
ToJSONSchema converts an OpenAPI 3.0.3 Schema to JSON Schema format
type PackConverter ¶
type PackConverter struct {
// contains filtered or unexported fields
}
PackConverter converts Pack manifests to OpenAPI 3.0.3 Operations
func NewPackConverter ¶
func NewPackConverter() *PackConverter
NewPackConverter creates a new Pack converter instance
func (*PackConverter) LoadPackFromDir ¶
func (c *PackConverter) LoadPackFromDir(dirPath string) (*PackManifest, error)
LoadPackFromDir loads a Pack manifest from a directory
func (*PackConverter) LoadPackFromFile ¶
func (c *PackConverter) LoadPackFromFile(filePath string) (*PackManifest, error)
LoadPackFromFile loads a Pack manifest from a file
func (*PackConverter) PackToOpenAPI ¶
func (c *PackConverter) PackToOpenAPI(manifest *PackManifest) (map[string]*openapi3.Operation, error)
PackToOpenAPI converts a Pack manifest to OpenAPI 3.0.3 operations
type PackEntity ¶
type PackEntity struct {
ID string `json:"id"`
Name string `json:"name"`
Schema map[string]interface{} `json:"schema"`
Operations []PackEntityOperation `json:"operations"`
}
PackEntity represents an entity in the Pack manifest
type PackEntityOperation ¶
type PackEntityOperation struct {
OP string `json:"op"` // create/read/update/delete/custom
Name string `json:"name"`
Params map[string]interface{} `json:"params"`
Returns map[string]interface{} `json:"returns"`
Target map[string]interface{} `json:"target,omitempty"`
}
PackEntityOperation represents an entity operation
type PackFunction ¶
type PackFunction struct {
ID string `json:"id"`
Name string `json:"name"`
Summary string `json:"summary"`
Description string `json:"description"`
Params map[string]interface{} `json:"params"`
Returns map[string]interface{} `json:"returns"`
Category string `json:"category,omitempty"`
Risk string `json:"risk,omitempty"`
Entity string `json:"entity,omitempty"`
Operation string `json:"operation,omitempty"` // create/read/update/delete/custom
}
PackFunction represents a function in the Pack manifest
type PackManifest ¶
type PackManifest struct {
ID string `json:"id"`
Version string `json:"version"`
Name string `json:"name"`
Provider string `json:"provider"`
Functions []PackFunction `json:"functions"`
Entities []PackEntity `json:"entities,omitempty"`
}
PackManifest represents the old Pack manifest format
type ProtoConverter ¶
type ProtoConverter struct {
// contains filtered or unexported fields
}
ProtoConverter converts Proto descriptors to OpenAPI 3.0.3 Operations
func NewProtoConverter ¶
func NewProtoConverter() *ProtoConverter
NewProtoConverter creates a new Proto converter instance
func (*ProtoConverter) ProtoSchemaToOpenAPISchema ¶
func (c *ProtoConverter) ProtoSchemaToOpenAPISchema(descriptor *descriptorpb.DescriptorProto) (*openapi3.Schema, error)
ProtoSchemaToOpenAPISchema converts a Proto message descriptor to OpenAPI Schema This is a placeholder for full proto-to-json-schema conversion
func (*ProtoConverter) ProtoToOpenAPI ¶
func (c *ProtoConverter) ProtoToOpenAPI(method *ProtoMethodInfo, extensions map[string]interface{}) (*openapi3.Operation, error)
ProtoToOpenAPI converts a Proto method descriptor to OpenAPI 3.0.3 Operation