representation

package
v1.10.0-alpha.10 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 15 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 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 DocumentationPlanRequest

func DocumentationPlanRequest(request expr.ValuePlanRequest) expr.ValuePlanRequest

DocumentationPlanRequest captures OpenAPI visibility in the value plan before projection. It preserves supplied emitter policies and hides only fields explicitly excluded from the documentation contract. Runtime plans are unchanged.

func FieldWireNames

func FieldWireNames(attribute *expr.AttributeExpr, name string) (string, string, error)

FieldWireNames returns the actual JSON and form names emitted for a field. A name of "-" excludes that codec; an empty form name is not form-encoded. JSON's empty tag name falls back to the emitted Go field name.

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 Field

type Field struct {
	// Layout owns pointer and wrapper choices used by the declaration emitter.
	Layout encodingmeta.FieldLayout
	// Encoding owns emitted tags and their corresponding JSON observation.
	Encoding FieldEncoding
}

Field is one physical body field and its resolved encoding contract.

func ResolveField

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

ResolveField selects the field layout once for declaration and projection. Callers restore registered named layouts before supplying occurrence flags.

type FieldEncoding

type FieldEncoding struct {
	// Tags is the rendered Go struct tag.
	Tags string
	// JSON describes the tag that is actually present in Tags.
	JSON encodingmeta.JSONField
}

FieldEncoding pairs all codec tags with the shared resolved JSON contract.

func FieldTags

func FieldTags(att *expr.AttributeExpr, name string, optional bool, policy encodingmeta.JSONFieldPolicy) FieldEncoding

FieldTags resolves all codec tags from the actual JSON field policy. Non-JSON codecs retain their existing empty-value omission contract.

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