ast

package
v2.932.6 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: AGPL-3.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AnnotationTypeJSON              = "json"
	AnnotationTypeSecurity          = "security"
	AnnotationTypeOperationSecurity = "opSecurity"
	AnnotationTypeParam             = "param"
	AnnotationTypeRequestWrapper    = "requestWrapper"
	AnnotationTypeRequest           = "request"
	AnnotationTypeMultipartForm     = "multipartForm"
	AnnotationTypeForm              = "form"
	AnnotationTypeEncoding          = "encoding"
	AnnotationTypeResponse          = "response"
	AnnotationTypeNeedsCasing       = "needsCasing"
)
View Source
const (
	ParamTypeQueryParam = "queryParam"
	ParamTypePathParam  = "pathParam"
	ParamTypeHeader     = "header"
)
View Source
const (
	ASTVersion       = "0.3.0"
	ErrTerminateWalk = generatorErrors.Error("walk terminated")
)
View Source
const (
	ErrTypeMismatch               = generatorErrors.Error("type mismatch")
	ErrEnumMismatch               = generatorErrors.Error("enum mismatch")
	ErrFieldMismatch              = generatorErrors.Error("field mismatch")
	ErrAnnotationMismatch         = generatorErrors.Error("annotation mismatch")
	ErrItemTypeMismatch           = generatorErrors.Error("item type mismatch")
	ErrScopeMismatch              = generatorErrors.Error("scope mismatch")
	ErrUnionDiscriminatorMismatch = generatorErrors.Error("union discriminator mismatch")
	ErrUnionTypeMismatch          = generatorErrors.Error("union type mismatch")
)
View Source
const (
	InternalTypeRequest  = "request"
	InternalTypeResponse = "response"
)
View Source
const HumanizedRequestBody = "RequestBody"
View Source
const HumanizedResponseBody = "ResponseBody"

Variables

View Source
var SanitizeFieldName = sanitizeFieldNameWithCache()

Functions

func AreEquivalentRequirements

func AreEquivalentRequirements(a, b []SecurityRequirement) bool

func FieldExists

func FieldExists(ff Fields, field *FieldDef, sanitize bool) (bool, int)

func GetRegistrationID

func GetRegistrationID(scope Scope, contextStack ContextStack, originalName string, opts ...RegistrationIDOption) string

This has been factored out so that it can be use to find pre-built types in the type register / other caches

func HasParams

func HasParams(fields Fields) bool

func HasPathParams

func HasPathParams(fields Fields) bool

func TerraformGoTypeName

func TerraformGoTypeName(name string) string

TerraformGoTypeName sanitizes a name for use as a Go type name by applying SanitizeName and converting to GoPascal case with acronym preservation. Used for both entity type names and symbol names in generated Terraform provider code.

func TerraformSymbolName

func TerraformSymbolName(t *TypeDef) string

TerraformSymbolName derives the candidate symbol name for a TypeDef by sanitizing the TypeDef name via TerraformGoTypeName and stripping Input/Output suffixes when the TypeDef is marked as an input or output type respectively.

func YAMLToJSONCompatibleGoType

func YAMLToJSONCompatibleGoType(node *yaml.Node) (any, error)

Types

type AST

type AST struct {
	ASTVersion string

	// Given that this AST is primarily concerned with producing an AST
	// for the *generated* SDK, there are often cases where we don't want
	// to pollute the resulting AST with lower level OpenAPI document structures.
	// For the docs product where we produce a "view model" AST, we still need to
	// access these underlying constructs so we embed the OpenAPI document here.
	OpenAPIDocument *openapi.OpenAPI
	MainSDK         *SDK
	Webhooks        *sequencedmap.Map[string, []Operation]
	// Arazzo contains test-generation workflow graph data derived from
	// x-speakeasy-test Arazzo documents.
	Arazzo           *Arazzo
	Tests            *Tests
	Components       *sequencedmap.Map[string, *TypeDef]
	UsedFeatures     map[string]bool
	UsedTypes        map[string]bool
	BucketedTypes    BucketedTypes
	OperationServers *sequencedmap.Map[string, *Servers]
	PublicExports    *PublicExports

	// Terraform Provider as gathered from various x-speakeasy-entity*
	// extensions across the source document. Only set when generation target
	// is "terraform".
	TerraformProvider *TerraformProvider
}

func NewAST

func NewAST() *AST

func (AST) EntityOperations

func (a AST) EntityOperations() (*sequencedmap.Map[string, *Operation], error)

Returns all operations which are entity operations.

func (AST) MarshalYAML

func (a AST) MarshalYAML() (any, error)

func (*AST) Resolve

func (a *AST) Resolve()

func (*AST) ResolveTypeDef

func (a *AST) ResolveTypeDef(t *TypeDef) *TypeDef

func (*AST) Walk

func (a *AST) Walk(visit VisitFn) error

func (*AST) WalkAnnotations

func (a *AST) WalkAnnotations(annotations Annotations, parents []Node, visit VisitFn, visited map[string]bool) error

func (*AST) WalkArguments

func (a *AST) WalkArguments(arguments *Arguments, parents []Node, visit VisitFn, visited map[string]bool) error

func (*AST) WalkComment

func (a *AST) WalkComment(comment *Comment, parents []Node, visit VisitFn, visited map[string]bool) error

func (*AST) WalkContextStack

func (a *AST) WalkContextStack(stack ContextStack, parents []Node, visit VisitFn, visited map[string]bool) error

func (*AST) WalkDiscriminator

func (a *AST) WalkDiscriminator(discriminator *Discriminator, parents []Node, visit VisitFn, visited map[string]bool) error

func (*AST) WalkDiscriminatorMapping

func (a *AST) WalkDiscriminatorMapping(dm *DiscriminatorMapping, parents []Node, visit VisitFn, visited map[string]bool) error

func (*AST) WalkEnum

func (a *AST) WalkEnum(enum *Enum, parents []Node, visit VisitFn, visited map[string]bool) error

func (*AST) WalkExamples

func (a *AST) WalkExamples(examples Examples, parents []Node, visit VisitFn, visited map[string]bool) error

func (*AST) WalkExtendedComment

func (a *AST) WalkExtendedComment(ec *ExtendedComment, parents []Node, visit VisitFn, visited map[string]bool) error

func (*AST) WalkExternalDocs

func (a *AST) WalkExternalDocs(ed *ExternalDocs, parents []Node, visit VisitFn, visited map[string]bool) error

func (*AST) WalkFieldDef

func (a *AST) WalkFieldDef(field *FieldDef, parents []Node, visit VisitFn, visited map[string]bool) error

func (*AST) WalkOperation

func (a *AST) WalkOperation(op *Operation, parents []Node, visit VisitFn, visited map[string]bool) error

func (*AST) WalkOperationExtensions

func (a *AST) WalkOperationExtensions(extensions *OperationExtensions, parents []Node, visit VisitFn, visited map[string]bool) error

func (*AST) WalkParam

func (a *AST) WalkParam(param *Param, parents []Node, visit VisitFn, visited map[string]bool) error

func (*AST) WalkRequest

func (a *AST) WalkRequest(req *Request, parents []Node, visit VisitFn, visited map[string]bool) error

func (*AST) WalkRequestParams

func (a *AST) WalkRequestParams(params *RequestParams, parents []Node, visit VisitFn, visited map[string]bool) error

func (*AST) WalkResponse

func (a *AST) WalkResponse(response *Response, parents []Node, visit VisitFn, visited map[string]bool) error

func (*AST) WalkResponseBodyContent

func (a *AST) WalkResponseBodyContent(content *ResponseBodyContent, parents []Node, visit VisitFn, visited map[string]bool) error

func (*AST) WalkSDK

func (a *AST) WalkSDK(sdk *SDK, parents []Node, visit VisitFn, visited map[string]bool) error

func (*AST) WalkServer

func (a *AST) WalkServer(server *Server, parents []Node, visit VisitFn, visited map[string]bool) error

func (*AST) WalkServerVariable

func (a *AST) WalkServerVariable(variable *ServerVariable, parents []Node, visit VisitFn, visited map[string]bool) error

func (*AST) WalkServers

func (a *AST) WalkServers(servers *Servers, parents []Node, visit VisitFn, visited map[string]bool) error

func (*AST) WalkSubResponse

func (a *AST) WalkSubResponse(resp *SubResponse, parents []Node, visit VisitFn, visited map[string]bool) error

func (*AST) WalkTypeDef

func (a *AST) WalkTypeDef(t *TypeDef, parents []Node, visit VisitFn, visited map[string]bool) error

func (*AST) WalkValidations

func (a *AST) WalkValidations(validations *Validations, parents []Node, visit VisitFn, visited map[string]bool) error

type Annotation

type Annotation interface {
	// Should return a deep copy of the Annotation.
	Clone() Annotation

	// Should return true if the Annotation is equal to the given Annotation.
	IsEqual(a Annotation) bool

	// Should return true if the Annotation is of the same concrete type as the given Annotation.
	IsSameType(a Annotation) bool

	// Should return true if the Annotation is of the given type.
	IsType(t AnnotationType) bool

	// Should return the type of the Annotation.
	Type() AnnotationType
}

Annotation represents metadata that controls serialization and deserialization for a Field associated with a Type

type AnnotationType

type AnnotationType string

AnnotationType represents the various types of annotation

type Annotations

type Annotations []Annotation

Collection of Annotations.

func (*Annotations) Append

func (aa *Annotations) Append(anno Annotation)

func (Annotations) Clone

func (a Annotations) Clone() Annotations

Clone creates a deep copy of the Annotations

func (Annotations) Find

func (aa Annotations) Find(anno Annotation) (int, Annotation)

func (Annotations) Get

func (Annotations) GetParam

func (aa Annotations) GetParam() *ParamAnnotation

Returns the ParamAnnotation from the Annotations if present.

func (Annotations) Has

func (aa Annotations) Has(typ AnnotationType) bool

func (Annotations) HasEqual

func (aa Annotations) HasEqual(anno Annotation) bool

func (Annotations) MarshalYAML

func (a Annotations) MarshalYAML() (any, error)

func (Annotations) Match

func (a Annotations) Match(matchers Matchers) error

func (*Annotations) UnmarshalYAML

func (a *Annotations) UnmarshalYAML(n *yaml.Node) error

type AnyValue

type AnyValue struct {
	Value any
}

func (*AnyValue) Clone

func (v *AnyValue) Clone() *AnyValue

Clone creates a shallow copy of the AnyValue

type Arazzo

type Arazzo struct {
	// Workflows are reusable workflow definitions keyed by workflow name and used
	// by templates to resolve workflow-step references.
	Workflows []*ArazzoWorkflow
}

Arazzo contains test-generation data derived from an input Arazzo document.

This keeps Arazzo-specific graph data namespaced under AST.Arazzo rather than flattening it onto the top-level AST alongside general SDK/OpenAPI fields.

type ArazzoInvocationContext

type ArazzoInvocationContext struct {
	SDK       *SDK
	Operation *Operation
	StepIdx   int
	StepID    string
}

ArazzoInvocationContext represents generic invocation metadata for an operation step.

type ArazzoOperationStep

type ArazzoOperationStep struct {
	ArazzoStepBase

	Invocation *ArazzoInvocationContext
	// The context of the test operation, this is used to provide details for things such as security, server_url etc
	UsageContext *UsageContext
	// Operation and StepIdx are transitional compatibility fields while consumers migrate to Invocation.
	// Prefer Invocation.Operation and Invocation.StepIdx in new code.
	Operation *Operation
	// StepIdx is the original index of this step in the source Arazzo workflow.
	//
	// Two different operation step nodes can reference the same operation but
	// have different StepIdx values based on which step in the workflow they are in.
	StepIdx int
	// Security is an example of the security that should be used for the operation
	Security *Example
	// ResponseContentType is the content type of the response that should be used for the operation
	ResponseContentType string
}

ArazzoOperationStep represents an operation step node and its required context/metadata for test generation.

func GetArazzoOperationStep

func GetArazzoOperationStep(step ArazzoStep) *ArazzoOperationStep

type ArazzoStep

type ArazzoStep interface {
	GetType() ArazzoStepType
	GetStepID() string
}

type ArazzoStepBase

type ArazzoStepBase struct {
	Type string
	// StepID is the ID of the step in an Arazzo workflow that this step is in
	StepID string
}

func (*ArazzoStepBase) GetStepID

func (t *ArazzoStepBase) GetStepID() string

func (*ArazzoStepBase) GetType

func (t *ArazzoStepBase) GetType() ArazzoStepType

type ArazzoStepType

type ArazzoStepType string
const (
	ArazzoStepTypeOperation ArazzoStepType = "operation"
	ArazzoStepTypeWorkflow  ArazzoStepType = "workflow"
)

type ArazzoWorkflow

type ArazzoWorkflow struct {
	Name        string
	Description string
	Server      string
	Security    *Example
	Steps       []ArazzoStep
	Inputs      *FieldDef
	Outputs     *FieldDef
}

ArazzoWorkflow represents a reusable workflow definition.

type ArazzoWorkflowStep

type ArazzoWorkflowStep struct {
	ArazzoStepBase

	// StepIdx is the original index of this step in the source Arazzo workflow.
	//
	// This must be used for example-name reconstruction because generated AST
	// step slices can omit unsupported steps (for example webhooks), which would
	// otherwise skew index-based lookups.
	StepIdx int
	// WorkflowID references the invoked workflow definition by name.
	WorkflowID string
	// Workflow is the resolved workflow definition when available.
	Workflow *ArazzoWorkflow
}

ArazzoWorkflowStep represents a step that invokes another workflow definition.

func GetArazzoWorkflow

func GetArazzoWorkflow(step ArazzoStep) *ArazzoWorkflowStep

type Arguments

type Arguments struct {
	// Flattening is the strategy used to flatten the request into a list of
	// SDK method arguments.
	// - "none": no flattening is applied. Sorted _may_ contain up to two fields
	//   representing the request and security inputs.
	//
	// - "all": parameters and request body fields have been exploded into the
	//   Sorted list. This implies that an operation contains both parameters
	//   _and_ a body. Security field may also be included depending on
	//   per-operation security requirements.
	//
	// - "params": parameters have been exploded into the Sorted and there may
	//   be a single field representing the request body if an operation has a
	//   body. Security field may also be included depending on per-operation
	//   security requirements.
	//
	// - "body": request body has been exploded into the Sorted list. This also
	//   means that the operation does not have parameters. Security field may
	//   also be included depending on per-operation security requirements.
	Flattening string `yaml:",omitempty"` // "none", "all", "body", "params"

	// Sorted is a list of the arguments to template in SDK methods. It includes
	// per-operation security, request parameters, and request body fields
	// depending on the flattening strategy. The ordering of fields is based
	// on a combination of criteria such as optionality and whether a field
	// represents additional properties.
	Sorted Fields `yaml:",omitempty"`

	// ParamFields is the subset of fields in Sorted that contains all request
	// parameters if the request is flattened. This will be an empty slice if
	// there are no parameters or the request is not flattened.
	ParamFields Fields `yaml:",omitempty"`

	// BodyFields is the subset of fields in Sorted that contains all request
	// body fields if the body is flattened. This will be an empty slice if the
	// body is not flattened.
	//
	// NOTE: This field is mutually exclusive with `BodyField`. Only one of them
	// is populated based on the flattening strategy.
	BodyFields Fields `yaml:",omitempty"`

	// BodyField is set when the request body is flattened. It is used to
	// determine how to reconstruct the request model.
	//
	// NOTE: This field is mutually exclusive with `BodyFields`. Only one of
	// them is populated based on the flattening strategy.
	BodyField *FieldDef `yaml:",omitempty"`

	Warning error `yaml:",omitempty"`
}

Arguments provides a list of fields that is used to generate arguments for SDK methods including informing on whether or not the fields were generated as a result of parameter and/or body flattening. The details provided can be used to rehydrate request models for use in method bodies.

func NewArguments

func NewArguments(op *Operation, security *FieldDef, options ArgumentsOptions) (*Arguments, error)

func (Arguments) IsBodyField

func (a Arguments) IsBodyField(f *FieldDef) bool

func (Arguments) IsFieldInBody

func (a Arguments) IsFieldInBody(f *FieldDef) bool

func (Arguments) IsFieldInParams

func (a Arguments) IsFieldInParams(f *FieldDef) bool

func (*Arguments) Match

func (a *Arguments) Match(matchers Matchers) error

type ArgumentsOptions

type ArgumentsOptions struct {
	// ParamFlatteningBodyFirst affects whether param fields come before the
	// request body field or the other way around.
	ParamFlatteningParamsFirst bool

	// MaxMethodParams is the maximum number of parameters that a method can
	// have and still be eligible for parameter flattening.
	MaxMethodParams int

	// FlattenRequest indicates if request body fields should be flattened.
	FlattenRequest bool

	// In many languages, for convenience we don't render const fields in
	// models / arguments because we just go ahead and fill it in
	// In Typescript, due to structural typing this can cause issues in unions
	ConstFieldsAlwaysOptional *bool
}

type Assertion

type Assertion struct {
	// Type of assertion, such as the operator in a condition.
	Type AssertionType

	// Target type of the assertion, such as status code or response body.
	TargetType AssertionTarget

	// Target of the assertion, such as the computed FieldDef.
	Target any

	// Value to assert against.
	Value any
}

Describes an assertion.

func (*Assertion) Clone

func (a *Assertion) Clone() *Assertion

Creates a deep copy of the Assertion.

type AssertionTarget

type AssertionTarget string

Describes the target of an assertion, such as status code or response body.

const (
	AssertionTargetResponseBody AssertionTarget = "responseBody"
	AssertionTargetStatusCode   AssertionTarget = "statusCode"
)

func AssertionTargetFromExpression

func AssertionTargetFromExpression(expr expression.Expression) (AssertionTarget, error)

Converts an Expression to an AssertionTarget.

type AssertionType

type AssertionType string

Describes the assertion type, such as the operator in a condition.

const (
	AssertionTypeEqual    AssertionType = "equal"
	AssertionTypeNotEqual AssertionType = "notEqual"
	AssertionTypeRegex    AssertionType = "regex"
)

func AssertionTypeFromArazzoOperator

func AssertionTypeFromArazzoOperator(operator criterion.Operator) (AssertionType, error)

Converts an Arazzo criterion operator to an AssertionType.

type Assertions

type Assertions []*Assertion

Collection of Assertion.

func (Assertions) Clone

func (a Assertions) Clone() Assertions

Creates a deep copy of the Assertions.

func (Assertions) FindAssertionByTarget

func (a Assertions) FindAssertionByTarget(target AssertionTarget) *Assertion

If found, returns the Assertion with given AssertionTarget.

type BaseOperation

type BaseOperation struct {
	ID                        string               `yaml:",omitempty"` // The unique ID of the operation
	OriginalID                string               `yaml:",omitempty"` // The original ID of the operation this won't be mutated by having multiple request bodies for example
	Request                   *Request             `yaml:",omitempty"` // The request of the operation
	Response                  *Response            `yaml:",omitempty"` // The response of the operation
	UsesUserAgentHeader       bool                 `yaml:",omitempty"` // Whether the operation uses the User-Agent header
	SerializationMethod       *SerializationMethod `yaml:",omitempty"` // The serialization method for the operation
	SerializationMethodSuffix string               `yaml:",omitempty"` // The serialization method suffix for the operation if its been split into multiple methods
}

BaseOperation represents an operation that could be a method, webhook or callback

func (*BaseOperation) NewPollingFromExtensionsPolling

func (o *BaseOperation) NewPollingFromExtensionsPolling(extensionConfiguration *extensions.Polling) (*Polling, error)

Creates a new Polling from the given extension configuration.

type BucketedTypes

type BucketedTypes = *sequencedmap.Map[string, *sequencedmap.Map[string, TypeDefs]]

func NewBucketedTypes

func NewBucketedTypes() BucketedTypes

type Comment

type Comment struct {
	Summary                string                      `yaml:",omitempty"`
	Description            string                      `yaml:",omitempty"`
	ExternalDocs           *ExternalDocs               `yaml:",omitempty"`
	ExtendedComments       map[string]*ExtendedComment `yaml:",omitempty"`
	Deprecated             bool                        `yaml:",omitempty"`
	DeprecationReplacement string                      `yaml:",omitempty"`
	DeprecationMessage     string                      `yaml:",omitempty"`
}

Comment represents a comment that is associated with a sdk, type or operation

func (*Comment) Clone

func (c *Comment) Clone() *Comment

Clone creates a deep copy of the Comment

func (*Comment) IsEmpty

func (c *Comment) IsEmpty() bool

IsEmpty returns true if the comment has no meaningful content

func (*Comment) Match

func (c *Comment) Match(matchers Matchers) error

func (*Comment) Merge

func (c *Comment) Merge(other *Comment)

Merges the given Comment into this Comment. The algorithm adds data from the given Comment to this Comment where it is undefined. Where there is conflicting data, this Comment's data is preserved or otherwise delegated to data-specific merge functionality. It does not remove any data from this Comment.

type ContextFrame

type ContextFrame struct {
	Type                ContextType `yaml:",omitempty"` // The Type of the context which represents things like whether it came from a request or response etc
	Identifier          string      `yaml:",omitempty"` // The identifier of the context, e.g. the operation id or parent schema ref
	IdentifierForNaming *string     `yaml:",omitempty"` // The humanized identifier of the context, e.g. the operation id or parent schema ref
	Used                bool        `yaml:",omitempty"` // Whether or not the context has been used for renaming
	MustUse             bool        `yaml:",omitempty"` // Deprecated: Whether or not the context must be used for renaming
}

func (ContextFrame) Clone

func (f ContextFrame) Clone() ContextFrame

Clone creates a deep copy of the ContextFrame

func (ContextFrame) DisplayName

func (f ContextFrame) DisplayName() string

func (*ContextFrame) MarkUsed

func (f *ContextFrame) MarkUsed()

type ContextStack

type ContextStack []ContextFrame

func (*ContextStack) Append

func (s *ContextStack) Append(typ ContextType, identifier string)

func (*ContextStack) AppendGroup

func (s *ContextStack) AppendGroup(name string)

Appends a group frame to the context stack.

func (*ContextStack) AppendMainSDK

func (s *ContextStack) AppendMainSDK(name string)

Appends a main SDK frame to the context stack.

func (*ContextStack) AppendModelNamespace

func (s *ContextStack) AppendModelNamespace(namespace string)

AppendModelNamespace appends a model namespace frame to the context stack. This is used to differentiate types that have the x-speakeasy-model-namespace extension.

func (*ContextStack) AppendOperation

func (s *ContextStack) AppendOperation(operation string)

func (*ContextStack) AppendRefType

func (s *ContextStack) AppendRefType(refType string)

func (*ContextStack) AppendRequestBody

func (s *ContextStack) AppendRequestBody(fixes *config.Fixes)

func (*ContextStack) AppendRequestMediaType

func (s *ContextStack) AppendRequestMediaType(mediaType string, fixes *config.Fixes)

func (*ContextStack) AppendResponseBody

func (s *ContextStack) AppendResponseBody(fixes *config.Fixes)

func (*ContextStack) AppendResponseMediaType

func (s *ContextStack) AppendResponseMediaType(identifier string, fixes *config.Fixes)

func (*ContextStack) AppendResponseStatusCode

func (s *ContextStack) AppendResponseStatusCode(statusCode string, fixes *config.Fixes)

func (*ContextStack) AppendWithHumanized

func (s *ContextStack) AppendWithHumanized(typ ContextType, identifier string, identifierForNaming string)

func (ContextStack) Clone

func (s ContextStack) Clone() ContextStack

Returns a deep copy of the ContextStack.

func (*ContextStack) Filter

func (s *ContextStack) Filter(fn func(ContextFrame) bool)

func (ContextStack) FindLastFrameOfType

func (s ContextStack) FindLastFrameOfType(typ ContextType) *ContextFrame

func (ContextStack) GetGroups

func (s ContextStack) GetGroups() []ContextFrame

func (ContextStack) HasFrameOfType

func (s ContextStack) HasFrameOfType(typ ContextType) bool

func (*ContextStack) IsUsed

func (s *ContextStack) IsUsed(typ ContextType) bool

func (ContextStack) LastFrame

func (s ContextStack) LastFrame() *ContextFrame

func (*ContextStack) MarkUnused

func (s *ContextStack) MarkUnused(typ ContextType)

func (*ContextStack) MarkUsed

func (s *ContextStack) MarkUsed(typ ContextType)

func (ContextStack) Match

func (s ContextStack) Match(matchers Matchers) error

func (*ContextStack) PopLastFrame

func (s *ContextStack) PopLastFrame()

func (ContextStack) String

func (s ContextStack) String() string

func (*ContextStack) Update

func (s *ContextStack) Update(typ ContextType, identifier string, humanizedIdentifier string)

func (*ContextStack) UpdateOperation

func (s *ContextStack) UpdateOperation(operation string)

type ContextStacks

type ContextStacks []ContextStack

Collection of ContextStack.

func (ContextStacks) Clone

func (s ContextStacks) Clone() ContextStacks

Clone creates a deep copy of the ContextStacks.

type ContextType

type ContextType string
const (
	ContextTypeRefType            ContextType = "refType" // normally "schemas" or "responses" but sometimes "properties"
	ContextTypeRefName            ContextType = "refName" // eg normally the component name but sometimes overridden with x-speakeasy-name-override
	ContextTypeProperty           ContextType = "property"
	ContextTypeInputOutput        ContextType = "inputOutput"
	ContextTypeOneOf              ContextType = "oneOf"
	ContextTypeOneOfPosition      ContextType = "oneOfPosition"
	ContextTypeConstProperty      ContextType = "constProperty"
	ContextTypeRequestResponse    ContextType = "requestResponse"
	ContextTypeRequestMediaType   ContextType = "requestMediaType"
	ContextTypeRequestBody        ContextType = "requestBody"
	ContextTypeResponseStatusCode ContextType = "responseStatusCode"
	ContextTypeResponseError      ContextType = "responseError"
	ContextTypeResponseMediaType  ContextType = "responseMediaType"
	ContextTypeResponseBody       ContextType = "responseBody"
	ContextTypeOperation          ContextType = "operation"
	ContextTypeOperationTag       ContextType = "operationTag"
	ContextTypeGroup              ContextType = "group"
	ContextTypeMainSDK            ContextType = "mainSDK"
	ContextTypeParameter          ContextType = "parameter"
	ContextTypeComponent          ContextType = "component"
	ContextTypeRegisterDuplicate  ContextType = "registerDuplicate"
	ContextTypeModelNamespace     ContextType = "modelNamespace" // x-speakeasy-model-namespace extension value
)

type DataType

type DataType string

DataType is the type of a type definition

const (
	DataTypeString         DataType = "string"
	DataTypeInteger        DataType = "integer"
	DataTypeInt32          DataType = "int32"
	DataTypeBigInt         DataType = "bigint"
	DataTypeNumber         DataType = "number"
	DataTypeFloat32        DataType = "float32"
	DataTypeDecimal        DataType = "decimal"
	DataTypeBoolean        DataType = "boolean"
	DataTypeDate           DataType = "date"
	DataTypeDateTime       DataType = "date-time"
	DataTypeUUID           DataType = "uuid"
	DataTypeDuration       DataType = "duration"
	DataTypeMap            DataType = "map"
	DataTypeArray          DataType = "array"
	DataTypeSet            DataType = "set"
	DataTypeAny            DataType = "any"
	DataTypeBytes          DataType = "bytes"
	DataTypeClass          DataType = "class"
	DataTypeEnum           DataType = "enum"
	DataTypeResponse       DataType = "response"
	DataTypeRequest        DataType = "request"
	DataTypeUnion          DataType = "union"
	DataTypeError          DataType = "error"
	DataTypeRequestStream  DataType = "request-stream"
	DataTypeResponseStream DataType = "response-stream"
	DataTypeEventStream    DataType = "event-stream"
	DataTypeJsonL          DataType = "jsonl"
)

type Discriminator

type Discriminator struct {
	TypePropertyName string                `yaml:",omitempty"`
	Mapping          DiscriminatorMappings `yaml:",omitempty"`
	Inferred         bool                  `yaml:",omitempty"`
}

func (*Discriminator) Clone

func (d *Discriminator) Clone() *Discriminator

Clone creates a deep copy of the Discriminator

func (*Discriminator) Match

func (d *Discriminator) Match(matchers Matchers) error

type DiscriminatorMapping

type DiscriminatorMapping struct {
	Name        string   `yaml:",omitempty"`
	DisplayName string   `yaml:",omitempty"`
	Type        *TypeDef `yaml:",omitempty"`
}

func (*DiscriminatorMapping) Clone

Clone creates a deep copy of the DiscriminatorMapping

func (*DiscriminatorMapping) Match

func (d *DiscriminatorMapping) Match(matchers Matchers) error

type DiscriminatorMappings

type DiscriminatorMappings []*DiscriminatorMapping

Collection of DiscriminatorMapping.

func (DiscriminatorMappings) Clone

type EncodingAnnotation

type EncodingAnnotation struct {
	MediaType string `yaml:",omitempty"`
}

func (*EncodingAnnotation) Clone

func (e *EncodingAnnotation) Clone() Annotation

Clone creates a deep copy of the EncodingAnnotation.

func (*EncodingAnnotation) IsEqual

func (e *EncodingAnnotation) IsEqual(a Annotation) bool

func (*EncodingAnnotation) IsSameType

func (e *EncodingAnnotation) IsSameType(a Annotation) bool

func (*EncodingAnnotation) IsType

func (e *EncodingAnnotation) IsType(t AnnotationType) bool

func (*EncodingAnnotation) Type

type Enum

type Enum struct {
	Type         *TypeDef          `yaml:",omitempty"`
	Values       []string          `yaml:",omitempty"`
	Names        []string          `yaml:",omitempty"`
	Open         bool              `yaml:",omitempty"`
	Format       string            `yaml:",omitempty"` // Whether the enum is templated as a native enum or union of literals. If empty use language default
	Descriptions map[string]string `yaml:",omitempty"`
}

func (*Enum) Clone

func (e *Enum) Clone() *Enum

Clone creates a deep copy of the Enum

func (*Enum) Match

func (e *Enum) Match(matchers Matchers) error

type Example

type Example struct {

	// Description is the description of the example
	Description string

	// Value is the example value if set otherwise it is a reference to another field
	Value *yaml.Node
	// Reference is a reference to another field in another operation if set
	Reference *ExampleReference

	// Replacements are replacements for fields in the example or reference
	Replacements []*ExampleReplacement
	// contains filtered or unexported fields
}

func NewExample

func NewExample(name, description string, value *yaml.Node) *Example

func NewExampleFromJSON

func NewExampleFromJSON(name, description string, jsonValue string) (*Example, error)

NewExampleFromJSON creates a new Example from a JSON string by converting the JSON to YAML, then using the YAML representation as the `value` in the Example. Resulting equivalent OpenAPI YAML:

examples:
  <name>:
    description: <description>
    value:
      <json>: <value>
      <converted>:
        <to>: <yaml>

func NewExampleFromString

func NewExampleFromString(name, description string, exampleValue string) (*Example, error)

NewExampleFromString creates a new Example for a single-value field from a string. Resulting equivalent OpenAPI YAML:

examples:
  <name>:
    description: <description>
    value: <exampleValue>

func NewExampleReference

func NewExampleReference(name, description string, reference *ExampleReference) *Example

func (*Example) Clone

func (e *Example) Clone() *Example

func (*Example) Name

func (e *Example) Name() string

func (*Example) ToJSON

func (e *Example) ToJSON() string

func (*Example) ToString

func (e *Example) ToString() string

type ExampleReference

type ExampleReference struct {
	// Target can be one of a number of different target types like ResponseBodyTarget, InputTarget or OutputTarget
	Target any
	// The type of the Target to help determine its typing
	Type string
}

ExampleReference represents a reference to another field in another operation, it could be a response body, headers etc

type ExampleReplacement

type ExampleReplacement struct {
	// Path is a json-pointer to the field in the example
	Path string
	// Value is the replacement for the field
	Value *Example
}

ExampleReplacement represents a replacement for a particular field in an example

type Examples

type Examples []*Example

func (Examples) AppendExample

func (e Examples) AppendExample(example *Example) Examples

func (Examples) Clone

func (e Examples) Clone() Examples

Clone creates a deep copy of the Examples

func (Examples) FindByName

func (e Examples) FindByName(name string) *Example

func (Examples) MarshalYAML

func (e Examples) MarshalYAML() (any, error)

func (Examples) Match

func (e Examples) Match(matchers Matchers) error

func (Examples) Merge

func (e Examples) Merge(other Examples)

Merges the given Examples into this Examples. The algorithm adds data from the given Examples to this Examples where it is undefined. Where there is a conflicting Example, this Examples's data is preserved. It does not remove any data from this Examples.

func (*Examples) UnmarshalYAML

func (e *Examples) UnmarshalYAML(node *yaml.Node) error

type ExtendedComment

type ExtendedComment struct {
	Summary     string `yaml:",omitempty"`
	Description string `yaml:",omitempty"`
}

ExtendedComment allows for the definition of special comments using the x-speakeasy-docs extension.

func (*ExtendedComment) Clone

func (e *ExtendedComment) Clone() *ExtendedComment

Clone creates a deep copy of the ExtendedComment

func (*ExtendedComment) Match

func (e *ExtendedComment) Match(matchers Matchers) error

func (*ExtendedComment) Merge

func (e *ExtendedComment) Merge(other *ExtendedComment)

Merges the given ExtendedComment into this ExtendedComment. The algorithm adds data from the given ExtendedComment to this ExtendedComment where it is undefined. Where there is conflicting data, this ExtendedComment's data is preserved or otherwise delegated to data-specific merge functionality. It does not remove any data from this ExtendedComment.

type ExternalDocs

type ExternalDocs struct {
	Description string `yaml:",omitempty"`
	URL         string `yaml:",omitempty"`
}

ExternalDocs represents a link to external documentation

func (*ExternalDocs) Clone

func (e *ExternalDocs) Clone() *ExternalDocs

Clone creates a deep copy of the ExternalDocs

func (*ExternalDocs) Match

func (e *ExternalDocs) Match(matchers Matchers) error

func (*ExternalDocs) Merge

func (e *ExternalDocs) Merge(other *ExternalDocs)

Merges the given ExternalDocs into this ExternalDocs. The algorithm adds data from the given ExternalDocs to this ExternalDocs where it is undefined. Where there is conflicting data, this ExternalDocs's data is preserved or otherwise delegated to data-specific merge functionality. It does not remove any data from this ExternalDocs.

type FieldAddOptions

type FieldAddOptions struct {
	MaintainOriginalOrder bool
	Sanitize              bool
}

FieldAddOptions contains options for adding fields to a Fields collection

func DefaultFieldAddOptions

func DefaultFieldAddOptions() FieldAddOptions

DefaultFieldAddOptions returns the default options for adding fields

type FieldDef

type FieldDef struct {
	Name                   string               `yaml:",omitempty"` // The name of the field within the class
	OriginalName           string               `yaml:",omitempty"` // The name of a field as it appears in the source document if it was a property in an object schema
	Type                   *TypeDef             `yaml:",omitempty"` // The type of the field
	Comments               *Comment             `yaml:",omitempty"` // The comments associated with the field
	Annotations            Annotations          `yaml:",omitempty"` // Any annotations applied to the field
	Nullable               bool                 `yaml:",omitempty"` // Whether the field is nullable
	Optional               bool                 `yaml:",omitempty"` // In the case of an object property, indicates whether the field is non-required. Otherwise, matches Nullable
	SerializationMethod    *SerializationMethod `yaml:",omitempty"` // The serialization method to use for the field if any
	ErrorMessage           bool                 `yaml:",omitempty"` // Whether or not the field is an error message when used in an error type
	Const                  *AnyValue            `yaml:",omitempty"` // The constant value of the field if any
	Default                *AnyValue            `yaml:",omitempty"` // The default value of the field if any
	IsAdditionalProperties bool                 `yaml:",omitempty"` // Whether or not the field is an additional properties field
	IsResponseHeaders      bool                 `yaml:",omitempty"` // Whether or not the field is the response headers field
	IsResponseMetadata     bool                 `yaml:",omitempty"` // Whether or not the field is HTTP response metadata (ContentType/StatusCode/RawResponse)
	ParameterIndex         *int                 `yaml:",omitempty"` // The index of the parameter in the operation if the field is a request parameter
}

FieldDef represents a field in a TypeDef if it is a class

func (*FieldDef) Clone

func (f *FieldDef) Clone() *FieldDef

Clone creates a deep copy of the FieldDef

func (*FieldDef) FindEntityFieldDef

func (f *FieldDef) FindEntityFieldDef(entityName string) *FieldDef

Returns this FieldDef or any of its children when the given entity name matches the x-speakeasy-entity configuration.

func (*FieldDef) FindTerraformEquivalentField

func (f *FieldDef) FindTerraformEquivalentField(fields Fields, useMatchConfig bool) (*FieldDef, []string)

FindTerraformEquivalentField finds the equivalent field in the given fields by matching using either the x-speakeasy-match path configuration or sanitized field name comparison.

When useMatchConfig is true and the receiver field has an x-speakeasy-match path configured, it resolves the dot-separated path through the target fields' nested types. Otherwise, it falls back to matching by sanitized field name.

Returns the matched field and the resolved path segments, or nil if no match is found.

func (*FieldDef) GetID

func (f *FieldDef) GetID() string

Initial use case of `GetID` was to avoid rendering the same field multiple times in a code sample Note: that this field may be duplicated in the AST in the sense it has the same ID eg { a: A, b: { a: A } } (field a is duplicated)

func (FieldDef) GetNavigableNode

func (def FieldDef) GetNavigableNode() (any, error)

func (*FieldDef) HasMatchConfigPath

func (f *FieldDef) HasMatchConfigPath() bool

HasMatchConfigPath returns true if the field has a path-only match config alias, indicating it references data sourced from another field path.

func (*FieldDef) IsEqual

func (def *FieldDef) IsEqual(other *FieldDef) bool

func (*FieldDef) IsTerraformEqual

func (f *FieldDef) IsTerraformEqual(other *FieldDef) bool

Returns true if the FieldDef is equal to given FieldDef for Terraform usage.

func (*FieldDef) IsTerraformImportRequired

func (f *FieldDef) IsTerraformImportRequired() bool

IsTerraformImportRequired returns true if the field is required for Terraform import state operations. A field is required when its param annotation has RequiredForOperation set, or when the field is neither Optional nor Nullable.

func (*FieldDef) Match

func (f *FieldDef) Match(matchers Matchers) error

type Fields

type Fields []*FieldDef

func (Fields) AddField

func (f Fields) AddField(field *FieldDef, maintainOriginalOrder bool) (Fields, error)

func (Fields) AddFieldWithOptions

func (f Fields) AddFieldWithOptions(field *FieldDef, opts FieldAddOptions) (Fields, error)

func (Fields) Clone

func (f Fields) Clone() Fields

Clone creates a deep copy of the Fields

func (Fields) ContainsAdditionalProperties

func (f Fields) ContainsAdditionalProperties() bool

func (Fields) Difference

func (f Fields) Difference(fields Fields) Fields

func (Fields) EnsureField

func (f Fields) EnsureField(field *FieldDef, maintainOriginalOrder bool) Fields

func (Fields) EnsureFieldWithOptions

func (f Fields) EnsureFieldWithOptions(field *FieldDef, opts FieldAddOptions) Fields

func (Fields) GetField

func (f Fields) GetField(name string) *FieldDef

Returns the FieldDef with the given name, if it exists.

func (Fields) GetFieldNames

func (f Fields) GetFieldNames() string

func (Fields) IsTerraformEqual

func (f Fields) IsTerraformEqual(other Fields) bool

Returns true if the Fields is equal to given Fields for Terraform usage.

func (Fields) IsTerraformSymbolEqual

func (f Fields) IsTerraformSymbolEqual(other Fields) bool

IsTerraformSymbolEqual reports whether two Fields slices are structurally equal for symbol deduplication, using sanitized field name matching. Unlike IsTerraformEqual which uses exact name matching via GetField, this method accounts for casing/formatting differences by comparing SanitizeFieldName values. Only unidirectional matching is needed because lengths are equal and sanitized field names are unique within a single Fields slice.

func (Fields) MustAddField

func (f Fields) MustAddField(field *FieldDef, maintainOriginalOrder bool) Fields

TODO: add tests for panics TODO: add tests for field renaming

func (Fields) MustAddFieldWithOptions

func (f Fields) MustAddFieldWithOptions(field *FieldDef, opts FieldAddOptions) Fields

func (Fields) PrintFields

func (f Fields) PrintFields()

type FormAnnotation

type FormAnnotation struct {
	Name      string   `yaml:",omitempty"`
	JSON      bool     `yaml:",omitempty"`
	Style     string   `yaml:",omitempty"`
	Explode   bool     `yaml:",omitempty"`
	FieldType *TypeDef `yaml:",omitempty"`
}

func (*FormAnnotation) Clone

func (f *FormAnnotation) Clone() Annotation

Clone creates a deep copy of the FormAnnotation.

func (*FormAnnotation) IsEqual

func (f *FormAnnotation) IsEqual(a Annotation) bool

func (*FormAnnotation) IsSameType

func (f *FormAnnotation) IsSameType(a Annotation) bool

func (*FormAnnotation) IsType

func (f *FormAnnotation) IsType(t AnnotationType) bool

func (*FormAnnotation) Type

func (f *FormAnnotation) Type() AnnotationType

type HoistedSecurityConfig

type HoistedSecurityConfig struct {
	// Equivalent is true when the operation's security requirements functionally match
	// global security (identical schemes, same OR-order, and matching optionality).
	// When false, templates must filter global security fields using Fields.
	Equivalent bool
	// Fields maps operation-level security requirements to their corresponding global security
	// fields, ordered according to the operation-level security definition.
	Fields []HoistedSecurityField
}

HoistedSecurityConfig describes how an operation's security was hoisted to global security.

type HoistedSecurityField

type HoistedSecurityField struct {
	// The global security field name corresponding to the hoisted security requirement
	Name string `yaml:",omitempty"`
	// The position of the hoisted field in the global security field slice
	Index int `yaml:",omitempty"`
	// The index of the requirement group, used to identify composite requirements (AND).
	// For flattened schemes (e.g. Username/Password): Group will always be 0.
	// For simple OR configurations (unflattened): Index and Group will match.
	Group int `yaml:",omitempty"`
}

HoistedSecurityField keeps track of a hoisted operation-level security requirement.

type InputTarget

type InputTarget struct {
	// Target is the target FieldDef or TypeDef that the reference is pointing to
	Target any
	// Path is a json-pointer to the field in the inputs
	Path string
	// The inputs content that the reference is pointing to
	Inputs *FieldDef
}

type IsEqualOpt

type IsEqualOpt func(opts *isEqualOpts)

func SkipAnnotations

func SkipAnnotations() IsEqualOpt

func WithVisited

func WithVisited(visited map[*TypeDef]bool) IsEqualOpt

type JSONAnnotation

type JSONAnnotation struct {
	Ignore    bool   `yaml:",omitempty"`
	FieldName string `yaml:",omitempty"`
}

func (*JSONAnnotation) Clone

func (j *JSONAnnotation) Clone() Annotation

Clone creates a deep copy of the JSONAnnotation.

func (*JSONAnnotation) IsEqual

func (j *JSONAnnotation) IsEqual(a Annotation) bool

func (*JSONAnnotation) IsSameType

func (j *JSONAnnotation) IsSameType(a Annotation) bool

func (*JSONAnnotation) IsType

func (j *JSONAnnotation) IsType(t AnnotationType) bool

func (*JSONAnnotation) Type

func (j *JSONAnnotation) Type() AnnotationType

type Matchers

type Matchers struct {
	SDK                  func(*SDK) error
	Servers              func(*Servers) error
	Server               func(*Server) error
	ServerVariable       func(*ServerVariable) error
	FieldDef             func(*FieldDef) error
	Annotations          func(Annotations) error
	TypeDef              func(*TypeDef) error
	ContextStack         func(ContextStack) error
	Validations          func(*Validations) error
	Enum                 func(*Enum) error
	Discriminator        func(*Discriminator) error
	DiscriminatorMapping func(*DiscriminatorMapping) error
	Examples             func(Examples) error
	Operation            func(*Operation) error
	Request              func(*Request) error
	RequestParams        func(*RequestParams) error
	Param                func(*Param) error
	Response             func(*Response) error
	SubResponse          func(*SubResponse) error
	ResponseBodyContent  func(*ResponseBodyContent) error
	OperationExtensions  func(*OperationExtensions) error
	TypeDefExtensions    func(*TypeDefExtensions) error
	Arguments            func(*Arguments) error
	Comment              func(*Comment) error
	ExtendedComment      func(*ExtendedComment) error
	ExternalDocs         func(*ExternalDocs) error
}

type MultipartFormAnnotation

type MultipartFormAnnotation struct {
	File      bool     `yaml:",omitempty"`
	Content   bool     `yaml:",omitempty"`
	JSON      bool     `yaml:",omitempty"`
	Name      string   `yaml:",omitempty"`
	FieldType *TypeDef `yaml:",omitempty"`
}

func (*MultipartFormAnnotation) Clone

Clone creates a deep copy of the MultipartFormAnnotation.

func (*MultipartFormAnnotation) IsEqual

func (m *MultipartFormAnnotation) IsEqual(a Annotation) bool

func (*MultipartFormAnnotation) IsSameType

func (m *MultipartFormAnnotation) IsSameType(a Annotation) bool

func (*MultipartFormAnnotation) IsType

func (*MultipartFormAnnotation) Type

type NeedsCasingAnnotation

type NeedsCasingAnnotation struct{}

func (*NeedsCasingAnnotation) Clone

func (n *NeedsCasingAnnotation) Clone() Annotation

Clone creates a deep copy of the NeedsCasingAnnotation.

func (*NeedsCasingAnnotation) IsEqual

func (n *NeedsCasingAnnotation) IsEqual(a Annotation) bool

func (*NeedsCasingAnnotation) IsSameType

func (n *NeedsCasingAnnotation) IsSameType(a Annotation) bool

func (*NeedsCasingAnnotation) IsType

func (*NeedsCasingAnnotation) Type

type Node

type Node interface {
	Match(Matchers) error
}

type NodeType

type NodeType string
const (
	NodeTypeSDK                  NodeType = "SDK"
	NodeTypeServers              NodeType = "Servers"
	NodeTypeServer               NodeType = "Server"
	NodeTypeServerVariable       NodeType = "ServerVariable"
	NodeTypeFieldDef             NodeType = "FieldDef"
	NodeTypeAnnotations          NodeType = "Annotations"
	NodeTypeTypeDef              NodeType = "TypeDef"
	NodeTypeContextStack         NodeType = "ContextStack"
	NodeTypeValidations          NodeType = "Validations"
	NodeTypeEnum                 NodeType = "Enum"
	NodeTypeDiscriminator        NodeType = "Discriminator"
	NodeTypeDiscriminatorMapping NodeType = "DiscriminatorMapping"
	NodeTypeExamples             NodeType = "Examples"
	NodeTypeOperation            NodeType = "Operation"
	NodeTypeRequest              NodeType = "Request"
	NodeTypeRequestParams        NodeType = "RequestParams"
	NodeTypeParam                NodeType = "Param"
	NodeTypeResponse             NodeType = "Response"
	NodeTypeSubResponse          NodeType = "SubResponse"
	NodeTypeResponseBodyContent  NodeType = "ResponseBodyContent"
	NodeTypeOperationExtensions  NodeType = "OperationExtensions"
	NodeTypeTypeDefExtensions    NodeType = "TypeDefExtensions"
	NodeTypeArguments            NodeType = "Arguments"
	NodeTypeComment              NodeType = "Comment"
	NodeTypeExtendedComment      NodeType = "ExtendedComment"
	NodeTypeExternalDocs         NodeType = "ExternalDocs"
)

func GetNodeType

func GetNodeType(n Node) NodeType

type OAuth2Config

type OAuth2Config map[string]OAuth2FlowConfig

type OAuth2Flow

type OAuth2Flow string
const (
	OAuth2FlowNone              OAuth2Flow = "none"
	OAuth2FlowClientCredentials OAuth2Flow = "client_credentials"
	OAuth2FlowPassword          OAuth2Flow = "password"
	OAuth2FlowImplicit          OAuth2Flow = "implicit"
	OAuth2FlowAuthorizationCode OAuth2Flow = "authorization_code"
)

type OAuth2FlowConfig

type OAuth2FlowConfig struct {
	Flow            OAuth2Flow
	Enabled         bool
	Comments        Comment
	RequiredScopes  []string
	AvailableScopes []OAuth2Scope
}

type OAuth2Scope

type OAuth2Scope struct {
	Name     string
	Comments Comment
}

type OpenAPILocation

type OpenAPILocation struct {
	Node *yaml.Node
}

func (*OpenAPILocation) Clone

func (l *OpenAPILocation) Clone() *OpenAPILocation

Clone creates a deep copy of the OpenAPILocation

type Operation

type Operation struct {
	BaseOperation
	Path                   string                 `yaml:",omitempty"` // The API path the operation is associated with
	Method                 string                 `yaml:",omitempty"` // The HTTP method the operation uses
	Security               *FieldDef              `yaml:",omitempty"` // The security definition for the operation (if any)
	GlobalSecurity         *FieldDef              `yaml:",omitempty"` // The global security definition for the SDK (if any)
	HoistedSecurityConfig  *HoistedSecurityConfig `yaml:",omitempty"` // Only set if the operation security was hoisted to the global level
	OAuth2Config           *OAuth2Config          `yaml:",omitempty"` // The operation-specific OAuth2 configuration override
	Scope                  Scope                  `yaml:",omitempty"` // The scope of the operation
	Servers                *Servers               `yaml:",omitempty"` // The list of servers that are specific to the operation
	Comments               *Comment               `yaml:",omitempty"` // The comments associated with the operation
	Tags                   []string               `yaml:",omitempty"` // The OpenAPI tags associated with the operation
	UsesUserAgentHeader    bool                   `yaml:",omitempty"` // Whether the operation uses the User-Agent header
	Callbacks              []*TypeDef             `yaml:",omitempty"` // The list of callbacks associated with the operation
	OwningSDK              *SDK                   `yaml:"-"`          // The SDK that owns the operation
	Extensions             *OperationExtensions   `yaml:",omitempty"` // The extensions associated with the operation
	Globals                *TypeDef               `yaml:",omitempty"` // The global variables associated with the operation
	MaxMethodParams        int                    `yaml:",omitempty"` // The maximum number of parameters the method can have
	Arguments              *Arguments             `yaml:",omitempty"` // The method arguments which include parameters and request body fields
	TestExplicitlyDisabled bool                   `yaml:",omitempty"` // Whether the test configuration was explicitly disabled
	Webhook                *Webhook               `yaml:",omitempty"` // Whether the operation is a webhook
	Location               *OpenAPILocation       `yaml:"-"`          // The location of the operation in the OpenAPI document
	// contains filtered or unexported fields
}

Operation represents an operation within an SDK

func (*Operation) ContainsTruncated

func (o *Operation) ContainsTruncated() bool

Returns true if the Operation contains a truncated (circular reference) type for the Request or Response.

func (Operation) GetAcceptTypes

func (o Operation) GetAcceptTypes() []string

func (*Operation) GetExampleSeed

func (o *Operation) GetExampleSeed() int

func (Operation) GetID

func (o Operation) GetID() string

func (Operation) GetSerializationMethod

func (o Operation) GetSerializationMethod() SerializationMethod

func (*Operation) Match

func (o *Operation) Match(matchers Matchers) error

type OperationExtensions

type OperationExtensions struct {
	MethodNameOverride        string                                `yaml:",omitempty"`
	UsageExample              *extensions.UsageExampleConfig        `yaml:",omitempty"`
	Retries                   *extensions.Retries                   `yaml:",omitempty"`
	Timeout                   *int64                                `yaml:",omitempty"`
	Pagination                *extensions.Pagination                `yaml:",omitempty"`
	DocsRateLimits            []extensions.RateLimit                `yaml:",omitempty"`
	ReactHook                 *extensions.ReactHook                 `yaml:",omitempty"`
	MCP                       *extensions.MCP                       `yaml:",omitempty"`
	SSEOverload               *extensions.SSEOverloadConfig         `yaml:",omitempty"`
	PublicExports             []extensions.PublicExport             `yaml:",omitempty"`
	GoOptionalMethodArguments *extensions.GoOptionalMethodArguments `yaml:",omitempty"`
	All                       map[string]any                        `yaml:",omitempty"`

	// Describes x-speakeasy-entity-operation extension configuration. The extension
	// is typically configured along with the x-speakeasy-entity extension to build
	// a single model to describe an API entity. That model is used to describe a
	// Terraform data or managed resource currently, but may represent other target
	// entities in the future.
	//
	// This extension accepts the following data types:
	//
	// - String: A value in the form of Entity#OpType[,OpType...][#Order].
	//   Entity is the name of the entity, OpType is the set of entity operation
	//   types (typically entity lifecycle operations such as "create", "read",
	//   "update", and "delete"), and Order is an optional integer greater than 0
	//   that specifies the order of the operation compared to other definitions of
	//   x-speakeasy-entity-operation with the same Entity#OpType.
	// - Array of string: Multiple values of the above string form when a single API
	//   operation is necessary across multiple entities, such as ["Entity#OpType",
	//   "Entity2#OpType"].
	// - Object: Target-specific configuration for the entity operation, where the
	//   properties are target-defined entity sub-types. This is typically used to
	//   disable automatically generated entity sub-types, should the target create
	//   multiple entity sub-types for the same entity operation, or other advanced
	//   configuration of individual entity sub-types. For example, the Terraform
	//   target automatically generates both a data and managed resource for each
	//   Entity#read associated with another Entity#create, so the object form can
	//   be used to disable data resource generation by specifying
	//   {"terraform-datasource": null, "terraform-resource": "Entity#read"}. Each
	//   property value accepts the above string and array of string forms.
	//   The supported properties are:
	//     - "terraform-datasource": Explicit configuration for Terraform target
	//       data resources.
	//     - "terraform-resource": Explicit configuration for Terraform target
	//       managed resources.
	//
	//
	// Only one of the EntityOperation (x-speakeasy-entity-operation) or
	// EntityOperations (x-speakeasy-entity-operations) extensions is valid in a
	// single API operation.
	EntityOperation *extensions.EntityOperationV1 `yaml:",omitempty"`

	// Describes polling configuration, derived from the x-speakeasy-polling
	// extension configuration. This configuration enables targets implementing
	// the operationPolling generator feature to template operation polling
	// logic for consumer opt-in (or in the case of the terraform target,
	// implement via x-speakeasy-entity-operation).
	Polling *Polling `yaml:",omitempty"`

	// Describes HTTP status codes that indicate an entity is missing/deleted.
	// Derived from the x-speakeasy-entity-missing-codes extension. Used by the
	// Terraform target to call RemoveResource() during Read operations when the
	// API returns one of these status codes.
	EntityMissingCodes extensions.EntityMissingCodes `yaml:",omitempty"`
}

OperationExtensions represents the extensions that operate on an operation

func (*OperationExtensions) Match

func (o *OperationExtensions) Match(matchers Matchers) error

type OperationSecurityAnnotation

type OperationSecurityAnnotation struct{}

func (*OperationSecurityAnnotation) Clone

Clone creates a deep copy of the OperationSecurityAnnotation.

func (*OperationSecurityAnnotation) IsEqual

func (*OperationSecurityAnnotation) IsSameType

func (r *OperationSecurityAnnotation) IsSameType(a Annotation) bool

func (*OperationSecurityAnnotation) IsType

func (*OperationSecurityAnnotation) Type

type OutputTarget

type OutputTarget struct {
	// Target is the target FieldDef or TypeDef that the reference is pointing to
	Target any
	// Path is a json-pointer to the field in the outputs
	Path string
	// The outputs content that the reference is pointing to
	Outputs *FieldDef
	// The index of the step and therefore the operation in the workflow that the reference is pointing to
	StepIdx int
}

type Param

type Param struct {
	Field           *FieldDef `yaml:",omitempty"` // The field that the parameter is associated with
	Examples        Examples  `yaml:",omitempty"` // The named examples available for the parameter
	Hidden          bool      `yaml:",omitempty"` // Whether the parameter is hidden as it is only accepted as a global parameter
	AllowEmptyValue bool      `yaml:",omitempty"` // Whether to send the parameter with an empty value in the query string (e.g., "?param=")
}

func (*Param) HasMatchConfigUsePriorState

func (p *Param) HasMatchConfigUsePriorState() bool

HasMatchConfigUsePriorState returns true if the parameter's field type has the MatchConfig.UsePriorState flag set.

func (*Param) Match

func (p *Param) Match(matchers Matchers) error

type ParamAnnotation

type ParamAnnotation struct {
	ParamType     string   `yaml:",omitempty"`
	Name          string   `yaml:",omitempty"`
	Serialization string   `yaml:",omitempty"`
	Style         string   `yaml:",omitempty"`
	Explode       bool     `yaml:",omitempty"`
	FieldType     *TypeDef `yaml:",omitempty"`
	AllowReserved bool     `yaml:",omitempty"`

	// Enabled when the parameter is global parameter
	IsGlobal bool `yaml:",omitempty"`
	// Contains the operations this parameter is used in if IsGlobal is true
	OperationsForGlobal []string `yaml:",omitempty"`

	// Enabled when the parameter is local to an operation but has a global representation
	HasGlobal bool `yaml:",omitempty"`

	// Enabled when the parameter should be hidden, where the value should not
	// be settable from an operation and only at the SDK level. Hidden is only set
	// if the parameter is global and the x-speakeasy-globals-hidden extension
	// is enabled.
	Hidden bool `yaml:",omitempty"`

	// Enabled when the parameter is global and the path or operation marks it
	// as required. Global parameters are implicitly marked as optional, so this
	// captures the overriding value requirement.
	RequiredForOperation bool `yaml:",omitempty"`
}

Parameter annotation data.

func (*ParamAnnotation) Clone

func (p *ParamAnnotation) Clone() Annotation

Clone creates a deep copy of the ParamAnnotation.

func (*ParamAnnotation) IsEqual

func (p *ParamAnnotation) IsEqual(a Annotation) bool

func (*ParamAnnotation) IsSameType

func (p *ParamAnnotation) IsSameType(a Annotation) bool

func (*ParamAnnotation) IsType

func (p *ParamAnnotation) IsType(t AnnotationType) bool

func (*ParamAnnotation) Type

func (p *ParamAnnotation) Type() AnnotationType

type Polling

type Polling struct {
	// Collection of polling options.
	Options PollingOptions `json:"options" yaml:"options"`
}

Describes polling configuration derived from the x-speakeasy-polling extension configuration.

func (*Polling) Clone

func (p *Polling) Clone() *Polling

Creates a deep copy of the Polling

type PollingOption

type PollingOption struct {
	// Delay in seconds before polling calls begin. Defaults to 1.
	DelaySeconds *int64 `json:"delaySeconds,omitempty" yaml:"delaySeconds,omitempty"`

	// Descibes immediate failure criteria for the polling option. When all
	// matching criteria are met (AND boolean), the operation will immediately
	// return an error.
	FailureCriteria Assertions `json:"failureCriteria,omitempty" yaml:"failureCriteria,omitempty"`

	// Interval between polling calls in seconds. Defaults to 1.
	IntervalSeconds *int64 `json:"intervalSeconds,omitempty" yaml:"intervalSeconds,omitempty"`

	// Name of the polling option.
	Name string `json:"name" yaml:"name"`

	// Number of polling calls not matching the FailureCriteria or
	// SuccessCriteria before returning a timeout error. Defaults to 60.
	LimitCount *int64 `json:"limitCount,omitempty" yaml:"limitCount,omitempty"`

	// Descibes success criteria for the polling option. When all matching
	// criteria are met (AND boolean), the operation will return successfully.
	SuccessCriteria Assertions `json:"successCriteria,omitempty" yaml:"successCriteria,omitempty"`
}

Describes a single polling option.

func (*PollingOption) Clone

func (o *PollingOption) Clone() *PollingOption

Creates a deep copy of the PollingOption.

type PollingOptions

type PollingOptions []*PollingOption

Collection of PollingOption.

func (PollingOptions) Clone

func (o PollingOptions) Clone() PollingOptions

Creates a deep copy of the PollingOptions.

type PublicExportAmbientExport

type PublicExportAmbientExport = publicExportAmbientExport

func InferAmbientPublicExportsForRoots

func InferAmbientPublicExportsForRoots(roots []PublicExportAmbientRoot) []PublicExportAmbientExport

type PublicExportAmbientRoot

type PublicExportAmbientRoot = publicExportAmbientRoot

type PublicExportChild

type PublicExportChild struct {
	Name  string   `yaml:",omitempty"`
	Group string   `yaml:",omitempty"`
	Parts []string `yaml:",omitempty"`
}

type PublicExportChildren

type PublicExportChildren []*PublicExportChild

type PublicExportGroup

type PublicExportGroup struct {
	Group    string               `yaml:",omitempty"`
	Parts    []string             `yaml:",omitempty"`
	Exports  PublicExportTargets  `yaml:",omitempty"`
	Children PublicExportChildren `yaml:",omitempty"`
}

type PublicExportGroups

type PublicExportGroups []*PublicExportGroup

type PublicExportTarget

type PublicExportTarget struct {
	Name   string   `yaml:",omitempty"`
	Target *TypeDef `yaml:",omitempty"`
	// Input marks exports that alias the target's input-side representation
	// (e.g. the Python TypedDict companion) instead of the model class.
	Input bool `yaml:",omitempty"`
	// Implicit marks exports registered from x-speakeasy-model-namespace
	// tagging rather than an explicit x-speakeasy-exports declaration.
	// Languages only render implicit exports when the SDK opts in via the
	// imports.paths.resources configuration.
	Implicit bool `yaml:",omitempty"`
}

type PublicExportTargets

type PublicExportTargets []*PublicExportTarget

type PublicExports

type PublicExports struct {
	RootChildren PublicExportChildren `yaml:",omitempty"`
	Groups       PublicExportGroups   `yaml:",omitempty"`
}

func BuildPublicExports

func BuildPublicExports(ctx context.Context, a *AST) *PublicExports

BuildPublicExports resolves x-speakeasy-exports into a language-agnostic public export tree after type names and model buckets have been finalized. Every rendered type tagged with x-speakeasy-model-namespace is implicitly exported to the export group matching its namespace, so new models appear on the public surface without per-type export annotations. Explicit x-speakeasy-exports entries always take precedence over implicit ones.

func (*PublicExports) HasExplicitExports

func (p *PublicExports) HasExplicitExports() bool

HasExplicitExports reports whether any export came from an explicit x-speakeasy-exports declaration (as opposed to implicit model-namespace auto-exports).

type RegistrationIDOption

type RegistrationIDOption func(opts *RegistrationIDOptions)

func WithSkipDuplicateFrame

func WithSkipDuplicateFrame() RegistrationIDOption

func WithSkipInputOutputFrame

func WithSkipInputOutputFrame() RegistrationIDOption

type RegistrationIDOptions

type RegistrationIDOptions struct {
	SkipDuplicateFrame   bool
	SkipInputOutputFrame bool
}

type Request

type Request struct {
	Field                 *FieldDef      `yaml:",omitempty"` // The field representing the entire request object
	RequestBody           *FieldDef      `yaml:",omitempty"` // The request body field
	MatchedContentTypes   []string       `yaml:",omitempty"` // The content types that were matched and flattened into this request body
	IsRequestBody         bool           `yaml:",omitempty"` // Whether the request is the same as the request body after flattening
	IsRequestBodyRequired bool           `yaml:",omitempty"` // Whether the request is required
	Params                *RequestParams `yaml:",omitempty"` // The parameters that can be passed to the operation
	Examples              Examples       `yaml:",omitempty"` // The examples of the request
}

Request represents the input to an operation

func (*Request) ContainsTruncated

func (r *Request) ContainsTruncated() bool

Returns true if the Request contains a truncated (circular reference) type.

func (*Request) FindEntityTypeDef

func (r *Request) FindEntityTypeDef(entityName string) *TypeDef

Returns the TypeDef or underlying TypeDef where the given entity name matches the x-speakeasy-entity extension configuration.

func (*Request) Match

func (r *Request) Match(matchers Matchers) error

type RequestAnnotation

type RequestAnnotation struct {
	MediaType string `yaml:",omitempty"`
}

func (*RequestAnnotation) Clone

func (r *RequestAnnotation) Clone() Annotation

Clone creates a deep copy of the RequestAnnotation.

func (*RequestAnnotation) IsEqual

func (r *RequestAnnotation) IsEqual(a Annotation) bool

func (*RequestAnnotation) IsSameType

func (r *RequestAnnotation) IsSameType(a Annotation) bool

func (*RequestAnnotation) IsType

func (r *RequestAnnotation) IsType(t AnnotationType) bool

func (*RequestAnnotation) Type

type RequestParams

type RequestParams struct {
	QueryParams  []*Param `yaml:",omitempty"`
	PathParams   []*Param `yaml:",omitempty"`
	HeaderParams []*Param `yaml:",omitempty"`
}

RequestParams represent the different parameter types that can be passed to an operation

func (RequestParams) HasHeaderParams

func (r RequestParams) HasHeaderParams() bool

func (RequestParams) HasPathParams

func (r RequestParams) HasPathParams() bool

func (RequestParams) HasQueryParams

func (r RequestParams) HasQueryParams() bool

func (*RequestParams) HasVisibleParams

func (r *RequestParams) HasVisibleParams() bool

func (*RequestParams) IsEmpty

func (r *RequestParams) IsEmpty() bool

func (*RequestParams) Match

func (r *RequestParams) Match(matchers Matchers) error

type RequestWrapperAnnotation

type RequestWrapperAnnotation struct{}

func (*RequestWrapperAnnotation) Clone

Clone creates a deep copy of the RequestWrapperAnnotation.

func (*RequestWrapperAnnotation) IsEqual

func (*RequestWrapperAnnotation) IsSameType

func (r *RequestWrapperAnnotation) IsSameType(a Annotation) bool

func (*RequestWrapperAnnotation) IsType

func (*RequestWrapperAnnotation) Type

type Response

type Response struct {
	Type      *TypeDef     // The type of the response object
	Responses SubResponses // The list of possible responses that the operation can return
}

Response represents the response output from an operation

func (*Response) ContainsTruncated

func (r *Response) ContainsTruncated() bool

Returns true if the Response contains a truncated (circular reference) type.

func (*Response) FindEntityTypeDef

func (r *Response) FindEntityTypeDef(entityName string) *TypeDef

Returns the TypeDef or underlying TypeDef where the given entity name matches the x-speakeasy-entity extension configuration.

func (*Response) FirstSuccessCodeSubResponse

func (r *Response) FirstSuccessCodeSubResponse() *SubResponse

Returns the first SubResponse with a non-error status code.

func (Response) GetErrorStatusCodes

func (r Response) GetErrorStatusCodes() []string

func (*Response) Match

func (r *Response) Match(matchers Matchers) error

func (*Response) TerraformBodyFieldDef

func (r *Response) TerraformBodyFieldDef(entityName string) *FieldDef

Returns the root FieldDef representing the body of the response for Terraform.

type ResponseAnnotation

type ResponseAnnotation struct {
	ResultField bool `yaml:",omitempty"`
}

func (*ResponseAnnotation) Clone

func (r *ResponseAnnotation) Clone() Annotation

Clone creates a deep copy of the ResponseAnnotation.

func (*ResponseAnnotation) IsEqual

func (r *ResponseAnnotation) IsEqual(a Annotation) bool

func (*ResponseAnnotation) IsSameType

func (r *ResponseAnnotation) IsSameType(a Annotation) bool

func (*ResponseAnnotation) IsType

func (r *ResponseAnnotation) IsType(t AnnotationType) bool

func (*ResponseAnnotation) Type

type ResponseBodyAssertion

type ResponseBodyAssertion struct {
	Path    string
	Value   *Example
	Content *ResponseBodyContent
}

Describes an assertion on a response body.

type ResponseBodyContent

type ResponseBodyContent struct {
	SerializationMethod string    `yaml:",omitempty"` // The serialization method for the content
	ContentType         string    `yaml:",omitempty"` // The content type of the content
	Content             *FieldDef `yaml:",omitempty"` // The content field returned in the response type
	UsageExample        bool      `yaml:",omitempty"` // Whether or not the content should be used as a usage example
	Examples            Examples  `yaml:",omitempty"` // The examples of the content
	SSESentinel         string    `yaml:",omitempty"`
}

ResponseBodyContent represents the type of content that is returned in a response

func (*ResponseBodyContent) Clone

Clone creates a deep copy of ResponseBodyContent

func (*ResponseBodyContent) IsEqual

func (r *ResponseBodyContent) IsEqual(other *ResponseBodyContent) bool

Returns true if ResponseBodyContent is equal to given ResponseBodyContent.

func (*ResponseBodyContent) Match

func (r *ResponseBodyContent) Match(matchers Matchers) error

Runs any ResponseBodyContent matcher against this ResponseBodyContent.

type ResponseBodyTarget

type ResponseBodyTarget struct {
	// Target is the target FieldDef or TypeDef that the reference is pointing to
	Target any
	// Path is a json-pointer to the field in the response body
	Path string
	// The response body content that the reference is pointing to
	Body *ResponseBodyContent
	// The index of the step and therefore the operation in the workflow that the reference is pointing to
	StepIdx int
}

ResponseBodyTarget represents a reference to a particular field in a response body of a particular operation in an Arazzo workflow

type SDK

type SDK struct {
	FieldName       string         `yaml:",omitempty"` // The name of the field used to access the SDK
	Type            *TypeDef       `yaml:",omitempty"` // The type definition for the SDK class
	Group           string         `yaml:",omitempty"` // The group that the SDK belongs to
	Servers         *Servers       `yaml:",omitempty"` // The defined list of servers the SDK has available to make requests to
	Comments        *Comment       `yaml:",omitempty"` // The documentation for the SDK
	SubSDKs         SDKs           `yaml:",omitempty"` // The list of sub SDKs that are available, containing operations scoped to a particular tag
	Security        *FieldDef      `yaml:",omitempty"` // The security definition for the SDK (if any and generally only populated for the main SDK)
	SecurityConfig  SecurityConfig `yaml:",omitempty"` // The security options for the SDK
	Operations      []*Operation   `yaml:",omitempty"` // The list of operations that are available to this SDK
	AdditionalTypes []*TypeDef     `yaml:",omitempty"` // A list of additional types that are available to the SDK, these are populated from components in the OpenAPI document that use the x-speakeasy-include extension and aren't already present elsewhere in the tree (generally only populated for the main SDK)
	OutputTests     bool           `yaml:",omitempty"` // Whether or not to output tests for the SDK
	TestGroup       string         `yaml:",omitempty"` // Which group of tests to generate (should match the spec file)
	Globals         *TypeDef       `yaml:",omitempty"` // The global variables that are available to the SDK
}

SDK represents the start of an SDKs Syntax tree.

func NewMainSDK

func NewMainSDK(typeDef *TypeDef) *SDK

Returns a new main SDK.

func NewSubSDK

func NewSubSDK(typeDef *TypeDef, name string, group string) *SDK

Returns a new sub SDK.

func (*SDK) AddOperations

func (s *SDK) AddOperations(operations ...Operation)

Adds the given operation(s) to the SDK operations, setting the OwningSDK.

func (*SDK) ChildContextStack

func (s *SDK) ChildContextStack() *ContextStack

Returns the context stack for the SDK, including the SDK itself.

func (*SDK) CountUniqueOperations

func (s *SDK) CountUniqueOperations() int64

func (*SDK) FindOperation

func (s *SDK) FindOperation(operationID string) *Operation

Find an operation by its ID in the SDK or its sub SDKs.

Note: This function is used by templating.

func (*SDK) HasAnyOperationServers

func (s *SDK) HasAnyOperationServers() bool

HasAnyOperationServers returns true if any operation in the SDK or its sub SDKs has operation-level servers defined. Used by templates to determine whether server_url should be optional in the constructor (when no global servers exist but some operations define their own).

func (*SDK) HasOperations

func (s *SDK) HasOperations() bool

Returns true if the SDK has or its sub SDKs have underlying operations.

func (*SDK) ID

func (s *SDK) ID(nameResolutionFeb2025 bool) string

Returns the identifier for the SDK.

func (*SDK) Match

func (s *SDK) Match(matchers Matchers) error

func (*SDK) SortSubSDKsByTags

func (s *SDK) SortSubSDKsByTags(tags []*openapi.Tag)

Sorts sub SDKs by the ordering of the OpenAPI document tags. Generally called after checking the maintainTagBasedOrdering configuration.

func (*SDK) WalkOperations

func (s *SDK) WalkOperations() iter.Seq[*Operation]

type SDKs

type SDKs []*SDK

Collection of SDK, such as sub SDKs.

func (*SDKs) DeleteByFieldName

func (s *SDKs) DeleteByFieldName(fieldName string)

Deletes the SDK with the given field name, if found.

func (SDKs) GetByFieldName

func (s SDKs) GetByFieldName(fieldName string) *SDK

Returns the SDK with the given field name, or nil if not found.

func (SDKs) HasOperations

func (s SDKs) HasOperations() bool

Returns true if any SDK has operations.

type Scope

type Scope string

Scope represents within which scope a type is defined

const (
	ScopeShared     Scope = "shared"     // The shared scope contains types that are generally components used by multiple operations
	ScopeOperations Scope = "operations" // The operations scope contains request/response types and operations
	ScopeUtils      Scope = "utils"      // The utils scope represents types/methods that are provided by utils packages
	ScopeSDK        Scope = "sdk"        // The sdk scope represents the sdk classes
	ScopeWebhooks   Scope = "webhooks"   // The webhooks scope represents the webhook types
	ScopeCallbacks  Scope = "callbacks"  // The callbacks scope represents the callback types
	ScopeErrors     Scope = "errors"     // The errors scope represents the error types
	ScopeGlobals    Scope = "globals"    // The globals scope represents the global variables
)

type Security

type Security struct {
	// Security represents the field added either to the SDK or an operation representing how its security is configured
	Security *FieldDef
	// Requirements are stored to determine if operation security is a subset of global security.
	Requirements []SecurityRequirement
	// SecurityConfig represents the security configuration options for this security block
	SecurityConfig SecurityConfig
}

Security represents a security configuration block

type SecurityAnnotation

type SecurityAnnotation struct {
	FieldName string `yaml:",omitempty"`

	// Security scheme type from the OAS Security Scheme object "type" field.
	// Values include "apiKey", "http", "oauth2", and "openIdConnect".
	SecType string `yaml:",omitempty"`

	// Underlying security type. Usage is dependent on SecType:
	// - apiKey: Location of API key from the OAS Security Scheme object "in"
	//           field. Values include "cookie", "header", and "query".
	// - http: HTTP Authentication scheme from the OAS Security Scheme object
	//         "scheme" field, normalized to lowercase. Values include "basic",
	//         "bearer", and "custom".
	// - oauth2: OAuth2 Flow type from the OAuth Flows object field name,
	//           normalized to lowercase snakecase. Values include
	//           "client_credentials" and "password".
	// - openIdConnect: N/A
	SubType string `yaml:",omitempty"`

	// Option (a.k.a. "OptionWrapper") marks this field as a wrapper struct
	// that groups one or more scheme fields together.
	// Option is false for flat configurations, i.e. when multiple simple
	// schemes are in either a OR or AND group (but not both).
	// Option is set for all fields when the security definition is a
	// combination of OR and AND relationships.
	Option bool `yaml:",omitempty"`

	// Scheme marks this field as a security scheme entry point. True for
	// flattened credential fields, unflattened security classes, and fields
	// inside OptionWrapper structs.
	Scheme bool `yaml:",omitempty"`

	// SecurityOption (a.k.a. "Alternative") marks this field as one of multiple
	// independent OR alternatives for authentication. Set on both OptionWrappers
	// and flattened scheme fields when numSchemes > 1. When false, the field
	// is either the only scheme available or part of an AND group.
	SecurityOption bool `yaml:",omitempty"`

	// Composite marks this field as part of an AND group of security schemes.
	Composite bool `yaml:",omitempty"`

	// SchemeKey represents the key of the security scheme in the security field
	SchemeKey string `yaml:",omitempty"`
}

func (*SecurityAnnotation) Clone

func (s *SecurityAnnotation) Clone() Annotation

Clone creates a deep copy of the SecurityAnnotation.

func (*SecurityAnnotation) IsEqual

func (s *SecurityAnnotation) IsEqual(a Annotation) bool

func (*SecurityAnnotation) IsSameType

func (s *SecurityAnnotation) IsSameType(a Annotation) bool

func (*SecurityAnnotation) IsType

func (s *SecurityAnnotation) IsType(t AnnotationType) bool

func (*SecurityAnnotation) Merge

func (*SecurityAnnotation) Type

type SecurityConfig

type SecurityConfig struct {
	// OptionalityReason represents the reason why this security block is optional
	OptionalityReason SecurityOptionalityReason
	// OAuth2Config configures a OAuth2 flow in this security block, used to collect OAuth2Scopes and enable hooks
	OAuth2Config OAuth2Config
	// Disabled indicates whether this security block was explicitly disabled
	Disabled bool
	// HoistedSecurityConfig is populated when the operation security was hoisted to the global level.
	// Nil when the operation defines its own non-matching security or no operation-level security exists.
	HoistedSecurityConfig *HoistedSecurityConfig
}

func (SecurityConfig) IsSubsetOfGlobalSecurity

func (c SecurityConfig) IsSubsetOfGlobalSecurity() bool

IsSubsetOfGlobalSecurity returns true if the operation's security requirements are a subset of (or equivalent to) the global security requirements. In this case the operation-security gets hoisted and global security is reused. Note for this function to return true, the operation security does not have to be a *strict* (or proper) subset.

type SecurityOptionalityReason

type SecurityOptionalityReason string
const (
	// SecOptReasonNotOptional indicates that the security has been determined to be required
	SecOptReasonNotOptional       SecurityOptionalityReason = "not-optional"
	SecOptReasonOptionalScheme    SecurityOptionalityReason = "optional-scheme"
	SecOptReasonOperationOverride SecurityOptionalityReason = "operation-override"
	SecOptReasonEnvVar            SecurityOptionalityReason = "env-var"
)

type SecurityRequirement

type SecurityRequirement []SecurityScheme

A security requirement can be either: - a single scheme - a composition of multiple schemes (AND)

type SecurityScheme

type SecurityScheme string

type SerializationMethod

type SerializationMethod string
const (
	SerializationMethodJSON        SerializationMethod = "json"
	SerializationMethodRAW         SerializationMethod = "raw"
	SerializationMethodMultipart   SerializationMethod = "multipart"
	SerializationMethodForm        SerializationMethod = "form"
	SerializationMethodString      SerializationMethod = "string"
	SerializationMethodEventStream SerializationMethod = "eventstream"
	SerializationMethodJsonL       SerializationMethod = "jsonl"
)

type Server

type Server struct {
	ID         string            `yaml:",omitempty"` // The ID of the server (if any)
	URL        string            `yaml:",omitempty"` // Server URLs can be templated strings containing braces, e.g. "https://{env}.example.com"
	IsRelative bool              `yaml:",omitempty"` // Whether or not the url is relative
	Comments   *Comment          `yaml:",omitempty"` // The comments associated with the server
	Variables  []*ServerVariable `yaml:",omitempty"` // The variables associated with the url if it is templated
}

Server represents a single server that is available to an SDK or operation

func (*Server) Match

func (s *Server) Match(matchers Matchers) error

type ServerVariable

type ServerVariable struct {
	Name        string   `yaml:",omitempty"`
	Type        *TypeDef `yaml:",omitempty"`
	Default     string   `yaml:",omitempty"`
	ServerIndex int      `yaml:",omitempty"` // Index of the server this variable belongs to
	Server      *Server  `yaml:",omitempty"` // Reference to the server this variable belongs to
}

func (*ServerVariable) Match

func (v *ServerVariable) Match(matchers Matchers) error

type Servers

type Servers struct {
	Servers   []*Server `yaml:",omitempty"` // The list of servers
	Default   string    `yaml:",omitempty"` // The ID of the default server (if any)
	ServerMap bool      `yaml:",omitempty"` // Whether or not the list of servers should be represented as a map
}

Servers represents the list of servers that are available to and SDK or operation

func (*Servers) GetDefaultURL

func (s *Servers) GetDefaultURL(useDefaultVariables bool) string

GetDefaultURL returns the URL of the default server

func (*Servers) GetVariables

func (s *Servers) GetVariables() []*ServerVariable

GetVariables returns the variables associated with the servers

func (*Servers) HasAbsoluteURL

func (s *Servers) HasAbsoluteURL() bool

HasAbsoluteURL returns true if the servers list contains at least one server with an absolute URL

func (*Servers) Match

func (s *Servers) Match(matchers Matchers) error

type SubResponse

type SubResponse struct {
	Code    []string               // The status code associated with this particular response
	Headers bool                   // Whether or not the response has headers
	Content []*ResponseBodyContent // The content that is returned in the response
	Error   bool                   // Whether or not the response is an error
}

SubResponse represents one of the possible responses that an operation can return

func (*SubResponse) IsEqualExceptExactCode

func (r *SubResponse) IsEqualExceptExactCode(other *SubResponse) bool

func (*SubResponse) Match

func (r *SubResponse) Match(matchers Matchers) error

type SubResponses

type SubResponses []*SubResponse

Collection of SubResponse.

func (SubResponses) FindByCode

func (r SubResponses) FindByCode(code string) *SubResponse

If found, returns the SubResponse with given code.

type TerraformAction

type TerraformAction struct {
	// Description for the action. Sourced from
	// x-speakeasy-entity-description configuration, if available.
	Description string `json:"description" yaml:"description"`

	// Mapping of global field names to definitions for all operations. These
	// are added to the entity resource struct type, copied in the Configure()
	// method, made optional in the resource schema, and checked in the resource
	// methods.
	GlobalFields map[string]*FieldDef `json:"globalFields" yaml:"globalFields"`

	// Computed Go type name for the action data model struct, e.g.
	// "ExampleActionModel". Set by NewTerraformAction.
	GoDataModelTypeName string `json:"goDataModelTypeName" yaml:"goDataModelTypeName"`

	// Computed Go type name for the action private data model struct, e.g.
	// "ExampleActionPrivateDataModel". Set by NewTerraformAction.
	GoPrivateDataModelTypeName string `json:"goPrivateDataModelTypeName" yaml:"goPrivateDataModelTypeName"`

	// Computed Go type name for the action struct implementation, e.g.
	// "ExampleAction". Set by NewTerraformAction.
	GoTypeName string `json:"goTypeName" yaml:"goTypeName"`

	// Whether the entity requires SDK method options in its generated code.
	// This is true when any operation has a Patch.Style configuration.
	// Populated by AssembleSchemaTypeDef.
	IncludeSDKMethodOptions bool `json:"includeSDKMethodOptions,omitempty" yaml:"includeSDKMethodOptions,omitempty"`

	// Unsanitized name of the action type, such as "Thing".
	Name string `json:"name" yaml:"name"`

	// Operation security configuration for the action. This is set
	// when the underlying operations have operation security defined and the
	// enableOperationSecurity generation configuration flag is enabled. Only
	// a single operation security configuration is supported per action,
	// even if multiple operations have differing security configurations. This
	// is intentional to simplify the generated Terraform code and avoid
	// complexity around per-operation security configuration for consumers.
	OperationSecurity *FieldDef `json:"operationSecurity" yaml:"operationSecurity"`

	// All operations associated with the action.
	Operations *TerraformActionOperations `json:"operations" yaml:"operations"`

	// Mapping of pagination input field names to an unused boolean value
	// that is replaceable for future updates.
	PaginationInputFields map[string]bool `json:"paginationInputFields" yaml:"paginationInputFields"`

	// Mapping of pagination output field names to an unused boolean value
	// that is replaceable for future updates.
	PaginationOutputFields map[string]bool `json:"paginationOutputFields" yaml:"paginationOutputFields"`

	// Merged Terraform resource schema TypeDef across all operations. This
	// represents the combined schema view of the action after merging all
	// operation shards together.
	SchemaTypeDef *TypeDef `json:"-" yaml:"-"`

	// Deduplicated, sorted list of SDK request conversion methods (To_ prefix)
	// pre-computed from all operations. Populated by AssembleSchemaTypeDef.
	SDKRequestMethods []*TerraformSDKMethod `json:"-" yaml:"-"`

	// Deduplicated, sorted list of SDK response conversion methods
	// (RefreshFrom_ or RefreshFromArrayOf_ prefix) pre-computed from
	// DataModelRefreshOperations. Populated by AssembleSchemaTypeDef.
	SDKResponseMethods []*TerraformSDKMethod `json:"-" yaml:"-"`

	// Server configuration for the action. This is defined when
	// the underlying operations have path or operation server URLs defined.
	// Only a single server configuration is supported per action,
	// even if multiple operations have differing server URLs defined. This is
	// intentional to simplify the generated Terraform code and avoid complexity
	// around per-operation server configuration for consumers.
	Server *TerraformServer `json:"server" yaml:"server"`

	// Resolved full Terraform action type name (e.g.
	// "myprovider_my_action"), composed from the resolved provider type
	// name and the snake_case form of Name. Used as the value of
	// resp.TypeName in the action Metadata implementation and in example
	// Terraform configuration files. Populated by
	// TerraformProvider.AddOrGetAction.
	TerraformTypeName string `json:"terraformTypeName" yaml:"terraformTypeName"`
}

Describes a Terraform action.

func NewTerraformAction

func NewTerraformAction(name string) *TerraformAction

Creates a new Terraform action, safely initializing underlying fields.

func (*TerraformAction) AddOperation

func (r *TerraformAction) AddOperation(generationConfig map[string]any, entityOperationConfig extensions.EntityOperationV1Config, operation *Operation) error

Adds an operation to the action.

func (*TerraformAction) AssembleSchemaTypeDef

func (r *TerraformAction) AssembleSchemaTypeDef(excludeEmptyObjectSchemas bool) error

AssembleSchemaTypeDef builds the merged schema TypeDef for the action by combining all invoke operation shards. The result is deep-cloned to break shared *TypeDef pointers from OAS $ref resolution, making it safe for subsequent path-dependent modifications (extension tagging, propagation).

func (*TerraformAction) SchemaDescription

func (r *TerraformAction) SchemaDescription() string

SchemaDescription returns the description string for the Terraform schema. If a description is set via x-speakeasy-entity-description, it is returned directly. Otherwise, a default description is generated from the entity name.

type TerraformActionOperations

type TerraformActionOperations struct {
	// Ordered invoke operations. Populated by MergeOperationShards.
	Invoke TerraformOperations `json:"-" yaml:"-"`

	// Merged request shard across all invoke operations. Populated by
	// MergeOperationShards.
	InvokeRequestShard *TypeDef `json:"-" yaml:"-"`

	// Merged response shard across all invoke operations. Populated by
	// MergeOperationShards.
	InvokeResponseShard *TypeDef `json:"-" yaml:"-"`

	// Merged request and response shard across all invoke operations.
	// Populated by MergeOperationShards.
	InvokeShard *TypeDef `json:"-" yaml:"-"`
	// contains filtered or unexported fields
}

Describes operations associated with a Terraform action.

func NewTerraformActionOperations

func NewTerraformActionOperations() *TerraformActionOperations

Creates a new Terraform action operations, safely initializing underlying fields.

func (*TerraformActionOperations) AddOperation

func (o *TerraformActionOperations) AddOperation(generationConfig map[string]any, entityOperationConfig extensions.EntityOperationV1Config, op *Operation) error

func (*TerraformActionOperations) All

All returns all operations. For actions this is the invoke operations.

func (*TerraformActionOperations) DataModelRefreshOperations

func (o *TerraformActionOperations) DataModelRefreshOperations() TerraformOperations

DataModelRefreshOperations returns operations whose API responses are mapped back into the Terraform data model. For actions this is the invoke operations.

Read operations are listed first across all resource types to ensure pagination-aware RefreshFrom methods take priority during method name deduplication (TFGEN-214).

func (*TerraformActionOperations) MergeOperationShards

func (o *TerraformActionOperations) MergeOperationShards() error

MergeOperationShards computes and stores the merged shards for each operation type. This should be called after all operations have been added and any per-operation shard mutations (e.g. tagging rules) have been applied.

func (*TerraformActionOperations) Validate

func (o *TerraformActionOperations) Validate() error

Validate checks that the operations are valid for schema assembly. This should be called before AssembleSchemaTypeDef to surface errors early.

type TerraformDataResource

type TerraformDataResource struct {
	// Description for the data resource. Sourced from
	// x-speakeasy-entity-description configuration, if available.
	Description string `json:"description" yaml:"description"`

	// Mapping of global field names to definitions for all operations. These
	// are added to the entity resource struct type, copied in the Configure()
	// method, made optional in the resource schema, and checked in the resource
	// methods.
	GlobalFields map[string]*FieldDef `json:"globalFields" yaml:"globalFields"`

	// Computed Go type name for the data resource data model struct, e.g.
	// "ExampleDataSourceModel". Set by NewTerraformDataResource.
	GoDataModelTypeName string `json:"goDataModelTypeName" yaml:"goDataModelTypeName"`

	// Computed Go type name for the data resource private data model struct, e.g.
	// "ExampleDataSourcePrivateDataModel". Set by NewTerraformDataResource.
	GoPrivateDataModelTypeName string `json:"goPrivateDataModelTypeName" yaml:"goPrivateDataModelTypeName"`

	// Computed Go type name for the data resource struct implementation, e.g.
	// "ExampleDataSource". Set by NewTerraformDataResource.
	GoTypeName string `json:"goTypeName" yaml:"goTypeName"`

	// Whether the entity requires SDK method options in its generated code.
	// This is true when any operation has a Patch.Style configuration.
	// Populated by AssembleSchemaTypeDef.
	IncludeSDKMethodOptions bool `json:"includeSDKMethodOptions,omitempty" yaml:"includeSDKMethodOptions,omitempty"`

	// Unsanitized name of the data resource type, such as "Thing".
	Name string `json:"name" yaml:"name"`

	// Operation security configuration for the data resource. This is set
	// when the underlying operations have operation security defined and the
	// enableOperationSecurity generation configuration flag is enabled. Only
	// a single operation security configuration is supported per data resource,
	// even if multiple operations have differing security configurations. This
	// is intentional to simplify the generated Terraform code and avoid
	// complexity around per-operation security configuration for consumers.
	OperationSecurity *FieldDef `json:"operationSecurity" yaml:"operationSecurity"`

	// All operations associated with the data resource.
	Operations *TerraformDataResourceOperations `json:"operations" yaml:"operations"`

	// Mapping of pagination input field names to an unused boolean value
	// that is replaceable for future updates.
	PaginationInputFields map[string]bool `json:"paginationInputFields" yaml:"paginationInputFields"`

	// Mapping of pagination output field names to an unused boolean value
	// that is replaceable for future updates.
	PaginationOutputFields map[string]bool `json:"paginationOutputFields" yaml:"paginationOutputFields"`

	// Merged Terraform resource schema TypeDef across all operations. This
	// represents the combined schema view of the data resource after merging
	// all operation shards together.
	SchemaTypeDef *TypeDef `json:"-" yaml:"-"`

	// Deduplicated, sorted list of SDK request conversion methods (To_ prefix)
	// pre-computed from all operations. Populated by AssembleSchemaTypeDef.
	SDKRequestMethods []*TerraformSDKMethod `json:"-" yaml:"-"`

	// Deduplicated, sorted list of SDK response conversion methods
	// (RefreshFrom_ or RefreshFromArrayOf_ prefix) pre-computed from
	// DataModelRefreshOperations. Populated by AssembleSchemaTypeDef.
	SDKResponseMethods []*TerraformSDKMethod `json:"-" yaml:"-"`

	// Server configuration for the data resource. This is defined when
	// the underlying operations have path or operation server URLs defined.
	// Only a single server configuration is supported per data resource,
	// even if multiple operations have differing server URLs defined. This is
	// intentional to simplify the generated Terraform code and avoid complexity
	// around per-operation server configuration for consumers.
	Server *TerraformServer `json:"server" yaml:"server"`

	// Resolved full Terraform data source type name (e.g.
	// "myprovider_my_data_source"), composed from the resolved provider type
	// name and the snake_case form of Name. Used as the value of
	// resp.TypeName in the data source Metadata implementation and in
	// example Terraform configuration files. Populated by
	// TerraformProvider.AddOrGetDataResource.
	TerraformTypeName string `json:"terraformTypeName" yaml:"terraformTypeName"`
}

Describes a Terraform data resource.

func NewTerraformDataResource

func NewTerraformDataResource(name string) *TerraformDataResource

Creates a new Terraform data resource, safely initializing underlying fields.

func (*TerraformDataResource) AddOperation

func (r *TerraformDataResource) AddOperation(generationConfig map[string]any, entityOperationConfig extensions.EntityOperationV1Config, operation *Operation) error

Adds an operation to the data resource.

func (*TerraformDataResource) AssembleSchemaTypeDef

func (r *TerraformDataResource) AssembleSchemaTypeDef(excludeEmptyObjectSchemas bool) error

AssembleSchemaTypeDef builds the merged schema TypeDef for the data resource by combining all read operation shards with pre-processing and per-operation extension tagging. The result is deep-cloned to break shared *TypeDef pointers from OAS $ref resolution, making it safe for subsequent modifications.

The method performs the following steps:

  1. Merge individual operation shards into combined per-type shards
  2. Pre-processing: tag readonly/computed extensions and apply field properties
  3. Override unsound readonly fields using per-op request shards
  4. Rename pre-processed extensions (readonly → manual-param-readonly)
  5. Merge per-operation shards and alias nodes
  6. Per-operation extension tagging and cleanup of non-read fields
  7. DeepClone to break all shared pointers

func (*TerraformDataResource) SchemaDescription

func (r *TerraformDataResource) SchemaDescription() string

SchemaDescription returns the description string for the Terraform schema. If a description is set via x-speakeasy-entity-description, it is returned directly. Otherwise, a default description is generated from the entity name.

type TerraformDataResourceOperations

type TerraformDataResourceOperations struct {
	// Ordered read operations. Populated by MergeOperationShards.
	Read TerraformOperations `json:"-" yaml:"-"`

	// Merged request shard across all read operations. Populated by
	// MergeOperationShards.
	ReadRequestShard *TypeDef `json:"-" yaml:"-"`

	// Merged response shard across all read operations. Populated by
	// MergeOperationShards.
	ReadResponseShard *TypeDef `json:"-" yaml:"-"`

	// Merged request and response shard across all read operations.
	// Populated by MergeOperationShards.
	ReadShard *TypeDef `json:"-" yaml:"-"`
	// contains filtered or unexported fields
}

Describes operations associated with a Terraform data resource.

func NewTerraformDataResourceOperations

func NewTerraformDataResourceOperations() *TerraformDataResourceOperations

Creates a new Terraform data resource operations, safely initializing underlying fields.

func (*TerraformDataResourceOperations) AddOperation

func (o *TerraformDataResourceOperations) AddOperation(generationConfig map[string]any, entityOperationConfig extensions.EntityOperationV1Config, op *Operation) error

func (*TerraformDataResourceOperations) All

All returns all operations. For data resources this is the read operations.

func (*TerraformDataResourceOperations) DataModelRefreshOperations

func (o *TerraformDataResourceOperations) DataModelRefreshOperations() TerraformOperations

DataModelRefreshOperations returns operations whose API responses are mapped back into the Terraform data model. For data resources this is the read operations.

Read operations are listed first across all resource types to ensure pagination-aware RefreshFrom methods take priority during method name deduplication (TFGEN-214).

func (*TerraformDataResourceOperations) MergeOperationShards

func (o *TerraformDataResourceOperations) MergeOperationShards() error

MergeOperationShards computes and stores the merged shards for each operation type. This should be called after all operations have been added and any per-operation shard mutations (e.g. tagging rules) have been applied.

func (*TerraformDataResourceOperations) Validate

func (o *TerraformDataResourceOperations) Validate() error

Validate checks that the operations are valid for schema assembly. This should be called before AssembleSchemaTypeDef to surface errors early.

type TerraformEphemeralResource

type TerraformEphemeralResource struct {
	// Description for the ephemeral resource. Sourced from
	// x-speakeasy-entity-description configuration, if available.
	Description string `json:"description" yaml:"description"`

	// Mapping of global field names to definitions for all operations. These
	// are added to the entity resource struct type, copied in the Configure()
	// method, made optional in the resource schema, and checked in the resource
	// methods.
	GlobalFields map[string]*FieldDef `json:"globalFields" yaml:"globalFields"`

	// Computed Go type name for the ephemeral resource data model struct, e.g.
	// "ExampleEphemeralResourceModel". Set by NewTerraformEphemeralResource.
	GoDataModelTypeName string `json:"goDataModelTypeName" yaml:"goDataModelTypeName"`

	// Computed Go type name for the ephemeral resource private data model struct,
	// e.g. "ExampleEphemeralResourcePrivateDataModel". Set by
	// NewTerraformEphemeralResource.
	GoPrivateDataModelTypeName string `json:"goPrivateDataModelTypeName" yaml:"goPrivateDataModelTypeName"`

	// Computed Go type name for the ephemeral resource struct implementation, e.g.
	// "ExampleEphemeralResource". Set by NewTerraformEphemeralResource.
	GoTypeName string `json:"goTypeName" yaml:"goTypeName"`

	// Whether the entity requires SDK method options in its generated code.
	// This is always false for ephemeral resources since their operations
	// (open/close) are not checked for SDK method option conditions.
	IncludeSDKMethodOptions bool `json:"includeSDKMethodOptions,omitempty" yaml:"includeSDKMethodOptions,omitempty"`

	// Unsanitized name of the ephemeral resource type, such as "Thing".
	Name string `json:"name" yaml:"name"`

	// Operation security configuration for the ephemeral resource. This is set
	// when the underlying operations have operation security defined and the
	// enableOperationSecurity generation configuration flag is enabled. Only
	// a single operation security configuration is supported per ephemeral resource,
	// even if multiple operations have differing security configurations. This
	// is intentional to simplify the generated Terraform code and avoid
	// complexity around per-operation security configuration for consumers.
	OperationSecurity *FieldDef `json:"operationSecurity" yaml:"operationSecurity"`

	// All operations associated with the ephemeral resource.
	Operations *TerraformEphemeralResourceOperations `json:"operations" yaml:"operations"`

	// Mapping of pagination input field names to an unused boolean value
	// that is replaceable for future updates.
	PaginationInputFields map[string]bool `json:"paginationInputFields" yaml:"paginationInputFields"`

	// Mapping of pagination output field names to an unused boolean value
	// that is replaceable for future updates.
	PaginationOutputFields map[string]bool `json:"paginationOutputFields" yaml:"paginationOutputFields"`

	// Merged Terraform resource schema TypeDef across all operations. This
	// represents the combined schema view of the ephemeral resource after
	// merging all operation shards together.
	SchemaTypeDef *TypeDef `json:"-" yaml:"-"`

	// Deduplicated, sorted list of SDK request conversion methods (To_ prefix)
	// pre-computed from all operations. Populated by AssembleSchemaTypeDef.
	SDKRequestMethods []*TerraformSDKMethod `json:"-" yaml:"-"`

	// Deduplicated, sorted list of SDK response conversion methods
	// (RefreshFrom_ or RefreshFromArrayOf_ prefix) pre-computed from
	// DataModelRefreshOperations. Populated by AssembleSchemaTypeDef.
	SDKResponseMethods []*TerraformSDKMethod `json:"-" yaml:"-"`

	// Server configuration for the ephemeral resource. This is defined when
	// the underlying operations have path or operation server URLs defined.
	// Only a single server configuration is supported per ephemeral resource,
	// even if multiple operations have differing server URLs defined. This is
	// intentional to simplify the generated Terraform code and avoid complexity
	// around per-operation server configuration for consumers.
	Server *TerraformServer `json:"server" yaml:"server"`

	// Resolved full Terraform ephemeral resource type name (e.g.
	// "myprovider_my_ephemeral_resource"), composed from the resolved
	// provider type name and the snake_case form of Name. Used as the value
	// of resp.TypeName in the ephemeral resource Metadata implementation and
	// in example Terraform configuration files. Populated by
	// TerraformProvider.AddOrGetEphemeralResource.
	TerraformTypeName string `json:"terraformTypeName" yaml:"terraformTypeName"`
}

Describes a Terraform ephemeral resource.

func NewTerraformEphemeralResource

func NewTerraformEphemeralResource(name string) *TerraformEphemeralResource

Creates a new Terraform ephemeral resource, safely initializing underlying fields.

func (*TerraformEphemeralResource) AddOperation

func (r *TerraformEphemeralResource) AddOperation(generationConfig map[string]any, entityOperationConfig extensions.EntityOperationV1Config, operation *Operation) error

Adds an operation to the ephemeral resource.

func (*TerraformEphemeralResource) AssembleSchemaTypeDef

func (r *TerraformEphemeralResource) AssembleSchemaTypeDef(excludeEmptyObjectSchemas bool) error

AssembleSchemaTypeDef builds the merged schema TypeDef for the ephemeral resource by combining all open operation shards and close alias nodes with pre-processing and per-operation extension tagging. The result is deep-cloned to break shared *TypeDef pointers from OAS $ref resolution, making it safe for subsequent modifications.

The method performs the following steps:

  1. Merge individual operation shards into combined per-type shards
  2. Pre-processing: tag readonly/computed extensions and apply field properties
  3. Rename pre-processed extensions (readonly → manual-param-readonly)
  4. Merge per-operation shards and alias nodes (open + close)
  5. Per-operation extension tagging and request body readonly override
  6. DeepClone to break all shared pointers

func (*TerraformEphemeralResource) HasCloseOperations

func (r *TerraformEphemeralResource) HasCloseOperations() bool

HasCloseOperations returns whether the ephemeral resource has close operations defined.

func (*TerraformEphemeralResource) SchemaDescription

func (r *TerraformEphemeralResource) SchemaDescription() string

SchemaDescription returns the description string for the Terraform schema. If a description is set via x-speakeasy-entity-description, it is returned directly. Otherwise, a default description is generated from the entity name.

type TerraformEphemeralResourceOperations

type TerraformEphemeralResourceOperations struct {
	// Ordered close operations. Populated by MergeOperationShards.
	Close TerraformOperations `json:"-" yaml:"-"`

	// Merged request shard across all close operations. Populated by
	// MergeOperationShards.
	CloseRequestShard *TypeDef `json:"-" yaml:"-"`

	// Merged response shard across all close operations. Populated by
	// MergeOperationShards.
	CloseResponseShard *TypeDef `json:"-" yaml:"-"`

	// Merged request and response shard across all close operations.
	// Populated by MergeOperationShards.
	CloseShard *TypeDef `json:"-" yaml:"-"`

	// Ordered open operations. Populated by MergeOperationShards.
	Open TerraformOperations `json:"-" yaml:"-"`

	// Merged request shard across all open operations. Populated by
	// MergeOperationShards.
	OpenRequestShard *TypeDef `json:"-" yaml:"-"`

	// Merged response shard across all open operations. Populated by
	// MergeOperationShards.
	OpenResponseShard *TypeDef `json:"-" yaml:"-"`

	// Merged request and response shard across all open operations.
	// Populated by MergeOperationShards.
	OpenShard *TypeDef `json:"-" yaml:"-"`
	// contains filtered or unexported fields
}

Describes operations associated with a Terraform ephemeral resource.

func NewTerraformEphemeralResourceOperations

func NewTerraformEphemeralResourceOperations() *TerraformEphemeralResourceOperations

Creates a new Terraform ephemeral resource operations, safely initializing underlying fields.

func (*TerraformEphemeralResourceOperations) AddOperation

func (o *TerraformEphemeralResourceOperations) AddOperation(generationConfig map[string]any, entityOperationConfig extensions.EntityOperationV1Config, op *Operation) error

func (*TerraformEphemeralResourceOperations) All

All returns all operations. For ephemeral resources this is the open and close operations.

func (*TerraformEphemeralResourceOperations) DataModelRefreshOperations

func (o *TerraformEphemeralResourceOperations) DataModelRefreshOperations() TerraformOperations

DataModelRefreshOperations returns operations whose API responses are mapped back into the Terraform data model. For ephemeral resources this is the open operations. Close operations are excluded because their responses do not carry entity data for the data model.

Read operations are listed first across all resource types to ensure pagination-aware RefreshFrom methods take priority during method name deduplication (TFGEN-214).

func (*TerraformEphemeralResourceOperations) MergeOperationShards

func (o *TerraformEphemeralResourceOperations) MergeOperationShards() error

MergeOperationShards computes and stores the merged shards for each operation type. This should be called after all operations have been added and any per-operation shard mutations (e.g. tagging rules) have been applied.

func (*TerraformEphemeralResourceOperations) Validate

Validate checks that the operations are valid for schema assembly. This should be called before AssembleSchemaTypeDef to surface errors early.

type TerraformHoistedSource

type TerraformHoistedSource struct {
	// AssociatedTypeName is the name of the oneOf associated type containing the source field.
	AssociatedTypeName string `yaml:"associatedTypeName" json:"associatedTypeName"`
	// FieldName is the name of the source field within the associated type.
	FieldName string `yaml:"fieldName" json:"fieldName"`
	// PathPrefix is the path from root to the parent oneOf, used to build absolute paths
	// in plan modifiers. For nested oneOf unions, this contains all intermediate path segments.
	PathPrefix []string `yaml:"pathPrefix,omitempty" json:"pathPrefix,omitempty"`
}

TerraformHoistedSource describes the path to a source field within a oneOf associated type that was hoisted to the parent level.

type TerraformInvalidImportType

type TerraformInvalidImportType struct {
	// Hierarchy is the dot-separated path to the node within the TypeDef tree.
	Hierarchy string

	// TypeName is the string representation of the unsupported DataType.
	TypeName string
}

TerraformInvalidImportType describes a TypeDef node with a DataType that is not supported for Terraform import state operations.

type TerraformManagedResource

type TerraformManagedResource struct {
	// Description for the managed resource. Sourced from
	// x-speakeasy-entity-description configuration, if available.
	Description string `json:"description" yaml:"description"`

	// Mapping of global field names to definitions for all operations. These
	// are added to the entity resource struct type, copied in the Configure()
	// method, made optional in the resource schema, and checked in the resource
	// methods.
	GlobalFields map[string]*FieldDef `json:"globalFields" yaml:"globalFields"`

	// Computed Go type name for the managed resource data model struct, e.g.
	// "ExampleResourceModel". Set by NewTerraformManagedResource.
	GoDataModelTypeName string `json:"goDataModelTypeName" yaml:"goDataModelTypeName"`

	// Computed Go type name for the managed resource private data model struct,
	// e.g. "ExampleResourcePrivateDataModel". Set by NewTerraformManagedResource.
	GoPrivateDataModelTypeName string `json:"goPrivateDataModelTypeName" yaml:"goPrivateDataModelTypeName"`

	// Computed Go type name for the managed resource struct implementation, e.g.
	// "ExampleResource". Set by NewTerraformManagedResource.
	GoTypeName string `json:"goTypeName" yaml:"goTypeName"`

	// Import state TypeDef for the managed resource, derived from the read
	// request shard. Contains only required fields (as determined by
	// FieldDef.IsTerraformImportRequired), sorted alphabetically. Used by
	// Terraform import state template generation to determine the import ID
	// shape. Populated by AssembleSchemaTypeDef.
	ImportStateTypeDef *TypeDef `json:"-" yaml:"-"`

	// Whether the entity requires SDK method options in its generated code.
	// This is true when any operation has a Patch.Style configuration, any
	// update operation has UsePriorState parameters, or any create/update
	// operation has a TerraformWriteOnly extension. Populated by
	// AssembleSchemaTypeDef.
	IncludeSDKMethodOptions bool `json:"includeSDKMethodOptions,omitempty" yaml:"includeSDKMethodOptions,omitempty"`

	// List of HTTP status codes that represent the managed resource is not
	// found in the API during read operations. These codes automatically cause
	// the resource to be removed from the Terraform state rather than return an
	// API error.
	//
	// Defaults to 404, which has historically been used by many APIs to
	// represent this situation. 410 could potentially also be considered in the
	// future. Values can be customized via x-speakeasy-entity-missing-codes
	// extension configuration.
	MissingCodes []int `json:"missingCodes" yaml:"missingCodes"`

	// Name of the managed resource type, such as "examplecloud_thing".
	Name string `json:"name" yaml:"name"`

	// Operation security configuration for the managed resource. This is set
	// when the underlying operations have operation security defined and the
	// enableOperationSecurity generation configuration flag is enabled. Only
	// a single operation security configuration is supported per managed
	// resource, even if multiple operations have differing security
	// configurations. This is intentional to simplify the generated Terraform
	// code and avoid complexity around per-operation security configuration
	// for consumers.
	OperationSecurity *FieldDef `json:"operationSecurity" yaml:"operationSecurity"`

	// All operations associated with the managed resource.
	Operations *TerraformManagedResourceOperations `json:"operations" yaml:"operations"`

	// Mapping of pagination input field names to an unused boolean value
	// that is replaceable for future updates.
	PaginationInputFields map[string]bool `json:"paginationInputFields" yaml:"paginationInputFields"`

	// Mapping of pagination output field names to an unused boolean value
	// that is replaceable for future updates.
	PaginationOutputFields map[string]bool `json:"paginationOutputFields" yaml:"paginationOutputFields"`

	// Fields from the read response shard that have the
	// x-speakeasy-soft-delete-property extension set. These are used to
	// generate soft-delete handling in the resource Read method.
	// Populated by AssembleSchemaTypeDef.
	ReadSoftDeleteProperties Fields `json:"readSoftDeleteProperties,omitempty" yaml:"readSoftDeleteProperties,omitempty"`

	// Terraform schema for the managed resource.
	Schema *TerraformManagedResourceSchema `json:"schema" yaml:"schema"`

	// Merged Terraform resource schema TypeDef across all operations. This
	// represents the combined schema view of the resource after merging all
	// operation shards together.
	SchemaTypeDef *TypeDef `json:"-" yaml:"-"`

	// Warnings collected during schema assembly. These are non-fatal messages
	// (e.g. optional read request field ignoring, update-in-create suggestions)
	// that should be logged after assembly completes.
	SchemaWarnings []string `json:"schemaWarnings,omitempty" yaml:"schemaWarnings,omitempty"`

	// Deduplicated, sorted list of SDK request conversion methods (To_ prefix)
	// pre-computed from all operations. Populated by AssembleSchemaTypeDef.
	SDKRequestMethods []*TerraformSDKMethod `json:"-" yaml:"-"`

	// Deduplicated, sorted list of SDK response conversion methods
	// (RefreshFrom_ or RefreshFromArrayOf_ prefix) pre-computed from
	// DataModelRefreshOperations. Populated by AssembleSchemaTypeDef.
	SDKResponseMethods []*TerraformSDKMethod `json:"-" yaml:"-"`

	// Server configuration for the managed resource. This is defined when
	// the underlying operations have path or operation server URLs defined.
	// Only a single server configuration is supported per managed resource,
	// even if multiple operations have differing server URLs defined. This is
	// intentional to simplify the generated Terraform code and avoid complexity
	// around per-operation server configuration for consumers.
	Server *TerraformServer `json:"server" yaml:"server"`

	// Resolved full Terraform managed resource type name (e.g.
	// "myprovider_my_resource"), composed from the resolved provider type
	// name and the snake_case form of Name. Used as the value of
	// resp.TypeName in the resource Metadata implementation, in example
	// Terraform configuration files, and in import command examples.
	// Populated by TerraformProvider.AddOrGetManagedResource.
	TerraformTypeName string `json:"terraformTypeName" yaml:"terraformTypeName"`
}

Describes a Terraform managed resource.

func NewTerraformManagedResource

func NewTerraformManagedResource(name string) *TerraformManagedResource

Creates a new Terraform managed resource, safely initializing underlying fields.

func (*TerraformManagedResource) AddOperation

func (r *TerraformManagedResource) AddOperation(generationConfig map[string]any, entityOperationConfig extensions.EntityOperationV1Config, operation *Operation) error

Adds an operation to the managed resource.

func (*TerraformManagedResource) AssembleSchemaTypeDef

func (r *TerraformManagedResource) AssembleSchemaTypeDef(excludeEmptyObjectSchemas bool) error

AssembleSchemaTypeDef builds the merged Terraform resource schema TypeDef from all operation shards. This includes merging individual operation shards, pre-processing, merging CREATE/READ/DELETE/UPDATE shards with validation, deep-cloning, and extension modifications for computed/readonly/force-new semantics.

func (*TerraformManagedResource) SchemaDescription

func (r *TerraformManagedResource) SchemaDescription() string

SchemaDescription returns the description string for the Terraform schema. If a description is set via x-speakeasy-entity-description, it is returned directly. Otherwise, a default description is generated from the entity name.

func (*TerraformManagedResource) SchemaVersion

func (r *TerraformManagedResource) SchemaVersion() int64

SchemaVersion returns the schema version for the managed resource. Returns 0 if no schema is configured.

type TerraformManagedResourceOperations

type TerraformManagedResourceOperations struct {
	// Ordered create operations. Populated by MergeOperationShards.
	Create TerraformOperations `json:"-" yaml:"-"`

	// CreateNeedsReadAfter indicates whether the read operation should be
	// invoked after create operations because the read response shard
	// contains entity fields not present in the create response shard.
	// Populated by MergeOperationShards.
	CreateNeedsReadAfter bool `json:"-" yaml:"-"`

	// Merged request shard across all create operations. Populated by
	// MergeOperationShards.
	CreateRequestShard *TypeDef `json:"-" yaml:"-"`

	// Merged response shard across all create operations. Populated by
	// MergeOperationShards.
	CreateResponseShard *TypeDef `json:"-" yaml:"-"`

	// Merged request and response shard across all create operations.
	// Populated by MergeOperationShards.
	CreateShard *TypeDef `json:"-" yaml:"-"`

	// Ordered delete operations. Populated by MergeOperationShards.
	Delete TerraformOperations `json:"-" yaml:"-"`

	// Merged request shard across all delete operations. Populated by
	// MergeOperationShards.
	DeleteRequestShard *TypeDef `json:"-" yaml:"-"`

	// Merged response shard across all delete operations. Populated by
	// MergeOperationShards.
	DeleteResponseShard *TypeDef `json:"-" yaml:"-"`

	// Merged request and response shard across all delete operations.
	// Populated by MergeOperationShards.
	DeleteShard *TypeDef `json:"-" yaml:"-"`

	// Ordered read operations. Populated by MergeOperationShards.
	Read TerraformOperations `json:"-" yaml:"-"`

	// Merged request shard across all read operations. Populated by
	// MergeOperationShards.
	ReadRequestShard *TypeDef `json:"-" yaml:"-"`

	// Merged response shard across all read operations. Populated by
	// MergeOperationShards.
	ReadResponseShard *TypeDef `json:"-" yaml:"-"`

	// Merged request and response shard across all read operations.
	// Populated by MergeOperationShards.
	ReadShard *TypeDef `json:"-" yaml:"-"`

	// Ordered update operations. Populated by MergeOperationShards.
	Update TerraformOperations `json:"-" yaml:"-"`

	// UpdateNeedsReadAfter indicates whether the read operation should be
	// invoked after update operations because the read response shard
	// contains entity fields not present in the update response shard.
	// Populated by MergeOperationShards.
	UpdateNeedsReadAfter bool `json:"-" yaml:"-"`

	// Merged request shard across all update operations. Populated by
	// MergeOperationShards.
	UpdateRequestShard *TypeDef `json:"-" yaml:"-"`

	// Merged response shard across all update operations. Populated by
	// MergeOperationShards.
	UpdateResponseShard *TypeDef `json:"-" yaml:"-"`

	// Merged request and response shard across all update operations.
	// Populated by MergeOperationShards.
	UpdateShard *TypeDef `json:"-" yaml:"-"`
	// contains filtered or unexported fields
}

Describes operations associated with a Terraform managed resource.

func NewTerraformManagedResourceOperations

func NewTerraformManagedResourceOperations() *TerraformManagedResourceOperations

Creates a new Terraform managed resource operations, safely initializing underlying fields.

func (*TerraformManagedResourceOperations) AddOperation

func (o *TerraformManagedResourceOperations) AddOperation(generationConfig map[string]any, entityOperationConfig extensions.EntityOperationV1Config, op *Operation) error

func (*TerraformManagedResourceOperations) All

All returns all operations. For managed resources this is the create, read, update, and delete operations.

func (*TerraformManagedResourceOperations) DataModelRefreshOperations

func (o *TerraformManagedResourceOperations) DataModelRefreshOperations() TerraformOperations

DataModelRefreshOperations returns operations whose API responses are mapped back into the Terraform data model. For managed resources this is the read, create, and update operations. Delete operations are excluded because their response types are covered by read operations.

Read operations are listed first to ensure pagination-aware RefreshFrom methods take priority during method name deduplication (TFGEN-214).

func (*TerraformManagedResourceOperations) MergeOperationShards

func (o *TerraformManagedResourceOperations) MergeOperationShards(entityName string) error

MergeOperationShards computes and stores the merged shards for each operation type. This should be called after all operations have been added and any per-operation shard mutations (e.g. tagging rules) have been applied.

The entityName is used to compute CreateNeedsReadAfter and UpdateNeedsReadAfter by checking whether the read shard is a structural subset of the create/update shards.

func (*TerraformManagedResourceOperations) Validate

Validate checks that the operations are valid for schema assembly. This should be called before AssembleSchemaTypeDef to surface errors early.

type TerraformManagedResourceSchema

type TerraformManagedResourceSchema struct {
	// Schema version for the managed resource. This relates to Terraform's
	// managed resource state upgrade mechanism. By default and in most cases,
	// this is never set and left as the default value of 0. Sourced from
	// x-speakeasy-entity-version configuration, if available.
	Version int64 `json:"version" yaml:"version"`
}

Describes a Terraform managed resource schema.

func NewTerraformManagedResourceSchema

func NewTerraformManagedResourceSchema() *TerraformManagedResourceSchema

Creates a new Terraform managed resource schema, safely initializing underlying fields.

func (*TerraformManagedResourceSchema) SetVersion

func (s *TerraformManagedResourceSchema) SetVersion(version int64) error

Sets the version.

type TerraformOperation

type TerraformOperation struct {
	// Original API operation. Should always remain untouched.
	APIOperation *Operation

	// EntityMissingCodes holds the HTTP status codes that indicate the entity
	// is not found by the API. Set on read and delete operations for managed
	// resources. The semantics vary by operation type: read operations remove
	// the resource from state (soft delete detection), while delete operations
	// treat these codes as success (the resource is already gone).
	EntityMissingCodes []int

	// Name of the entity this operation is associated with.
	EntityName string

	// String representation from the entity operation configuration in the form
	// of Entity#Op[#Order], such as Thing#create.
	EntityOperation string

	// Has409ConflictCode indicates whether the operation's API response spec
	// defines a 409 Conflict response code. When true, create operations
	// produce "resource already exists" error handling.
	Has409ConflictCode bool

	// IncludeOperationSecurity indicates that this operation has API-level
	// security defined and the entity's enableOperationSecurity generation
	// config flag is enabled. When true, the Terraform resource method
	// invocation includes an operation security variable.
	IncludeOperationSecurity bool

	// Options associated with the entity operation configuration.
	Options *extensions.EntityOperationV1Options

	// Operation request shard. Unset if there is no relevant request.
	//
	// A shard represents the portion of the data that is most relevant to the
	// Terraform resource. For example, the x-speakeasy-entity extension
	// is used to indicate which data represents the top level of the Terraform
	// resource schema, potentially bypassing API-defined intermediate
	// properties such as "data" that are undesirable in Terraform
	// configurations. Resource logic is generated to handle the translation
	// between the API-defined schema and the Terraform resource schema.
	RequestShard *TypeDef

	// RequestBodySDKMethod is the SDK method for the operation's root request
	// type. Matches the target in RequestSDKMethodTargets whose TypeDef
	// equals the request field type. Nil when no matching target exists
	// (e.g. non-class/union request types).
	RequestBodySDKMethod *TerraformSDKMethod

	// RequestSDKMethodTargets holds all SDK TypeDefs that need model-to-SDK
	// (To_) conversion methods for this operation's request. Includes
	// TypeDefs on the path from the request type to the entity TypeDef,
	// plus the root request type itself.
	RequestSDKMethodTargets []TerraformSDKMethodTarget

	// ResponseBodyFieldDef is the response body FieldDef for this operation,
	// resolved by calling TerraformBodyFieldDef(entityName) on the API
	// operation response. Populated by setResponseShard during operation
	// construction. Nil when the response has no body field relevant to the
	// entity or when skipDataModelRefresh is true (cleared by setSDKMethodData).
	// A nil check on this field alone is sufficient to determine whether a
	// data model refresh applies.
	ResponseBodyFieldDef *FieldDef

	// SupportsPagination indicates this operation has a Pagination extension
	// and the response body represents a direct entity (not an array
	// extraction). When true, the Terraform resource method includes
	// pagination loop and pre-refresh field reinitialization logic.
	SupportsPagination bool

	// ResponseBodySDKMethod is the SDK method for the operation's response
	// body type. Matches the target in ResponseSDKMethodTargets whose TypeDef
	// equals ResponseBodyFieldDef.Type. Nil when no matching target or body
	// field exists.
	ResponseBodySDKMethod *TerraformSDKMethod

	// ResponseSDKMethodTargets holds all SDK TypeDefs that need SDK-to-model
	// (RefreshFrom_) conversion methods for this operation's response.
	// Includes the response body type, TypeDefs on the path from the response
	// body to the entity TypeDef, and the entity TypeDef from the full
	// response type. For entity array responses, includes the array wrapper
	// (IsArrayWrapper=true) and item type targets.
	ResponseSDKMethodTargets []TerraformSDKMethodTarget

	// Operation response shard. Unset if there is no relevant response.
	//
	// A shard represents the portion of the data that is most relevant to the
	// Terraform resource. For example, the x-speakeasy-entity extension
	// is used to indicate which data represents the top level of the Terraform
	// resource schema, potentially bypassing API-defined intermediate
	// properties such as "data" that are undesirable in Terraform
	// configurations. Resource logic is generated to handle the translation
	// between the API-defined schema and the Terraform resource schema.
	ResponseShard *TypeDef

	// ServerAttributeName is the Terraform schema attribute name used to look
	// up the per-operation server URL from state. Empty string indicates no
	// server URL support for this operation. The value is derived from
	// entity-level Server configuration during assembly.
	ServerAttributeName string

	// SuccessCodes holds the unique 2xx HTTP status codes defined in the
	// operation's API response spec, used for response validation in
	// Terraform resource methods. Codes containing "X" (e.g. "2XX") are
	// included as-is and matched with a prefix check.
	SuccessCodes []string
	// contains filtered or unexported fields
}

Describes a Terraform operation, which is an API operation that has been mapped to a Terraform resource operation. This accounts for configuration, such as the x-speakeasy-entity extension, that modifies the operation request and response data in preparation for merging all operation data into a single Terraform resource schema.

func NewTerraformOperation

func NewTerraformOperation(apiOperation *Operation, entityOperation extensions.EntityOperationV1Config) (*TerraformOperation, error)

Creates a new TerraformOperation.

func (*TerraformOperation) CleanupShards

func (o *TerraformOperation) CleanupShards()

CleanupShards removes ignored fields from the operation's request and response shards. This should be called after schema assembly is complete, as the shards are used during assembly but need cleanup for code generation.

func (*TerraformOperation) Clone

Returns a deep clone of the TerraformOperation. Note: SDK method targets and pre-computed body SDK methods retain Operation pointers to the original, not the clone. This is safe because Clone is called before setSDKMethodData during entity assembly, so these fields are empty at clone time.

func (*TerraformOperation) FindResponseSDKMethodTarget

func (o *TerraformOperation) FindResponseSDKMethodTarget(td *TypeDef) *TerraformSDKMethodTarget

FindResponseSDKMethodTarget returns the target in ResponseSDKMethodTargets whose TypeDef pointer matches td. Returns nil if no match is found, indicating the TypeDef has no compatible RefreshFrom method.

The returned pointer references a slice element and is valid only while the TerraformOperation remains alive. Callers should use it immediately rather than storing it for later access.

func (*TerraformOperation) HasPatchStyle

func (o *TerraformOperation) HasPatchStyle() bool

HasPatchStyle returns true if the operation has a Patch.Style configuration set. This is one of the conditions that enables IncludeSDKMethodOptions on a Terraform entity.

func (*TerraformOperation) HasTerraformWriteOnly

func (o *TerraformOperation) HasTerraformWriteOnly() bool

HasTerraformWriteOnly returns true if the operation's API request body contains any TypeDef with the TerraformWriteOnly extension set. This is checked for create/update operations as one of the conditions that enables IncludeSDKMethodOptions.

func (*TerraformOperation) HasUsePriorStateParameters

func (o *TerraformOperation) HasUsePriorStateParameters() bool

HasUsePriorStateParameters returns true if the operation's API request has any parameters (path, query, or header) with the MatchConfig.UsePriorState flag set. This is checked for update operations as one of the conditions that enables IncludeSDKMethodOptions.

func (TerraformOperation) String

func (o TerraformOperation) String() string

Returns a string representation of the TerraformOperation.

type TerraformOperations

type TerraformOperations []*TerraformOperation

Describes an ordered collection of Terraform operations for a single operation type (e.g. all create operations for a managed resource).

func (TerraformOperations) SDKRequestMethods

func (ops TerraformOperations) SDKRequestMethods() []*TerraformSDKMethod

SDKRequestMethods builds a deduplicated, sorted list of request SDK methods (To_ prefix) from the operations. Methods are deduplicated by MethodName (first operation wins) and sorted alphabetically.

func (TerraformOperations) SDKResponseMethods

func (ops TerraformOperations) SDKResponseMethods() []*TerraformSDKMethod

SDKResponseMethods builds a deduplicated, sorted list of response SDK methods (RefreshFrom_ or RefreshFromArrayOf_ prefix) from the operations. Methods are deduplicated by MethodName (first operation wins) and sorted alphabetically.

The receiver should be DataModelRefreshOperations() which lists Read operations first for pagination-aware RefreshFrom method priority (TFGEN-214).

func (TerraformOperations) Shards

func (ops TerraformOperations) Shards() (requestShard, responseShard, shard *TypeDef, err error)

Shards computes and returns the merged request shard, response shard, and combined shard from all operations. Any of the returned values may be nil if no operations have the corresponding shard.

The merged shards are computed from scratch each time this method is called, reflecting the current state of each operation's individual RequestShard and ResponseShard. This allows callers to re-compute after mutating individual operation shards (e.g. applying tagging rules).

Alias node merging into SchemaTypeDef is handled separately by each resource type's AssembleSchemaTypeDef since the timing and shard sources vary per resource type.

type TerraformProvider

type TerraformProvider struct {
	// Valid actions sorted by name. Populated by AssembleSchemas.
	//
	// Terraform actions are entities with an invoke lifecycle operation.
	// These are represented in Terraform using "action" configuration blocks.
	Actions []*TerraformAction `json:"actions" yaml:"actions"`

	// Valid data resources sorted by name. Populated by AssembleSchemas.
	//
	// Terraform data resources are entities with only a Read lifecycle
	// operation. These are represented in Terraform using "data" configuration
	// blocks and colloquially referred to as "data sources".
	DataResources []*TerraformDataResource `json:"data_resources" yaml:"data_resources"`

	// Valid ephemeral resources sorted by name. Populated by AssembleSchemas.
	//
	// Terraform ephemeral resources are entities with an open lifecycle
	// operation. These are represented in Terraform using "ephemeral"
	// configuration blocks.
	EphemeralResources []*TerraformEphemeralResource `json:"ephemeral_resources" yaml:"ephemeral_resources"`

	// Valid managed resources sorted by name. Populated by AssembleSchemas.
	//
	// Terraform managed resources are entities with Create, Read, Update,
	// and Delete lifecycle operations. These are represented in Terraform
	// using "resource" configuration blocks and colloquially referred to as
	// "resources" due to that implementation detail and existing before other
	// resource types in Terraform.
	ManagedResources []*TerraformManagedResource `json:"managed_resources" yaml:"managed_resources"`

	// Resolved Terraform provider type name (e.g. "myprovider"). Used as the
	// value of resp.TypeName in the provider Metadata implementation, and as
	// the prefix for all resource, data source, ephemeral resource, and
	// action type names. Sourced from the providerTypeNameOverride generation
	// configuration if set, otherwise from packageName. Must be set before
	// any AddOrGet* method is called so that entity TerraformTypeName fields
	// are composed with the correct prefix.
	TerraformTypeName string `json:"terraformTypeName" yaml:"terraformTypeName"`
	// contains filtered or unexported fields
}

Describes all Terraform Provider related data in the AST as collected from various x-speakeasy-entity* extensions. Data is split by resource type.

func NewTerraformProvider

func NewTerraformProvider() *TerraformProvider

Creates a new Terraform AST, safely initializing underlying fields.

func (*TerraformProvider) AddOperation

func (p *TerraformProvider) AddOperation(generationConfig map[string]any, operation *Operation) error

Adds an operation to the appropriate resources based on the x-speakeasy-entity-operation configuration.

func (*TerraformProvider) AddOrGetAction

func (a *TerraformProvider) AddOrGetAction(name string) (*TerraformAction, error)

Adds a new action or retrieves an existing action.

func (*TerraformProvider) AddOrGetDataResource

func (a *TerraformProvider) AddOrGetDataResource(name string) (*TerraformDataResource, error)

Adds a new data resource or retrieves an existing data resource.

func (*TerraformProvider) AddOrGetEphemeralResource

func (a *TerraformProvider) AddOrGetEphemeralResource(name string) (*TerraformEphemeralResource, error)

Adds a new ephemeral resource or retrieves an existing ephemeral resource.

func (*TerraformProvider) AddOrGetManagedResource

func (a *TerraformProvider) AddOrGetManagedResource(name string) (*TerraformManagedResource, error)

Adds a new managed resource or retrieves an existing managed resource.

func (*TerraformProvider) AnnotateTerraformSymbols

func (p *TerraformProvider) AnnotateTerraformSymbols(ctx context.Context, enableTypeDeduplication bool) error

AnnotateTerraformSymbols assigns unique deduplicated "Symbol" extension values to all complex types (class and union) across all entity SchemaTypeDefs. Structurally identical types may share a symbol to reduce generated code duplication. When enableTypeDeduplication is true, any structurally matching type is deduplicated regardless of name; when false, types must also share the same candidate name. Must be called after AssembleSchemas.

func (*TerraformProvider) AssembleSchemas

func (p *TerraformProvider) AssembleSchemas(ctx context.Context, excludeEmptyObjectSchemas bool) error

AssembleSchemas calls AssembleSchemaTypeDef on all valid entities in the provider. This must be called after all operations have been added. Schema warnings from managed resources are logged as warnings.

type TerraformSDKMethod

type TerraformSDKMethod struct {
	// MethodName is the fully sanitized method name, e.g.
	// "ToSharedCreateThingRequest" or "RefreshFromSharedGetThingResponse".
	MethodName string

	// Operation is the first TerraformOperation that contributed this method
	// during deduplication (first-wins). Provides operation context such as
	// patch style, pagination, and entity operation string.
	Operation *TerraformOperation

	// Optional indicates whether the SDK parameter for response methods
	// should be a pointer type.
	Optional bool

	// Target is the underlying SDK method target, containing the TypeDef
	// and metadata needed for method body rendering.
	Target TerraformSDKMethodTarget
}

TerraformSDKMethod describes a deduplicated SDK conversion method for a Terraform entity's data model type. Contains the resolved method name and operation context needed for method body rendering.

type TerraformSDKMethodTarget

type TerraformSDKMethodTarget struct {
	// TypeDef is the target type that needs a conversion method.
	TypeDef *TypeDef

	// Operation is the TerraformOperation that owns this target. Provides
	// operation context such as patch style, pagination, and entity
	// operation string.
	Operation *TerraformOperation

	// Optional indicates whether this TypeDef was reached through an
	// optional/nullable field. Determines whether the SDK parameter for
	// response methods should be a pointer type.
	Optional bool

	// IsArrayWrapper indicates this target represents an array/set type
	// that directly wraps entity items. When true, the method uses a
	// RefreshFromArrayOf_ prefix instead of RefreshFrom_.
	// Reference: TFGEN-212.
	IsArrayWrapper bool
}

TerraformSDKMethodTarget represents a TypeDef along the path from an API request or response type to a Terraform entity TypeDef that needs an SDK conversion method. This includes the entity TypeDef itself and any intermediate TypeDefs.

func (TerraformSDKMethodTarget) SDKRequestMethod

func (t TerraformSDKMethodTarget) SDKRequestMethod() *TerraformSDKMethod

SDKRequestMethod creates a TerraformSDKMethod for a request conversion using the To_ prefix.

func (TerraformSDKMethodTarget) SDKResponseMethod

func (t TerraformSDKMethodTarget) SDKResponseMethod() *TerraformSDKMethod

SDKResponseMethod creates a TerraformSDKMethod for a response conversion. The prefix is RefreshFromArrayOf_ for array wrapper targets, otherwise RefreshFrom_.

type TerraformServer

type TerraformServer struct {
	// Name of the configurable attribute in the schema.
	AttributeName string `json:"attributeName" yaml:"attributeName"`

	// Server description.
	Description string `json:"description" yaml:"description"`

	// Server URL.
	URL string `json:"url" yaml:"url"`
}

Describes Terraform per-operation server configuration. This is defined when the underlying operations have path or operation server URLs defined. Only a single server configuration is supported, even if multiple operations have differing server URLs defined. This is intentional to simplify the generated Terraform code and avoid complexity around per-operation server URL configuration for Terraform consumers.

type Test

type Test struct {
	Name            string
	Workflow        *ArazzoWorkflow
	UsingMockServer bool
	Incomplete      []string
	InternalID      string
	InternalEnvVars []TestEnvVar
}

type TestEnvVar

type TestEnvVar struct {
	Name  string
	Value string
}

type TestGroup

type TestGroup struct {
	Name  string
	Tests []*Test
}

type Tests

type Tests struct {
	// TestGroups represent different groups of tests that will be grouped with the x-speakeasy-test-group extension in an Arazzo document.
	// Tests live at the top level of the AST as they aren't associated with any particular SDK or operation and could contain calls to multiple.
	TestGroups          []*TestGroup
	GenerateExampleFile bool
}

type TypeDef

type TypeDef struct {
	// The unresolved name of the type, only used for complex types
	Name string `yaml:",omitempty"`

	// The original name of the type before resolution, only used for complex types
	OriginalName string `yaml:",omitempty"`

	// The hash of the type, only used for complex types
	Hash string `yaml:",omitempty"`

	// Sometimes we were lazy and didn't write "t.OriginalName" and just wrote "t.Name"
	// This flag is used to indicate that the original name has been frozen and should not be changed
	OriginalNameFrozen bool

	// The context stack for this type only present for complex types
	ContextStack ContextStack

	// Deduplicated context stacks
	DeduplicatedContextStacks ContextStacks `yaml:"-"`

	// The location of the type in the OpenAPI document. Might be nil if the type is derived.
	Location *OpenAPILocation `yaml:"-"`

	// The actual type of this definition
	Type DataType `yaml:",omitempty"`

	// If this is a container this is the type of the items
	ItemType *TypeDef `yaml:",omitempty"`

	// If this is a container that can  hold null values then this is true
	ContainsNull bool `yaml:",omitempty"`

	// Whether this is a union that can be null
	IsNullableUnion bool `yaml:",omitempty"`

	// If this is a class, this is the list of fields
	Fields Fields `yaml:",omitempty"`

	// JSON Schema Validations
	Validations *Validations `yaml:",omitempty"`

	// If this is an any type this is a list of types it could be
	AssociatedTypes TypeDefs `yaml:",omitempty"`

	// If this is an enum, this contains the details of the enum
	Enum *Enum `yaml:",omitempty"`

	// The scope of this type, only used for complex types
	Scope Scope `yaml:",omitempty"`

	// Whether this type is an inline request
	IsInlineRequestBody bool `yaml:",omitempty"`

	// Whether this type is an inline response
	IsInlineResponseBody bool `yaml:",omitempty"`

	// Whether this type is a component
	IsComponent bool `yaml:",omitempty"`

	// Whether this is a partial class that was truncated to avoid circular references, only used for field types not templating
	Truncated bool `yaml:",omitempty"`

	// Comments for this type
	Comments *Comment `yaml:",omitempty"`

	// Whether this type is an input type, ie contains write-only fields
	Input bool `yaml:",omitempty"`

	// Whether this type is an output type, ie contains read-only fields
	Output bool `yaml:",omitempty"`

	// Extensions available for this type
	Extensions *TypeDefExtensions `yaml:",omitempty"`

	// Example values for this type
	Examples Examples `yaml:",omitempty"`

	// If data type is a string, will contain a hint as to the format of the string to help drive usage snippets (e.g. format="email"); if data type is bigint it might contain "string" to indicate it should be serialized/deserialized to a JSON string
	Format string `yaml:",omitempty"`

	// ContentMediaType is the JSON Schema content vocabulary contentMediaType value for this type (e.g. "application/json")
	ContentMediaType string `yaml:",omitempty"`

	// Discriminator for union types
	Discriminator *Discriminator `yaml:",omitempty"`

	// DiscriminatorPreApplied is the name of the discriminator property that this type is always used with
	// When a type appears in multiple unions with the same discriminator property and value, this field is set
	DiscriminatorPreApplied string `yaml:",omitempty"`

	// Whether this discriminated union should be open (tolerating unknown discriminator values)
	IsUnionOpen bool `yaml:",omitempty"`

	// Whether this is a complex any type, ie it would be a union in supported languages
	ComplexAny bool `yaml:",omitempty"`

	// The location this model will be generated to if its a top level model
	OutputLocation string `yaml:",omitempty"`

	// The name of the model the type ended up in after resolution by `getModelTypes` in the templates
	ResolvedModel string `yaml:",omitempty"`

	// Whether this is an event stream envelope type
	EventStreamEnvelope bool `yaml:",omitempty"`

	// Whether this is a response envelope type
	ResponseEnvelope bool `yaml:",omitempty"`

	// Whether this type is used in a union, used for resolving type conflicts
	UsedInUnion bool `yaml:",omitempty"`

	// Whether this type is referenced by a request (as a immediate child or reachable via a chain of children)
	UsedInRequest bool `yaml:",omitempty"`

	// Whether this type is referenced by a response (as a immediate child or reachable via a chain of children)
	UsedInResponse bool `yaml:",omitempty"`

	// Whether this type is referenced by a webhook (as a immediate child or reachable via a chain of children)
	UsedInWebhook bool `yaml:",omitempty"`

	// Whether this type is referenced by a callback (as a immediate child or reachable via a chain of children)
	UsedInCallback bool `yaml:",omitempty"`

	// Whether this type is referenced by security (as a immediate child or reachable via a chain of children)
	UsedInSecurity bool `yaml:",omitempty"`

	// The reference in the serialized JSON
	Reference string `yaml:",omitempty"`

	// Whether this type has been registered
	Registered bool `yaml:"-"`

	// Special cache for sanitized enum names used during name resolution
	CachedEnumNames []string `yaml:"-"`

	// Whether this type is a multipart file
	IsMultipartFile bool `yaml:"-"`

	// EventStreamSentinel value for event streams
	EventStreamSentinel string `yaml:",omitempty"`
}

TypeDef is a definition of a type, it can represent a class, enum, container or primitive type

func NewSDKTypeDef

func NewSDKTypeDef(name string, contextStack ContextStack) *TypeDef

Returns a new SDK TypeDef with the given name and context stack.

func NewType

func NewType(typ *TypeDef, contextStack ContextStack) *TypeDef

func (*TypeDef) AssociatedTypeName

func (t *TypeDef) AssociatedTypeName(associatedType *TypeDef) string

Returns the name of the given associated type using the precedence of: - Discriminator mapping name - OriginalName - Name - Associated type DataType

func (*TypeDef) Children

func (t *TypeDef) Children(yield func(field *FieldDef, typ *TypeDef) bool)

Returns the shallow children of a type If it has fields, it will return the fields If it's a union, it will return the associated types as children (fieldDef is nil) If it's a container, it will return the item type as a child (fieldDef is nil)

func (*TypeDef) Clone

func (t *TypeDef) Clone() *TypeDef

Clone creates a deep copy of the TypeDef

func (*TypeDef) ContainsTruncated

func (t *TypeDef) ContainsTruncated() bool

Returns true if this TypeDef or any of its children are truncated (contain circular references).

func (*TypeDef) DeepClone

func (t *TypeDef) DeepClone() *TypeDef

DeepClone creates a fully independent deep copy of the TypeDef tree. Unlike Clone(), which preserves shared *TypeDef pointers via a visited map, DeepClone creates independent copies for every position in the tree. The visited maps are used only for cycle detection (back-edges): entries are added before recursing into children and removed after, so shared pointers (cross-edges) each get their own copy.

This is necessary when the cloned tree will be mutated by path-dependent operations (e.g. TerraformPropagateComputedParent) that propagate state differently depending on the path to a node. OAS $ref resolution caches TypeDef pointers (getCachedType in schemas.go), so the same *TypeDef can appear at multiple positions in the tree. Clone() preserves this sharing; DeepClone() breaks it.

func (*TypeDef) EnsureExtensions

func (t *TypeDef) EnsureExtensions()

EnsureExtensions initializes Extensions if nil, including the All map.

func (*TypeDef) FindAssociatedTypeByTypeDef

func (t *TypeDef) FindAssociatedTypeByTypeDef(typeDef *TypeDef) *TypeDef

Returns the associated type that matches the given TypeDef. The algorithm uses the naming precedence of: - Discriminator mapping name - OriginalName - Name - Associated type DataType

func (*TypeDef) FindEntitySDKMethodTargets

func (t *TypeDef) FindEntitySDKMethodTargets(entityName string, optional bool) []TerraformSDKMethodTarget

FindEntitySDKMethodTargets returns the TerraformSDKMethodTarget for each TypeDef on the path from this TypeDef to the TypeDef matching the given entity name, ordered deepest match first (entity TypeDef) to shallowest (this TypeDef). Returns nil if no matching entity TypeDef is found.

The optional parameter indicates whether this TypeDef was reached through an optional/nullable access path, which propagates into each TerraformSDKMethodTarget.

Only the first matching path is returned via depth-first search through Fields, then ItemType, then AssociatedTypes.

func (*TypeDef) FindEntityTypeDef

func (t *TypeDef) FindEntityTypeDef(entityName string) *TypeDef

Returns this TypeDef or any of its children when the given entity name matches the x-speakeasy-entity configuration.

func (*TypeDef) FindFieldByName

func (t *TypeDef) FindFieldByName(fieldName string) *FieldDef

func (*TypeDef) FreezeOriginalName

func (t *TypeDef) FreezeOriginalName()

func (*TypeDef) GetFullyQualifiedName

func (t *TypeDef) GetFullyQualifiedName() string

func (*TypeDef) GetLocationNode

func (t *TypeDef) GetLocationNode() *yaml.Node

func (*TypeDef) GetRegistrationID

func (t *TypeDef) GetRegistrationID(opts ...RegistrationIDOption) string

func (*TypeDef) GetRegistrationIDOrType

func (t *TypeDef) GetRegistrationIDOrType() string

Unlike GetRegistrationID() this method will not panic if there's no ContextStack If possible GetRegistrationID will be used. Otherwise this is a best effort unique string for this type. The ID is not guaranteed to be unique.

func (*TypeDef) HasEntityName

func (t *TypeDef) HasEntityName(entityName string) bool

Returns true if TypeDef has x-speakeasy-entity configured with the given entity name.

func (*TypeDef) HoistArrayItemResponseFilterFields

func (t *TypeDef) HoistArrayItemResponseFilterFields()

HoistArrayItemResponseFilterFields checks the entity's array fields for item types that contain x-speakeasy-response-filter fields and hoists those filter fields to the entity level. This supports the "entity-above-array" pattern where the entity wraps an array of items that should be filtered by a user-provided value. Hoisted fields are Optional-only (not Computed) since they exist purely as filter inputs at the entity level.

func (*TypeDef) IsContainer

func (t *TypeDef) IsContainer() bool

IsContainer returns true if this type is an array or map

func (*TypeDef) IsCustomClass

func (t *TypeDef) IsCustomClass() bool

IsCustomClass returns true if this type is a class defined by the OpenAPI Document

func (*TypeDef) IsCustomType

func (t *TypeDef) IsCustomType() bool

IsCustomType returns true if this type is a named type defined by the OpenAPI Document

func (*TypeDef) IsEmpty

func (t *TypeDef) IsEmpty() bool

IsEmpty returns true if this type can be considered empty. For example, a class type with no child fields.

func (*TypeDef) IsEqual

func (t *TypeDef) IsEqual(other *TypeDef, opts ...IsEqualOpt) error

func (TypeDef) IsEqualType

func (t TypeDef) IsEqualType(other TypeDef) bool

func (*TypeDef) IsInput

func (t *TypeDef) IsInput(nameResolutionFixesDec2023 bool) bool

IsInput returns true if this type is an input type, ie contains write-only fields

func (*TypeDef) IsObjectType

func (t *TypeDef) IsObjectType() bool

IsObjectType returns true if this type is a class, map or any type and generally serializes to a JSON object

func (*TypeDef) IsOutput

func (t *TypeDef) IsOutput(nameResolutionFixesDec2023 bool) bool

IsOutput returns true if this type is an output type, ie contains read-only fields

func (*TypeDef) IsPrimitive

func (t *TypeDef) IsPrimitive() bool

IsPrimitive returns true if this type is a primitive type

func (*TypeDef) IsPrimitiveContainer

func (t *TypeDef) IsPrimitiveContainer() bool

IsPrimitiveContainer returns true if this type is an array or map of primitive types

func (*TypeDef) IsRequest

func (t *TypeDef) IsRequest() bool

func (*TypeDef) IsSimpleObjectOrContainerType

func (t *TypeDef) IsSimpleObjectOrContainerType() bool

IsSimpleObjectOrContainerType returns true if this type is a class, map or array that contains a simple object with no complex type fields

func (*TypeDef) IsStructurallyDeduplicated

func (t *TypeDef) IsStructurallyDeduplicated() bool

func (*TypeDef) IsTerraformEqual

func (t *TypeDef) IsTerraformEqual(other *TypeDef) bool

Returns true if the TypeDef is equal to given TypeDef for Terraform usage.

NOTE: This logic is a subset of the full equality logic in IsEqual, focusing on aspects relevant to Terraform. It also differs from IsEqual in certain ways, such as treating matching TypeDef DataType and Enum underlying DataType as equivalent.

func (*TypeDef) IsTerraformPrimitiveType

func (t *TypeDef) IsTerraformPrimitiveType() bool

Returns true if TypeDef DataType is a primitive type for Terraform usage.

func (*TypeDef) IsTerraformSubsetOf

func (t *TypeDef) IsTerraformSubsetOf(other *TypeDef) bool

IsTerraformSubsetOf returns true if every field, associated type, and item type in t has a structural equivalent in other (and those equivalents are themselves subsets). Used to determine whether a read operation must follow another operation to capture fields not present in that operation's response.

func (*TypeDef) IsTerraformSubsetOfEntity

func (t *TypeDef) IsTerraformSubsetOfEntity(entityName string, other *TypeDef) bool

IsTerraformSubsetOfEntity finds the entity TypeDef in both t and other, then returns whether the entity in t is a structural subset of the entity in other. Returns true (is a subset) when either entity cannot be found.

func (*TypeDef) IsTerraformSymbolEqual

func (t *TypeDef) IsTerraformSymbolEqual(other *TypeDef) bool

IsTerraformSymbolEqual reports whether two TypeDefs are structurally equal for Terraform symbol deduplication purposes. Unlike IsTerraformEqual, fields are matched using sanitized name comparison (SanitizeFieldName) rather than exact name matching, which accounts for casing/formatting differences in field names from different operation shards.

The TypeDef graph must be acyclic. Circular references are rejected earlier by ContainsTruncated checks in generateTerraformAST.

func (*TypeDef) IsTypeWithFields

func (t *TypeDef) IsTypeWithFields() bool

HasFields returns true if this type has fields

func (*TypeDef) JSON

func (t *TypeDef) JSON() map[string]any

Intended to be used for debugging, not for any other purpose - avoids circular references

func (TypeDef) MarshalYAML

func (t TypeDef) MarshalYAML() (any, error)

func (*TypeDef) Match

func (t *TypeDef) Match(matchers Matchers) error

func (TypeDef) NavigateWithIndex

func (t TypeDef) NavigateWithIndex(index int) (any, error)

NavigateWithIndex implements the jsonpointer.IndexNavigable interface for traversing JSON Pointers, such as Arazzo conditions.

func (TypeDef) NavigateWithKey

func (t TypeDef) NavigateWithKey(key string) (any, error)

NavigateWithKey implements the jsonpointer.KeyNavigable interface for traversing JSON Pointers, such as Arazzo conditions.

func (*TypeDef) OverrideExtensionOnAliasMatchedFields

func (t *TypeDef) OverrideExtensionOnAliasMatchedFields(source *TypeDef, extensionName string, extensionValue any)

OverrideExtensionOnAliasMatchedFields walks the source TypeDef fields and for each field with an x-speakeasy-match configuration (MatchConfig.Path), resolves the target field in the receiver using alias-aware matching, then overrides the specified extension on the matched receiver field. This handles cases where source fields (e.g., path parameters) alias to receiver fields via different names that OverrideExtensionOnEquivalentTypes cannot resolve.

func (*TypeDef) OverrideExtensionOnEquivalentTypes

func (t *TypeDef) OverrideExtensionOnEquivalentTypes(other *TypeDef, extensionName string, extensionValue any)

OverrideExtensionOnEquivalentTypes is like SetExtensionOnEquivalentTypes but forces the value regardless of whether the extension already exists. This is useful for correcting previously-set extensions, such as overriding x-speakeasy-param-readonly from true to false on fields that appear in per-operation request shards.

func (*TypeDef) PromoteResponseFilterFields

func (t *TypeDef) PromoteResponseFilterFields()

PromoteResponseFilterFields recursively walks the TypeDef tree and promotes any field with ResponseFilter set to true to Optional+Computed in the data source schema. This sets x-speakeasy-param-optional and x-speakeasy-param-computed, and removes x-speakeasy-param-readonly (which would otherwise override Optional to false).

func (*TypeDef) PropagateExtensionValueRecursive

func (t *TypeDef) PropagateExtensionValueRecursive(extensionName string)

PropagateExtensionValueRecursive propagates an extension value downward through the TypeDef tree. If a node has the extension set, its value is propagated to all descendants that don't already have the key present. Uses key-presence semantics (not truthiness).

func (*TypeDef) RemoveEmptyObjectsRecursive

func (t *TypeDef) RemoveEmptyObjectsRecursive()

RemoveEmptyObjectsRecursive recursively removes Fields whose Type is "class" with no Fields and no AssociatedTypes. Recurses into remaining children. Mutates the receiver in place.

func (*TypeDef) RemoveExtensionOnEquivalentTypes

func (t *TypeDef) RemoveExtensionOnEquivalentTypes(other *TypeDef, extensionName string)

RemoveExtensionOnEquivalentTypes recursively removes an extension from this TypeDef at types that have equivalents in the other TypeDef. It follows the same walk structure as SetExtensionOnEquivalentTypes, but deletes the extension instead of setting it.

Special handling: x-speakeasy-ignore sets Extensions.Ignore to false instead of deleting from the All map.

func (*TypeDef) RemoveExtensionRecursive

func (t *TypeDef) RemoveExtensionRecursive(extensionName string)

RemoveExtensionRecursive recursively removes an extension from all types in the TypeDef tree.

func (*TypeDef) RenameExtensionRecursive

func (t *TypeDef) RenameExtensionRecursive(fromName string, toName string)

RenameExtensionRecursive recursively renames an extension key throughout the TypeDef tree. At each node, if Extensions.All[fromName] exists, its value is moved to Extensions.All[toName] and the old key is deleted.

func (*TypeDef) SetExtensionIfAbsentRecursive

func (t *TypeDef) SetExtensionIfAbsentRecursive(tagName string, tagValue any)

SetExtensionIfAbsentRecursive recursively sets an extension on all types in the TypeDef tree that don't already have the specified extension. Stops recursing into children when the extension is already present.

func (*TypeDef) SetExtensionOnEquivalentTypes

func (t *TypeDef) SetExtensionOnEquivalentTypes(other *TypeDef, extensionName string, extensionValue any)

SetExtensionOnEquivalentTypes recursively sets an extension on this TypeDef and on nested types that have equivalents in the other TypeDef.

At each matching level, Extensions.All[extensionName] is set to extensionValue if not already present. Fields are matched using FindTerraformEquivalentField, AssociatedTypes using AssociatedTypeName comparison, and ItemType directly.

func (*TypeDef) SetExtensionOnExclusiveTypes

func (t *TypeDef) SetExtensionOnExclusiveTypes(whenIn *TypeDef, butNotIn *TypeDef, extensionName string, extensionValue any)

SetExtensionOnExclusiveTypes recursively tags the receiver TypeDef at fields that are present in the whenIn TypeDef but absent from the butNotIn TypeDef.

For each field in whenIn:

  • If found in both receiver and butNotIn: recurse deeper to check nested levels.
  • If found in receiver but NOT in butNotIn: tag the receiver field's entire subtree via SetExtensionRecursive.

The same logic applies to AssociatedTypes and ItemType.

func (*TypeDef) SetExtensionRecursive

func (t *TypeDef) SetExtensionRecursive(tagName string, tagValue any)

SetExtensionRecursive recursively sets an extension on all types in the TypeDef tree (bottom-up). Only sets the extension if it doesn't already exist. Special handling for x-speakeasy-ignore which sets Extensions.Ignore.

func (*TypeDef) SetTerraformIgnoreOnExclusiveTypes

func (t *TypeDef) SetTerraformIgnoreOnExclusiveTypes(whenIn *TypeDef, butNotIn *TypeDef, dataModel, schema bool)

SetTerraformIgnoreOnExclusiveTypes recursively sets TerraformIgnore on the receiver TypeDef at fields that are present in the whenIn TypeDef but absent from the butNotIn TypeDef.

This follows the same walk structure as SetExtensionOnExclusiveTypes, but instead of setting an extension via SetExtensionRecursive, it recursively sets TerraformIgnore on exclusive subtrees.

func (TypeDef) ShallowCopy

func (t TypeDef) ShallowCopy() *TypeDef

ShallowCopy creates a new instance of a TypeDef from an original, generally allowing for superficial changes to the original without affecting the original. Use carefully as it could cause conflicts if not changed sufficiently and reregistered. Currently only being used in tests to reference the original type but add custom examples to avoid overwriting the original.

func (*TypeDef) SortFieldsByName

func (t *TypeDef) SortFieldsByName()

SortFieldsByName sorts the TypeDef's Fields slice in place by field Name using lexicographic comparison.

func (*TypeDef) TerraformApplyEquivalentFieldProperties

func (t *TypeDef) TerraformApplyEquivalentFieldProperties(source *TypeDef)

TerraformApplyEquivalentFieldProperties recursively copies field-level properties (Optional, Nullable, Type.Name, Comments) from matching fields in the source TypeDef onto this TypeDef's fields.

Fields are matched using sanitized name comparison via FindTerraformEquivalentField. AssociatedTypes are matched using AssociatedTypeName comparison. The source's values take precedence when merging Comments.

func (*TypeDef) TerraformClearReadonlyOnMatchPaths

func (t *TypeDef) TerraformClearReadonlyOnMatchPaths(requestShard *TypeDef)

TerraformClearReadonlyOnMatchPaths walks the requestShard fields looking for x-speakeasy-match paths that contain dots (nested paths). For each such path, it resolves intermediate containers in the receiver (schema TypeDef) and clears the readonly extension so they become Optional+Computed instead of Computed-only. The leaf field is also cleared since it is user-provided through the flat request field.

func (*TypeDef) TerraformDeleteIgnored

func (t *TypeDef) TerraformDeleteIgnored()

TerraformDeleteIgnored recursively removes Fields and AssociatedTypes that are marked as ignored for Terraform purposes. A field is removed when its Type has Extensions.TerraformIgnore.DataModel set, Extensions.Ignore set to true, or the field has a Const value. An associated type is removed when it has TerraformIgnore.DataModel or Ignore set. Remaining children are recursed into. Mutates the receiver in place.

func (*TypeDef) TerraformFinalizeSchema

func (t *TypeDef) TerraformFinalizeSchema(excludeEmptyObjectSchemas bool)

TerraformFinalizeSchema applies the shared post-assembly TypeDef modifications that are common to all Terraform entity types (managed resource, data resource, ephemeral resource, action). This should be called at the end of each entity's AssembleSchemaTypeDef after DeepClone.

The operations are performed in the following order, which must be preserved:

  1. Set x-speakeasy-root extension
  2. Set ConflictsWith on union types (TerraformSetConflictsWith)
  3. Propagate x-speakeasy-param-suppress-computed-diff downward
  4. Delete ignored fields/types (TerraformDeleteIgnored)
  5. Propagate computed parent flags (TerraformPropagateComputedParent)
  6. Sort fields alphabetically (SortFieldsByName)
  7. Rename manual-readonly back to readonly (RenameExtensionRecursive)
  8. Conditionally delete empty object schemas (RemoveEmptyObjectsRecursive)

func (*TypeDef) TerraformHandleWrappedAttribute

func (t *TypeDef) TerraformHandleWrappedAttribute(entityName string, entityOperation string) *TypeDef

Returns a mutated TypeDef where, if necessary, the TypeDef is wrapped into a new single Field TypeDef for Terraform usage when:

  • The x-speakeasy-wrapped-attribute extension is configured. The Field is named with the extension value.
  • The TypeDef DataType is not class or union. The Field is named "data".

Clone the TypeDef before calling this method to preserve the original.

func (*TypeDef) TerraformHasInvalidImportTypes

func (t *TypeDef) TerraformHasInvalidImportTypes() bool

TerraformHasInvalidImportTypes returns true if any node in the TypeDef tree has a DataType not supported for Terraform import state operations.

func (*TypeDef) TerraformHasNestedWriteOnlyFields

func (t *TypeDef) TerraformHasNestedWriteOnlyFields(sdkType *TypeDef) bool

TerraformHasNestedWriteOnlyFields checks whether the receiver (schema) TypeDef has any write-only fields at any nesting depth relative to the given SDK TypeDef. A field is "write-only" when it exists in the schema type but has no name-equivalent in the SDK type.

Used to decide whether to capture prior state data before reallocating a parent object so that write-only values from the previous state are not lost.

func (*TypeDef) TerraformHoistAssociatedTypesCommonFields

func (t *TypeDef) TerraformHoistAssociatedTypesCommonFields(pathPrefix []string) error

Mutates the TypeDef where common AssociatedTypes Fields are hoisted to the TypeDef Fields for Terraform usage.

This function also tracks hoisting sources via TerraformHoistedFrom on each hoisted field's extensions. This enables plan modifiers to prevent false drift detection by copying values from the active oneOf variant.

The pathPrefix parameter is used for nested oneOf unions to build absolute paths in plan modifiers. For root-level hoisting, pass nil.

func (*TypeDef) TerraformHoistByEntityName

func (t *TypeDef) TerraformHoistByEntityName(entityName string) error

Returns a mutated TypeDef where data is hoisted to the top level Fields when the x-speakeasy-entity configuration matches the given entity name for Terraform usage. Clone the TypeDef before calling this method to preserve the original.

When the entity is found within an array's ItemType, the TypeDef is transformed to the hoisted item type (e.g., array becomes class).

func (*TypeDef) TerraformImportRequiredFields

func (t *TypeDef) TerraformImportRequiredFields()

TerraformImportRequiredFields recursively filters the TypeDef's Fields to only those required for Terraform import state operations (as determined by FieldDef.IsTerraformImportRequired), then sorts remaining fields by name. Recurses into remaining Field Types, AssociatedTypes, and ItemType. Mutates the receiver in place; clone before calling to preserve the original.

func (*TypeDef) TerraformInvalidImportTypes

func (t *TypeDef) TerraformInvalidImportTypes() []*TerraformInvalidImportType

TerraformInvalidImportTypes walks the TypeDef tree and returns all nodes with DataTypes not supported for Terraform import state operations. Returns nil if all types are valid.

func (*TypeDef) TerraformMerge

func (t *TypeDef) TerraformMerge(other *TypeDef) error

Returns a mutated TypeDef that has been merged with the given TypeDef. The algorithm adds data from the given TypeDef to this TypeDef where it is undefined. Where there is conflicting data, this TypeDef's data is preserved or otherwise delegated to data-specific merge functionality. It does not remove any data from this TypeDef.

Fields are matched using FindTerraformEquivalentField (sanitized name matching) and sorted by Name after merging. AssociatedTypes are matched using dual-context name lookup and sorted by OriginalName after merging.

NOTE: This algorithm was originally designed for Terraform and did not have handling for every struct field. If considering for other use cases, deeply evaluate the behavior to ensure it is suitable.

func (*TypeDef) TerraformMergeAliasNodes

func (t *TypeDef) TerraformMergeAliasNodes(entityName string, other *TypeDef) error

TerraformMergeAliasNodes merges only the alias nodes (fields/types with x-speakeasy-match configuration) from other into the receiver. The other TypeDef is cloned, hoisted by entity name, filtered to only alias nodes, then merged via TerraformMerge.

func (*TypeDef) TerraformMergeDataType

func (t *TypeDef) TerraformMergeDataType(other *TypeDef) (DataType, error)

Returns the most suitable DataType when there is a mismatch between the TypeDef and the given TypeDef. An error is returned if the mismatch cannot be reconciled.

NOTE: This algorithm was originally designed for Terraform. If considering for other use cases, deeply evaluate the behavior to ensure it is suitable.

func (*TypeDef) TerraformPropagateComputedParent

func (t *TypeDef) TerraformPropagateComputedParent()

TerraformPropagateComputedParent walks the TypeDef tree and, for optional container types (map/array/set/class/union) that have x-speakeasy-param-computed or x-speakeasy-param-readonly, sets both x-speakeasy-parent-require-to-not-null and x-speakeasy-param-computed on the container and all its descendants.

Instead of using SetExtensionRecursive (which modifies entire subtrees and can contaminate shared TypeDef pointers), this propagates the "computed parent" context through the walk itself. Each node tags itself based on its walk position, avoiding cross-path contamination on shared nodes.

func (*TypeDef) TerraformSetConflictsWith

func (t *TypeDef) TerraformSetConflictsWith(nameFunc func(parent *TypeDef, associated *TypeDef) string)

TerraformSetConflictsWith walks the TypeDef tree and, for each node that has AssociatedTypes (union), sets x-speakeasy-conflicts-with on each branch to the names of the other branches. Also sets x-speakeasy-param-computed-override to false and defaults x-speakeasy-param-suppress-computed-diff to false on each branch.

The nameFunc parameter provides the display name for each associated type, allowing the caller to control naming.

func (*TypeDef) TerraformWalkEquivalent

func (t *TypeDef) TerraformWalkEquivalent(other *TypeDef, hierarchy string, fn func(hierarchy string, self *TypeDef, other *TypeDef, optional bool) bool, optional bool)

TerraformWalkEquivalent walks the receiver and other TypeDef trees in parallel, calling fn on each pair of matched nodes. Only recurses into subtrees where the receiver has an equivalent in other (matched via FindTerraformEquivalentField for fields, AssociatedTypeName for associated types, and directly for ItemType). The callback returns true to stop recursion at that branch.

func (*TypeDef) TerraformWalkTypes

func (t *TypeDef) TerraformWalkTypes(hierarchy string, fn func(hierarchy string, typedef *TypeDef, optional bool), optional bool)

TerraformWalkTypes walks the receiver TypeDef tree, calling fn on every node with hierarchy tracking. Recurses into Fields (by SanitizeFieldName), AssociatedTypes (by AssociatedTypeName), and ItemType.

func (*TypeDef) ValidateAliasNodes

func (t *TypeDef) ValidateAliasNodes(shards ...*TypeDef) error

ValidateAliasNodes walks the given request shard TypeDefs and validates that each field with an x-speakeasy-match configuration (alias node) can be resolved in the receiver (finalized schema) TypeDef, that the target field is not itself an alias (nested aliases not supported), and that the types are compatible. Errors are accumulated across all shards, deduplicated, and returned as a single error.

func (*TypeDef) ValidateMatchConfigTypes

func (t *TypeDef) ValidateMatchConfigTypes(requestShard *TypeDef, opString string) error

ValidateMatchConfigTypes walks the requestShard TypeDef and validates that each field with an x-speakeasy-match configuration (MatchConfig.Path) can be resolved in the receiver TypeDef and that the types are compatible. Returns an error containing all validation failures.

func (*TypeDef) Walk

func (t *TypeDef) Walk() func(func(state *TypeDefWalkState, typeDef *TypeDef) bool)

Walk returns an iterator that traverses the type definition tree depth-first. Note: The walk includes the type itself as the first element yielded.

type TypeDefExtensions

type TypeDefExtensions struct {

	// All extensions, including those not represented in other fields. Ideally,
	// any TypeDef extensions should be fully validated and typed for templating
	// rather than relying on this catch-all.
	All map[string]any `yaml:",omitempty"`

	// Describes x-speakeasy-allow-empty-value extension configuration.
	AllowEmptyValue bool `yaml:",omitempty"`

	// Describes x-speakeasy-base64-input-mode extension configuration.
	// Set on request-side string schemas with format:byte or contentEncoding:base64.
	Base64InputMode string `yaml:",omitempty"`

	// Describes x-speakeasy-entity extension configuration.
	Entity *extensions.Entity `yaml:",omitempty"`

	// Describes x-speakeasy-entity-description extension configuration.
	EntityDescription *extensions.EntityDescription `yaml:",omitempty"`

	// Describes x-speakeasy-entity-version extension configuration.
	EntityVersion *extensions.EntityVersion `yaml:",omitempty"`

	// Describes x-speakeasy-example-unset extension configuration.
	ExampleUnset *bool `yaml:",omitempty"`

	// Describes x-speakeasy-ignore extension configuration.
	Ignore *bool `yaml:",omitempty"`

	// Describes x-speakeasy-match extension configuration.
	//
	// NOTE: Awkward naming to avoid conflict with existing Match method.
	MatchConfig *extensions.MatchConfig `yaml:",omitempty"`

	// Describes x-speakeasy-model-namespace extension configuration.
	// Determines the namespace folder where the type will be generated.
	// This enables multiple components with the same name to exist in different namespaces.
	ModelNamespace *string `yaml:",omitempty"`

	// Describes x-speakeasy-overridable-scopes extension configuration.
	OverridableOAuth2Scopes bool `yaml:",omitempty"`

	// Describes x-speakeasy-pagination extension configuration.
	//
	// NOTE: This is not parsed directly for TypeDef, but instead added to the
	// response TypeDef when configured on the containing operation.
	Pagination *extensions.Pagination `yaml:",omitempty"`

	// Describes x-speakeasy-exports extension configuration.
	// These are language-agnostic public export aliases keyed by SDK group path.
	// Export declarations are source-site specific and are not merged into
	// structurally similar schemas.
	PublicExports []extensions.PublicExport `yaml:",omitempty"`

	// Describes x-speakeasy-terraform-alias-to extension configuration.
	TerraformAliasTo *string `yaml:",omitempty"`

	// TerraformHoistedFrom tracks source associated types for hoisted oneOf fields.
	// When set, generates UseHoistedValue plan modifier to prevent false drift.
	// This is set during template processing, not from OAS extensions.
	//
	// This is an array because a hoisted field can originate from multiple oneOf
	// variants. For example, if a oneOf has variants A, B, and C, and all three
	// have a common "description" field that gets hoisted to the parent, the
	// plan modifier needs to check all three variants to find the active one
	// and copy its value to the hoisted field.
	TerraformHoistedFrom []TerraformHoistedSource `yaml:",omitempty"`

	// Describes x-speakeasy-terraform-custom-default extension configuration.
	TerraformCustomDefault *extensions.TerraformCustomDefault `yaml:",omitempty"`

	// Describes x-speakeasy-terraform-ignore extension configuration.
	TerraformIgnore *extensions.TerraformIgnore `yaml:",omitempty"`

	// Describes x-speakeasy-response-filter extension configuration.
	ResponseFilter *bool `yaml:",omitempty"`

	// Describes x-speakeasy-terraform-write-only extension configuration.
	TerraformWriteOnly *bool `yaml:",omitempty"`

	// Describes x-speakeasy-transform-from-api extension configuration.
	TransformFromAPI *extensions.TransformerConfig `yaml:",omitempty"`

	// Describes x-speakeasy-transform-to-api extension configuration.
	TransformToAPI *extensions.TransformerConfig `yaml:",omitempty"`

	// Describes x-speakeasy-wrapped-attribute extension configuration.
	WrappedAttribute *string `yaml:",omitempty"`
}

Describes extensions for a TypeDef.

func NewTypeDefExtensions

func NewTypeDefExtensions(e *extensions.Extensions, typeDef *TypeDef, oaExtensions extensions.OAExtensions) (*TypeDefExtensions, error)

Returns a new TypeDefExtensions instance or any decoding errors.

func (*TypeDefExtensions) Clone

Clone creates a deep copy of the TypeDefExtensions

func (*TypeDefExtensions) Get

func (e *TypeDefExtensions) Get(name string) (any, bool)

Get returns the extension value and whether it exists in All.

func (*TypeDefExtensions) Has

func (e *TypeDefExtensions) Has(name string) bool

Has returns true if the extension exists in All.

func (*TypeDefExtensions) Match

func (o *TypeDefExtensions) Match(matchers Matchers) error

func (*TypeDefExtensions) Merge

func (e *TypeDefExtensions) Merge(other *TypeDefExtensions)

Merges the given TypeDefExtensions into this TypeDefExtensions. The algorithm adds data from the given TypeDefExtensions to this TypeDefExtensions where it is undefined. Where there is conflicting data, this TypeDefExtensions's data is preserved. It does not remove any data from this TypeDefExtensions.

func (*TypeDefExtensions) MergeWithoutOverwrite

func (e *TypeDefExtensions) MergeWithoutOverwrite(extensions *extensions.Extensions, typeDef *TypeDef, oaExtensions extensions.OAExtensions) error

Merges extensions from the given OAExtensions into the TypeDefExtensions, without overwriting any existing values.

func (*TypeDefExtensions) Remove

func (e *TypeDefExtensions) Remove(name string)

Remove deletes the extension from All.

func (*TypeDefExtensions) Rename

func (e *TypeDefExtensions) Rename(from, to string)

Rename moves the extension value from one key to another in All, only when the value is truthy (not false or nil). Falsy values serve as negative markers that must remain under the original key.

func (*TypeDefExtensions) Set

func (e *TypeDefExtensions) Set(name string, value any)

Set unconditionally sets the extension value in All.

func (*TypeDefExtensions) SetIfAbsent

func (e *TypeDefExtensions) SetIfAbsent(name string, value any)

SetIfAbsent sets the extension value in All only if the key does not already exist.

func (*TypeDefExtensions) TerraformMerge

func (e *TypeDefExtensions) TerraformMerge(other *TypeDefExtensions)

Merges the given TypeDefExtensions into this TypeDefExtensions for Terraform usage. The algorithm first calls Merge for base "preserve existing" semantics, then overrides specific fields where the other TypeDefExtensions should take precedence:

  • Ignore: other wins
  • TerraformIgnore: OR-merges DataModel and Schema
  • TerraformWriteOnly: other wins
  • TerraformHoistedFrom: other wins

type TypeDefWalkState

type TypeDefWalkState struct {
	Visited map[*TypeDef]bool
	Parents *sequencedmap.Map[*TypeDef, bool]
	Aborted bool
}

type TypeDefs

type TypeDefs []*TypeDef

Collection of TypeDef.

func TopologicalSortTypeDefs

func TopologicalSortTypeDefs(types TypeDefs, hoistCyclicUnions bool) TypeDefs

TopologicalSortTypeDefs sorts TypeDefs in topological order based on their dependencies. Children are placed before their parents.

hoistCyclicUnions was introduced for pythonv2 (GEN-2873) and is set to true only when conflictResistantModelImportsFeb2026 is enabled. It pre-sorts the input so that any union which participates in a cycle with one of its variant types (typically a class whose field references back to the union) is visited before non-unions. Non-cyclic unions are left in their original input position to minimize churn in generated SDKs.

func (TypeDefs) AllHaveTerraformEqualField

func (t TypeDefs) AllHaveTerraformEqualField(field *FieldDef) bool

Returns true if all TypeDefs have the given FieldDef that is equal for Terraform usage.

func (TypeDefs) Clone

func (t TypeDefs) Clone() []*TypeDef

Clone creates a deep copy of the TypeDefs.

func (TypeDefs) TerraformCommonFields

func (t TypeDefs) TerraformCommonFields() Fields

Returns Fields that are common across TypeDefs for Terraform usage.

type UsageContext

type UsageContext struct {
	// Operation is the operation to include in the snippet. It is technically okay
	// not to set Operation to nil, in which case the snippet will describe
	// initialization, but not show an example of calling any operation.
	Operation *Operation

	// StepIdx is the index of the step and therefore the operation in a multi-step arazzo workflow
	StepIdx int
	// StepID is the ID of the step in a multi-step arazzo workflow
	StepID string

	// SDK is the SDK that contains the operation.
	SDK *SDK

	// Whether to instantiate the SDK for this snippet (in a test for example multiple operations may use the same SDK or their own instance)
	SkipSDKInstantiation bool
	// ContextIndex is the index of this context in a multi-context snippet. If its the first then for example in go the SDK variable will be declared instead of overridden
	ContextIndex int

	// Config is the content of the x-usage-example extension associated with this
	// snippet (if any). It should always be set to a struct containing zero values.
	Config *extensions.UsageExampleConfig

	// Scopes hold information on which feature(s) the usage snippet is rendered for
	Scopes []UsageExampleScope

	// SkipResponseBodyAssertions indicates whether the usage snippet should skip templating response body assertions
	SkipResponseBodyAssertions bool

	// The name of the example this usage snippet is associated with if being used with a specific named example from the OpenAPI doc
	ExampleName string

	// IsMainExample indicates whether this usage snippet is a main example for the SDK.
	IsMainExample bool

	// Test is the parent test workflow associated with this usage snippet
	Test *ArazzoWorkflow

	// Assertions are test-only assertions associated with this step's usage context.
	Assertions []Assertion

	// UsingMockServer indicates whether the enclosing test is targeting the generated mock server.
	UsingMockServer bool

	// Controls if this is rendered as a usage snippet in the async paradigm(used in 1 target: java)
	AsyncMode bool
}

UsageContext represents the information required to render a usage snippet.

func CreateUsageContext

func CreateUsageContext(sdk *SDK, operation *Operation, usageExample *extensions.UsageExampleConfig, skipResponseBodyAssertions bool) *UsageContext

func (*UsageContext) PopulateGlobalParameterScopes

func (u *UsageContext) PopulateGlobalParameterScopes(exampleName string, shouldIncludeServerSelection bool)

func (UsageContext) RenderFeature

func (usageContext UsageContext) RenderFeature(feature string, global bool) bool

type UsageExampleScope

type UsageExampleScope struct {
	// OpFilter determines which operations should be used for usage the snippet
	// See SelectExampleOperations() function for more details.
	// If the string starts with an exclamation mark (`!`), then the filter is
	// used to _exclude_ matching operations.
	OpFilter string

	// Feature is a tag that can be used to determine which aspect or config needs
	// to be covered in the usage snippet.
	Feature string

	// If IsGlobal is true the usage snippet SDK should be configured globally,
	// otherwise the feature should be enabled at the operation level.
	IsGlobal bool

	// Value is the value of the feature that should be used in the snippet.
	Value any
}

type Validations

type Validations struct {
	// An array instance is valid against "maxItems" if its size is less than, or equal to, the value of this keyword,
	// defaults to 0
	MinItems *int64 `yaml:",omitempty"`

	// A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.
	// The length of a string instance is defined as the number of its characters as defined by RFC 8259.
	MinLength *int64 `yaml:",omitempty"`

	// If the instance is a number, then this keyword validates only if the instance is greater than or exactly equal to "minimum".
	Minimum *float64 `yaml:",omitempty"`

	// Maximum number of items in an array, no default
	MaxItems *int64 `yaml:",omitempty"`

	// A string instance is valid against this keyword if its length is less than, or equal to, the value of this keyword.
	// The length of a string instance is defined as the number of its characters as defined by RFC 8259.
	MaxLength *int64 `yaml:",omitempty"`

	// If the instance is a number, then this keyword validates only if the instance is less than or exactly equal to "maximum".
	Maximum *float64 `yaml:",omitempty"`

	// A string instance is considered valid if the regular expression matches the instance successfully.
	Pattern *string `yaml:",omitempty"`

	// If this keyword has boolean value false, the instance validates successfully.
	// If it has boolean value true, the instance validates successfully if all of its elements are unique.
	UniqueItems *bool `yaml:",omitempty"`
}

func (*Validations) Clone

func (v *Validations) Clone() *Validations

Clone creates a deep copy of the Validations

func (*Validations) Match

func (v *Validations) Match(matchers Matchers) error

func (*Validations) Merge

func (v *Validations) Merge(other *Validations)

Merges the given Validations into this Validations. The algorithm adds data from the given Validations to this Validations where it is undefined. Where there is conflicting data, the stricter validation value is used depending on the validation type. For example with Maximum, the minimum of the two values is used. It does not remove any data from this Validations.

Pattern is merged by creating a new pattern that is the alternation of both patterns if they differ.

type VisitFn

type VisitFn func(Node, []Node, *AST) error

VisitFn now takes a slice of parents.

type Webhook

type Webhook struct {
	// A webhook key is used to identify the PathItemObject in the OpenAPI document, similar to the `Operation.Path` but for webhooks
	Key string `yaml:",omitempty"`

	// A webhook security configuration
	Security *extensions.WebhookSecurity `yaml:",omitempty"`
}

A webhook configuration indicates that the operation is a webhook operation

Jump to

Keyboard shortcuts

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