generatedapi

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package generatedapi turns bounded external API descriptions into ordinary workflow step kinds. Generated kinds expose exact schemas, effects, capabilities, and credential-reference inputs before execution, then route the actual request through the existing HTTP adapter.

The initial source family is a deliberately portable OpenAPI 3.0/3.1 subset. Unsupported or ambiguous source features fail generation instead of being ignored or implemented by a second runtime. HTTP Basic sources require x-hadron-basic-username as a fixed non-secret username; the generated input remains a SecretRef-only password and is resolved by http@v1. Custom apiKey schemes must use a dedicated non-cookie, non-Authorization request header; Authorization credentials use the explicit bearer or Basic mappings.

Index

Constants

View Source
const (
	// SourceFamilyOpenAPI is the stable source-family identifier.
	SourceFamilyOpenAPI = "openapi"
	// DefaultMaxSpecBytes is the default source-document bound.
	DefaultMaxSpecBytes int64 = 2 << 20
)

Variables

View Source
var (
	// ErrInvalidOptions identifies an invalid generator dependency or bound.
	ErrInvalidOptions = errors.New("invalid generated API options")
	// ErrInvalidSource identifies an unsupported or malformed source document.
	ErrInvalidSource = errors.New("invalid generated API source")
	// ErrInvalidInvocation identifies input or runtime config that does not
	// satisfy the generated operation contract.
	ErrInvalidInvocation = errors.New("invalid generated API invocation")
)

Functions

This section is empty.

Types

type CredentialDescription

type CredentialDescription struct {
	Input    string `json:"input"`
	Scheme   string `json:"scheme"`
	Kind     string `json:"kind"`
	Header   string `json:"header,omitempty"`
	Username string `json:"username,omitempty"`
}

CredentialDescription is the non-secret generated credential contract. Input names a typed secret_ref input; it never contains credential material or the reference selected by a workflow invocation.

type Family

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

Family is one immutable generated catalog. Its step kinds are ordinary registry entries and do not introduce an alternate execution path.

func GenerateOpenAPI

func GenerateOpenAPI(ctx context.Context, source []byte, options Options) (*Family, error)

GenerateOpenAPI generates ordinary first-class step kinds from one bounded OpenAPI 3.0 or 3.1 JSON/YAML document.

func (*Family) Kinds

func (f *Family) Kinds() []stepkind.StepKind

Kinds returns generated kinds ordered by stable name and version.

func (*Family) Operations

func (f *Family) Operations() []OperationDescription

Operations returns deterministic defensive catalog projections.

func (*Family) Register

func (f *Family) Register(registry stepkind.Registry) error

Register adds every generated kind to registry in deterministic order.

func (*Family) SourceDigest

func (f *Family) SourceDigest() string

SourceDigest returns the digest of the canonical source document.

type Kind

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

Kind is one generated operation implemented through http@v1.

func (*Kind) Description

func (k *Kind) Description() OperationDescription

Description returns a defensive non-secret operation projection.

func (*Kind) Execute

func (k *Kind) Execute(ctx context.Context, prepared stepkind.PreparedInvocation) (stepkind.StepResult, error)

Execute maps typed operation inputs to a fixed HTTP declaration and invokes http@v1. Credential references remain opaque until that adapter resolves its auth configuration at the existing secret boundary.

func (*Kind) Spec

func (k *Kind) Spec() stepkind.StepKindSpec

Spec returns fresh policy-visible metadata for this generated operation.

func (*Kind) ValidateConfig

func (k *Kind) ValidateConfig(ctx context.Context, config graph.Config) []diagnostic.Diagnostic

ValidateConfig validates only bounded execution controls. Request identity, destination, method, auth, schemas, effects, and capabilities are generated constants and have no runtime override fields.

type OperationDescription

type OperationDescription struct {
	SourceFamily         string                  `json:"source_family"`
	SourceDigest         string                  `json:"source_digest"`
	SourceTitle          string                  `json:"source_title"`
	SourceVersion        string                  `json:"source_version"`
	Name                 string                  `json:"name"`
	Version              string                  `json:"version"`
	OperationID          string                  `json:"operation_id"`
	Method               string                  `json:"method"`
	Origin               string                  `json:"origin"`
	PathTemplate         string                  `json:"path_template"`
	ConfigSchema         graph.Schema            `json:"config_schema"`
	InputSchema          graph.Schema            `json:"input_schema"`
	OutputSchema         graph.Schema            `json:"output_schema"`
	Effects              graph.EffectSet         `json:"effects"`
	RequiredCapabilities []string                `json:"required_capabilities"`
	Credentials          []CredentialDescription `json:"credentials,omitempty"`
	SuccessStatuses      []int                   `json:"success_statuses"`
}

OperationDescription is the immutable generated catalog projection used by authoring and policy surfaces before an operation executes.

type Options

type Options struct {
	Namespace    string
	HTTP         *httpadapter.Kind
	MaxSpecBytes int64
}

Options supplies the stable catalog namespace and the only execution implementation used by generated HTTP operations.

Jump to

Keyboard shortcuts

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