openrpc

package module
v0.0.0-...-e8da5e4 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 10 Imported by: 0

README

openrpc

CI

openrpc is a design-first Go implementation of OpenRPC 1.3.x and 1.4.x. It models their shared document shape, preserves arbitrary Draft 7 schemas and extension values, parses untrusted JSON under finite policies, emits canonical JSON, and provides explicit validation, reference resolution, runtime expressions, discovery, composition, compatibility diffing, and JSON-RPC handler integration.

The core performs no implicit network or filesystem access. External reference resolution requires a caller-supplied store and an allowlist policy. Earlier or future OpenRPC feature lines are rejected until their semantics are separately inventoried and tested.

Five-minute design-first quickstart

version, _ := openrpc.ParseVersion("1.4.1")
info, _ := openrpc.NewInfo(openrpc.InfoInput{
    Title: "Calculator",
    Version: "1.0.0",
})
add, _ := openrpc.NewMethod(openrpc.MethodInput{
    Name: "add",
    Params: []openrpc.ContentDescriptorOrReference{},
})

documentBuilder, _ := builder.NewDocument(version, info)
documentBuilder, _ = documentBuilder.WithMethod(add)
document, _ := documentBuilder.Build()
encoded, _ := openrpc.MarshalCanonical(document)

Parsing and validation quickstart

options := parse.DefaultOptions()
options.UnknownFields = parse.RejectUnknownFields
parsed, err := parse.Decode(untrustedJSON, options)
if err != nil {
    return err
}

semantic := validate.Document(ctx, parsed.Document(), validate.DefaultOptions())
if !semantic.Valid() {
    return fmt.Errorf("invalid OpenRPC document: %v", semantic.Diagnostics())
}

raw, _ := jsonvalue.Parse(untrustedJSON, jsonvalue.DefaultPolicy())
structural := validate.MetaSchema(ctx, raw, 1000)
if !structural.Valid() {
    return fmt.Errorf("meta-schema failure: %v", structural.Issues())
}

parse.Preserving retains the exact accepted source for lossless re-emission; canonical serialization sorts object keys and omits insignificant whitespace.

Discovery quickstart

service, _ := discovery.NewService(discovery.Static(document), visibilityPolicy)
snapshot, err := service.Discover(ctx)
if err != nil {
    return err
}

fmt.Println(snapshot.ETag())
fmt.Println(string(snapshot.Bytes()))

Wrap a service with discovery.NewCache for explicit concurrent miss deduplication. Call Invalidate when the provider revision changes. No cache, goroutine, or registry is process-global.

Optional observability

The observe leaf package wraps parse, validate, resolve, bundle, diff, and discovery operations without changing core APIs or installing an exporter. Observers receive only finite phase and outcome labels, diagnostic or reference counts, and duration. Events never contain documents, schemas, method names, references, URLs, or error strings. Observer panics are contained.

result, err := observe.Parse(ctx, input, parse.DefaultOptions(),
    observe.ObserverFunc(func(ctx context.Context, event observe.Event) {
        metrics.Record(event.Phase, event.Outcome, event.Duration)
    }),
)

jsonrpc integration quickstart

registry := gojsonrpc.NewRegistry()
err := openrpcjsonrpc.RegisterDiscovery[gojsonrpc.Handler](registry, service)
if err != nil {
    return err
}

handler, _ := registry.Lookup("rpc.discover")
result, err := handler(ctx, requestParams)

The sibling jsonrpc.Registry exposes an explicit trusted system-method path while continuing to reserve rpc.* from application registration. The adapter does not fork JSON-RPC batch, notification, request, response, error, or transport behavior.

Explicit references

store, _ := reference.NewMemoryStore(map[string][]byte{
    "https://schemas.example/value.json": schemaBytes,
})
policy := reference.DefaultResolvePolicy()
policy.AllowExternal = true
policy.AllowedSchemes = []string{"https"}
policy.AllowedHosts = []string{"schemas.example"}
resolver, _ := reference.NewResolver(store, policy)

target, err := resolver.Resolve(ctx, rootJSON, documentURI, rawReference)

reference.NewFSStore scopes an explicit fs.FS. The optional reference/httpstore package adds DNS/IP checks, HTTPS-by-default behavior, redirect and timeout limits, compression rejection, and streamed byte limits.

Compatibility and support

  • Supported OpenRPC feature lines: 1.3.x and 1.4.x.
  • Authoritative pinned release: OpenRPC 1.4.1.
  • JSON Schema dialect: Draft 7, including boolean schemas.
  • Minimum Go version: see .go-version and go.mod.
  • The official 1.3.0 metrics example is retained as accepted interoperability evidence. Examples on earlier feature lines remain explicit rejection fixtures.

See security, architecture, compatibility, the explicit specification decisions, and the generated conformance evidence under specification/conformance/.

AI-assisted documentation consumers can use llms.txt or the complete generated llms-full.txt bundle.

Local verification

make check
make check-all

The implementation is still working toward the goal's meaningful 100% production statement coverage. make coverage reports the current value; it does not disguise uncovered code as generated or unreachable. make check-all is intentionally blocking until coverage and mutation requirements are met.

Ecosystem

Use the Golib documentation portal to choose companion packages, supported stacks, recipes, and operations guidance.

Documentation

Overview

Package openrpc provides an ownership-safe OpenRPC document model and the core contracts shared by parsing, validation, resolution, and discovery.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidExtensionName reports a specification extension without the
	// required case-sensitive x- prefix.
	ErrInvalidExtensionName = errors.New("openrpc: invalid extension name")
	// ErrDuplicateField reports repeated field input to an ownership-safe
	// constructor.
	ErrDuplicateField = errors.New("openrpc: duplicate field")
	// ErrInvalidField reports an empty name or invalid zero JSON value.
	ErrInvalidField = errors.New("openrpc: invalid field")
)
View Source
var (
	// ErrFieldCollision reports an extension or preserved unknown field whose
	// name collides with a standard field during serialization.
	ErrFieldCollision = errors.New("openrpc: field collision")
	// ErrInvalidUnion reports a zero or otherwise unselected union value.
	ErrInvalidUnion = errors.New("openrpc: invalid union value")
)
View Source
var ErrInvalidInteger = errors.New("openrpc: invalid integer")

ErrInvalidInteger reports a non-canonical JSON integer lexeme.

View Source
var ErrInvalidParamStructure = errors.New("openrpc: invalid parameter structure")

ErrInvalidParamStructure reports a value outside the specification's closed parameter-structure set.

View Source
var ErrMissingRequiredField = errors.New("openrpc: missing required field")

ErrMissingRequiredField reports a required field absent from constructor input.

View Source
var ErrUnsupportedVersion = errors.New("openrpc: unsupported specification version")

ErrUnsupportedVersion reports a malformed, unsupported, or future OpenRPC specification version. Callers must not infer semantics for rejected values.

Functions

func JSONSchemaToolsMetaSchema

func JSONSchemaToolsMetaSchema() []byte

JSONSchemaToolsMetaSchema returns an owned copy of the companion meta-schema referenced by the authoritative OpenRPC 1.4.1 schema.

func MarshalCanonical

func MarshalCanonical(document Document) ([]byte, error)

MarshalCanonical serializes a Document deterministically. Object members are sorted lexically, insignificant whitespace is removed, and optional field presence is retained without materializing defaults.

func MetaSchema

func MetaSchema() []byte

MetaSchema returns an owned copy of the authoritative pinned OpenRPC 1.4.1 Draft 7 meta-schema.

func SupportedVersions

func SupportedVersions() []string

SupportedVersions returns the supported OpenRPC compatibility lines.

Types

type Components

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

Components is an immutable OpenRPC Components Object.

func NewComponents

func NewComponents(input ComponentsInput) (Components, error)

NewComponents constructs an owned Components Object.

func (Components) ContentDescriptors

func (components Components) ContentDescriptors() (map[string]ContentDescriptor, bool)

ContentDescriptors returns an owned optional descriptor component map.

func (Components) Errors

func (components Components) Errors() (map[string]Error, bool)

Errors returns an owned optional error component map.

func (Components) ExamplePairings

func (components Components) ExamplePairings() (map[string]ExamplePairing, bool)

ExamplePairings returns an owned optional example-pairing component map.

func (Components) Examples

func (components Components) Examples() (map[string]Example, bool)

Examples returns an owned optional example component map.

func (components Components) Links() (map[string]Link, bool)

Links returns an owned optional link component map.

func (Components) Schemas

func (components Components) Schemas() (map[string]jsonschema.Schema, bool)

Schemas returns an owned optional schema component map.

func (Components) Tags

func (components Components) Tags() (map[string]Tag, bool)

Tags returns an owned optional tag component map.

func (Components) UnknownFields

func (components Components) UnknownFields() Fields

UnknownFields returns fields retained by preserving parse mode.

type ComponentsInput

type ComponentsInput struct {
	Schemas            map[string]jsonschema.Schema
	Links              map[string]Link
	Errors             map[string]Error
	Examples           map[string]Example
	ExamplePairings    map[string]ExamplePairing
	ContentDescriptors map[string]ContentDescriptor
	Tags               map[string]Tag
	UnknownFields      Fields
}

ComponentsInput supplies reusable Components maps. Nil means absent; an allocated empty map means explicitly present and empty.

type Contact

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

Contact is an immutable OpenRPC Contact Object.

func NewContact

func NewContact(input ContactInput) (Contact, error)

NewContact constructs a Contact Object with owned optional values.

func (Contact) Email

func (contact Contact) Email() (string, bool)

Email returns the optional contact email address.

func (Contact) Extensions

func (fields Contact) Extensions() Fields

Extensions returns immutable specification extension fields.

func (Contact) Name

func (contact Contact) Name() (string, bool)

Name returns the optional identifying name.

func (Contact) URL

func (contact Contact) URL() (string, bool)

URL returns the optional contact URL.

func (Contact) UnknownFields

func (fields Contact) UnknownFields() Fields

UnknownFields returns immutable fields retained by preserving parse mode.

type ContactInput

type ContactInput struct {
	Name          *string
	Email         *string
	URL           *string
	Extensions    Fields
	UnknownFields Fields
}

ContactInput supplies optional Contact Object fields.

type ContentDescriptor

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

ContentDescriptor is an immutable OpenRPC Content Descriptor Object.

func NewContentDescriptor

func NewContentDescriptor(input ContentDescriptorInput) (ContentDescriptor, error)

NewContentDescriptor constructs a Content Descriptor Object.

func (ContentDescriptor) Deprecated

func (descriptor ContentDescriptor) Deprecated() (bool, bool)

Deprecated returns the declared value and whether the field was present.

func (ContentDescriptor) DeprecatedOrDefault

func (descriptor ContentDescriptor) DeprecatedOrDefault() bool

DeprecatedOrDefault returns the effective value, whose default is false.

func (ContentDescriptor) Description

func (descriptor ContentDescriptor) Description() (string, bool)

Description returns the optional rich-text description.

func (ContentDescriptor) Extensions

func (fields ContentDescriptor) Extensions() Fields

Extensions returns immutable specification extension fields.

func (ContentDescriptor) Name

func (descriptor ContentDescriptor) Name() string

Name returns the required content name.

func (ContentDescriptor) Required

func (descriptor ContentDescriptor) Required() (bool, bool)

Required returns the declared value and whether the field was present.

func (ContentDescriptor) RequiredOrDefault

func (descriptor ContentDescriptor) RequiredOrDefault() bool

RequiredOrDefault returns the effective value, whose default is false.

func (ContentDescriptor) Schema

func (descriptor ContentDescriptor) Schema() jsonschema.Schema

Schema returns the required Draft 7 schema.

func (ContentDescriptor) Summary

func (descriptor ContentDescriptor) Summary() (string, bool)

Summary returns the optional short summary.

func (ContentDescriptor) UnknownFields

func (fields ContentDescriptor) UnknownFields() Fields

UnknownFields returns immutable fields retained by preserving parse mode.

type ContentDescriptorInput

type ContentDescriptorInput struct {
	Name          string
	Description   *string
	Summary       *string
	Schema        *jsonschema.Schema
	Required      *bool
	Deprecated    *bool
	Extensions    Fields
	UnknownFields Fields
}

ContentDescriptorInput supplies Content Descriptor Object fields.

type ContentDescriptorOrReference

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

ContentDescriptorOrReference is the union permitted in OpenRPC document locations that accept a descriptor or reusable reference.

func ContentDescriptorReference

func ContentDescriptorReference(value Reference) ContentDescriptorOrReference

ContentDescriptorReference constructs the reference union case.

func ContentDescriptorValue

func ContentDescriptorValue(value ContentDescriptor) ContentDescriptorOrReference

ContentDescriptorValue constructs the descriptor union case.

func (ContentDescriptorOrReference) Descriptor

func (value ContentDescriptorOrReference) Descriptor() (ContentDescriptor, bool)

Descriptor returns the descriptor case and true.

func (ContentDescriptorOrReference) Reference

func (value ContentDescriptorOrReference) Reference() (Reference, bool)

Reference returns the reference case and true.

type Document

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

Document is an immutable OpenRPC root document.

func NewDocument

func NewDocument(input DocumentInput) (Document, error)

NewDocument constructs an owned OpenRPC document.

func (Document) Components

func (document Document) Components() (Components, bool)

Components returns the optional reusable Components Object.

func (Document) EffectiveServers

func (document Document) EffectiveServers() []Server

EffectiveServers returns explicit non-empty servers or the specification's localhost default when servers are absent or empty.

func (Document) Extensions

func (fields Document) Extensions() Fields

Extensions returns immutable specification extension fields.

func (Document) ExternalDocs

func (document Document) ExternalDocs() (ExternalDocumentation, bool)

ExternalDocs returns optional external documentation.

func (Document) Info

func (document Document) Info() Info

Info returns the required Info Object.

func (Document) MethodCount

func (document Document) MethodCount() int

MethodCount returns the required method collection size without allocating an owned snapshot. It supports resource-policy checks before traversal.

func (Document) Methods

func (document Document) Methods() []MethodOrReference

Methods returns an owned required method slice. It may be empty after context-aware security filtering.

func (Document) SchemaURI

func (document Document) SchemaURI() (string, bool)

SchemaURI returns the effective schema URI and whether it was explicit.

func (Document) Servers

func (document Document) Servers() ([]Server, bool)

Servers returns an owned explicit server slice and its presence.

func (Document) UnknownFields

func (fields Document) UnknownFields() Fields

UnknownFields returns immutable fields retained by preserving parse mode.

func (Document) Version

func (document Document) Version() Version

Version returns the required OpenRPC specification version.

type DocumentInput

type DocumentInput struct {
	Version       Version
	SchemaURI     *string
	Info          *Info
	ExternalDocs  *ExternalDocumentation
	Servers       []Server
	HasServers    bool
	Methods       []MethodOrReference
	Components    *Components
	Extensions    Fields
	UnknownFields Fields
}

DocumentInput supplies root OpenRPC document fields. Info must be non-nil, and Methods must be non-nil even when the visible list is empty.

type Error

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

Error is an immutable OpenRPC Error Object.

func NewError

func NewError(input ErrorInput) (Error, error)

NewError constructs an Error Object without narrowing its integer code.

func (Error) Code

func (object Error) Code() Integer

Code returns the required arbitrary-precision integer code.

func (Error) Data

func (object Error) Data() (jsonvalue.Value, bool)

Data returns the optional arbitrary JSON error data.

func (Error) Extensions

func (fields Error) Extensions() Fields

Extensions returns immutable specification extension fields.

func (Error) Message

func (object Error) Message() string

Message returns the required message.

func (Error) UnknownFields

func (fields Error) UnknownFields() Fields

UnknownFields returns immutable fields retained by preserving parse mode.

type ErrorInput

type ErrorInput struct {
	Code          Integer
	Message       string
	HasMessage    bool
	Data          *jsonvalue.Value
	Extensions    Fields
	UnknownFields Fields
}

ErrorInput supplies Error Object fields. Set HasMessage when representing a required but empty message.

type ErrorOrReference

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

ErrorOrReference is an Error Object or Reference Object union.

func ErrorReference

func ErrorReference(value Reference) ErrorOrReference

ErrorReference constructs the Reference Object union case.

func ErrorValue

func ErrorValue(value Error) ErrorOrReference

ErrorValue constructs the Error Object union case.

func (ErrorOrReference) Error

func (value ErrorOrReference) Error() (Error, bool)

Error returns the Error Object case and true.

func (ErrorOrReference) Reference

func (value ErrorOrReference) Reference() (Reference, bool)

Reference returns the Reference Object case and true.

type Example

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

Example is an immutable OpenRPC Example Object.

func NewExample

func NewExample(input ExampleInput) (Example, error)

NewExample constructs an Example Object. A JSON null Value remains a present required value.

func (Example) Description

func (example Example) Description() (string, bool)

Description returns the optional rich-text description.

func (Example) Extensions

func (fields Example) Extensions() Fields

Extensions returns immutable specification extension fields.

func (Example) Name

func (example Example) Name() string

Name returns the required canonical example name.

func (Example) Summary

func (example Example) Summary() (string, bool)

Summary returns the optional summary.

func (Example) UnknownFields

func (fields Example) UnknownFields() Fields

UnknownFields returns immutable fields retained by preserving parse mode.

func (Example) Value

func (example Example) Value() jsonvalue.Value

Value returns the required arbitrary JSON value.

type ExampleInput

type ExampleInput struct {
	Name          string
	Summary       *string
	Description   *string
	Value         jsonvalue.Value
	Extensions    Fields
	UnknownFields Fields
}

ExampleInput supplies Example Object fields.

type ExampleOrReference

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

ExampleOrReference is an Example Object or Reference Object union.

func ExampleReference

func ExampleReference(value Reference) ExampleOrReference

ExampleReference constructs the Reference Object union case.

func ExampleValue

func ExampleValue(value Example) ExampleOrReference

ExampleValue constructs the Example Object union case.

func (ExampleOrReference) Example

func (value ExampleOrReference) Example() (Example, bool)

Example returns the Example Object case and true.

func (ExampleOrReference) Reference

func (value ExampleOrReference) Reference() (Reference, bool)

Reference returns the Reference Object case and true.

type ExamplePairing

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

ExamplePairing is an immutable OpenRPC Example Pairing Object.

func NewExamplePairing

func NewExamplePairing(input ExamplePairingInput) (ExamplePairing, error)

NewExamplePairing constructs an Example Pairing Object. An absent Result represents notification usage.

func (ExamplePairing) Description

func (pairing ExamplePairing) Description() (string, bool)

Description returns the optional pairing description.

func (ExamplePairing) Name

func (pairing ExamplePairing) Name() string

Name returns the required pairing name.

func (ExamplePairing) Params

func (pairing ExamplePairing) Params() []ExampleOrReference

Params returns an owned parameter example slice.

func (ExamplePairing) Result

func (pairing ExamplePairing) Result() (ExampleOrReference, bool)

Result returns the optional result example. Absence denotes a notification.

func (ExamplePairing) UnknownFields

func (pairing ExamplePairing) UnknownFields() Fields

UnknownFields returns fields retained by preserving parse mode.

type ExamplePairingInput

type ExamplePairingInput struct {
	Name          string
	Description   *string
	Params        []ExampleOrReference
	Result        *ExampleOrReference
	UnknownFields Fields
}

ExamplePairingInput supplies Example Pairing Object fields.

type ExamplePairingOrReference

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

ExamplePairingOrReference is an Example Pairing or Reference Object union.

func ExamplePairingReference

func ExamplePairingReference(value Reference) ExamplePairingOrReference

ExamplePairingReference constructs the Reference Object union case.

func ExamplePairingValue

func ExamplePairingValue(value ExamplePairing) ExamplePairingOrReference

ExamplePairingValue constructs the Example Pairing union case.

func (ExamplePairingOrReference) ExamplePairing

func (value ExamplePairingOrReference) ExamplePairing() (ExamplePairing, bool)

ExamplePairing returns the pairing case and true.

func (ExamplePairingOrReference) Reference

func (value ExamplePairingOrReference) Reference() (Reference, bool)

Reference returns the Reference Object case and true.

type ExternalDocumentation

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

ExternalDocumentation is an immutable External Documentation Object.

func NewExternalDocumentation

func NewExternalDocumentation(input ExternalDocumentationInput) (ExternalDocumentation, error)

NewExternalDocumentation constructs an External Documentation Object.

func (ExternalDocumentation) Description

func (documentation ExternalDocumentation) Description() (string, bool)

Description returns the optional rich-text description.

func (ExternalDocumentation) Extensions

func (fields ExternalDocumentation) Extensions() Fields

Extensions returns immutable specification extension fields.

func (ExternalDocumentation) URL

func (documentation ExternalDocumentation) URL() string

URL returns the required target URL.

func (ExternalDocumentation) UnknownFields

func (fields ExternalDocumentation) UnknownFields() Fields

UnknownFields returns immutable fields retained by preserving parse mode.

type ExternalDocumentationInput

type ExternalDocumentationInput struct {
	URL           string
	Description   *string
	Extensions    Fields
	UnknownFields Fields
}

ExternalDocumentationInput supplies External Documentation Object fields.

type Field

type Field struct {
	Name  string
	Value jsonvalue.Value
}

Field is one named, arbitrary JSON value supplied to a field constructor.

type Fields

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

Fields is an immutable, deterministically ordered collection of arbitrary JSON fields.

func NewExtensions

func NewExtensions(fields ...Field) (Fields, error)

NewExtensions constructs specification extension fields. Names must begin with the case-sensitive x- prefix required by OpenRPC.

func NewUnknownFields

func NewUnknownFields(fields ...Field) (Fields, error)

NewUnknownFields constructs preserved standard-looking fields for explicit preserving parser mode.

func (Fields) Get

func (fields Fields) Get(name string) (jsonvalue.Value, bool)

Get returns an immutable value by its exact case-sensitive name.

func (Fields) Len

func (fields Fields) Len() int

Len returns the number of fields.

func (Fields) Names

func (fields Fields) Names() []string

Names returns an owned, lexically sorted name snapshot.

type Info

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

Info is an immutable OpenRPC Info Object.

func NewInfo

func NewInfo(input InfoInput) (Info, error)

NewInfo constructs an Info Object.

func (Info) Contact

func (info Info) Contact() (Contact, bool)

Contact returns the optional Contact Object.

func (Info) Description

func (info Info) Description() (string, bool)

Description returns the optional rich-text description.

func (Info) Extensions

func (fields Info) Extensions() Fields

Extensions returns immutable specification extension fields.

func (Info) License

func (info Info) License() (License, bool)

License returns the optional License Object.

func (Info) TermsOfService

func (info Info) TermsOfService() (string, bool)

TermsOfService returns the optional terms URL.

func (Info) Title

func (info Info) Title() string

Title returns the required application title.

func (Info) UnknownFields

func (fields Info) UnknownFields() Fields

UnknownFields returns immutable fields retained by preserving parse mode.

func (Info) Version

func (info Info) Version() string

Version returns the required API document version.

type InfoInput

type InfoInput struct {
	Title          string
	Version        string
	Description    *string
	TermsOfService *string
	Contact        *Contact
	License        *License
	Extensions     Fields
	UnknownFields  Fields
}

InfoInput supplies Info Object fields. Title and Version must be non-empty.

type Integer

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

Integer is an immutable arbitrary-precision JSON integer lexeme.

func ParseInteger

func ParseInteger(value string) (Integer, error)

ParseInteger validates a canonical JSON integer without narrowing it to a Go machine integer.

func (Integer) String

func (integer Integer) String() string

String returns the exact integer lexeme.

type License

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

License is an immutable OpenRPC License Object.

func NewLicense

func NewLicense(input LicenseInput) (License, error)

NewLicense constructs a License Object.

func (License) Extensions

func (fields License) Extensions() Fields

Extensions returns immutable specification extension fields.

func (License) Name

func (license License) Name() (string, bool)

Name returns the optional license name.

func (License) URL

func (license License) URL() (string, bool)

URL returns the optional license URL.

func (License) UnknownFields

func (fields License) UnknownFields() Fields

UnknownFields returns immutable fields retained by preserving parse mode.

type LicenseInput

type LicenseInput struct {
	Name          *string
	URL           *string
	Extensions    Fields
	UnknownFields Fields
}

LicenseInput supplies optional License Object fields.

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

Link is an immutable OpenRPC Link Object.

func NewLink(input LinkInput) (Link, error)

NewLink constructs a Link Object.

func (Link) Description

func (link Link) Description() (string, bool)

Description returns the optional rich-text description.

func (Link) Extensions

func (fields Link) Extensions() Fields

Extensions returns immutable specification extension fields.

func (Link) Method

func (link Link) Method() (string, bool)

Method returns the optional target method name.

func (Link) Name

func (link Link) Name() (jsonvalue.Value, bool)

Name returns the optional lossless name value.

func (Link) Params

func (link Link) Params() (jsonvalue.Value, bool)

Params returns the optional lossless parameter map.

func (Link) Server

func (link Link) Server() (Server, bool)

Server returns the optional target server.

func (Link) Summary

func (link Link) Summary() (string, bool)

Summary returns the optional summary.

func (Link) UnknownFields

func (fields Link) UnknownFields() Fields

UnknownFields returns immutable fields retained by preserving parse mode.

type LinkInput

type LinkInput struct {
	Name          *jsonvalue.Value
	Summary       *string
	Description   *string
	Method        *string
	Params        *jsonvalue.Value
	Server        *Server
	Extensions    Fields
	UnknownFields Fields
}

LinkInput supplies Link Object fields.

type LinkOrReference

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

LinkOrReference is a Link Object or Reference Object union.

func LinkReference

func LinkReference(value Reference) LinkOrReference

LinkReference constructs the Reference Object union case.

func LinkValue

func LinkValue(value Link) LinkOrReference

LinkValue constructs the Link Object union case.

func (value LinkOrReference) Link() (Link, bool)

Link returns the Link Object case and true.

func (LinkOrReference) Reference

func (value LinkOrReference) Reference() (Reference, bool)

Reference returns the Reference Object case and true.

type Method

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

Method is an immutable OpenRPC Method Object.

func NewMethod

func NewMethod(input MethodInput) (Method, error)

NewMethod constructs a Method Object and owns every supplied collection.

func (Method) Deprecated

func (method Method) Deprecated() (bool, bool)

Deprecated returns the declared value and whether it was present.

func (Method) DeprecatedOrDefault

func (method Method) DeprecatedOrDefault() bool

DeprecatedOrDefault returns the effective value, whose default is false.

func (Method) Description

func (method Method) Description() (string, bool)

Description returns the optional rich-text description.

func (Method) Errors

func (method Method) Errors() ([]ErrorOrReference, bool)

Errors returns an owned optional error slice.

func (Method) Examples

func (method Method) Examples() ([]ExamplePairingOrReference, bool)

Examples returns an owned optional example-pairing slice.

func (Method) Extensions

func (fields Method) Extensions() Fields

Extensions returns immutable specification extension fields.

func (Method) ExternalDocs

func (method Method) ExternalDocs() (ExternalDocumentation, bool)

ExternalDocs returns optional external documentation.

func (method Method) Links() ([]LinkOrReference, bool)

Links returns an owned optional link slice.

func (Method) Name

func (method Method) Name() string

Name returns the required canonical method name.

func (Method) ParamStructure

func (method Method) ParamStructure() (ParamStructure, bool)

ParamStructure returns the effective value and whether it was explicit.

func (Method) Params

func (method Method) Params() []ContentDescriptorOrReference

Params returns an owned required parameter slice.

func (Method) Result

func (method Method) Result() (ContentDescriptorOrReference, bool)

Result returns the optional result. Absence makes the method notification only according to the specification.

func (Method) Servers

func (method Method) Servers() ([]Server, bool)

Servers returns an owned optional server slice.

func (Method) Summary

func (method Method) Summary() (string, bool)

Summary returns the optional summary.

func (Method) Tags

func (method Method) Tags() ([]TagOrReference, bool)

Tags returns an owned optional tag slice.

func (Method) UnknownFields

func (fields Method) UnknownFields() Fields

UnknownFields returns immutable fields retained by preserving parse mode.

type MethodInput

type MethodInput struct {
	Name           string
	Description    *string
	Summary        *string
	Servers        []Server
	HasServers     bool
	Tags           []TagOrReference
	HasTags        bool
	Params         []ContentDescriptorOrReference
	ParamStructure *ParamStructure
	Result         *ContentDescriptorOrReference
	Errors         []ErrorOrReference
	HasErrors      bool
	Links          []LinkOrReference
	HasLinks       bool
	Examples       []ExamplePairingOrReference
	HasExamples    bool
	Deprecated     *bool
	ExternalDocs   *ExternalDocumentation
	Extensions     Fields
	UnknownFields  Fields
}

MethodInput supplies Method Object fields. Params must be non-nil; an empty slice represents a method without parameters.

type MethodOrReference

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

MethodOrReference is a Method Object or Reference Object union.

func MethodReference

func MethodReference(value Reference) MethodOrReference

MethodReference constructs the Reference Object union case.

func MethodValue

func MethodValue(value Method) MethodOrReference

MethodValue constructs the Method Object union case.

func (MethodOrReference) Method

func (value MethodOrReference) Method() (Method, bool)

Method returns the Method Object case and true.

func (MethodOrReference) Reference

func (value MethodOrReference) Reference() (Reference, bool)

Reference returns the Reference Object case and true.

type MissingRequiredFieldError

type MissingRequiredFieldError struct {
	Field string
}

MissingRequiredFieldError identifies one absent required field without including document values.

func (*MissingRequiredFieldError) Error

func (err *MissingRequiredFieldError) Error() string

Error implements error.

func (*MissingRequiredFieldError) Unwrap

func (err *MissingRequiredFieldError) Unwrap() error

Unwrap supports errors.Is with ErrMissingRequiredField.

type ParamStructure

type ParamStructure string

ParamStructure is the method parameter assignment structure.

const (
	// ParamStructureByName assigns parameters by Content Descriptor name.
	ParamStructureByName ParamStructure = "by-name"
	// ParamStructureByPosition assigns parameters by array position.
	ParamStructureByPosition ParamStructure = "by-position"
	// ParamStructureEither permits either assignment structure and is default.
	ParamStructureEither ParamStructure = "either"
)

type Reference

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

Reference is an immutable OpenRPC Reference Object.

func NewReference

func NewReference(ref string) (Reference, error)

NewReference constructs a Reference Object.

func (Reference) Ref

func (reference Reference) Ref() string

Ref returns the required reference string.

type Server

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

Server is an immutable OpenRPC Server Object.

func NewServer

func NewServer(input ServerInput) (Server, error)

NewServer constructs a Server Object and owns its variables map.

func (Server) Description

func (server Server) Description() (string, bool)

Description returns the optional rich-text server description.

func (Server) Extensions

func (fields Server) Extensions() Fields

Extensions returns immutable specification extension fields.

func (Server) Name

func (server Server) Name() (string, bool)

Name returns the optional server name.

func (Server) Summary

func (server Server) Summary() (string, bool)

Summary returns the optional short server summary.

func (Server) URL

func (server Server) URL() string

URL returns the required server URL template.

func (Server) UnknownFields

func (fields Server) UnknownFields() Fields

UnknownFields returns immutable fields retained by preserving parse mode.

func (Server) Variables

func (server Server) Variables() (map[string]ServerVariable, bool)

Variables returns an owned map of optional server variables.

type ServerInput

type ServerInput struct {
	URL           string
	Name          *string
	Description   *string
	Summary       *string
	Variables     map[string]ServerVariable
	HasVariables  bool
	Extensions    Fields
	UnknownFields Fields
}

ServerInput supplies Server Object fields.

type ServerVariable

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

ServerVariable is an immutable OpenRPC Server Variable Object.

func NewServerVariable

func NewServerVariable(input ServerVariableInput) (ServerVariable, error)

NewServerVariable constructs a Server Variable Object.

func (ServerVariable) Default

func (variable ServerVariable) Default() string

Default returns the required substitution default.

func (ServerVariable) Description

func (variable ServerVariable) Description() (string, bool)

Description returns the optional rich-text description.

func (ServerVariable) Enum

func (variable ServerVariable) Enum() ([]string, bool)

Enum returns an owned copy of the optional allowed values.

func (ServerVariable) UnknownFields

func (variable ServerVariable) UnknownFields() Fields

UnknownFields returns fields retained by preserving parse mode.

type ServerVariableInput

type ServerVariableInput struct {
	Default       *string
	Description   *string
	Enum          []string
	HasEnum       bool
	UnknownFields Fields
}

ServerVariableInput supplies Server Variable Object fields. Default uses a pointer because the required value may legally be an empty string.

type Tag

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

Tag is an immutable OpenRPC Tag Object.

func NewTag

func NewTag(input TagInput) (Tag, error)

NewTag constructs a Tag Object.

func (Tag) Description

func (tag Tag) Description() (string, bool)

Description returns the optional tag description.

func (Tag) Extensions

func (fields Tag) Extensions() Fields

Extensions returns immutable specification extension fields.

func (Tag) ExternalDocs

func (tag Tag) ExternalDocs() (ExternalDocumentation, bool)

ExternalDocs returns the optional external documentation.

func (Tag) Name

func (tag Tag) Name() string

Name returns the required tag name.

func (Tag) UnknownFields

func (fields Tag) UnknownFields() Fields

UnknownFields returns immutable fields retained by preserving parse mode.

type TagInput

type TagInput struct {
	Name          string
	Description   *string
	ExternalDocs  *ExternalDocumentation
	Extensions    Fields
	UnknownFields Fields
}

TagInput supplies Tag Object fields.

type TagOrReference

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

TagOrReference is a Tag Object or Reference Object union.

func TagReference

func TagReference(value Reference) TagOrReference

TagReference constructs the Reference Object union case.

func TagValue

func TagValue(value Tag) TagOrReference

TagValue constructs the Tag Object union case.

func (TagOrReference) Reference

func (value TagOrReference) Reference() (Reference, bool)

Reference returns the Reference Object case and true.

func (TagOrReference) Tag

func (value TagOrReference) Tag() (Tag, bool)

Tag returns the Tag Object case and true.

type Version

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

Version is a validated OpenRPC specification version.

func ParseVersion

func ParseVersion(value string) (Version, error)

ParseVersion validates that value belongs to an explicitly supported OpenRPC feature line. Patch releases share their major.minor feature set as required by the specification's versioning rules.

func (Version) FeatureSet

func (version Version) FeatureSet() string

FeatureSet returns the major.minor OpenRPC feature line.

func (Version) String

func (version Version) String() string

String returns the exact validated semantic version.

Directories

Path Synopsis
Package builder provides ownership-safe, deterministic OpenRPC construction without making design-first documents depend on reflection or registration.
Package builder provides ownership-safe, deterministic OpenRPC construction without making design-first documents depend on reflection or registration.
Package compose provides explicit, deterministic OpenRPC filtering, merging, and overlay operations.
Package compose provides explicit, deterministic OpenRPC filtering, merging, and overlay operations.
Package diff performs deterministic semantic compatibility comparisons of OpenRPC documents without resolving external resources implicitly.
Package diff performs deterministic semantic compatibility comparisons of OpenRPC documents without resolving external resources implicitly.
Package discovery provides transport-neutral OpenRPC service discovery.
Package discovery provides transport-neutral OpenRPC service discovery.
Package expression parses and evaluates the JSON Template Language used by OpenRPC runtime expressions.
Package expression parses and evaluates the JSON Template Language used by OpenRPC runtime expressions.
internal
specification/cmd/specmatrix command
Command specmatrix regenerates the reviewed conformance inventories from the pinned OpenRPC specification inputs.
Command specmatrix regenerates the reviewed conformance inventories from the pinned OpenRPC specification inputs.
Package jsonrpc adapts transport-neutral OpenRPC discovery to the handler signature used by github.com/faustbrian/golib/pkg/jsonrpc without coupling the core model, parser, or validator to that server implementation.
Package jsonrpc adapts transport-neutral OpenRPC discovery to the handler signature used by github.com/faustbrian/golib/pkg/jsonrpc without coupling the core model, parser, or validator to that server implementation.
Package jsonschema provides lossless JSON Schema Draft 7 values used by OpenRPC.
Package jsonschema provides lossless JSON Schema Draft 7 values used by OpenRPC.
Package jsonvalue preserves arbitrary JSON values without numeric coercion, key reordering, or shared mutable byte storage.
Package jsonvalue preserves arbitrary JSON values without numeric coercion, key reordering, or shared mutable byte storage.
Package observe provides optional, payload-free operation hooks.
Package observe provides optional, payload-free operation hooks.
Package parse provides bounded strict and preserving OpenRPC JSON parsing.
Package parse provides bounded strict and preserving OpenRPC JSON parsing.
Package reference provides JSON Pointer, URI reference, and bounded OpenRPC reference-resolution primitives without implicit I/O.
Package reference provides JSON Pointer, URI reference, and bounded OpenRPC reference-resolution primitives without implicit I/O.
httpstore
Package httpstore provides an optional, SSRF-resistant HTTP document store for the reference resolver.
Package httpstore provides an optional, SSRF-resistant HTTP document store for the reference resolver.
Package validate provides deterministic, resource-bounded OpenRPC document validation with stable machine-readable diagnostics.
Package validate provides deterministic, resource-bounded OpenRPC document validation with stable machine-readable diagnostics.

Jump to

Keyboard shortcuts

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