representation

package
v1.10.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyLayout

func ApplyLayout(context *codegen.AttributeContext, attribute *expr.AttributeExpr)

ApplyLayout applies the already allocated physical declaration layout. The maps belong to the generation context and use generated Go identity, never schema identity or an occurrence's semantic cache key.

func AttributeTags

func AttributeTags(att *expr.AttributeExpr, t string, optional, omitZero bool) string

AttributeTags computes the struct field tags.

func BuildValuePlan

BuildValuePlan runs at the actual body declaration owner, after layout and view selection. Its policies consume the same tags used by the emitter.

func CustomCodec

func CustomCodec(attribute *expr.AttributeExpr) string

CustomCodec follows the same replacement sites as goTypeDef. Finalization removes recognized matching framework Nullable metadata; ordinary Optional/Nullable/JSONValue layout chosen by the emitter needs no replacement. Any residual authored replacement keeps its external codec contract.

func DocumentTarget

func DocumentTarget(source *service.ValueData, target *expr.AttributeExpr, selected string, independent, schemaOnly bool) *transportir.ValueTarget

func FieldOmission

func FieldOmission(parent *expr.MappedAttributeExpr, name string, attribute *expr.AttributeExpr, pointer, useDefault, jsonPresence bool) (bool, bool)

FieldOmission is shared by emitted tags and semantic target plans.

func MergeJSONOmitOption

func MergeJSONOmitOption(tag, option string) string

MergeJSONOmitOption replaces omission options while preserving the exact ignore tag.

func PrepareEndpointExamples

func PrepareEndpointExamples(endpoint *transportir.Endpoint, generator *expr.ExampleGenerator) error

PrepareEndpointExamples binds every documentation surface after schema plans exist. Callers omit this stage when a custom projector owns raw sampling.

func PrepareService

func PrepareService(source *expr.HTTPServiceExpr, semantic *service.Data) (*transportir.Service, error)

PrepareService captures transport representation ownership before either Go emission or schema registration. An emitter supplies its existing semantic service data. A standalone schema caller supplies nil: only source occurrences are captured, without service generation, example selection or synthesis. Go naming remains a separate operation on the emitter's owned transport graph.

func PrepareServiceExamples

func PrepareServiceExamples(service *transportir.Service, source *expr.HTTPServiceExpr, generator *expr.ExampleGenerator) error

PrepareServiceExamples selects each service-owned representative once. It is an explicit example stage: schema-only preparation never calls it.

func PrepareStandaloneExamples

func PrepareStandaloneExamples(
	attribute *expr.AttributeExpr,
	generator *expr.ExampleGenerator,
) (*transportir.ValueTarget, error)

PrepareStandaloneExamples captures one documentation occurrence for a schema analyzed outside a service method. It selects or synthesizes once and builds separate structural and projecting plans over the same owner.

func PrepareStreamSchema

func PrepareStreamSchema(endpoint *transportir.Endpoint, target *expr.AttributeExpr, inbound bool) *transportir.ValueTarget

PrepareStreamSchema pairs a finalized inline or view-projected stream target with the prepared stream's source and codec. It uses the service's existing declaration layout; neither media labels nor schema shape select the codec.

func PrepareTargetExamples

func PrepareTargetExamples(
	target *transportir.ValueTarget,
	attribute *expr.AttributeExpr,
	generator *expr.ExampleGenerator,
) error

PrepareTargetExamples binds one target's selected authored group, or its retained representative, to exact semantic-owner plans. It never reads raw example values or selects a union branch in the documentation consumer.

func ServiceLayouts

func ServiceLayouts(endpoints []*transportir.Endpoint) (Layout, Layout)

ServiceLayouts allocates the same root-before-nested layout precedence used by emitted server and client body declarations.

func TargetGraph

func TargetGraph(target *expr.AttributeExpr) *expr.AttributeExpr

func ValueTarget

func ValueTarget(source *service.ValueData, target *expr.AttributeExpr, selection string, codec expr.ValueCodec, schemaOnly bool) *transportir.ValueTarget

func WalkUserTypes

func WalkUserTypes(dt expr.DataType, cb func(expr.UserType), seen ...map[string]struct{})

WalkUserTypes visits each generated declaration identity once, including recursive types.

Types

type Layout

type Layout struct {
	// JSONPresence selects explicit JSON field presence.
	JSONPresence map[string]bool
	// Pointer selects pointer storage.
	Pointer map[string]bool
	// UseDefault selects defaulted value storage.
	UseDefault map[string]bool
}

Layout records the physical presence policy allocated to Go declarations. It is generation-local mutable analysis state, not semantic occurrence state.

func NewLayout

func NewLayout() Layout

NewLayout creates an empty physical declaration registry.

func (Layout) Bind

func (l Layout) Bind(context *codegen.AttributeContext)

Bind exposes this registry through the shared attribute context.

func (Layout) Record

func (l Layout) Record(userType expr.UserType, presence, pointer, defaults bool)

Record preserves the highest-priority physical layout for a declaration.

func (Layout) RecordAll

func (l Layout) RecordAll(attribute *expr.AttributeExpr, presence, pointer, defaults bool)

RecordAll records every declaration reachable from an attribute.

func (Layout) RecordNested

func (l Layout) RecordNested(attribute *expr.AttributeExpr, presence, pointer, defaults bool)

RecordNested records descendants without replacing the separately allocated root.

func (Layout) RecordRoot

func (l Layout) RecordRoot(attribute *expr.AttributeExpr, presence, pointer, defaults bool)

RecordRoot records only a named root declaration.

type SSEEncoding

type SSEEncoding struct {
	// Codec identifies the mapped field's physical wire encoding.
	Codec expr.ValueCodec
	// DereferenceString records the emitter's optional native string handling.
	DereferenceString bool
}

SSEEncoding describes the dynamic value passed to EncodeSSEData. Named Go types and pointer/presence wrappers use its JSON fallback, not native dispatch.

func MappedSSEEncoding

func MappedSSEEncoding(typeRef string, pointer bool) SSEEncoding

MappedSSEEncoding classifies an actual emitted Go field type reference and pointer policy. It is shared by SSE payload emission and schema preparation.

Jump to

Keyboard shortcuts

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