Documentation
¶
Index ¶
- Constants
- type Cookie
- type Endpoint
- type Error
- type ErrorRemedy
- type Header
- type InformationalResponse
- type MediaVariant
- type Parameter
- type Redirect
- type Request
- type Response
- type ResponseBody
- type ResponseContractAnalysis
- type ResponseContractCase
- type ResponseContractCaseKind
- type ResponseContractCookie
- type ResponseContractHeader
- type ResponseContractLimitation
- type ResponseContractLimitationCode
- type ResponseContractMultipartPart
- type ResponseContractMultipartRequest
- type ResponseContractSSE
- type ResponseContractTransport
- type ResponseContractWebSocket
- type ResponseLink
- type ResponseStatus
- type Route
- type SSE
- type Security
- type SecurityParameter
- type Service
- type StatusBinding
- type Stream
- type ValueExample
- type ValueExampleSet
- type ValueTarget
Constants ¶
const ( // ResponseContractSuccess identifies a successful response contract case. ResponseContractSuccess ResponseContractCaseKind = "success" // ResponseContractError identifies an error response contract case. ResponseContractError ResponseContractCaseKind = "error" // ResponseContractInformational identifies an interim informational // response contract case. ResponseContractInformational ResponseContractCaseKind = "informational" // ResponseContractHTTP identifies an ordinary HTTP response contract. ResponseContractHTTP ResponseContractTransport = "http" // ResponseContractSSE identifies a Server-Sent Events response contract. ResponseContractSSETransport ResponseContractTransport = "sse" // ResponseContractWebSocketTransport identifies a WebSocket response contract. ResponseContractWebSocketTransport ResponseContractTransport = "websocket" // ResponseContractMissingEndpoint indicates that no endpoint was supplied. ResponseContractMissingEndpoint ResponseContractLimitationCode = "missing_endpoint" // ResponseContractMissingIdentity indicates that a stable service or method // identity is unavailable. ResponseContractMissingIdentity ResponseContractLimitationCode = "missing_identity" // ResponseContractJSONRPC indicates that the endpoint uses JSON-RPC rather // than plain HTTP semantics. ResponseContractJSONRPC ResponseContractLimitationCode = "jsonrpc" // ResponseContractStreaming indicates that a streaming endpoint shape is // outside the supported SSE or WebSocket response contract scope. ResponseContractStreaming ResponseContractLimitationCode = "streaming" // ResponseContractRedirect indicates that the endpoint is a redirect. ResponseContractRedirect ResponseContractLimitationCode = "redirect" // ResponseContractMultipart indicates that request construction depends on // multipart handling outside the unary contract case. ResponseContractMultipart ResponseContractLimitationCode = "multipart" // ResponseContractRawRequestBody indicates that the service owns the raw // request body stream. ResponseContractRawRequestBody ResponseContractLimitationCode = "raw_request_body" // ResponseContractRawResponseBody indicates that the service owns the raw // response body stream. ResponseContractRawResponseBody ResponseContractLimitationCode = "raw_response_body" // ResponseContractDuplicateCaseID indicates that distinct response branches // produced the same stable identifier. ResponseContractDuplicateCaseID ResponseContractLimitationCode = "duplicate_case_id" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cookie ¶
type Cookie struct {
// Value shares the selected service member and its actual field codec.
Value *ValueTarget
Name string
HTTPName string
Attribute *expr.AttributeExpr
Required bool
PrimitivePointer bool
Path string
Domain string
MaxAge string
Secure bool
HTTPOnly bool
SameSite expr.CookieSameSiteValue
}
type Endpoint ¶
type Endpoint struct {
Service *Service
Name string
MethodName string
Description string
Meta expr.MetaExpr
MethodMeta expr.MetaExpr
MethodDocs *expr.DocsExpr
Generate bool
MethodGenerate bool
IsJSONRPC bool
Request *Request
Response *Response
Routes []*Route
Stream *Stream
Redirect *Redirect
Security *Security
}
func BuildEndpoint ¶
func BuildEndpoint(endpoint *expr.HTTPEndpointExpr) *Endpoint
type Error ¶
type Error struct {
// JSONRPCCode is present only for a named JSON-RPC error mapping.
JSONRPCCode *int
Name string
Attribute *expr.AttributeExpr
Type expr.DataType
Remedy *ErrorRemedy
}
type ErrorRemedy ¶
type Header ¶
type Header struct {
// Codec is the resolved simple-header grammar.
Codec httpencoding.Codec
// Value shares the selected service member and its actual field codec.
Value *ValueTarget
Name string
HTTPName string
Attribute *expr.AttributeExpr
Required bool
PrimitivePointer bool
}
type InformationalResponse ¶ added in v1.10.0
type InformationalResponse struct {
// Name is the authored declaration name used for typed sender/observer APIs.
Name string
// Response is the common carrier, binding and selector record.
Response *ResponseStatus
}
InformationalResponse names one header-only response occurrence.
type MediaVariant ¶ added in v1.10.0
type MediaVariant struct {
// ContentType is the authored media type or range.
ContentType string
// Branch is the semantic union branch name.
Branch string
// Tag is the generated union discriminator for this branch.
Tag string
// Body retains the branch's effective transport attribute.
Body *expr.AttributeExpr
// Value retains service provenance and the selected branch's representation plan.
Value *ValueTarget
// Form retains the complete form contract for this media occurrence.
Form *expr.HTTPFormEncoding
// Multipart retains the complete multipart contract for this media occurrence.
Multipart *expr.HTTPMultipartEncoding
// Metadata retains occurrence-first media annotations through aliases.
Metadata expr.MetaExpr
}
MediaVariant owns one HTTP representation of a semantic body union branch. Codec, examples and schema plans belong to this occurrence, not to other media that happen to use an equal schema.
type Parameter ¶
type Parameter struct {
// Codec is the resolved grammar shared by runtime and contract projections.
Codec httpencoding.Codec
// Keys identifies this binding's wire namespace.
Keys httpencoding.KeySet
// Value shares the selected service member and its actual field codec.
Value *ValueTarget
Name string
HTTPName string
In string
Attribute *expr.AttributeExpr
Required bool
PrimitivePointer bool
Map bool
MapQueryParams *string
StringSlice bool
Slice bool
}
type Request ¶
type Request struct {
// MediaVariants retains each typed request representation independently.
MediaVariants []*MediaVariant
// ContentType is the admitted authored typed request media, empty when implicit.
ContentType string
// JSONRPCID retains the canonical envelope binding.
JSONRPCID *expr.JSONRPCIDBinding
Payload *expr.AttributeExpr
// BodyValue shares service source authority for the request body.
BodyValue *ValueTarget
// DocumentValue has documentation-only source authority when explicitly authored.
DocumentValue *ValueTarget
// DocumentValues records separately declared documentation media representations.
DocumentValues map[string]*ValueTarget
// StreamingValue shares the service streaming-payload occurrence.
StreamingValue *ValueTarget
Body *expr.AttributeExpr
// DocumentBody is the documentation-only request body schema.
DocumentBody *expr.AttributeExpr
// DocumentContentTypes are the documentation-only request media types.
DocumentContentTypes []string
// DocumentRequired is the documentation-only request body requiredness.
DocumentRequired bool
// StreamingBody is the body of the WebSocket messages of a streaming
// payload, normalized like Body: named non-object types, including
// named unions, are replaced with their underlying types.
StreamingBody *expr.AttributeExpr
// BodyOrigin is the attribute name of the payload attribute selected
// with Body(name), or empty when the body is not one attribute.
BodyOrigin string
// BodyOriginKey is the object key of the payload attribute that
// BodyOrigin names, such as "v:x" for "v". Requiredness, defaults
// and pointer semantics of the attribute are looked up by this key.
BodyOriginKey string
PathParams []*Parameter
QueryParams []*Parameter
Headers []*Parameter
Cookies []*Parameter
MapQueryParams *string
Multipart bool
// MultipartEncoding retains the complete occurrence-owned multipart contract.
MultipartEncoding *expr.HTTPMultipartEncoding
FormEncoded bool
// Form retains the complete occurrence-owned form body encoding.
Form *expr.HTTPFormEncoding
OptionalBody bool
MustHaveBody bool
SkipBodyEncode bool
}
type Response ¶
type Response struct {
Result *expr.AttributeExpr
StreamingResult *expr.AttributeExpr
// Responses retains validated success occurrences in selection order:
// tagged branches precede untagged branches; status-selected branches retain
// declaration order and are selected by the captured selector keys.
Responses []*ResponseStatus
ErrorResponses []*ResponseStatus
// Informational retains every declaration, independent of observer registration.
Informational []*InformationalResponse
// FinalKeys is the detached complete final-selector inventory.
FinalKeys []expr.HTTPStatusSelector
// InformationalKeys is the detached observation-selector inventory, not emission domains.
InformationalKeys []expr.HTTPStatusSelector
// StatusSelected selects successes through the native status field.
StatusSelected bool
// NoSuccess records an explicitly error-only endpoint.
NoSuccess bool
HasMixedResults bool
SkipBodyEncode bool
FileResponse bool
IDAttribute string
IDAttributeRequired bool
}
type ResponseBody ¶ added in v1.10.0
type ResponseBody struct {
// Body is the finalized physical body derived from the whole unary Result.
Body *expr.AttributeExpr
// ContentType is an authored encoder selection, empty for negotiation.
ContentType string
// ContentTypes lists this body's advertised media independently of SSE.
ContentTypes []string
// MediaVariants retains any authored union media contracts.
MediaVariants []*MediaVariant
// BodyValue binds the body to the existing service Result occurrence.
BodyValue *ValueTarget
// BodyValues retains its per-media preparation contexts.
BodyValues map[string]*ValueTarget
}
ResponseBody retains one physical body representation and its captured source authority, without duplicating response status or metadata ownership.
type ResponseContractAnalysis ¶ added in v1.8.0
type ResponseContractAnalysis struct {
// Cases lists the declared response branches in design order.
Cases []*ResponseContractCase
// Limitations explains why cases could not be produced.
Limitations []ResponseContractLimitation
}
ResponseContractAnalysis describes the exhaustive response cases for a supported HTTP endpoint. Cases is empty when Limitations is not.
func AnalyzeResponseContractCases ¶ added in v1.8.0
func AnalyzeResponseContractCases(endpoint *Endpoint) *ResponseContractAnalysis
AnalyzeResponseContractCases builds deterministic, exhaustive descriptors for the declared response branches of a supported HTTP endpoint.
func (*ResponseContractAnalysis) Supported ¶ added in v1.8.0
func (a *ResponseContractAnalysis) Supported() bool
Supported reports whether the endpoint is inside the HTTP response contract analysis scope.
type ResponseContractCase ¶ added in v1.8.0
type ResponseContractCase struct {
// ID is stable across generation when the service contract is unchanged.
ID string
// Kind distinguishes successful results, informational responses and
// service errors.
Kind ResponseContractCaseKind
// Transport identifies the response protocol.
Transport ResponseContractTransport
// Selector is the declared status selector that owns the response.
Selector expr.HTTPStatusSelector
// Domain lists the HTTP statuses the response may use. An exact
// selector has its single status as the domain.
Domain []int
// ErrorName is the declared service error name for error cases.
ErrorName string
// ErrorNameFromStatus identifies responses that omit Loom-Error.
ErrorNameFromStatus bool
// TagName is the result field selecting a tagged success response.
TagName string
// TagValue is the result field value selecting a tagged success response.
TagValue string
// ContentTypes lists the declared response media types.
ContentTypes []string
// HasBody reports whether the response contract asserts a body media type.
HasBody bool
// Headers lists the declared response header assertions.
Headers []ResponseContractHeader
// Cookies lists the declared response cookie assertions.
Cookies []ResponseContractCookie
// Multipart describes the designed multipart request, if present.
Multipart *ResponseContractMultipartRequest
// SSE describes stream assertions for an SSE success case.
SSE *ResponseContractSSE
// WebSocket describes stream assertions for a WebSocket success case.
WebSocket *ResponseContractWebSocket
}
ResponseContractCase describes one declared HTTP response branch.
type ResponseContractCaseKind ¶ added in v1.8.0
type ResponseContractCaseKind string
ResponseContractCaseKind identifies whether a contract case exercises a successful result, an informational response or a service error.
type ResponseContractCookie ¶ added in v1.8.0
type ResponseContractCookie struct {
// Name is the result or error attribute mapped to the cookie.
Name string
// HTTPName is the wire cookie name.
HTTPName string
// Required reports whether the mapped attribute is required.
Required bool
// Path is the declared cookie Path attribute.
Path string
// Domain is the declared cookie Domain attribute.
Domain string
// MaxAge is the declared cookie Max-Age attribute.
MaxAge string
// Secure reports whether the cookie is restricted to secure transports.
Secure bool
// HTTPOnly reports whether scripts are denied cookie access.
HTTPOnly bool
// SameSite is the declared cookie SameSite policy.
SameSite expr.CookieSameSiteValue
}
ResponseContractCookie describes a declared response cookie assertion.
type ResponseContractHeader ¶ added in v1.8.0
type ResponseContractHeader struct {
// Name is the result or error attribute mapped to the header.
Name string
// HTTPName is the wire header name.
HTTPName string
// Required reports whether the mapped attribute is required.
Required bool
}
ResponseContractHeader describes a declared response header assertion.
type ResponseContractLimitation ¶ added in v1.8.0
type ResponseContractLimitation struct {
// Code identifies the unsupported endpoint feature.
Code ResponseContractLimitationCode
// Detail explains the limitation for diagnostics.
Detail string
}
ResponseContractLimitation explains why an endpoint is outside the response contract analysis scope.
type ResponseContractLimitationCode ¶ added in v1.8.0
type ResponseContractLimitationCode string
ResponseContractLimitationCode identifies an endpoint feature that the HTTP response contract analysis intentionally does not support.
type ResponseContractMultipartPart ¶ added in v1.8.0
type ResponseContractMultipartPart struct {
// Name is the multipart form field name.
Name string
// MediaType is the default media type for the part value.
MediaType string
// Required reports whether the request body requires the part.
Required bool
}
ResponseContractMultipartPart describes one designed multipart field.
type ResponseContractMultipartRequest ¶ added in v1.8.0
type ResponseContractMultipartRequest struct {
// ContentType is the request media type.
ContentType string
// Parts lists the designed multipart fields in body order.
Parts []ResponseContractMultipartPart
}
ResponseContractMultipartRequest describes a multipart request shape that can be represented without an application-owned codec.
type ResponseContractSSE ¶ added in v1.8.0
type ResponseContractSSE struct {
// Direction is the designed stream direction.
Direction string
// MessageType is the designed streaming result type name.
MessageType string
// DataField is the result field encoded into SSE data, if any.
DataField string
// DataEncoding identifies whether SSE data is JSON or plain text.
DataEncoding string
// IDField is the result field encoded into SSE id, if any.
IDField string
// EventField is the result field encoded into SSE event, if any.
EventField string
// RetryField is the result field encoded into SSE retry, if any.
RetryField string
// IDRequired reports whether every observed event must include an ID.
IDRequired bool
// EventTypeRequired reports whether every observed event must include a type.
EventTypeRequired bool
// EventTypes lists allowed projection discriminator values, if constrained.
EventTypes []string
// Terminal identifies the expected stream completion behavior.
Terminal string
}
ResponseContractSSE describes a generated Server-Sent Events contract.
type ResponseContractTransport ¶ added in v1.8.0
type ResponseContractTransport string
ResponseContractTransport identifies the wire protocol validated by a response contract case.
type ResponseContractWebSocket ¶ added in v1.8.0
type ResponseContractWebSocket struct {
// Direction is the designed stream direction.
Direction string
// InboundMessageType is the designed client-to-server message type name.
InboundMessageType string
// OutboundMessageType is the designed server-to-client message type name.
OutboundMessageType string
// HandshakeHeaders lists required WebSocket upgrade response headers.
HandshakeHeaders []string
// Terminal identifies the expected stream completion behavior.
Terminal string
}
ResponseContractWebSocket describes a generated WebSocket contract.
type ResponseLink ¶
type ResponseStatus ¶
type ResponseStatus struct {
// Unary is the separate whole Result representation of typed mixed success.
Unary *ResponseBody
// Occurrence identifies the validated response across semantic capture and backends.
Occurrence *expr.HTTPResponseExpr
// Carrier is the native result, error, handshake or informational source.
Carrier *expr.AttributeExpr
// Handshake marks metadata owned separately from the stream event.
Handshake bool
// StatusField is the resolved native status binding, or nil for literal-only responses.
StatusField *StatusBinding
// Required retains detached validation-time requirements by native result view.
Required map[string][]string
// AuthoredBody is read-only pre-finalization provenance, not another example source.
AuthoredBody *expr.AttributeExpr
// MediaVariants retains each typed response representation independently.
MediaVariants []*MediaVariant
// BodyValue carries the effective result or error occurrence.
BodyValue *ValueTarget
// BodyValues binds each advertised media label to the actual server encoder
// authority. A mapped header alone does not select that encoder.
BodyValues map[string]*ValueTarget
// DocumentValue carries the documentation body authority.
DocumentValue *ValueTarget
// DocumentValues records per-media schema authority: actual encoder plans
// for inherited bodies, declared media contracts for independent bodies.
DocumentValues map[string]*ValueTarget
// IndependentDocumentBody marks an authored OpenAPIBody contract.
IndependentDocumentBody bool
Error *Error
// Selector is the authored HTTP status owner; JSON-RPC errors leave it unset.
Selector expr.HTTPStatusSelector
// Domain is the detached validation-time domain captured by the expression.
Domain []int
Description string
ContentType string
ContentTypes []string
Headers []*Header
Cookies []*Cookie
Body *expr.AttributeExpr
DocumentBody *expr.AttributeExpr
BodyOrigin string
// Tag binds response selection to a validated semantic result field.
Tag *expr.HTTPResponseTag
IsError bool
EmitExamples bool
BinaryBody bool
Meta expr.MetaExpr
Links []*ResponseLink
// ErrorSelector records the effective JSON-RPC ErrorName path.
ErrorSelector []string
// StatusErrorName is the service field reconstructed from the error
// name selected by a unique HTTP status, or empty for wire identity.
StatusErrorName string
}
type Route ¶
type Security ¶
type Security struct {
// CredentialBindings retains all effective credential source roles and wire slots.
CredentialBindings []expr.HTTPCredentialBinding
Requirements []*expr.SecurityExpr
Parameters []*SecurityParameter
Disabled bool
}
func (*Security) IsParameter ¶ added in v1.10.0
IsParameter reports whether the exact HTTP location and name identify a security credential parameter. A nil Security has no credential parameters.
type SecurityParameter ¶
type Service ¶
type Service struct {
Name string
Meta expr.MetaExpr
ServiceMeta expr.MetaExpr
Generate bool
ServiceGenerate bool
Endpoints []*Endpoint
// SchemaTypeLayouts is the immutable service registry shared by schema
// targets, including subsequently projected stream messages.
SchemaTypeLayouts *codegen.TypeLayouts
}
func BuildService ¶
func BuildService(service *expr.HTTPServiceExpr) *Service
type StatusBinding ¶ added in v1.10.0
type StatusBinding struct {
// Name is the resolved native object key, including its mapped suffix.
Name string
// Attribute is the native field, not a projected wire-body field.
Attribute *expr.AttributeExpr
// Value retains the field's effective semantic occurrence when prepared.
Value *ValueTarget
}
StatusBinding identifies the actual native field that stores an HTTP status.
type Stream ¶
type Stream struct {
// RequestValue and ResponseValue carry stream message source authority.
RequestValue *ValueTarget
ResponseValue *ValueTarget
Kind expr.StreamKind
Direction string
IsStreaming bool
Transport string
IsSSE bool
IsWebSocket bool
HasMixedResults bool
RequestHasBody bool
RequestPayload *expr.AttributeExpr
RequestMessage *expr.AttributeExpr
ResponseMessage *expr.AttributeExpr
HandshakeMethod string
HandshakeStatus int
HandshakeContent string
SSE *SSE
}
type ValueExample ¶ added in v1.10.0
type ValueExample struct {
// Source owns the occurrence and resolved or synthesized result.
Source *service.ValueData
// Authored is the opaque authored source, or zero for synthesis.
Authored expr.ValueSource
// Plan is the matching target representation for Source.Occurrence.
Plan expr.ValuePlan
// Summary is detached authored metadata.
Summary string
// Description is detached authored metadata.
Description string
// Meta is detached authored metadata.
Meta expr.MetaExpr
}
ValueExample is one semantic example and its exact target association. Authored remains opaque; consumers project Source.Example through Plan.
type ValueExampleSet ¶ added in v1.10.0
type ValueExampleSet struct {
// Examples retains an authored group in declaration order.
Examples []ValueExample
// Representative is the selected authored entry or synthesized value.
Representative *ValueExample
// Prepared distinguishes an empty or suppressed set from missing analysis.
Prepared bool
}
ValueExampleSet is the complete prepared example state for one schema occurrence. An empty prepared set suppresses consumer-side fallback.
type ValueTarget ¶ added in v1.10.0
type ValueTarget struct {
// Source is the shared effective service occurrence and selected result.
Source *service.ValueData
// Anchor retains the original service occurrence when a transport-local
// authored group owns Source.
Anchor *service.ValueData
// Selection is an authored member path within Source.
Selection []string
// Codec is selected by actual transport behavior, never media labels.
Codec expr.ValueCodec
// SSEDataField identifies the physical field passed to EncodeSSEData.
// Its codec is derived from the emitted type and presence layout.
SSEDataField string
// ProjectionContext is the captured body layout used to build Plan.
// Its immutable service registry is shared; local override maps are
// detached from mutable generation registries.
// Consumers treat the snapshot as read-only; rebuilding replaces it.
ProjectionContext *codegen.AttributeContext
// Plan is populated only after actual emitter policies are available.
Plan expr.ValuePlan
// AnchorPlan projects values owned by Anchor through this target.
AnchorPlan expr.ValuePlan
// ExampleOccurrence is the independently captured effective target used
// for schema annotations and transport-local authored examples. Runtime
// targets without a local authored root example leave it zero.
ExampleOccurrence expr.ValueOccurrence
// ExamplePlan projects values owned by ExampleOccurrence through this target.
ExamplePlan expr.ValuePlan
// Examples retains the selected authored group in declaration order.
Examples []ValueExample
// Representative retains the last entry of Examples when an authored
// group applies; otherwise it retains the selected or synthesized result.
Representative *ValueExample
// ExamplesPrepared reports that the explicit preparation stage ran, even
// when suppression or projection failure leaves no emitted value.
ExamplesPrepared bool
// ExampleSets binds each schema-plan node to the examples prepared for
// that exact documentation occurrence. Records retain their own semantic
// owners and projection plans; schema traversal never reselects a source.
ExampleSets map[expr.ValuePlanNode]*ValueExampleSet
// AnnotationsPrepared reports successful preparation independently of optional examples.
AnnotationsPrepared bool
// Annotations retains checked required values for each exact schema node.
Annotations map[expr.ValuePlanNode]expr.JSONSchemaAnnotations
// Error retains a plan construction failure for consuming analysis.
Error error
// Boundary records an external codec whose guarantees are not built-in JSON.
Boundary string
// Documentary excludes runtime decoding claims for a documentation-only target.
Documentary bool
}
ValueTarget retains source provenance and the actual target codec. A boundary or error is explicit; an absent plan never implies validity.