ir

package
v0.0.0-...-d4700bc Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package ir defines Morphic's spec-agnostic intermediate representation: the single contract between spec compilers and generator emitters.

The shapes in this package are normatively specified in docs/ir-design.md; field names and struct layouts must match that document exactly. All named entities live in flat, ID-keyed registries on Document and reference each other by ID. The whole Document round-trips through JSON deterministically.

This package imports only the standard library. It contains no parsing, no generation, and no I/O. All types are plain data and safe for concurrent reads; nothing in this package mutates package-level state.

Index

Constants

View Source
const IRVersion = "0.1.0"

IRVersion is the semver of the IR schema itself. Compilers stamp it into Document.IRVersion; consumers compare against it to detect schema drift.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdditionalMode

type AdditionalMode string

AdditionalMode describes the openness of a model's property set beyond its declared properties and AdditionalProps (ir-design §4.3).

const (
	// AdditionalUnspecified leaves openness unspecified (open by JSON Schema default).
	AdditionalUnspecified AdditionalMode = ""
	// AdditionalClosed forbids properties beyond the declared set
	// (additionalProperties: false, closed-by-construction records).
	AdditionalClosed AdditionalMode = "closed"
	// AdditionalClosedAfterComposition closes the set once composition is resolved
	// (unevaluatedProperties: false).
	AdditionalClosedAfterComposition AdditionalMode = "closed_after_composition"
)

Additional-property modes.

type AdditionalProps

type AdditionalProps struct {
	// Value is the value schema for catch-all properties.
	Value TypeRef `json:"value"`
	// Key is the key schema; nil = string keys.
	Key *TypeRef `json:"key,omitempty"`
	// Patterns are key-pattern-scoped value schemas (JSON Schema patternProperties).
	Patterns []PatternProps `json:"patterns,omitempty"`
}

AdditionalProps describes a model's map-like catch-all for undeclared properties (ir-design §4.3).

type Any

type Any struct {
	TypeCommon
}

Any is a schemaless type (ir-design §4.6).

func (*Any) Common

func (a *Any) Common() *TypeCommon

Common returns the shared TypeCommon of an Any.

func (*Any) Kind

func (*Any) Kind() TypeKind

Kind reports the TypeKind of an Any.

func (*Any) MarshalJSON

func (a *Any) MarshalJSON() ([]byte, error)

MarshalJSON encodes the Any with an adjacent "kind" tag.

type AuthID

type AuthID string

AuthID identifies an AuthScheme in Document.Auth.

type AuthKind

type AuthKind string

AuthKind names one authentication mechanism (ir-design §9). X509 is distinct from mutual_tls (certificate as credential vs mutual verification); compilers must not conflate them.

const (
	// AuthKindAPIKey is an API key in a header, query, cookie, or transport slot.
	AuthKindAPIKey AuthKind = "apiKey"
	// AuthKindHTTPBasic is HTTP Basic authentication.
	AuthKindHTTPBasic AuthKind = "http_basic"
	// AuthKindHTTPBearer is HTTP Bearer-token authentication.
	AuthKindHTTPBearer AuthKind = "http_bearer"
	// AuthKindOAuth2 is OAuth 2.0 with one or more flows.
	AuthKindOAuth2 AuthKind = "oauth2"
	// AuthKindOpenIDConnect is OpenID Connect discovery.
	AuthKindOpenIDConnect AuthKind = "openid_connect"
	// AuthKindMutualTLS is mutual TLS verification.
	AuthKindMutualTLS AuthKind = "mutual_tls"
	// AuthKindUserPassword is a transport user/password credential.
	AuthKindUserPassword AuthKind = "user_password"
	// AuthKindX509 is an X.509 certificate used as a credential.
	AuthKindX509 AuthKind = "x509"
	// AuthKindSymmetricEncryption is symmetric-key encryption.
	AuthKindSymmetricEncryption AuthKind = "symmetric_encryption"
	// AuthKindAsymmetricEncryption is asymmetric-key encryption.
	AuthKindAsymmetricEncryption AuthKind = "asymmetric_encryption"
	// AuthKindSASLPlain is SASL PLAIN.
	AuthKindSASLPlain AuthKind = "sasl_plain"
	// AuthKindSASLSCRAMSHA256 is SASL SCRAM-SHA-256.
	AuthKindSASLSCRAMSHA256 AuthKind = "sasl_scram_sha256"
	// AuthKindSASLSCRAMSHA512 is SASL SCRAM-SHA-512.
	AuthKindSASLSCRAMSHA512 AuthKind = "sasl_scram_sha512"
	// AuthKindSASLGSSAPI is SASL GSSAPI (Kerberos).
	AuthKindSASLGSSAPI AuthKind = "sasl_gssapi"
	// AuthKindCustom is a custom/unmodeled scheme.
	AuthKindCustom AuthKind = "custom"
)

Authentication mechanisms.

type AuthRequirement

type AuthRequirement struct {
	// Schemes must all be satisfied together to fulfill this option.
	Schemes []SchemeUse `json:"schemes,omitempty"`
}

AuthRequirement is one authentication option: all its SchemeUses must be satisfied together (ir-design §9). A slice of AuthRequirement is an OR across options in priority order; an empty option means "no auth is one acceptable choice".

type AuthScheme

type AuthScheme struct {
	// ID is the scheme's stable synthetic identity.
	ID AuthID `json:"id,omitempty"`
	// Name is the scheme's naming.
	Name Naming `json:"name"`
	// Kind is the authentication mechanism.
	Kind AuthKind `json:"kind,omitempty"`
	// Docs is the scheme's documentation.
	Docs Docs `json:"docs"`
	// Deprecation marks the scheme as deprecated.
	Deprecation *Deprecation `json:"deprecation,omitempty"`
	// In is the apiKey location: header | query | cookie | user | password.
	In string `json:"in,omitempty"`
	// KeyName is the apiKey name.
	KeyName string `json:"keyName,omitempty"`
	// Scheme is the HTTP scheme (bearer, basic, digest…); also legal for apiKey
	// (Smithy @httpApiKeyAuth scheme).
	Scheme string `json:"scheme,omitempty"`
	// BearerFormat is the bearer-token format hint.
	BearerFormat string `json:"bearerFormat,omitempty"`
	// Flows are the OAuth2 flows; device flow's deviceAuthorizationUrl rides
	// OAuthFlow.AuthorizationURL.
	Flows []OAuthFlow `json:"flows,omitempty"`
	// OAuth2MetadataURL is the RFC 8414 authorization-server metadata URL
	// (OpenAPI 3.2).
	OAuth2MetadataURL string `json:"oauth2MetadataURL,omitempty"`
	// OpenIDConnectURL is the OpenID Connect discovery URL.
	OpenIDConnectURL string `json:"openIDConnectURL,omitempty"`
	// Extensions carries source metadata without a first-class IR node.
	Extensions Extensions `json:"extensions,omitempty"`
	// Provenance records where the scheme came from.
	Provenance Provenance `json:"provenance"`
}

AuthScheme is a named authentication scheme in Document.Auth (ir-design §9).

type Availability

type Availability struct {
	// Added lists the version labels at which the entity was added, ordered;
	// multiple entries with Removed support add/remove/re-add cycles.
	Added []string `json:"added,omitempty"`
	// Removed lists the version labels at which the entity was removed.
	Removed []string `json:"removed,omitempty"`
	// Deprecated is the version at which the entity was deprecated.
	Deprecated string `json:"deprecated,omitempty"`
	// RenamedFrom records prior names by version.
	RenamedFrom []VersionedName `json:"renamedFrom,omitempty"`
	// TypeChangedFrom records prior property/return types by version (TypeSpec
	// @typeChangedFrom).
	TypeChangedFrom []VersionedType `json:"typeChangedFrom,omitempty"`
	// RequiredChanged records optionality flips by version (TypeSpec
	// @madeOptional/@madeRequired); the slice pass reconstructs Required for older
	// snapshots from it.
	RequiredChanged []VersionedBool `json:"requiredChanged,omitempty"`
}

Availability stores the versioning timeline of an entity (ir-design §11). The IR stores the timeline (TypeSpec model); the version-slice pass produces a concrete snapshot document per version. Formats without versioning leave this nil.

type BigVal

type BigVal string

BigVal is an arbitrary-precision numeric value carried as its decimal string form. The IR never stores float64 (the TypeSpec Numeric lesson); helpers may convert through math/big at the boundary.

A BigVal is always a JSON-valid numeric literal: NewBigVal canonicalizes source spellings that are numerically valid but not valid JSON (a leading dot as in ".5", a trailing dot as in "5.", a leading "+") into their JSON form without touching a single significant digit, so every stored value round-trips through JSON unchanged. Digits, exponent form, and case are preserved exactly; only the non-JSON affixes are rewritten.

func NewBigVal

func NewBigVal(s string) (BigVal, error)

NewBigVal validates s as a decimal or scientific-notation numeric literal and returns it in canonical JSON form. It rejects the empty string, hex, NaN, and infinities. It never rounds or reformats the significant digits: an out-of-float64-range magnitude, a high-precision decimal, and an exponential literal are all preserved verbatim (only JSON-invalid affixes are normalized).

func (BigVal) String

func (v BigVal) String() string

String returns the literal decimal form.

type Callback

type Callback struct {
	// Expression is the runtime expression that resolves the callback URL.
	Expression string `json:"expression,omitempty"`
	// Operations are the callback operations keyed by that expression.
	Operations []OpID `json:"operations,omitempty"`
}

Callback is an out-of-band operation set keyed by a runtime expression (ir-design §8.1).

type Channel

type Channel struct {
	// ID is the channel's stable synthetic identity.
	ID ChannelID `json:"id,omitempty"`
	// Name is the channel's naming.
	Name Naming `json:"name"`
	// Address is the topic/routing key/path, may contain {params}; nil =
	// unknown/runtime-assigned address (reply channels and dynamic topics; SDKs
	// expose a runtime address arg).
	Address *string `json:"address,omitempty"`
	// Docs is the channel's documentation.
	Docs Docs `json:"docs"`
	// Tags are the channel's tag memberships.
	Tags []string `json:"tags,omitempty"`
	// Params are the channel's address parameters.
	Params []Parameter `json:"params,omitempty"`
	// Messages is the channel's message set; messages live in Document.Messages.
	Messages []MessageID `json:"messages,omitempty"`
	// Servers indexes into Document.Servers scoped to this channel.
	Servers []int `json:"servers,omitempty"`
	// Bindings holds protocol-specific config ("kafka", "amqp", "ws", "mqtt")
	// kept as namespaced raw config.
	Bindings map[string]Extensions `json:"bindings,omitempty"`
	// Extensions carries source metadata without a first-class IR node.
	Extensions Extensions `json:"extensions,omitempty"`
	// Provenance records where the channel came from.
	Provenance Provenance `json:"provenance"`
}

Channel is an event/messaging endpoint: an AsyncAPI channel, a webhook, a subscription, or an OTP process (ir-design §8.3). Its messages live in Document.Messages and are referenced here by identity.

type ChannelID

type ChannelID string

ChannelID identifies a Channel in Document.Channels.

type Constraints

type Constraints struct {
	// Min is the inclusive (or exclusive, per ExclusiveMin) lower numeric bound.
	Min *BigVal `json:"min,omitempty"`
	// Max is the inclusive (or exclusive, per ExclusiveMax) upper numeric bound.
	Max *BigVal `json:"max,omitempty"`
	// ExclusiveMin makes Min an exclusive bound.
	ExclusiveMin bool `json:"exclusiveMin"`
	// ExclusiveMax makes Max an exclusive bound.
	ExclusiveMax bool `json:"exclusiveMax"`
	// MultipleOf constrains the value to a multiple of this number.
	MultipleOf *BigVal `json:"multipleOf,omitempty"`
	// Precision bounds the total decimal digits (Avro decimal, XSD totalDigits,
	// OData Edm.Decimal).
	Precision *int64 `json:"precision,omitempty"`
	// Scale bounds the fractional decimal digits (XSD fractionDigits).
	Scale *int64 `json:"scale,omitempty"`
	// MinLength is the minimum string/bytes length.
	MinLength *int64 `json:"minLength,omitempty"`
	// MaxLength is the maximum string/bytes length.
	MaxLength *int64 `json:"maxLength,omitempty"`
	// Pattern is an ECMA-262 regex as written; emitters translate or drop it with
	// a diagnostic.
	Pattern string `json:"pattern,omitempty"`
	// PatternMessage is a human-readable validation message (TypeSpec @pattern's
	// second argument).
	PatternMessage string `json:"patternMessage,omitempty"`
	// MinItems is the minimum collection length.
	MinItems *int64 `json:"minItems,omitempty"`
	// MaxItems is the maximum collection length.
	MaxItems *int64 `json:"maxItems,omitempty"`
	// UniqueItems requires distinct collection elements.
	UniqueItems bool `json:"uniqueItems"`
	// MinProps is the minimum number of properties.
	MinProps *int64 `json:"minProps,omitempty"`
	// MaxProps is the maximum number of properties.
	MaxProps *int64 `json:"maxProps,omitempty"`
}

Constraints restricts the admissible values of a scalar, list, string, or numeric type (ir-design §5.3). Numeric bounds are arbitrary-precision decimal strings, never float64.

type Contact

type Contact struct {
	// Name is the contact name.
	Name string `json:"name,omitempty"`
	// URL is the contact URL.
	URL string `json:"url,omitempty"`
	// Email is the contact email address.
	Email string `json:"email,omitempty"`
}

Contact is the API contact information (OpenAPI/AsyncAPI info.contact).

type Content

type Content struct {
	// MediaType is "application/json", "multipart/form-data", or "" for non-HTTP.
	MediaType string `json:"mediaType,omitempty"`
	// SchemaFormat is the schema language the type graph was lowered from, in
	// media-type form (AsyncAPI multiFormatSchema: Avro/Protobuf/RAML/…);
	// "" = source-native. The verbatim source schema is preserved in Extensions.
	SchemaFormat string `json:"schemaFormat,omitempty"`
	// Type is the content's type.
	Type TypeRef `json:"type"`
	// Item is the element shape of a sequential stream declared per media type
	// (OpenAPI 3.2 itemSchema for SSE/JSONL/json-seq); nil = not sequential.
	Item *TypeRef `json:"item,omitempty"`
	// ItemEncoding holds per-item encoding for sequential media types
	// (3.2 itemEncoding).
	ItemEncoding map[string]PartEncoding `json:"itemEncoding,omitempty"`
	// Encoding holds multipart/form per-property (part) wire config, keyed by
	// PropID.
	Encoding map[string]PartEncoding `json:"encoding,omitempty"`
	// File marks the body as a file upload/download (TypeSpec file bodies, binary
	// payloads).
	File *FileInfo `json:"file,omitempty"`
	// Examples are content-level example values.
	Examples []Example `json:"examples,omitempty"`
	// Extensions carries source metadata without a first-class IR node.
	Extensions Extensions `json:"extensions,omitempty"`
}

Content is one media-type view of a Payload (ir-design §7.2).

type CtorValue

type CtorValue struct {
	// Scalar identifies the scalar whose constructor is invoked.
	Scalar TypeID `json:"scalar,omitempty"`
	// Name is the constructor name ("fromISO", "now", custom inits).
	Name string `json:"name,omitempty"`
	// Args are the constructor arguments in source order; a present-but-empty
	// argument list round-trips as [] rather than nil, so it carries no omitempty.
	Args []Value `json:"args"`
}

CtorValue captures a value built by a named scalar constructor, such as utcDateTime.now() or plainDate.fromISO("2024-05-06"). Such values are inherently non-literal, so compilers must not fold them (ir-design §6).

type Deprecation

type Deprecation struct {
	// Message explains the deprecation and any migration path.
	Message string `json:"message,omitempty"`
	// Since is the version in which the entity was deprecated.
	Since string `json:"since,omitempty"`
	// RemovalVersion is the version in which the entity is scheduled for removal.
	RemovalVersion string `json:"removalVersion,omitempty"`
}

Deprecation marks an entity as deprecated with optional migration guidance.

type Diagnostic

type Diagnostic struct {
	Severity   Severity   `json:"severity"`
	Code       string     `json:"code"`
	Message    string     `json:"message"`
	Provenance Provenance `json:"provenance"`
}

Diagnostic is a typed report from a compiler or pass. Codes are stable strings ("openapi/unresolved-ref", "ir/dangling-type-ref") so CI can allowlist them.

func NewDiagnostic

func NewDiagnostic(sev Severity, code, message string, prov Provenance) Diagnostic

NewDiagnostic builds a Diagnostic, coercing message to well-formed UTF-8 so the enclosing Document round-trips through JSON byte-for-byte (invariant #7). A third-party validator can render a truncated multibyte rune into its error text; stored verbatim, that ill-formed byte run would reach Document diagnostics, and json.Marshal rewrites invalid UTF-8 to U+FFFD — so the document would no longer re-encode to identical bytes. Coercing at construction keeps every message idempotent under marshal/unmarshal.

Compilers and passes build diagnostics through this constructor; irverify's ir/diagnostic-invalid-utf8 check flags any message that still reaches a Document ill-formed. strings.ToValidUTF8 returns message unchanged, without allocating, when it is already valid, so the common path costs one scan.

type Discriminator

type Discriminator struct {
	// Property is the property carrying the tag in model hierarchies.
	Property PropID `json:"property,omitempty"`
	// PropertyName is the wire name of the tag property in unions, where the
	// property exists on no single model (TypeSpec @discriminated
	// discriminatorPropertyName, OpenAPI discriminator on oneOf).
	PropertyName string `json:"propertyName,omitempty"`
	// Index is the 0-based tuple element carrying the tag Literal (Erlang tagged
	// tuples, JSON arrays with a const head via prefixItems).
	Index *int `json:"index,omitempty"`
	// Mapping maps wire value to subtype; nil = infer by type name.
	Mapping map[string]TypeID `json:"mapping,omitempty"`
	// Default is the variant to use when the tag is absent/unrecognized (OpenAPI
	// 3.2 defaultMapping); zero = none.
	Default TypeID `json:"default,omitempty"`
	// Envelope is "" for an inline tag or "object" for a {kind, value} wrapper
	// (TypeSpec @discriminated envelope).
	Envelope string `json:"envelope,omitempty"`
	// EnvelopeValueName is the wire name of the envelope's value property (default
	// "value"); meaningful only when Envelope == "object".
	EnvelopeValueName string `json:"envelopeValueName,omitempty"`
	// Inferred marks a discriminator discovered heuristically, not declared.
	Inferred bool `json:"inferred"`
}

Discriminator locates and maps the tag that selects a variant in a polymorphic model hierarchy or union (ir-design §4.3). Exactly one of Property, PropertyName, or Index locates the tag.

type Docs

type Docs struct {
	// Summary is a short single-line description.
	Summary string `json:"summary,omitempty"`
	// Description is CommonMark; it may contain {t:TypeID} cross-reference
	// tokens that emitters resolve to language-appropriate links.
	Description string `json:"description,omitempty"`
	// ExternalDocs links to supplementary documentation.
	ExternalDocs []Link `json:"externalDocs,omitempty"`
}

Docs is the human-readable documentation attached to a named entity (ir-design §12).

type Document

type Document struct {
	// IRVersion is the version of the IR schema itself (semver).
	IRVersion string `json:"irVersion,omitempty"`
	// Name is the API title.
	Name string `json:"name,omitempty"`
	// Version is the source-declared API version string.
	Version string `json:"version,omitempty"`
	// Docs is the document-level documentation.
	Docs Docs `json:"docs"`
	// Contact is the API contact (OpenAPI/AsyncAPI info.contact).
	Contact *Contact `json:"contact,omitempty"`
	// License is the API license (OpenAPI/AsyncAPI info.license).
	License *License `json:"license,omitempty"`
	// TermsOfService is the terms-of-service URL or text.
	TermsOfService string `json:"termsOfService,omitempty"`
	// Services holds one or more services; multi-service documents are normal
	// (TypeSpec, stitching).
	Services []Service `json:"services,omitempty"`
	// Types is the type registry — the only owner of TypeDefs.
	Types TypeRegistry `json:"types,omitempty"`
	// Channels is the event/messaging layer (AsyncAPI, webhooks, subscriptions,
	// OTP processes).
	Channels map[ChannelID]Channel `json:"channels,omitempty"`
	// Messages is the message registry; messages are reused across channels and
	// referenced by identity from operations and replies (AsyncAPI 3).
	Messages map[MessageID]Message `json:"messages,omitempty"`
	// Auth is the auth scheme registry.
	Auth map[AuthID]AuthScheme `json:"auth,omitempty"`
	// Servers holds the endpoint templates.
	Servers []Server `json:"servers,omitempty"`
	// TagDefs is the tag metadata registry; tag membership stays []string on the
	// tagged nodes.
	TagDefs []TagDef `json:"tagDefs,omitempty"`
	// Versions holds the ordered version labels when availability metadata is used.
	Versions []string `json:"versions,omitempty"`
	// Extensions carries source metadata without a first-class IR node.
	Extensions Extensions `json:"extensions,omitempty"`
	// Diagnostics is accumulated by the compiler and passes; not part of API
	// meaning.
	Diagnostics []Diagnostic `json:"diagnostics,omitempty"`
	// Sources describes the input files: format, path, content hash.
	Sources []SourceInfo `json:"sources,omitempty"`
}

Document is the root of a Morphic IR document (ir-design §2). It is self-contained: no node references anything outside it.

type Encoding

type Encoding struct {
	// Name is the encoding scheme ("rfc3339", "base64", "zigzag", "packed",
	// "delimited", format strings, ...).
	Name string `json:"name,omitempty"`
	// WireType is the on-wire primitive when it differs from the logical type
	// (utcDateTime encoded as int32; bytes as base64 string).
	WireType *TypeRef `json:"wireType,omitempty"`
	// MediaType is the content media type of the value itself (Smithy @mediaType,
	// JSON Schema contentMediaType); "" = none.
	MediaType string `json:"mediaType,omitempty"`
}

Encoding is the logical-type / encoding-name / wire-type triple that reifies TypeSpec @encode and absorbs OpenAPI format and Protobuf wire variants (ir-design §5.3). Property encoding overrides scalar encoding.

type Enum

type Enum struct {
	TypeCommon
	// ValueType is the primitive type of the members' values.
	ValueType PrimKind `json:"valueType"`
	// Members are the enum's members, in source order.
	Members []EnumMember `json:"members,omitempty"`
	// Closed is false for open/extensible enums: unknown values must be
	// representable.
	Closed bool `json:"closed"`
	// Flags marks bitfield semantics.
	Flags bool `json:"flags"`
	// FallbackMember is the wire name of the member to substitute for an unknown
	// value (Avro enum default symbol); "" = none.
	FallbackMember string `json:"fallbackMember,omitempty"`
}

Enum is a closed or open set of named values (ir-design §4.5).

func (*Enum) Common

func (e *Enum) Common() *TypeCommon

Common returns the shared TypeCommon of an Enum.

func (*Enum) Kind

func (*Enum) Kind() TypeKind

Kind reports the TypeKind of an Enum.

func (*Enum) MarshalJSON

func (e *Enum) MarshalJSON() ([]byte, error)

MarshalJSON encodes the Enum with an adjacent "kind" tag.

type EnumMember

type EnumMember struct {
	// Name is the member's naming.
	Name Naming `json:"name"`
	// Value is the member's typed value, matching Enum.ValueType.
	Value Value `json:"value"`
	// WireName is the serialized form when it differs from Value (rare).
	WireName string `json:"wireName,omitempty"`
	// Docs is the member's documentation.
	Docs Docs `json:"docs"`
	// Deprecation marks the member as deprecated.
	Deprecation *Deprecation `json:"deprecation,omitempty"`
	// Availability records the member's versioning timeline (TypeSpec @added on
	// EnumMember).
	Availability *Availability `json:"availability,omitempty"`
	// Examples are typed example values for the member.
	Examples []Example `json:"examples,omitempty"`
	// Extensions carries source metadata without a first-class IR node.
	Extensions Extensions `json:"extensions,omitempty"`
}

EnumMember is one member of an Enum (ir-design §4.5).

type ErrorCase

type ErrorCase struct {
	// Type is an error-flagged model.
	Type TypeRef `json:"type"`
	// Conditions are the status codes/ranges this error maps to.
	Conditions ResponseConditions `json:"conditions"`
	// Fault is "" | "client" | "server" — protocol-neutral fault classification
	// (Smithy @error; OpenAPI 4XX/5XX is its HTTP lowering). Drives exception
	// hierarchies and default status synthesis.
	Fault string `json:"fault,omitempty"`
	// Retryable reports whether the error is retryable (Smithy @retryable);
	// nil = unknown.
	Retryable *bool `json:"retryable,omitempty"`
	// Throttling reports that the error is retryable specifically due to
	// throttling — a distinct backoff class (Smithy @retryable(throttling: true));
	// nil = unknown.
	Throttling *bool `json:"throttling,omitempty"`
	// Docs is the error case's documentation.
	Docs Docs `json:"docs"`
	// Extensions carries source metadata without a first-class IR node.
	Extensions Extensions `json:"extensions,omitempty"`
}

ErrorCase is a declared failure shape of an Operation (ir-design §7.2).

type ErrorExample

type ErrorExample struct {
	// Type is the error type produced by the scenario.
	Type TypeRef `json:"type"`
	// Content is the error value.
	Content Value `json:"content"`
}

ErrorExample is the error arm of an operation-scenario Example.

type EventInfo

type EventInfo struct {
	// ContentType is the per-event content type (TypeSpec @Events.contentType).
	ContentType string `json:"contentType,omitempty"`
	// Terminal reports that receiving this event ends the stream (TypeSpec
	// @SSE.terminalEvent).
	Terminal bool `json:"terminal"`
}

EventInfo carries per-event metadata when a union is an event stream's event set (ir-design §4.4).

type Example

type Example struct {
	// Name identifies the example.
	Name string `json:"name,omitempty"`
	// Summary is a short description of the example.
	Summary string `json:"summary,omitempty"`
	// Description is a long-form description of the example.
	Description string `json:"description,omitempty"`
	// Value is a single-value example (schemas, properties, parameters); for
	// message examples it is the payload.
	Value *Value `json:"value,omitempty"`
	// Headers holds the correlated header values for message examples (AsyncAPI
	// message examples are header+payload pairs — never split them).
	Headers *Value `json:"headers,omitempty"`
	// Input is the operation-scenario input, paired with Output or Error.
	Input *Value `json:"input,omitempty"`
	// Output is the operation-scenario success result paired with Input.
	Output *Value `json:"output,omitempty"`
	// Error ends the scenario in this error instead of Output.
	Error *ErrorExample `json:"error,omitempty"`
	// ExternalURL points to an externally hosted example.
	ExternalURL string `json:"externalURL,omitempty"`
	// Extensions carries source metadata without a first-class IR node.
	Extensions Extensions `json:"extensions,omitempty"`
}

Example is a documentation example. Field legality is contextual (validated): Value/Headers apply to types, properties, parameters, contents, and messages; Input/Output/Error apply to operations. An Example never mixes the two arms.

type Extensions

type Extensions map[string]RawValue

Extensions is the lossless escape hatch: source metadata without a first-class IR node survives here, keys namespaced by origin so two formats' extensions never collide: "openapi:x-rate-limit", "smithy:aws.api#arn", "graphql:@key", "erlang:opaque" (ir-design §12).

type External

type External struct {
	TypeCommon
	// Identity is the external type's stable identity (e.g. "erlang:pid").
	Identity string `json:"identity"`
	// Package is the providing package.
	Package string `json:"package,omitempty"`
	// MinVersion is the minimum package version.
	MinVersion string `json:"minVersion,omitempty"`
}

External is a well-known library type that no target can structurally model, resolved to a runtime handle by the emitter (TCGC external) (ir-design §4.6).

func (*External) Common

func (e *External) Common() *TypeCommon

Common returns the shared TypeCommon of an External.

func (*External) Kind

func (*External) Kind() TypeKind

Kind reports the TypeKind of an External.

func (*External) MarshalJSON

func (e *External) MarshalJSON() ([]byte, error)

MarshalJSON encodes the External with an adjacent "kind" tag.

type Field

type Field struct {
	// Name is the member name.
	Name string `json:"name,omitempty"`
	// Value is the member value.
	Value Value `json:"value"`
}

Field is one named member of a ValueObject, in source order.

type FileInfo

type FileInfo struct {
	// IsText reports textual vs binary contents.
	IsText bool `json:"isText"`
	// Contents is the declared contents scalar chain (string/bytes extensions);
	// nil = bytes.
	Contents *TypeRef `json:"contents,omitempty"`
	// ContentTypes is the declared allowed content-type set (TypeSpec
	// File<"image/png" | "image/jpeg">); runtime Content-Type comes from the file
	// value.
	ContentTypes []string `json:"contentTypes,omitempty"`
	// ContentTypeDefault is the default used when the file value carries none.
	ContentTypeDefault string `json:"contentTypeDefault,omitempty"`
	// FilenameLocation is "content-disposition" (default) | "path" | "header".
	FilenameLocation string `json:"filenameLocation,omitempty"`
	// FilenameWireName is the wire name when FilenameLocation is path/header.
	FilenameWireName string `json:"filenameWireName,omitempty"`
}

FileInfo describes a file-upload/download body (ir-design §7.2).

type GraphQLBinding

type GraphQLBinding struct {
	// Kind is "query" | "mutation" | "subscription".
	Kind string `json:"kind,omitempty"`
	// FieldPath is the entry-point field (nesting for namespaced schemas).
	FieldPath []string `json:"fieldPath,omitempty"`
	// Extensions carries source metadata without a first-class IR node.
	Extensions Extensions `json:"extensions,omitempty"`
}

GraphQLBinding maps an Operation onto a GraphQL entry point (ir-design §8.4).

type HTTPBinding

type HTTPBinding struct {
	// Method is the method as sent on the wire (OpenAPI 3.2 additionalOperations
	// keys carry exact capitalization; QUERY and custom methods are legal).
	Method string `json:"method,omitempty"`
	// URITemplate is the RFC 6570 path template — the one true path
	// representation.
	URITemplate string `json:"uriTemplate,omitempty"`
	// HostPrefix is the endpoint host prefix, may contain {param} labels
	// (Smithy @endpoint).
	HostPrefix string `json:"hostPrefix,omitempty"`
	// SharedRoute reports that multiple operations legally share method+path,
	// disambiguated by request content (TypeSpec @sharedRoute); validate must not
	// reject the duplicate, and single-route emitters must merge.
	SharedRoute bool `json:"sharedRoute"`
	// ParamBindings assigns each logical parameter its HTTP location.
	ParamBindings []HTTPParamBinding `json:"paramBindings,omitempty"`
	// RequestContentTypes are the priority-ordered request media types.
	RequestContentTypes []string `json:"requestContentTypes,omitempty"`
	// ResponseBodyPath sets the HTTP response body to this sub-field of the
	// response type (gRPC transcoding response_body); nil = the whole payload.
	ResponseBodyPath *PropPath `json:"responseBodyPath,omitempty"`
	// SuccessStatus maps response index to primary status (denormalized
	// convenience; conditions are the truth).
	SuccessStatus map[int]int `json:"successStatus,omitempty"`
	// Compression requires the client to compress the request body
	// (Smithy @requestCompression).
	Compression *RequestCompression `json:"compression,omitempty"`
	// ChecksumRequired requires the client to send a payload checksum
	// (Smithy @httpChecksumRequired).
	ChecksumRequired bool `json:"checksumRequired"`
	// PatchImplicitOptionality controls PATCH implicit optionality: nil = protocol
	// default (PATCH projections make properties optional); false = disabled
	// (TypeSpec @patch implicitOptionality).
	PatchImplicitOptionality *bool `json:"patchImplicitOptionality,omitempty"`
	// IsWebhook marks an inbound webhook operation (OpenAPI 3.1 webhooks).
	IsWebhook bool `json:"isWebhook"`
	// Callbacks are out-of-band operations keyed by runtime expressions.
	Callbacks []Callback `json:"callbacks,omitempty"`
	// Extensions carries source metadata without a first-class IR node.
	Extensions Extensions `json:"extensions,omitempty"`
}

HTTPBinding maps an Operation onto one HTTP method+path (ir-design §8.1).

type HTTPLocation

type HTTPLocation string

HTTPLocation is where an HTTP parameter binds on the wire (ir-design §8.1).

const (
	// HTTPLocationPath binds to a path template segment.
	HTTPLocationPath HTTPLocation = "path"
	// HTTPLocationQuery binds to a single query parameter.
	HTTPLocationQuery HTTPLocation = "query"
	// HTTPLocationQuerystring binds the whole query string serialized from one
	// schema (OpenAPI 3.2 in: querystring, combined with ContentType).
	HTTPLocationQuerystring HTTPLocation = "querystring"
	// HTTPLocationHeader binds to a request header.
	HTTPLocationHeader HTTPLocation = "header"
	// HTTPLocationCookie binds to a cookie.
	HTTPLocationCookie HTTPLocation = "cookie"
	// HTTPLocationBody binds the whole request body.
	HTTPLocationBody HTTPLocation = "body"
	// HTTPLocationBodyProperty binds to a property within the body model.
	HTTPLocationBodyProperty HTTPLocation = "body_property"
	// HTTPLocationHost binds to a host-prefix label (Smithy @hostLabel).
	HTTPLocationHost HTTPLocation = "host"
)

HTTP parameter locations.

type HTTPParamBinding

type HTTPParamBinding struct {
	// Param is the Operation.Params name it binds.
	Param string `json:"param,omitempty"`
	// ParamPath is the nested source field within the logical param, when the
	// binding targets a sub-field of a message-typed param (gRPC transcoding
	// {book.name}, dotted query params); empty = the whole param.
	ParamPath []PropID `json:"paramPath,omitempty"`
	// Location is where the parameter binds on the wire. host = the param fills a
	// HostPrefix label (Smithy @hostLabel); querystring = the whole query string
	// serialized from one schema (OpenAPI 3.2 in: querystring, with ContentType).
	Location HTTPLocation `json:"location,omitempty"`
	// WireName is the serialized parameter name.
	WireName string `json:"wireName,omitempty"`
	// Style is the serialization style: simple | form | label | matrix |
	// deepObject | pipe/space-delimited.
	Style string `json:"style,omitempty"`
	// Explode overrides the default explode behavior; nil = default.
	Explode *bool `json:"explode,omitempty"`
	// AllowReserved permits reserved characters unescaped in the value.
	AllowReserved bool `json:"allowReserved"`
	// PathPattern is a multi-segment path pattern constraint for this param
	// (gRPC transcoding {name=shelves/*/books/*}); "" = single segment. The URI
	// template uses reserved expansion; emitters that cannot validate the pattern
	// drop it with a diagnostic.
	PathPattern string `json:"pathPattern,omitempty"`
	// Prefix spreads a map-typed param as prefixed wire entries: prefixed headers
	// (Smithy @httpPrefixHeaders) or catch-all query maps (@httpQueryParams with
	// Prefix "").
	Prefix string `json:"prefix,omitempty"`
	// ContentType serializes the param as a media type (OpenAPI content-style
	// params).
	ContentType string `json:"contentType,omitempty"`
	// BodyPath is, for body_property, where in the body model it lands
	// (TypeSpec HttpProperty).
	BodyPath []PropID `json:"bodyPath,omitempty"`
}

HTTPParamBinding assigns one logical parameter its HTTP wire location (ir-design §8.1).

type Idempotency

type Idempotency struct {
	// Kind is the idempotency class.
	Kind IdempotencyKind `json:"kind,omitempty"`
	// TokenParam names the idempotency-token parameter; set only when Kind is
	// IdempotencyToken.
	TokenParam string `json:"tokenParam,omitempty"`
}

Idempotency is the resolved idempotency classification of an Operation. It reifies the spec's shorthand states unknown | safe | idempotent | idempotency_token(param); TokenParam is set only for the token kind (ir-design §7.2).

type IdempotencyKind

type IdempotencyKind string

IdempotencyKind names the idempotency class of an Operation (ir-design §7.2).

const (
	// IdempotencyUnknown means idempotency is undeclared.
	IdempotencyUnknown IdempotencyKind = ""
	// IdempotencySafe means the operation has no side effects (Smithy @readonly,
	// HTTP GET semantics).
	IdempotencySafe IdempotencyKind = "safe"
	// IdempotencyIdempotent means repeating the call has the same effect as one
	// call.
	IdempotencyIdempotent IdempotencyKind = "idempotent"
	// IdempotencyToken means idempotency is achieved via a client-supplied token
	// parameter named by Idempotency.TokenParam.
	IdempotencyToken IdempotencyKind = "idempotency_token"
)

Idempotency kinds.

type License

type License struct {
	// Name is the license name.
	Name string `json:"name,omitempty"`
	// Identifier is the SPDX license identifier.
	Identifier string `json:"identifier,omitempty"`
	// URL is the license URL.
	URL string `json:"url,omitempty"`
}

License is the API license information (OpenAPI/AsyncAPI info.license).

type Lifecycle

type Lifecycle = string

Lifecycle names a visibility lifecycle class. It is an OPEN set; canonical values are "create", "read", "update", "delete", and "query". TypeSpec custom visibility classes lower as "<class>:<member>" strings so nothing is dropped (ir-design §5.2).

const (
	// LifecycleCreate is the create lifecycle.
	LifecycleCreate Lifecycle = "create"
	// LifecycleRead is the read lifecycle.
	LifecycleRead Lifecycle = "read"
	// LifecycleUpdate is the update lifecycle.
	LifecycleUpdate Lifecycle = "update"
	// LifecycleDelete is the delete lifecycle.
	LifecycleDelete Lifecycle = "delete"
	// LifecycleQuery is the query lifecycle.
	LifecycleQuery Lifecycle = "query"
)

Canonical lifecycle values.

type Link struct {
	// URL is the link target.
	URL string `json:"url,omitempty"`
	// Description labels the link.
	Description string `json:"description,omitempty"`
}

Link is an external documentation reference.

type List

type List struct {
	TypeCommon
	// Elem is the element type.
	Elem TypeRef `json:"elem"`
	// Constraints restricts minItems/maxItems/uniqueItems.
	Constraints *Constraints `json:"constraints,omitempty"`
	// Encoding is the container-level wire encoding (protobuf packed vs expanded
	// repeated fields); it stacks with the element's own encoding.
	Encoding *Encoding `json:"encoding,omitempty"`
}

List is an ordered collection (ir-design §4.6).

func (*List) Common

func (l *List) Common() *TypeCommon

Common returns the shared TypeCommon of a List.

func (*List) Kind

func (*List) Kind() TypeKind

Kind reports the TypeKind of a List.

func (*List) MarshalJSON

func (l *List) MarshalJSON() ([]byte, error)

MarshalJSON encodes the List with an adjacent "kind" tag.

type Literal

type Literal struct {
	TypeCommon
	// Value is the constant value.
	Value Value `json:"value"`
}

Literal is a single constant value used as a type (const, single-value enum, discriminator pin) (ir-design §4.6).

func (*Literal) Common

func (l *Literal) Common() *TypeCommon

Common returns the shared TypeCommon of a Literal.

func (*Literal) Kind

func (*Literal) Kind() TypeKind

Kind reports the TypeKind of a Literal.

func (*Literal) MarshalJSON

func (l *Literal) MarshalJSON() ([]byte, error)

MarshalJSON encodes the Literal with an adjacent "kind" tag.

type LongRunning

type LongRunning struct {
	// FinalStateVia is "operation-location" | "status-monitor" | "original-uri" |
	// … — how the final state is located.
	FinalStateVia string `json:"finalStateVia,omitempty"`
	// PollingOperation is the declared poll op (Azure.Core @pollingOperation — a
	// library convention, not core TypeSpec).
	PollingOperation *OpID `json:"pollingOperation,omitempty"`
	// FinalOperation is the declared final-result op (Azure.Core @finalOperation).
	FinalOperation *OpID `json:"finalOperation,omitempty"`
	// PollingType is the status-monitor type.
	PollingType *TypeRef `json:"pollingType,omitempty"`
	// FinalType is the final-result type.
	FinalType *TypeRef `json:"finalType,omitempty"`
	// ResultPath locates the final result within the polling response.
	ResultPath *PropPath `json:"resultPath,omitempty"`
}

LongRunning describes long-running-operation semantics (ir-design §7.3).

type MapT

type MapT struct {
	TypeCommon
	// Key is the key type.
	Key TypeRef `json:"key"`
	// Value is the value type.
	Value TypeRef `json:"value"`
}

MapT is a keyed collection (Record/additionalProperties-only/proto map) (ir-design §4.6).

func (*MapT) Common

func (m *MapT) Common() *TypeCommon

Common returns the shared TypeCommon of a MapT.

func (*MapT) Kind

func (*MapT) Kind() TypeKind

Kind reports the TypeKind of a MapT.

func (*MapT) MarshalJSON

func (m *MapT) MarshalJSON() ([]byte, error)

MarshalJSON encodes the MapT with an adjacent "kind" tag.

type Message

type Message struct {
	// ID is the message's stable synthetic identity.
	ID MessageID `json:"id,omitempty"`
	// Name is the message's naming.
	Name Naming `json:"name"`
	// Payload is the message payload.
	Payload Payload `json:"payload"`
	// Headers is the header schema — an object-constrained model hoisted into the
	// type registry like any anonymous type (headers can be named, composed, even
	// Avro-defined; and $message.header#/… paths need a type to resolve against).
	// Emitters compute flat lists per §4.3.
	Headers *TypeRef `json:"headers,omitempty"`
	// CorrelationID locates the correlation value: In: "header" | "" (payload).
	CorrelationID *PropPath `json:"correlationID,omitempty"`
	// ContentType is the message content type.
	ContentType string `json:"contentType,omitempty"`
	// Tags are the message's tag memberships.
	Tags []string `json:"tags,omitempty"`
	// Docs is the message's documentation.
	Docs Docs `json:"docs"`
	// Deprecation marks the message as deprecated.
	Deprecation *Deprecation `json:"deprecation,omitempty"`
	// Examples are correlated header+payload example pairs (Example.Headers +
	// .Value).
	Examples []Example `json:"examples,omitempty"`
	// Bindings holds message-level protocol bindings (kafka message key, …).
	Bindings map[string]Extensions `json:"bindings,omitempty"`
	// Extensions carries source metadata without a first-class IR node.
	Extensions Extensions `json:"extensions,omitempty"`
	// Provenance records where the message came from.
	Provenance Provenance `json:"provenance"`
}

Message is a reusable message shape referenced by channels, operations, and replies by identity (ir-design §8.3, AsyncAPI 3).

type MessageBinding

type MessageBinding struct {
	// Channel is the channel the operation acts on.
	Channel ChannelID `json:"channel,omitempty"`
	// Direction is send | receive (application perspective).
	Direction MsgDirection `json:"direction,omitempty"`
	// Messages are which of the channel's messages this operation uses (must be a
	// subset — validated).
	Messages []MessageID `json:"messages,omitempty"`
	// Reply carries request-reply semantics; nil = none. A send-op with no Reply
	// and no Responses is one-way (set Operation.OneWay).
	Reply *Reply `json:"reply,omitempty"`
	// Bindings holds operation-level protocol bindings kept raw (kafka
	// groupId/clientId — constrain SDK client config).
	Bindings map[string]Extensions `json:"bindings,omitempty"`
	// Extensions carries source metadata without a first-class IR node.
	Extensions Extensions `json:"extensions,omitempty"`
}

MessageBinding maps an Operation onto a messaging channel (ir-design §8.3).

type MessageID

type MessageID string

MessageID identifies a Message in Document.Messages.

type Model

type Model struct {
	TypeCommon
	// Properties are the model's own properties, in source order.
	Properties []Property `json:"properties,omitempty"`
	// Base is the declared single inheritance parent (TypeSpec extends,
	// allOf-as-inheritance).
	Base *TypeRef `json:"base,omitempty"`
	// Implements is N-ary interface conformance (GraphQL implements A & B);
	// targets are Abstract models.
	Implements []TypeRef `json:"implements,omitempty"`
	// Mixins is composition without subtyping (Smithy mixins, TypeSpec spread,
	// extra allOf entries).
	Mixins []TypeRef `json:"mixins,omitempty"`
	// AdditionalProps is a map-like catch-all alongside declared properties.
	AdditionalProps *AdditionalProps `json:"additionalProps,omitempty"`
	// Additional is the openness of the property set.
	Additional AdditionalMode `json:"additional,omitempty"`
	// Abstract marks a model that cannot be instantiated directly (GraphQL
	// interface types).
	Abstract bool `json:"abstract"`
	// Positional serializes properties positionally as a tuple ordered by WireID
	// (Erlang records).
	Positional bool `json:"positional"`
	// ExtensionRanges are wire-ID ranges reserved for third-party extension fields
	// (protobuf extensions 100 to 199).
	ExtensionRanges []WireIDRange `json:"extensionRanges,omitempty"`
	// Discriminator is set on the polymorphic base.
	Discriminator *Discriminator `json:"discriminator,omitempty"`
	// DiscriminatorValue is set on each subtype: its wire tag value.
	DiscriminatorValue string `json:"discriminatorValue,omitempty"`
	// InputOnly marks GraphQL input types, which have distinct identity from
	// output types.
	InputOnly bool `json:"inputOnly"`
}

Model is a struct, object, or message shape (ir-design §4.3). Properties holds only the model's own properties; consumers walk Base, Implements, and Mixins for the full shape.

func (*Model) Common

func (m *Model) Common() *TypeCommon

Common returns the shared TypeCommon of a Model.

func (*Model) Kind

func (*Model) Kind() TypeKind

Kind reports the TypeKind of a Model.

func (*Model) MarshalJSON

func (m *Model) MarshalJSON() ([]byte, error)

MarshalJSON encodes the Model with an adjacent "kind" tag.

type MsgDirection

type MsgDirection string

MsgDirection is the application-perspective direction of a MessageBinding (ir-design §8.3, AsyncAPI 3 semantics).

const (
	// MsgDirectionSend means the application sends the message.
	MsgDirectionSend MsgDirection = "send"
	// MsgDirectionReceive means the application receives the message.
	MsgDirectionReceive MsgDirection = "receive"
)

Message directions.

type Naming

type Naming struct {
	// Source is the name exactly as written in the spec ("user_id", a $ref
	// name, a GraphQL field).
	Source string `json:"source,omitempty"`
	// Canonical is the IR-normalized identifier in neutral form: lower_snake
	// words with no casing opinions.
	Canonical string `json:"canonical,omitempty"`
	// Hint is a context-derived suggestion for anonymous types only
	// (e.g. "connection_domain").
	Hint string `json:"hint,omitempty"`
	// Aliases are alternate names for schema-resolution matching (Avro
	// aliases). Versionless — rename history tied to version labels lives in
	// Availability.RenamedFrom.
	Aliases []string `json:"aliases,omitempty"`
}

Naming carries the identity of a named entity as words, never as a cased identifier: emitters apply casing, acronym policy, and reserved-word escaping (ir-design §3.2). Anonymous (hoisted) types have an empty Source and a Hint.

type OAuthFlow

type OAuthFlow struct {
	// Kind is authorization_code | client_credentials | implicit | password |
	// device.
	Kind string `json:"kind,omitempty"`
	// AuthorizationURL is the authorization endpoint; also carries device flow's
	// deviceAuthorizationUrl.
	AuthorizationURL string `json:"authorizationURL,omitempty"`
	// TokenURL is the token endpoint.
	TokenURL string `json:"tokenURL,omitempty"`
	// RefreshURL is the token-refresh endpoint.
	RefreshURL string `json:"refreshURL,omitempty"`
	// Scopes maps scope names to their descriptions.
	Scopes map[string]string `json:"scopes,omitempty"`
	// Extensions carries source metadata without a first-class IR node.
	Extensions Extensions `json:"extensions,omitempty"`
}

OAuthFlow is one OAuth 2.0 flow of an AuthScheme (ir-design §9).

type OTPBinding

type OTPBinding struct {
	// Behaviour is "gen_server" | "gen_statem" | "gen_event".
	Behaviour string `json:"behaviour,omitempty"`
	// Kind is "call" (synchronous request→reply) | "cast" (fire-and-forget; the
	// operation also sets OneWay) | "info" (raw message send).
	Kind string `json:"kind,omitempty"`
	// Process is the channel modeling the target process: Address = registered
	// name (nil Address = unregistered/runtime pid); registration kind
	// (local/global/via) in Channel.Bindings["otp"].
	Process ChannelID `json:"process,omitempty"`
	// RequestTag is the tag of the request tuple (a symbol Value, e.g. 'get');
	// nil = the whole term is the request.
	RequestTag *Value `json:"requestTag,omitempty"`
	// Extensions carries source metadata without a first-class IR node.
	Extensions Extensions `json:"extensions,omitempty"`
}

OTPBinding maps an Operation onto an Erlang/OTP behaviour callback (ir-design §8.5).

type OpBindings

type OpBindings struct {
	// HTTP holds the HTTP mappings (OpenAPI/Swagger ops, TypeSpec @route, Smithy
	// http traits). A slice: one operation may carry several HTTP mappings — gRPC
	// transcoding additional_bindings — with the primary first.
	HTTP []HTTPBinding `json:"http,omitempty"`
	// RPC is the Protobuf/gRPC, Smithy RPC, or JSON-RPC binding.
	RPC *RPCBinding `json:"rpc,omitempty"`
	// Message is the AsyncAPI operation / webhook binding.
	Message *MessageBinding `json:"message,omitempty"`
	// GraphQL is the query/mutation/subscription field binding. GraphQL
	// subscriptions bind here plus streaming fields on the core — not via
	// MessageBinding.
	GraphQL *GraphQLBinding `json:"graphql,omitempty"`
	// OTP is the Erlang/OTP behaviour-operation binding (§8.5).
	OTP *OTPBinding `json:"otp,omitempty"`
}

OpBindings holds the concrete-protocol mappings of an Operation's neutral core (ir-design §8). An operation has at least one binding; more than one is legal (a Smithy service exposed over both HTTP and RPC; gRPC with HTTP transcoding).

type OpID

type OpID string

OpID identifies an Operation, same construction as TypeID.

type Operation

type Operation struct {
	// ID is the operation's stable synthetic identity.
	ID OpID `json:"id,omitempty"`
	// Name is the operation's naming.
	Name Naming `json:"name"`
	// Docs is the operation's documentation.
	Docs Docs `json:"docs"`
	// Deprecation marks the operation as deprecated.
	Deprecation *Deprecation `json:"deprecation,omitempty"`
	// Availability records the operation's versioning timeline.
	Availability *Availability `json:"availability,omitempty"`
	// Params are all logical inputs, protocol-unbound.
	Params []Parameter `json:"params,omitempty"`
	// Request is the body/message content; nil = none.
	Request *Payload `json:"request,omitempty"`
	// Responses are the ordered success and alternative-success responses.
	Responses []Response `json:"responses,omitempty"`
	// Errors are the declared failure shapes.
	Errors []ErrorCase `json:"errors,omitempty"`
	// OneWay marks fire-and-forget operations for which no response ever exists
	// (OTP cast, AsyncAPI send-without-reply, Thrift oneway, JSON-RPC
	// notifications). Distinct from a response with no body (an ack still
	// exists); validate rejects OneWay with a non-empty Responses.
	OneWay bool `json:"oneWay"`
	// Streaming is the derived streaming summary: none | client | server | bidi.
	Streaming StreamingMode `json:"streaming,omitempty"`
	// RequestStream carries client-to-server streaming semantics, when present.
	RequestStream *StreamDetail `json:"requestStream,omitempty"`
	// ResponseStream carries server-to-client streaming semantics, when present.
	ResponseStream *StreamDetail `json:"responseStream,omitempty"`
	// Pagination describes the operation's pagination, when present.
	Pagination *Pagination `json:"pagination,omitempty"`
	// LongRunning describes long-running-operation semantics, when present.
	LongRunning *LongRunning `json:"longRunning,omitempty"`
	// Idempotency is the operation's idempotency classification: unknown | safe |
	// idempotent | idempotency_token(param). safe = no side effects
	// (Smithy @readonly, HTTP GET semantics).
	Idempotency Idempotency `json:"idempotency"`
	// Auth overrides the service default; an empty slice differs from nil (empty
	// = explicitly public). The four-state distinction requires the field to
	// serialize even when empty, so it carries no omitempty.
	Auth []AuthRequirement `json:"auth"`
	// Tags are the operation's tag memberships.
	Tags []string `json:"tags,omitempty"`
	// ParameterVisibility overrides the visibility filter for the request view
	// (TypeSpec @parameterVisibility); nil = protocol default.
	ParameterVisibility []Lifecycle `json:"parameterVisibility,omitempty"`
	// ReturnTypeVisibility overrides the visibility filter for the response view;
	// nil = protocol default.
	ReturnTypeVisibility []Lifecycle `json:"returnTypeVisibility,omitempty"`
	// OverloadOf points at the operation this one overloads (TypeSpec @overload).
	OverloadOf *OpID `json:"overloadOf,omitempty"`
	// Bindings describes how the neutral core maps onto concrete protocols (§8).
	Bindings OpBindings `json:"bindings"`
	// Examples are operation-scenario examples.
	Examples []Example `json:"examples,omitempty"`
	// Extensions carries source metadata without a first-class IR node.
	Extensions Extensions `json:"extensions,omitempty"`
	// Provenance records where the operation came from.
	Provenance Provenance `json:"provenance"`
}

Operation is the protocol-neutral core of a callable API operation (ir-design §7.2). Parameters carry no protocol location; each binding in Bindings maps the core onto a concrete protocol.

type OperationGroup

type OperationGroup struct {
	// Name is the group's naming.
	Name Naming `json:"name"`
	// Docs is the group's documentation.
	Docs Docs `json:"docs"`
	// Groups holds nested groups: Smithy resources, sub-clients.
	Groups []OperationGroup `json:"groups,omitempty"`
	// Operations holds the group's operations.
	Operations []Operation `json:"operations,omitempty"`
	// Resource carries Smithy resource semantics when declared.
	Resource *ResourceInfo `json:"resource,omitempty"`
	// Availability records the group's versioning timeline (TypeSpec interfaces
	// are versionable).
	Availability *Availability `json:"availability,omitempty"`
	// Extensions carries source metadata without a first-class IR node.
	Extensions Extensions `json:"extensions,omitempty"`
}

OperationGroup is a hierarchical grouping of operations: a TypeSpec interface, Smithy resource, or tag (ir-design §7.1).

type PageStrategy

type PageStrategy string

PageStrategy names the pagination mechanism of an Operation (ir-design §7.3).

const (
	// PageStrategyCursor is opaque-cursor pagination.
	PageStrategyCursor PageStrategy = "cursor"
	// PageStrategyOffset is numeric-offset pagination.
	PageStrategyOffset PageStrategy = "offset"
	// PageStrategyPage is page-number pagination.
	PageStrategyPage PageStrategy = "page"
	// PageStrategyLinkHeader is RFC 5988 Link-header pagination.
	PageStrategyLinkHeader PageStrategy = "link_header"
	// PageStrategyNextLink is body next-link pagination.
	PageStrategyNextLink PageStrategy = "next_link"
	// PageStrategyToken is continuation-token pagination.
	PageStrategyToken PageStrategy = "token"
)

Pagination strategies.

type Pagination

type Pagination struct {
	// Strategy is the pagination mechanism.
	Strategy PageStrategy `json:"strategy,omitempty"`
	// Inferred reports heuristic detection (OpenAPI name-matching policy) vs
	// declared (Smithy/TypeSpec).
	Inferred bool `json:"inferred"`
	// InputCursor is the input that continues iteration.
	InputCursor *ParamPath `json:"inputCursor,omitempty"`
	// InputLimit is the page-size input.
	InputLimit *ParamPath `json:"inputLimit,omitempty"`
	// Items is where result items live in the response — a path, not a name.
	Items *PropPath `json:"items,omitempty"`
	// NextCursor is the continuation source in the response.
	NextCursor *PropPath `json:"nextCursor,omitempty"`
	// NextLink is the next-page link in the response.
	NextLink *PropPath `json:"nextLink,omitempty"`
	// PrevLink is the previous-page navigation link.
	PrevLink *PropPath `json:"prevLink,omitempty"`
	// FirstLink is the first-page navigation link.
	FirstLink *PropPath `json:"firstLink,omitempty"`
	// LastLink is the last-page navigation link.
	LastLink *PropPath `json:"lastLink,omitempty"`
	// TotalCount is the total-count source in the response.
	TotalCount *PropPath `json:"totalCount,omitempty"`
}

Pagination describes an Operation's pagination (ir-design §7.3).

type ParamPath

type ParamPath struct {
	// Param is the parameter name the path roots in.
	Param string `json:"param,omitempty"`
	// Segments are the ordered property IDs walked from the parameter.
	Segments []PropID `json:"segments,omitempty"`
}

ParamPath addresses a member within a named parameter (ir-design §7.3).

type Parameter

type Parameter struct {
	// Name is the parameter's naming.
	Name Naming `json:"name"`
	// Type is the parameter's type.
	Type TypeRef `json:"type"`
	// Required reports whether the caller must supply the parameter.
	Required bool `json:"required"`
	// Default is the parameter's default value.
	Default *Value `json:"default,omitempty"`
	// Constraints restricts the parameter's admissible values.
	Constraints *Constraints `json:"constraints,omitempty"`
	// ValueFrom derives the parameter's value from a location in the
	// outgoing/incoming message (AsyncAPI parameter location runtime
	// expressions); SDKs may auto-fill it. nil = caller-supplied.
	ValueFrom *PropPath `json:"valueFrom,omitempty"`
	// Docs is the parameter's documentation.
	Docs Docs `json:"docs"`
	// Deprecation marks the parameter as deprecated.
	Deprecation *Deprecation `json:"deprecation,omitempty"`
	// Availability records the parameter's versioning timeline.
	Availability *Availability `json:"availability,omitempty"`
	// Examples are parameter-level example values.
	Examples []Example `json:"examples,omitempty"`
	// Extensions carries source metadata without a first-class IR node.
	Extensions Extensions `json:"extensions,omitempty"`
}

Parameter is one logical input of an Operation, protocol-unbound; its wire location is HTTP-binding detail (ir-design §7.2). GraphQL field arguments (Property.Args) reuse this shape.

type PartEncoding

type PartEncoding struct {
	// ContentTypes are the media type(s) of this part.
	ContentTypes []string `json:"contentTypes,omitempty"`
	// Headers are the per-part headers.
	Headers []Property `json:"headers,omitempty"`
	// Multi reports that the part repeats (array member → repeated parts).
	Multi bool `json:"multi"`
	// Filename reports that the part carries a filename (file part).
	Filename bool `json:"filename"`
	// Style is the form-style serialization for non-file parts.
	Style string `json:"style,omitempty"`
	// Explode overrides the default explode behavior; nil = default.
	Explode *bool `json:"explode,omitempty"`
}

PartEncoding is the wire configuration of one multipart part or sequential item (ir-design §7.2). TypeSpec tuple-form multipart lowers to a synthesized model whose properties are the parts.

type PatternProps

type PatternProps struct {
	// Pattern is the ECMA-262 key pattern.
	Pattern string `json:"pattern"`
	// Value is the value schema for matching keys.
	Value TypeRef `json:"value"`
}

PatternProps binds a key pattern to a value schema (JSON Schema patternProperties).

type Payload

type Payload struct {
	// Contents holds one entry per media type / message schema — all kept.
	Contents []Content `json:"contents,omitempty"`
	// Extensions carries source metadata without a first-class IR node.
	Extensions Extensions `json:"extensions,omitempty"`
}

Payload is the body/message content of a request, response, or message (ir-design §7.2). All media types are kept.

type PresenceKind

type PresenceKind string

PresenceKind is the wire-presence discipline of a property where the format distinguishes more than required/optional (protobuf) (ir-design §5.1).

const (
	// PresenceDefault is the format default (Required/Nullable say everything in
	// the JSON world).
	PresenceDefault PresenceKind = ""
	// PresenceImplicit means absence equals the default value; unset is
	// unobservable and zero values are not serialized (proto3 no-label, editions
	// IMPLICIT).
	PresenceImplicit PresenceKind = "implicit"
	// PresenceExplicit means unset is distinguishable from default-valued
	// (hazzers/pointers; proto2 optional, proto3 optional, editions EXPLICIT).
	PresenceExplicit PresenceKind = "explicit"
	// PresenceRequired means the property must be present on the wire (proto2
	// required, editions LEGACY_REQUIRED).
	PresenceRequired PresenceKind = "required"
)

Presence disciplines.

type PrimKind

type PrimKind string

PrimKind names a built-in primitive scalar (ir-design §4.1). The set is the union of TypeSpec's intrinsic scalars, JSON Schema's types, and Protobuf's needs.

const (
	// PrimBool is a boolean.
	PrimBool PrimKind = "bool"
	// PrimString is a Unicode string.
	PrimString PrimKind = "string"
	// PrimBytes is a byte string.
	PrimBytes PrimKind = "bytes"
	// PrimInt8 is a signed 8-bit integer.
	PrimInt8 PrimKind = "int8"
	// PrimInt16 is a signed 16-bit integer.
	PrimInt16 PrimKind = "int16"
	// PrimInt32 is a signed 32-bit integer.
	PrimInt32 PrimKind = "int32"
	// PrimInt64 is a signed 64-bit integer.
	PrimInt64 PrimKind = "int64"
	// PrimUint8 is an unsigned 8-bit integer.
	PrimUint8 PrimKind = "uint8"
	// PrimUint16 is an unsigned 16-bit integer.
	PrimUint16 PrimKind = "uint16"
	// PrimUint32 is an unsigned 32-bit integer.
	PrimUint32 PrimKind = "uint32"
	// PrimUint64 is an unsigned 64-bit integer.
	PrimUint64 PrimKind = "uint64"
	// PrimInteger is an arbitrary-precision integer (JSON Schema/TypeSpec integer).
	PrimInteger PrimKind = "integer"
	// PrimFloat32 is a 32-bit IEEE-754 float.
	PrimFloat32 PrimKind = "float32"
	// PrimFloat64 is a 64-bit IEEE-754 float.
	PrimFloat64 PrimKind = "float64"
	// PrimFloat is an arbitrary-precision binary float (supertype of float32/64).
	PrimFloat PrimKind = "float"
	// PrimNumber is an arbitrary-precision number (JSON Schema number, TypeSpec numeric).
	PrimNumber PrimKind = "number"
	// PrimDecimal is an arbitrary-precision decimal.
	PrimDecimal PrimKind = "decimal"
	// PrimDecimal128 is a 128-bit IEEE-754 decimal.
	PrimDecimal128 PrimKind = "decimal128"
	// PrimDate is a calendar date without time.
	PrimDate PrimKind = "date"
	// PrimTime is a time of day without date.
	PrimTime PrimKind = "time"
	// PrimDatetime is a date and time without offset.
	PrimDatetime PrimKind = "datetime"
	// PrimDatetimeOffset is a date and time with UTC offset.
	PrimDatetimeOffset PrimKind = "datetime_offset"
	// PrimDuration is a time span.
	PrimDuration PrimKind = "duration"
	// PrimURL is a URL.
	PrimURL PrimKind = "url"
	// PrimUUID is a UUID.
	PrimUUID PrimKind = "uuid"
	// PrimAny is an unknown/JSON any (schemaless) primitive.
	PrimAny PrimKind = "any"
)

Primitive kinds.

type Primitive

type Primitive struct {
	TypeCommon
	// Prim selects the primitive kind.
	Prim PrimKind `json:"prim"`
}

Primitive is a built-in scalar leaf type (ir-design §4.1).

func (*Primitive) Common

func (p *Primitive) Common() *TypeCommon

Common returns the shared TypeCommon of a Primitive.

func (*Primitive) Kind

func (*Primitive) Kind() TypeKind

Kind reports the TypeKind of a Primitive.

func (*Primitive) MarshalJSON

func (p *Primitive) MarshalJSON() ([]byte, error)

MarshalJSON encodes the Primitive with an adjacent "kind" tag.

type PropID

type PropID string

PropID identifies a Property within the document.

type PropPath

type PropPath struct {
	// Root is the type the path roots in; nil = determined by context (the
	// enclosing response body, message payload, …).
	Root *TypeRef `json:"root,omitempty"`
	// In is "" = body/payload | "header"; continuation tokens and reply addresses
	// can live in response/message headers, not just bodies.
	In string `json:"in,omitempty"`
	// Segments are the ordered property IDs walked from the root.
	Segments []PropID `json:"segments,omitempty"`
}

PropPath addresses a member within a type by identity, not by name (ir-design §7.3).

type Property

type Property struct {
	// ID is the property's stable synthetic identity.
	ID PropID `json:"id"`
	// Name is the property's naming.
	Name Naming `json:"name"`
	// WireName is the serialized name; defaults to Name.Source.
	WireName string `json:"wireName,omitempty"`
	// WireNameByFormat carries per-media-type overrides (TypeSpec @encodedName
	// json/xml).
	WireNameByFormat map[string]string `json:"wireNameByFormat,omitempty"`
	// WireID is the protobuf field number / thrift id / tuple element index
	// (1-based when Model.Positional); nil = none (pointer because 0 is a legal
	// ordinal).
	WireID *int `json:"wireID,omitempty"`
	// ExtensionOf is "" for the model's own field, else the fully-qualified
	// declaring scope of a third-party extension field (protobuf extend).
	ExtensionOf string `json:"extensionOf,omitempty"`
	// Type is the property's type.
	Type TypeRef `json:"type"`
	// Required reports wire presence; orthogonal to Type.Nullable.
	Required bool `json:"required"`
	// Presence is the wire-presence discipline where the format distinguishes more
	// than required/optional (protobuf).
	Presence PresenceKind `json:"presence,omitempty"`
	// ClientOptional marks a wire-required property that clients MUST treat as
	// optional (Smithy @clientOptional).
	ClientOptional bool `json:"clientOptional"`
	// DefaultAdded marks a default added post-publication; generators may ignore
	// it for backward compatibility (Smithy @addedDefault).
	DefaultAdded bool `json:"defaultAdded"`
	// Visibility is the lifecycle set; zero value = visible in all.
	Visibility Visibility `json:"visibility"`
	// Default is the property's default value.
	Default *Value `json:"default,omitempty"`
	// Constraints restricts the property's admissible values.
	Constraints *Constraints `json:"constraints,omitempty"`
	// Encoding overrides the property's wire encoding.
	Encoding *Encoding `json:"encoding,omitempty"`
	// Args are field arguments for parameterized fields: GraphQL field arguments
	// on any property at any depth; empty elsewhere.
	Args []Parameter `json:"args,omitempty"`
	// Flatten hoists the property's fields into the parent on the wire (Smithy/TCGC
	// flatten; also set on the synthetic property wrapping a hoisted protobuf
	// oneof).
	Flatten bool `json:"flatten"`
	// EventHeader marks an event-stream member that travels in the frame header,
	// not the payload (Smithy @eventHeader).
	EventHeader bool `json:"eventHeader"`
	// EventPayload marks the raw frame payload member (Smithy @eventPayload);
	// mutually exclusive with EventHeader, at most one per model.
	EventPayload bool `json:"eventPayload"`
	// Secret requests redaction in logs/docs (TypeSpec @secret, format:password).
	Secret bool `json:"secret"`
	// XML is the XML wire shape when it diverges from the JSON-implied shape.
	XML *XMLHints `json:"xml,omitempty"`
	// Examples are property-level example values.
	Examples []Example `json:"examples,omitempty"`
	// Docs is the property's documentation.
	Docs Docs `json:"docs"`
	// Deprecation marks the property as deprecated.
	Deprecation *Deprecation `json:"deprecation,omitempty"`
	// Availability records the property's versioning timeline.
	Availability *Availability `json:"availability,omitempty"`
	// Extensions carries source metadata without a first-class IR node.
	Extensions Extensions `json:"extensions,omitempty"`
	// Provenance records where the property came from.
	Provenance Provenance `json:"provenance"`
}

Property is one member of a Model (ir-design §5.1). Required (wire presence) is orthogonal to Type.Nullable (this usage admits null).

type ProtocolDecl

type ProtocolDecl struct {
	// Name is the protocol name, e.g. "aws.restJson1" or "grpc".
	Name string `json:"name,omitempty"`
	// Options holds per-protocol options kept raw (the Channel.Bindings pattern).
	Options Extensions `json:"options,omitempty"`
}

ProtocolDecl is a declared serde/protocol convention a service speaks (ir-design §7.1).

type Provenance

type Provenance struct {
	// Source indexes into Document.Sources.
	Source int `json:"source"`
	// Pointer is a JSON pointer or line:col into that source.
	Pointer string `json:"pointer,omitempty"`
	// Inferred is "" for declared facts; otherwise it names the heuristic that
	// produced this node (e.g. "pagination-name-match").
	Inferred string `json:"inferred,omitempty"`
}

Provenance records where a node came from and whether it was declared or inferred (ir-design §13). Everything heuristic is auditable; everything broken is reportable with an exact source location.

type RPCBinding

type RPCBinding struct {
	// System is "grpc" | "smithy-rpc" | "connect" | "jsonrpc" | ….
	System string `json:"system,omitempty"`
	// FullMethod is the fully-qualified method, e.g. "/pkg.Service/Method".
	FullMethod string `json:"fullMethod,omitempty"`
	// InputType is the request message type params fold into (nil = synthesize
	// from Params).
	InputType *TypeRef `json:"inputType,omitempty"`
	// ParamStructure is "" | "by_name" | "by_position" | "either" — how params
	// serialize (JSON-RPC positional vs named; OpenRPC paramStructure). Param
	// order is already source order; this is the mode.
	ParamStructure string `json:"paramStructure,omitempty"`
	// IdempotencyLevel is the RPC-declared idempotency level.
	IdempotencyLevel string `json:"idempotencyLevel,omitempty"`
	// Extensions carries source metadata without a first-class IR node.
	Extensions Extensions `json:"extensions,omitempty"`
}

RPCBinding maps an Operation onto an RPC method (ir-design §8.2).

type RawValue

type RawValue = json.RawMessage

RawValue is source JSON preserved verbatim.

type Reply

type Reply struct {
	// Channel is the static reply channel; nil when the address is dynamic-only
	// (an AsyncAPI reply channel's own address is null by spec).
	Channel *ChannelID `json:"channel,omitempty"`
	// Address is the dynamic reply address: where in the request message the
	// reply destination lives, e.g. In:"header", Segments:[replyTo] (AsyncAPI
	// Operation Reply Address runtime expressions).
	Address *PropPath `json:"address,omitempty"`
	// Messages is the reply payload message set.
	Messages []MessageID `json:"messages,omitempty"`
	// Docs is the reply's documentation.
	Docs Docs `json:"docs"`
}

Reply describes request-reply semantics of a MessageBinding (ir-design §8.3).

type RequestCompression

type RequestCompression struct {
	// Encodings are the priority-ordered compression encodings ("gzip", …).
	Encodings []string `json:"encodings,omitempty"`
}

RequestCompression declares required request-body compression encodings (ir-design §8.1).

type ResourceInfo

type ResourceInfo struct {
	// Identifiers are the resource identity fields.
	Identifiers []Property `json:"identifiers,omitempty"`
	// Properties are the resource state fields (Smithy 2.0 resource properties).
	Properties []Property `json:"properties,omitempty"`
	// Lifecycle maps lifecycle names ("create"|"put"|"read"|"update"|"delete"|
	// "list") to operations; put = create-or-replace with a client-provided
	// identifier.
	Lifecycle map[string]OpID `json:"lifecycle,omitempty"`
	// NoReplace reports that put may create but not replace (Smithy @noReplace).
	NoReplace bool `json:"noReplace"`
	// InstanceOps are declared non-lifecycle instance operations (require
	// identifiers).
	InstanceOps []OpID `json:"instanceOps,omitempty"`
	// CollectionOps are declared collection operations; the split drives
	// sub-client shape and is a declared fact, not a heuristic.
	CollectionOps []OpID `json:"collectionOps,omitempty"`
}

ResourceInfo carries Smithy resource semantics for an OperationGroup (ir-design §7.1).

type Response

type Response struct {
	// Name is the response naming for formats with named outputs; Hint elsewhere.
	Name Naming `json:"name"`
	// Conditions are the HTTP status codes/ranges; empty for RPC single-response.
	Conditions ResponseConditions `json:"conditions"`
	// Payload is the response body; nil = no body.
	Payload *Payload `json:"payload,omitempty"`
	// Headers are the response metadata fields.
	Headers []Property `json:"headers,omitempty"`
	// StatusCodeProp is the output member populated from the runtime HTTP status
	// line (Smithy @httpResponseCode, TypeSpec non-literal @statusCode); the
	// member is suppressed from the body.
	StatusCodeProp *PropPath `json:"statusCodeProp,omitempty"`
	// Docs is the response's documentation.
	Docs Docs `json:"docs"`
	// Extensions carries source metadata without a first-class IR node.
	Extensions Extensions `json:"extensions,omitempty"`
}

Response is one declared output of an Operation (ir-design §7.2). All responses and all content types survive; the plan layer picks a primary.

type ResponseConditions

type ResponseConditions struct {
	// StatusCodes are the applicable status ranges; empty = unconditional.
	StatusCodes []StatusRange `json:"statusCodes,omitempty"`
}

ResponseConditions selects the status codes a Response or ErrorCase applies to (ir-design §7.2).

type Scalar

type Scalar struct {
	TypeCommon
	// Base is the primitive or scalar this scalar extends; nil = opaque scalar
	// with implementation-defined representation (GraphQL custom scalars).
	Base *TypeRef `json:"base,omitempty"`
	// Constraints restricts the scalar's admissible values.
	Constraints *Constraints `json:"constraints,omitempty"`
	// Encoding overrides the scalar's wire encoding.
	Encoding *Encoding `json:"encoding,omitempty"`
}

Scalar is a named restricted or extended primitive (ir-design §4.2). Emitters resolve the Base chain to the nearest representable base, accumulating constraints and encoding along the way.

func (*Scalar) Common

func (s *Scalar) Common() *TypeCommon

Common returns the shared TypeCommon of a Scalar.

func (*Scalar) Kind

func (*Scalar) Kind() TypeKind

Kind reports the TypeKind of a Scalar.

func (*Scalar) MarshalJSON

func (s *Scalar) MarshalJSON() ([]byte, error)

MarshalJSON encodes the Scalar with an adjacent "kind" tag.

type SchemeUse

type SchemeUse struct {
	// Scheme is the referenced auth scheme.
	Scheme AuthID `json:"scheme,omitempty"`
	// Scopes are the scopes required of the scheme (OAuth2/OpenID).
	Scopes []string `json:"scopes,omitempty"`
}

SchemeUse names one scheme and the scopes required of it within an AuthRequirement (ir-design §9).

type Server

type Server struct {
	// Name is the server's naming.
	Name Naming `json:"name"`
	// URLTemplate is the endpoint URL, may contain {variables}.
	URLTemplate string `json:"urlTemplate,omitempty"`
	// Description is the server's documentation.
	Description Docs `json:"description"`
	// Variables are the URL template variables.
	Variables []ServerVariable `json:"variables,omitempty"`
	// Protocol is "https" (default); "kafka", "wss", … for messaging servers.
	Protocol string `json:"protocol,omitempty"`
	// ProtocolVersion is the protocol version, e.g. Kafka "3.5", AMQP "0-9-1"
	// (AsyncAPI).
	ProtocolVersion string `json:"protocolVersion,omitempty"`
	// Tags are the server's tag memberships.
	Tags []string `json:"tags,omitempty"`
	// Auth is server-scoped security — AsyncAPI's primary auth placement (broker
	// connections authenticate per server; different servers of one service may
	// require different schemes). An empty non-nil slice (explicitly public)
	// differs from nil, so the field carries no omitempty.
	Auth []AuthRequirement `json:"auth"`
	// Bindings holds server-level protocol bindings kept raw.
	Bindings map[string]Extensions `json:"bindings,omitempty"`
	// Extensions carries source metadata without a first-class IR node.
	Extensions Extensions `json:"extensions,omitempty"`
}

Server is a named endpoint template (ir-design §10). Servers are named entities (AsyncAPI name-keyed servers, OpenAPI 3.2 Server.name).

type ServerVariable

type ServerVariable struct {
	// Name is the variable name referenced in the URL template.
	Name string `json:"name,omitempty"`
	// Default is the default value used when the caller supplies none.
	Default string `json:"default,omitempty"`
	// Enum is the closed set of permitted values, when constrained.
	Enum []string `json:"enum,omitempty"`
	// Docs is the variable's documentation.
	Docs Docs `json:"docs"`
	// Extensions carries source metadata without a first-class IR node.
	Extensions Extensions `json:"extensions,omitempty"`
}

ServerVariable is one variable of a Server's URL template (ir-design §10).

type Service

type Service struct {
	// ID is the service's stable synthetic identity.
	ID ServiceID `json:"id,omitempty"`
	// Name is the service's naming.
	Name Naming `json:"name"`
	// Docs is the service's documentation.
	Docs Docs `json:"docs"`
	// Version is the per-service version string (Smithy service version); the
	// document-level Version remains the API title's version.
	Version string `json:"version,omitempty"`
	// Namespace is the source namespace path (TypeSpec/Smithy/proto package).
	Namespace []string `json:"namespace,omitempty"`
	// Extends lists client-visible service inheritance (Thrift service extends,
	// WSDL 2.0 interface extension, Cap'n Proto interface inheritance); inherited
	// operations are walked, never copied.
	Extends []ServiceID `json:"extends,omitempty"`
	// Groups holds the hierarchical operation groups; a group is a TypeSpec
	// interface / Smithy resource / tag.
	Groups []OperationGroup `json:"groups,omitempty"`
	// Auth is the service-level default requirement (OR-of-ANDs, §9). An empty
	// non-nil slice (explicitly public) differs from nil (no default), so the
	// field carries no omitempty.
	Auth []AuthRequirement `json:"auth"`
	// CommonErrors are errors every operation can return (Smithy service-level
	// errors).
	CommonErrors []ErrorCase `json:"commonErrors,omitempty"`
	// Protocols are the declared serde/protocol conventions the service speaks
	// (Smithy @protocolDefinition traits like aws.protocols#restJson1).
	Protocols []ProtocolDecl `json:"protocols,omitempty"`
	// Renames holds per-service shape presentation names (Smithy service rename);
	// the TypeID — and Naming on the type — are unchanged.
	Renames map[TypeID]Naming `json:"renames,omitempty"`
	// Servers indexes into Document.Servers scoped to this service.
	Servers []int `json:"servers,omitempty"`
	// Extensions carries source metadata without a first-class IR node.
	Extensions Extensions `json:"extensions,omitempty"`
	// Provenance records where the service came from.
	Provenance Provenance `json:"provenance"`
}

Service is a client-visible service: a coherent group of operations with a shared identity, auth default, and protocol conventions (ir-design §7.1).

type ServiceID

type ServiceID string

ServiceID identifies a Service.

type Severity

type Severity string

Severity classifies a Diagnostic. The engine decides what is fatal.

const (
	SeverityError   Severity = "error"
	SeverityWarning Severity = "warning"
	SeverityInfo    Severity = "info"
)

Diagnostic severities.

type SourceInfo

type SourceInfo struct {
	Format string `json:"format"`
	Path   string `json:"path"`
	Hash   string `json:"hash"`
}

SourceInfo describes one input file of a Document.

type StatusRange

type StatusRange struct {
	// From is the inclusive lower bound.
	From int `json:"from"`
	// To is the inclusive upper bound.
	To int `json:"to"`
}

StatusRange is an inclusive HTTP status-code range: 200–200, 400–499 ("4XX"), 0–0 = default/catch-all (ir-design §7.2).

type StreamDetail

type StreamDetail struct {
	// Events is the stream element type when it differs from the payload content
	// type — for event streams a WireTagged Union of event models; within an
	// event model, Property.EventHeader marks frame-header members and
	// Property.EventPayload marks a raw-payload member (Smithy @eventHeader/
	// @eventPayload). Per-event content types and terminal events live on
	// Variant.Event.
	Events *TypeRef `json:"events,omitempty"`
	// Initial is the initial-request/initial-response message preceding the
	// stream (Smithy event stream initial messages); nil = none.
	Initial *TypeRef `json:"initial,omitempty"`
	// RequiresLength reports that the streamed content must have a known finite
	// length up front (Smithy @requiresLength) — changes the generated parameter
	// type.
	RequiresLength bool `json:"requiresLength"`
}

StreamDetail describes one direction of a streaming Operation (ir-design §7.3).

type StreamingMode

type StreamingMode string

StreamingMode is the protocol-independent streaming direction of an Operation (ir-design §7.3).

const (
	// StreamingNone means the operation does not stream.
	StreamingNone StreamingMode = "none"
	// StreamingClient means the client streams to the server.
	StreamingClient StreamingMode = "client"
	// StreamingServer means the server streams to the client.
	StreamingServer StreamingMode = "server"
	// StreamingBidi means both directions stream.
	StreamingBidi StreamingMode = "bidi"
)

Streaming modes.

type TagDef

type TagDef struct {
	// Name is the tag name referenced by tagged nodes.
	Name string `json:"name,omitempty"`
	// Docs is the tag's documentation.
	Docs Docs `json:"docs"`
}

TagDef is one entry of the document's tag metadata registry. Tag membership stays []string on the tagged nodes.

type TemplateArg

type TemplateArg struct {
	// Type is the type argument, set when this is a type parameter.
	Type *TypeRef `json:"type,omitempty"`
	// Value is the value argument, set when this is a valueof parameter.
	Value *Value `json:"value,omitempty"`
}

TemplateArg is one argument of a TemplateInstantiation; exactly one of Type or Value is set (TypeSpec valueof template parameters).

type TemplateInstantiation

type TemplateInstantiation struct {
	// Template names the source template.
	Template string `json:"template,omitempty"`
	// Args are the type and value arguments; instances are identified by both.
	Args []TemplateArg `json:"args,omitempty"`
}

TemplateInstantiation records the template and arguments a monomorphized generic type was produced from (ir-design §4).

type Tuple

type Tuple struct {
	TypeCommon
	// Elems are the element types in position order.
	Elems []TypeRef `json:"elems,omitempty"`
}

Tuple is a positional, fixed-arity sequence (prefixItems, TypeSpec tuples, Erlang tuples) (ir-design §4.6).

func (*Tuple) Common

func (t *Tuple) Common() *TypeCommon

Common returns the shared TypeCommon of a Tuple.

func (*Tuple) Kind

func (*Tuple) Kind() TypeKind

Kind reports the TypeKind of a Tuple.

func (*Tuple) MarshalJSON

func (t *Tuple) MarshalJSON() ([]byte, error)

MarshalJSON encodes the Tuple with an adjacent "kind" tag.

type TypeCommon

type TypeCommon struct {
	// ID is the type's stable synthetic identity in Document.Types.
	ID TypeID `json:"id"`
	// Name is the source/canonical naming of the type.
	Name Naming `json:"name"`
	// Namespace is the type's declared logical namespace (proto package, Avro
	// namespace, Thrift/XSD/Cap'n Proto scopes); independent of Service.Namespace.
	Namespace []string `json:"namespace,omitempty"`
	// Anonymous reports that this is a hoisted inline type.
	Anonymous bool `json:"anonymous"`
	// Docs is the human-readable documentation for the type.
	Docs Docs `json:"docs"`
	// Tags are free-form labels (Smithy @tags, OpenAPI tag membership via policy);
	// tag metadata lives once in Document.TagDefs.
	Tags []string `json:"tags,omitempty"`
	// Sensitive requests whole-type redaction (Smithy @sensitive on shapes);
	// Property.Secret is the per-use form.
	Sensitive bool `json:"sensitive"`
	// Access is "" for public or "internal" for a type outside the exported SDK
	// surface (protobuf editions export/local, TCGC @access(internal)).
	Access string `json:"access,omitempty"`
	// Deprecation marks the type as deprecated with optional migration guidance.
	Deprecation *Deprecation `json:"deprecation,omitempty"`
	// Availability records the type's versioning timeline.
	Availability *Availability `json:"availability,omitempty"`
	// Usage is the computed input/output/error/multipart usage bitset.
	Usage UsageFlags `json:"usage,omitempty"`
	// WireNameByFormat carries type-level serialized-name overrides per media type
	// (TypeSpec @encodedName on models/enums/scalars).
	WireNameByFormat map[string]string `json:"wireNameByFormat,omitempty"`
	// MediaTypeHint is the declared default content type when the type is a body
	// (TypeSpec @mediaTypeHint, Smithy @mediaType on string/blob shapes).
	MediaTypeHint string `json:"mediaTypeHint,omitempty"`
	// XML is the type-level XML wire shape: root element name/namespace.
	XML *XMLHints `json:"xml,omitempty"`
	// Examples are typed example values attached to the type.
	Examples []Example `json:"examples,omitempty"`
	// Instantiation records provenance for monomorphized generics (TypeSpec
	// templates).
	Instantiation *TemplateInstantiation `json:"instantiation,omitempty"`
	// Extensions carries source metadata without a first-class IR node.
	Extensions Extensions `json:"extensions,omitempty"`
	// Provenance records where the type came from.
	Provenance Provenance `json:"provenance"`
}

TypeCommon carries the identity, documentation, and cross-cutting metadata shared by every type-graph node (ir-design §4). It is embedded in each concrete kind and inlined by encoding/json.

type TypeDef

type TypeDef interface {
	Kind() TypeKind
	Common() *TypeCommon
	// contains filtered or unexported methods
}

TypeDef is the sealed sum of all type-graph nodes (ir-design §4). Concrete kinds: Primitive, Scalar, Model, Union, Enum, List, MapT, Tuple, Literal, External, Any. JSON encodes the sum with an adjacent "kind" tag.

func NewTypeDef

func NewTypeDef(k TypeKind) (TypeDef, bool)

NewTypeDef returns a new zero-valued concrete TypeDef for kind k, or false when k is not a registered kind.

type TypeID

type TypeID string

TypeID identifies a TypeDef in Document.Types, e.g. "t/openapi/components/schemas/User".

type TypeKind

type TypeKind string

TypeKind names one variant of the sealed TypeDef sum (ir-design §4).

const (
	// KindPrimitive is a built-in scalar leaf (Primitive).
	KindPrimitive TypeKind = "primitive"
	// KindScalar is a named restricted/extended primitive (Scalar).
	KindScalar TypeKind = "scalar"
	// KindModel is a struct/object/message shape (Model).
	KindModel TypeKind = "model"
	// KindUnion is a sum over variant types (Union).
	KindUnion TypeKind = "union"
	// KindEnum is a closed or open set of named values (Enum).
	KindEnum TypeKind = "enum"
	// KindList is an ordered collection (List).
	KindList TypeKind = "list"
	// KindMap is a keyed collection (MapT).
	KindMap TypeKind = "map"
	// KindTuple is a positional fixed-arity sequence (Tuple).
	KindTuple TypeKind = "tuple"
	// KindLiteral is a single constant value as a type (Literal).
	KindLiteral TypeKind = "literal"
	// KindExternal is a well-known library type resolved by the emitter (External).
	KindExternal TypeKind = "external"
	// KindAny is a schemaless type (Any).
	KindAny TypeKind = "any"
)

Type kinds: the closed set of type-graph node variants.

type TypeRef

type TypeRef struct {
	// Target identifies the referenced TypeDef in Document.Types.
	Target TypeID `json:"target"`
	// Nullable reports that this usage admits null on the wire. Compilers
	// normalize every source spelling to this one bit: OAS 3.0 nullable: true,
	// OAS 3.1 type: [T, "null"], TypeSpec T | null, GraphQL absence-of-!.
	Nullable bool `json:"nullable"`
}

TypeRef references a TypeDef by ID and records whether this particular usage admits null on the wire (ir-design §3.3). Nullability lives on the reference, not the target type, because the same type is nullable in one position and not another; combined with Property.Required it yields the four distinct required/optional × nullable/non-null states.

type TypeRegistry

type TypeRegistry map[TypeID]TypeDef

TypeRegistry is the flat, ID-keyed owner of every TypeDef in a Document (ir-design §2, §4). It is the only place TypeDefs live; every other node references types by TypeID. JSON (un)marshaling of the sealed sum is defined with the rest of the sum-type codec.

func (*TypeRegistry) UnmarshalJSON

func (r *TypeRegistry) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes a kind-tagged TypeDef per entry, dispatching through the same registry the completeness test walks.

type Union

type Union struct {
	TypeCommon
	// Variants are the union's members, in source order.
	Variants []Variant `json:"variants,omitempty"`
	// Exclusive is true for oneOf/tagged (exactly one variant matches) and false
	// for anyOf (one-or-more).
	Exclusive bool `json:"exclusive"`
	// WireTagged reports that the wire format itself encodes the variant (protobuf
	// oneof, Smithy union, GraphQL __typename) rather than untagged JSON oneOf.
	WireTagged bool `json:"wireTagged"`
	// Discriminator is the internal tag property, when one exists.
	Discriminator *Discriminator `json:"discriminator,omitempty"`
}

Union is a sum over variant types (ir-design §4.4). One node covers untagged anyOf/oneOf, discriminated oneOf, and natively tagged unions.

func (*Union) Common

func (u *Union) Common() *TypeCommon

Common returns the shared TypeCommon of a Union.

func (*Union) Kind

func (*Union) Kind() TypeKind

Kind reports the TypeKind of a Union.

func (*Union) MarshalJSON

func (u *Union) MarshalJSON() ([]byte, error)

MarshalJSON encodes the Union with an adjacent "kind" tag.

type UsageFlags

type UsageFlags uint32

UsageFlags is a bitset recording how a type is used across the API surface. It is computed by a pass and JSON-encoded as a number.

const (
	// UsageInput marks a type reachable from a request payload.
	UsageInput UsageFlags = 1 << iota
	// UsageOutput marks a type reachable from a response payload.
	UsageOutput
	// UsageError marks a type reachable from an error payload.
	UsageError
	// UsageMultipart marks a type used in a multipart body.
	UsageMultipart
)

Usage bits.

type Value

type Value struct {
	// Kind selects the meaningful payload field.
	Kind ValueKind `json:"kind"`
	// Bool is the payload for ValueBool.
	Bool bool `json:"bool,omitempty"`
	// Str is the payload for ValueString and ValueSymbol.
	Str string `json:"str,omitempty"`
	// Num is the payload for ValueNumber, an arbitrary-precision decimal string.
	Num BigVal `json:"num,omitempty"`
	// Bytes is the payload for ValueBytes, base64-encoded in JSON form.
	Bytes []byte `json:"bytes"`
	// List is the payload for ValueList, an ordered sequence of values.
	List []Value `json:"list"`
	// Object is the payload for ValueObject, an ordered set of named values.
	// Object member order carries meaning, so it is a slice, never a map.
	Object []Field `json:"object"`
	// Ref is the payload for ValueRefKind, a reference to a declared constant.
	Ref *ValueRef `json:"ref,omitempty"`
	// Ctor is the payload for ValueCtor, a constructor-built value.
	Ctor *CtorValue `json:"ctor,omitempty"`
}

Value is typed data kept separate from the type graph: defaults, constants, literal types, enum member values, and examples (ir-design §6). Kind selects which payload field is meaningful; the remaining fields hold their zero value. Collection payloads (Bytes/List/Object) carry no omitempty so a present-but-empty collection round-trips as []/{} rather than collapsing to nil; the ValueNull compact form therefore also carries their null fields, e.g. Value{Kind: ValueNull} marshals to {"kind":"null","bytes":null,"list":null,"object":null}.

type ValueKind

type ValueKind string

ValueKind names the shape of a Value payload. Values are typed data kept separate from the type graph (the TypeSpec Type-vs-Value split): defaults, constants, literal types, enum member values, and examples live here (ir-design §6).

const (
	// ValueNull is the null value.
	ValueNull ValueKind = "null"
	// ValueBool is a boolean value carried in Value.Bool.
	ValueBool ValueKind = "bool"
	// ValueString is a string value carried in Value.Str.
	ValueString ValueKind = "string"
	// ValueNumber is an arbitrary-precision numeric value carried in Value.Num.
	ValueNumber ValueKind = "number"
	// ValueBytes is a byte-string value carried in Value.Bytes.
	ValueBytes ValueKind = "bytes"
	// ValueSymbol is an interned-symbol value carried in Value.Str, distinct
	// from ValueString (Erlang atoms: on the native wire ok != <<"ok">>).
	ValueSymbol ValueKind = "symbol"
	// ValueList is an ordered sequence of values carried in Value.List.
	ValueList ValueKind = "list"
	// ValueObject is an ordered set of named values carried in Value.Object.
	ValueObject ValueKind = "object"
	// ValueRefKind is a reference to a declared constant carried in Value.Ref.
	// Its string form is "ref"; the constant is named ValueRefKind because
	// ValueRef is the referenced struct.
	ValueRefKind ValueKind = "ref"
	// ValueCtor is a value built by a named scalar constructor, carried in
	// Value.Ctor (TypeSpec scalar constructors such as plainDate.fromISO).
	ValueCtor ValueKind = "ctor"
)

Value kinds. The Kind field of a Value selects which payload field carries meaning; all other payload fields hold their zero value.

type ValueRef

type ValueRef struct {
	// Type identifies the declaring type.
	Type TypeID `json:"type,omitempty"`
	// Member names the referenced member within Type.
	Member string `json:"member,omitempty"`
}

ValueRef references a declared constant: a TypeSpec enum-member default or a reference to a named const (ir-design §6).

type Variant

type Variant struct {
	// Name is the variant's naming; Hint-only for bare oneOf members.
	Name Naming `json:"name"`
	// Type is the variant's type.
	Type TypeRef `json:"type"`
	// WireName is the serialized tag when it differs from Name.Source (Smithy
	// @jsonName on union members, protobuf oneof json_name).
	WireName string `json:"wireName,omitempty"`
	// WireID is the protobuf oneof field number or Cap'n Proto/Avro ordinal; nil =
	// none (pointer because 0 is a legal ordinal).
	WireID *int `json:"wireID,omitempty"`
	// XML is @xmlName/@xmlNamespace on union members.
	XML *XMLHints `json:"xml,omitempty"`
	// Event is event-stream metadata when the union is a stream's event set.
	Event *EventInfo `json:"event,omitempty"`
	// Docs is the variant's documentation.
	Docs Docs `json:"docs"`
	// Deprecation marks the variant as deprecated.
	Deprecation *Deprecation `json:"deprecation,omitempty"`
	// Availability records the variant's versioning timeline.
	Availability *Availability `json:"availability,omitempty"`
	// Examples are typed example values for the variant.
	Examples []Example `json:"examples,omitempty"`
	// Extensions carries source metadata without a first-class IR node.
	Extensions Extensions `json:"extensions,omitempty"`
}

Variant is one member of a Union (ir-design §4.4).

type VersionedBool

type VersionedBool struct {
	// Version is the version label.
	Version string `json:"version,omitempty"`
	// WasRequired is the Required state effective at that version.
	WasRequired bool `json:"wasRequired"`
}

VersionedBool records the prior required state at a version (ir-design §11).

type VersionedName

type VersionedName struct {
	// Version is the version label.
	Version string `json:"version,omitempty"`
	// Name is the name effective at that version.
	Name string `json:"name,omitempty"`
}

VersionedName is a prior name effective at a version (ir-design §11).

type VersionedType

type VersionedType struct {
	// Version is the version label.
	Version string `json:"version,omitempty"`
	// Type is the type effective at that version.
	Type TypeRef `json:"type"`
}

VersionedType is a prior type effective at a version (ir-design §11).

type Visibility

type Visibility struct {
	// Only lists the lifecycles the property is visible in; empty = visible in
	// all (unless None).
	Only []Lifecycle `json:"only,omitempty"`
	// None marks a property visible in NO lifecycle, excluded from every
	// projection (TypeSpec @invisible); distinct from the zero value.
	None bool `json:"none"`
}

Visibility is the set of lifecycles in which a property is visible (ir-design §5.2). The zero value is visible in all lifecycles.

type WireIDRange

type WireIDRange struct {
	// From is the first wire ID in the range.
	From int `json:"from"`
	// To is the last wire ID in the range.
	To int `json:"to"`
}

WireIDRange is an inclusive range of wire IDs (ir-design §4.3).

type XMLHints

type XMLHints struct {
	// Name is the element/attribute name override.
	Name string `json:"name,omitempty"`
	// Namespace is the namespace URI.
	Namespace string `json:"namespace,omitempty"`
	// Prefix is the namespace prefix.
	Prefix string `json:"prefix,omitempty"`
	// NodeType is "", "element", "attribute", "text", "cdata", or "none" (OpenAPI
	// 3.2 nodeType; "text" covers Smithy httpPayload text).
	NodeType string `json:"nodeType,omitempty"`
	// Wrapped reports that list items are wrapped in a container element.
	Wrapped bool `json:"wrapped"`
}

XMLHints describes an XML wire shape that diverges from the JSON-implied one (ir-design §5.4). Hints attach at TypeCommon (root shape) and Property (per-use overrides; property wins).

Directories

Path Synopsis
Package irtest provides golden-snapshot helpers for IR documents.
Package irtest provides golden-snapshot helpers for IR documents.
Package irverify checks a compiled ir.Document against the structural invariants every compiler must uphold (stable IDs, no dangling references, neutral naming).
Package irverify checks a compiled ir.Document against the structural invariants every compiler must uphold (stable IDs, no dangling references, neutral naming).

Jump to

Keyboard shortcuts

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