openapi

package
v0.28.1-rc2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package openapi imports immutable OpenAPI snapshots for the hosted wrapper. It does not generate MCP tools or make requests to the described API.

Index

Constants

View Source
const (
	MaxSchemaBytes = 1024 * 1024
)

Variables

This section is empty.

Functions

func Environment

func Environment(result *Result, headers []types.MCPConfig, devMode bool) ([]string, error)

Environment validates credential definitions and returns the wrapper's environment variables. Credential values and prefixes stay in Obot's per-request header handling. Definitions can change after schema import.

func SnapshotEnvironment

func SnapshotEnvironment(config types.OpenAPIRuntimeConfig, headers []types.MCPConfig, devMode bool) ([]string, error)

SnapshotEnvironment constructs deployment settings from the saved snapshot, never Source. Revalidate the snapshot before launching the wrapper because callers can supply a snapshot directly instead of using Importer. Destination policy is checked during manifest validation and immediately before deployment.

func ValidateDestination

func ValidateDestination(ctx context.Context, baseURL string, options safehttp.Options, devMode bool) error

ValidateDestination checks HTTPS and the configured address policy without requesting the API. The runtime must still enforce policy on API requests.

func ValidateInput

func ValidateInput(config types.OpenAPIRuntimeConfig) error

ValidateInput checks user-supplied configuration before importing its source. Schema is output only; Obot always generates it from Source.

func ValidateSnapshotEnvironment

func ValidateSnapshotEnvironment(ctx context.Context, config types.OpenAPIRuntimeConfig, headers []types.MCPConfig, options safehttp.Options, devMode bool) ([]string, error)

ValidateSnapshotEnvironment applies destination policy before producing the environment. It never fetches Source or requests the destination.

func ValidateSource

func ValidateSource(source types.OpenAPISource) error

ValidateSource checks source metadata without fetching the document.

Types

type Importer

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

Importer fetches schema sources. It never receives API credentials.

func NewImporter

func NewImporter(options safehttp.Options, devMode bool) *Importer

NewImporter applies the configured network policy to schema fetches. devMode permits HTTP schema sources and API destinations for local development. Redirects are not followed, including same-origin ones.

func (*Importer) Import

func (i *Importer) Import(ctx context.Context, config types.OpenAPIRuntimeConfig) (*Result, error)

Import always reads Source anew, ignoring any previous Schema snapshot. It returns no replacement snapshot on failure; callers retain the last good one. Destination failures are reported in Result, allowing import previews before an override is configured. Callers must validate destinations before saving or deploying the returned snapshot.

type Result

type Result struct {
	Schema                json.RawMessage
	BaseURL               string
	SuggestedHeaders      []types.MCPConfig
	SuggestedMetadata     types.OpenAPIMetadata
	DestinationValidation types.OpenAPIDestinationValidation
}

Result contains the stored schema, resolved API destination, and suggested credential inputs. MCP tools are generated and listed by the hosted wrapper.

func Parse

func Parse(data []byte, config types.OpenAPIRuntimeConfig) (*Result, error)

Parse normalizes JSON/YAML and checks the wrapper's supported subset. It does not resolve remote references or claim to validate every OpenAPI constraint. The importer applies transport and network policies after parsing. SuggestedHeaders are editable definitions, not credential values.

Jump to

Keyboard shortcuts

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