Documentation
¶
Index ¶
- Constants
- type Cookie
- type Endpoint
- type Error
- type ErrorRemedy
- type Header
- type Parameter
- type Redirect
- type Request
- type Response
- 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 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" // 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 text 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 {
Name string
Attribute *expr.AttributeExpr
Type expr.DataType
Remedy *ErrorRemedy
}
type ErrorRemedy ¶
type Header ¶
type Header struct {
// Value shares the selected service member and its actual text codec.
Value *ValueTarget
Name string
HTTPName string
Attribute *expr.AttributeExpr
Required bool
PrimitivePointer bool
}
type Request ¶
type Request struct {
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
FormEncoded bool
OptionalBody bool
MustHaveBody bool
SkipBodyEncode bool
IDAttribute string
IDAttributeRequired bool
}
type Response ¶
type Response struct {
Result *expr.AttributeExpr
StreamingResult *expr.AttributeExpr
// Responses holds tagged responses in authored priority order, followed by
// the unique untagged application response checked by expression validation.
Responses []*ResponseStatus
ErrorResponses []*ResponseStatus
HasMixedResults bool
SkipBodyEncode bool
FileResponse bool
IDAttribute string
IDAttributeRequired bool
}
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 from service errors.
Kind ResponseContractCaseKind
// Transport identifies the response protocol.
Transport ResponseContractTransport
// StatusCode is the declared HTTP response status.
StatusCode int
// ErrorName is the declared service error name for error cases.
ErrorName string
// 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 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 {
// 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
StatusCode int
Description string
ContentType string
ContentTypes []string
Headers []*Header
Cookies []*Cookie
Body *expr.AttributeExpr
DocumentBody *expr.AttributeExpr
BodyOrigin string
TagName string
TagValue string
IsError bool
EmitExamples bool
IsWebSocket bool
BinaryBody bool
Meta expr.MetaExpr
Links []*ResponseLink
}
type Security ¶
type Security struct {
Requirements []*expr.SecurityExpr
Parameters []*SecurityParameter
Disabled bool
}
func (*Security) IsParameter ¶
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
}
func BuildService ¶
func BuildService(service *expr.HTTPServiceExpr) *Service
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 ¶
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 ¶
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 ¶
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
// 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
// only to own transport-local authored examples.
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
// 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.