Documentation
¶
Index ¶
- Constants
- Variables
- func FindConfigFile(dir string, fileSystem FS) (*workspace.FindWorkspaceResult, error)
- func FormatGithubSecret(secret string) string
- func FormatGithubSecretName(name string) string
- func GetConfigChecksum(dir string, opts ...Option) (string, error)
- func GetTemplateVersion(dir, target string, opts ...Option) (string, error)
- func SaveConfig(dir string, cfg *Configuration, opts ...Option) error
- func SaveLockFile(dir string, lf *LockFile, opts ...Option) error
- type AllOfMergeStrategy
- type Auth
- type Config
- type Configuration
- type DevContainers
- type Examples
- type FS
- type Fixes
- type Force
- type GenerateOn
- type GenerateWorkflow
- type GeneratedTests
- type Generation
- type GetLanguageDefaultFunc
- type Inputs
- type InputsTesting
- type Job
- type Jobs
- type LanguageConfig
- type LockFile
- type LockfileOption
- type Management
- type MockServer
- type NameResolutionMode
- type OperationExamples
- type Option
- func WithDontWrite() Option
- func WithFileSystem(fs FS) Option
- func WithLanguageDefaultFunc(f GetLanguageDefaultFunc) Option
- func WithLanguages(langs ...string) Option
- func WithTransformerFunc(f TransformerFunc) Option
- func WithUpgradeFunc(f UpgradeFunc) Option
- func WithValidateFunc(f ValidateFunc) Option
- type OptionalPropertyRenderingOption
- type ParameterExamples
- type Permissions
- type PersistentEdits
- type PersistentEditsEnabled
- type PublishJob
- type PublishOn
- type PublishPyPiJob
- type PublishPyPiStep
- type PublishStep
- type PublishWorkflow
- type PullRequestOn
- type Push
- type PushCodeSamplesOnly
- type SDKGenConfigField
- type SDKInitStyle
- type Schedule
- type Schemas
- type ServerIndex
- type SetVersion
- type TagOn
- type TaggingWorkflow
- type Target
- type TestingOn
- type TestingWorkflow
- type Tests
- type TrackedFile
- type TrackedFiles
- type TransformerFunc
- type UpgradeFunc
- type UsageSnippets
- type ValidateFunc
- type VersioningStrategy
- type WorkflowDispatch
- type WorkflowDispatchEmpty
- type WorkflowDispatchTesting
Constants ¶
const ( Version = v2 GithubWritePermission = "write" // Constants to be used as keys in the config files Languages = "languages" Mode = "mode" GithubAccessToken = "github_access_token" SpeakeasyApiKey = "speakeasy_api_key" SpeakeasyServerURL = "speakeasy_server_url" OpenAPIDocAuthHeader = "openapi_doc_auth_header" OpenAPIDocAuthToken = "openapi_doc_auth_token" OpenAPIDocs = "openapi_docs" DefaultGithubTokenSecretName = "GITHUB_TOKEN" DefaultSpeakeasyAPIKeySecretName = "SPEAKEASY_API_KEY" )
Variables ¶
var ErrFailedUpgrade = errors.New("failed to upgrade config")
Functions ¶
func FindConfigFile ¶ added in v1.10.0
func FindConfigFile(dir string, fileSystem FS) (*workspace.FindWorkspaceResult, error)
func FormatGithubSecret ¶ added in v1.14.8
func FormatGithubSecretName ¶ added in v1.14.8
func GetConfigChecksum ¶ added in v1.5.0
func GetTemplateVersion ¶ added in v1.6.1
func SaveConfig ¶ added in v1.5.0
func SaveConfig(dir string, cfg *Configuration, opts ...Option) error
Types ¶
type AllOfMergeStrategy ¶ added in v1.36.0
type AllOfMergeStrategy string
const ( AllOfMergeStrategyDeepMerge AllOfMergeStrategy = "deepMerge" AllOfMergeStrategyShallowMerge AllOfMergeStrategy = "shallowMerge" )
type Auth ¶ added in v1.7.3
type Auth struct {
OAuth2ClientCredentialsEnabled bool `yaml:"oAuth2ClientCredentialsEnabled" description:"Enables support for OAuth2 client credentials grant type"`
OAuth2PasswordEnabled bool `yaml:"oAuth2PasswordEnabled" description:"Enables support for OAuth2 resource owner password credentials grant type"`
HoistGlobalSecurity bool `` /* 144-byte string literal not displayed */
// contains filtered or unexported fields
}
type Config ¶
type Config struct {
Config *Configuration
ConfigPath string
LockFile *LockFile
}
type Configuration ¶ added in v1.5.0
type Configuration struct {
ConfigVersion string `yaml:"configVersion" description:"The version of the configuration file" minLength:"1" required:"true"`
Generation Generation `yaml:"generation" required:"true"`
Languages map[string]LanguageConfig `yaml:",inline" jsonschema:"-"`
New map[string]bool `yaml:"-"`
// contains filtered or unexported fields
}
Ensure you update schema/gen.config.schema.json on changes
func GetDefaultConfig ¶
func GetDefaultConfig(newSDK bool, getLangDefaultFunc GetLanguageDefaultFunc, langs map[string]bool) (*Configuration, error)
func (*Configuration) GetGenerationFieldsMap ¶ added in v1.5.0
func (c *Configuration) GetGenerationFieldsMap() (map[string]any, error)
type DevContainers ¶ added in v0.8.2
type DevContainers struct {
Enabled bool `yaml:"enabled" description:"Whether dev containers are enabled"`
// This can be a local path or a remote URL
SchemaPath string `yaml:"schemaPath" description:"Path to the schema file for the dev container"`
AdditionalProperties map[string]any `yaml:",inline" jsonschema:"-"` // Captures any additional properties that are not explicitly defined for backwards/forwards compatibility
// contains filtered or unexported fields
}
type Fixes ¶ added in v1.4.0
type Fixes struct {
NameResolutionDec2023 bool `yaml:"nameResolutionDec2023,omitempty" description:"Deprecated. Use generation.nameResolution: 'ordered' instead."`
NameResolutionFeb2025 bool `yaml:"nameResolutionFeb2025" description:"Deprecated. Use generation.nameResolution: 'shortest' instead."`
ParameterOrderingFeb2024 bool `yaml:"parameterOrderingFeb2024" description:"Enables parameter ordering fixes from February 2024"`
RequestResponseComponentNamesFeb2024 bool `` /* 128-byte string literal not displayed */
SecurityFeb2025 bool `yaml:"securityFeb2025" description:"Enables fixes and refactoring for security that were introduced in February 2025"`
NameOverrideFeb2026 bool `` /* 181-byte string literal not displayed */
OpenSingleValueEnumsOct2026 bool `` /* 240-byte string literal not displayed */
AdditionalProperties map[string]any `yaml:",inline" jsonschema:"-"` // Captures any additional properties that are not explicitly defined for backwards/forwards compatibility
// contains filtered or unexported fields
}
func (*Fixes) UnmarshalYAML ¶ added in v1.30.5
type GenerateOn ¶ added in v0.4.2
type GenerateOn struct {
WorkflowDispatch WorkflowDispatch `yaml:"workflow_dispatch"`
Schedule []Schedule `yaml:"schedule,omitempty"`
PullRequest PullRequestOn `yaml:"pull_request,omitempty"`
}
type GenerateWorkflow ¶ added in v0.4.2
type GenerateWorkflow struct {
Name string `yaml:"name"`
Permissions Permissions `yaml:"permissions,omitempty"`
On GenerateOn `yaml:"on"`
Jobs Jobs `yaml:"jobs"`
}
func DefaultGenerationFile ¶ added in v1.14.8
func DefaultGenerationFile() *GenerateWorkflow
type GeneratedTests ¶ added in v1.25.0
type GeneratedTests = lockfile.GeneratedTests
type Generation ¶
type Generation struct {
DevContainers *DevContainers `yaml:"devContainers,omitempty"`
BaseServerURL string `` /* 143-byte string literal not displayed */
SDKClassName string `yaml:"sdkClassName,omitempty" description:"Generated name of the root SDK class"`
MaintainOpenAPIOrder bool `yaml:"maintainOpenAPIOrder,omitempty" description:"Maintains the order of parameters and fields in the OpenAPI specification"`
DeduplicateErrors bool `yaml:"deduplicateErrors,omitempty" description:"Deduplicates errors that have the same schema"`
UsageSnippets *UsageSnippets `yaml:"usageSnippets,omitempty"`
UseClassNamesForArrayFields bool `` /* 126-byte string literal not displayed */
NameResolution NameResolutionMode `` /* 895-byte string literal not displayed */
Fixes *Fixes `yaml:"fixes,omitempty"`
Auth *Auth `yaml:"auth,omitempty"`
SkipErrorSuffix bool `yaml:"skipErrorSuffix,omitempty" description:"Skips the automatic addition of an error suffix to error types"`
InferSSEOverload bool `` /* 199-byte string literal not displayed */
SDKHooksConfigAccess bool `yaml:"sdkHooksConfigAccess,omitempty" description:"Enables access to the SDK configuration from hooks"`
Schemas Schemas `yaml:"schemas"`
RequestBodyFieldName string `yaml:"requestBodyFieldName" description:"The name of the field to use for the request body in generated SDKs"`
VersioningStrategy VersioningStrategy `` /* 215-byte string literal not displayed */
// Mock server generation configuration.
MockServer *MockServer `yaml:"mockServer,omitempty"`
// PersistentEdits configures whether user edits persist across regenerations
PersistentEdits PersistentEdits `yaml:"persistentEdits"`
Tests Tests `yaml:"tests"`
AdditionalProperties map[string]any `yaml:",inline" jsonschema:"-"` // Captures any additional properties that are not explicitly defined for backwards/forwards compatibility
// contains filtered or unexported fields
}
func (*Generation) GetNameResolution ¶ added in v1.59.0
func (g *Generation) GetNameResolution() NameResolutionMode
GetNameResolution returns the effective mode
func (*Generation) NameResolutionAtLeastOrdered ¶ added in v1.59.0
func (g *Generation) NameResolutionAtLeastOrdered() bool
NameResolutionAtLeastOrdered reports whether the effective mode is ordered or newer.
func (*Generation) NameResolutionAtLeastQualified ¶ added in v1.59.0
func (g *Generation) NameResolutionAtLeastQualified() bool
NameResolutionAtLeastQualified reports whether the effective mode is qualified or newer.
func (*Generation) NameResolutionAtLeastShortest ¶ added in v1.59.0
func (g *Generation) NameResolutionAtLeastShortest() bool
NameResolutionAtLeastShortest reports whether the effective mode is shortest or newer.
func (*Generation) SyncNameResolution ¶ added in v1.59.0
func (g *Generation) SyncNameResolution()
SyncNameResolution aligns nameResolution and the deprecated fixes booleans so persisted configs stay readable by older tooling. Call before marshalling.
An explicitly set nameResolution mode is authoritative and backfills the boolean flags. In legacy mode (all-false or absent) the fixes block is left untouched. Otherwise, the mode gets materialized from the booleans and written back to the config.
type GetLanguageDefaultFunc ¶
type GetLanguageDefaultFunc func(string, bool) (*LanguageConfig, error)
type Inputs ¶ added in v0.4.2
type Inputs struct {
Force Force `yaml:"force"`
PushCodeSamplesOnly *PushCodeSamplesOnly `yaml:"push_code_samples_only,omitempty"`
SetVersion *SetVersion `yaml:"set_version,omitempty"`
Target *Target `yaml:"target,omitempty"`
}
type InputsTesting ¶ added in v1.30.3
type InputsTesting struct {
Target Target `yaml:"target"`
}
type Jobs ¶ added in v0.4.2
type Jobs struct {
Generate Job `yaml:"generate,omitempty"`
Publish Job `yaml:"publish,omitempty"`
Tag Job `yaml:"tag,omitempty"`
Test Job `yaml:"test,omitempty"`
PublishPypi *PublishJob `yaml:"publish-pypi,omitempty"`
PublishNuget *PublishJob `yaml:"publish-nuget,omitempty"`
}
type LanguageConfig ¶
type LockFile ¶ added in v1.5.0
func LoadLockfile ¶ added in v1.43.0
func NewLockFile ¶ added in v1.5.0
func NewLockFile() *LockFile
type LockfileOption ¶ added in v1.43.0
type LockfileOption = lockfile.LoadOption
func WithLockfileFileSystem ¶ added in v1.43.0
func WithLockfileFileSystem(fs FS) LockfileOption
type Management ¶
type Management = lockfile.Management
type MockServer ¶ added in v1.19.0
type MockServer struct {
// Disables the code generation of the mockserver target.
Disabled bool `yaml:"disabled" description:"Disables the code generation of the mock server target"`
// contains filtered or unexported fields
}
Generation configuration for the inter-templated mockserver target for test generation.
type NameResolutionMode ¶ added in v1.59.0
type NameResolutionMode string
NameResolutionMode consolidates the deprecated fixes.nameResolutionDec2023 and fixes.nameResolutionFeb2025 booleans into a single setting.
const ( // NameResolutionLegacy: pre-December 2023 behavior; first registered type keeps a conflicting name. NameResolutionLegacy NameResolutionMode = "legacy" // NameResolutionOrdered (formerly fixes.nameResolutionDec2023): conflicting types renamed by fixed precedence order. NameResolutionOrdered NameResolutionMode = "ordered" // NameResolutionShortest (formerly fixes.nameResolutionFeb2025): conflicting types renamed with the smallest distinguishing set of context labels. NameResolutionShortest NameResolutionMode = "shortest" // NameResolutionQualified: unnamed inline schemas are named after their property path from the // nearest enclosing named schema (e.g. Order.status -> OrderStatus), even without a conflict. NameResolutionQualified NameResolutionMode = "qualified" )
func NameResolutionModes ¶ added in v1.59.0
func NameResolutionModes() []NameResolutionMode
NameResolutionModes lists the supported modes, oldest first.
func (NameResolutionMode) AtLeast ¶ added in v1.59.0
func (m NameResolutionMode) AtLeast(mode NameResolutionMode) bool
AtLeast reports whether m is mode or newer.
func (NameResolutionMode) IsValid ¶ added in v1.59.0
func (m NameResolutionMode) IsValid() bool
func (NameResolutionMode) Validate ¶ added in v1.59.0
func (m NameResolutionMode) Validate() error
Validate returns an error if a mode is set but unsupported. An empty mode is valid: it defers to the deprecated fixes booleans.
type OperationExamples ¶ added in v1.20.0
type OperationExamples = lockfile.OperationExamples
type Option ¶
type Option func(*options)
func WithDontWrite ¶ added in v1.10.0
func WithDontWrite() Option
func WithFileSystem ¶ added in v1.10.0
func WithLanguageDefaultFunc ¶
func WithLanguageDefaultFunc(f GetLanguageDefaultFunc) Option
func WithLanguages ¶ added in v0.0.4
func WithTransformerFunc ¶ added in v0.8.4
func WithTransformerFunc(f TransformerFunc) Option
func WithUpgradeFunc ¶ added in v0.0.2
func WithUpgradeFunc(f UpgradeFunc) Option
func WithValidateFunc ¶ added in v1.16.0
func WithValidateFunc(f ValidateFunc) Option
type OptionalPropertyRenderingOption ¶ added in v1.2.0
type OptionalPropertyRenderingOption string
const ( OptionalPropertyRenderingOptionAlways OptionalPropertyRenderingOption = "always" OptionalPropertyRenderingOptionNever OptionalPropertyRenderingOption = "never" OptionalPropertyRenderingOptionWithExample OptionalPropertyRenderingOption = "withExample" )
type ParameterExamples ¶ added in v1.20.0
type ParameterExamples = lockfile.ParameterExamples
type Permissions ¶ added in v0.4.2
type PersistentEdits ¶ added in v1.43.0
type PersistentEdits struct {
// Enabled controls preservation of user edits:
// - "true": enables persistent edits
// - omitted/empty: disabled but will prompt on dirty detection
// - "never": disabled and will never prompt
Enabled *PersistentEditsEnabled `` /* 152-byte string literal not displayed */
// CompilePristine controls whether the initial compile pass runs to normalize
// pristine content to post-compile state. Formatters/linters rewrite files during
// compilation (e.g., go mod tidy, npm install). When true (default), an initial
// compile pass normalizes files so gen.lock checksums match actual files on disk.
// When false, this initial compile is skipped - useful when the generated SDK
// doesn't compile (syntax errors, missing deps) but you still want persistent edits.
CompilePristine *bool `` /* 212-byte string literal not displayed */
AdditionalProperties map[string]any `yaml:",inline" jsonschema:"-"` // Captures any additional properties
// contains filtered or unexported fields
}
PersistentEdits configures whether user edits to generated SDKs persist across regenerations When enabled, user changes are preserved via 3-way merge with Git tracking
func (*PersistentEdits) IsEnabled ¶ added in v1.43.0
func (p *PersistentEdits) IsEnabled() bool
IsEnabled returns true if persistent edits are enabled
func (*PersistentEdits) IsNever ¶ added in v1.43.0
func (p *PersistentEdits) IsNever() bool
IsNever returns true if persistent edits are explicitly set to never prompt
func (*PersistentEdits) ShouldCompilePristine ¶ added in v1.47.0
func (p *PersistentEdits) ShouldCompilePristine() bool
ShouldCompilePristine returns true if the initial compile pass should run to normalize pristine content. Defaults to true if not explicitly set.
type PersistentEditsEnabled ¶ added in v1.43.0
type PersistentEditsEnabled string
PersistentEditsEnabled controls whether user edits persist across regenerations
const ( // PersistentEditsEnabledTrue enables persistent edits PersistentEditsEnabledTrue PersistentEditsEnabled = "true" // PersistentEditsEnabledNever disables persistent edits and prevents prompting PersistentEditsEnabledNever PersistentEditsEnabled = "never" )
type PublishJob ¶ added in v1.62.0
type PublishJob struct {
Needs []string `yaml:"needs"`
If string `yaml:"if"`
RunsOn string `yaml:"runs-on"`
Steps []PublishStep `yaml:"steps"`
}
PublishJob represents a job in the caller's workflow that publishes a package using OIDC trusted publishing via a composite action
type PublishOn ¶ added in v0.4.2
type PublishOn struct {
Push Push `yaml:"push"`
WorkflowDispatch *WorkflowDispatchEmpty `yaml:"workflow_dispatch,omitempty"`
}
type PublishPyPiJob ¶ added in v1.48.1
type PublishPyPiJob = PublishJob
type PublishPyPiStep ¶ added in v1.48.1
type PublishPyPiStep = PublishStep
type PublishStep ¶ added in v1.62.0
PublishStep represents a step in a PublishJob
type PublishWorkflow ¶ added in v0.4.2
type PublishWorkflow struct {
Name string `yaml:"name"`
Permissions Permissions `yaml:"permissions,omitempty"`
On PublishOn `yaml:"on"`
Jobs Jobs `yaml:"jobs"`
}
type PullRequestOn ¶ added in v1.30.20
type PullRequestOn struct {
Types []string `yaml:"types,omitempty"`
}
type PushCodeSamplesOnly ¶ added in v1.14.11
type SDKGenConfigField ¶ added in v1.0.0
type SDKGenConfigField struct {
Name string `yaml:"name" json:"name"`
Required bool `yaml:"required" json:"required"`
RequiredForPublishing *bool `yaml:"requiredForPublishing,omitempty" json:"required_for_publishing,omitempty"`
DefaultValue *any `yaml:"defaultValue,omitempty" json:"default_value,omitempty"`
Description *string `yaml:"description,omitempty" json:"description,omitempty"`
Language *string `yaml:"language,omitempty" json:"language,omitempty"`
SecretName *string `yaml:"secretName,omitempty" json:"secret_name,omitempty"`
ValidationRegex *string `yaml:"validationRegex,omitempty" json:"validation_regex,omitempty"`
ValidationMessage *string `yaml:"validationMessage,omitempty" json:"validation_message,omitempty"`
TestValue *any `yaml:"testValue,omitempty" json:"test_value,omitempty"`
}
func GetGenerationDefaults ¶ added in v1.0.0
func GetGenerationDefaults(newSDK bool) []SDKGenConfigField
type SDKInitStyle ¶ added in v1.30.21
type SDKInitStyle string
const ( SDKInitStyleConstructor SDKInitStyle = "constructor" SDKInitStyleBuilder SDKInitStyle = "builder" )
type Schemas ¶ added in v1.36.0
type Schemas struct {
AllOfMergeStrategy AllOfMergeStrategy `yaml:"allOfMergeStrategy" enum:"deepMerge,shallowMerge" description:"Controls how allOf schemas are merged"`
// contains filtered or unexported fields
}
type ServerIndex ¶ added in v1.43.0
type ServerIndex string
ServerIndex is a type that can be either a string (server ID) or an integer (server index)
func (ServerIndex) PrepareJSONSchema ¶ added in v1.43.0
func (ServerIndex) PrepareJSONSchema(schema *jsg.Schema) error
type SetVersion ¶ added in v1.14.12
type TagOn ¶ added in v1.14.11
type TagOn struct {
Push Push `yaml:"push"`
WorkflowDispatch WorkflowDispatchEmpty `yaml:"workflow_dispatch"`
}
type TaggingWorkflow ¶ added in v1.14.11
type TaggingWorkflow struct {
Name string `yaml:"name"`
Permissions Permissions `yaml:"permissions,omitempty"`
On TagOn `yaml:"on"`
Jobs Jobs `yaml:"jobs"`
}
type TestingOn ¶ added in v1.30.3
type TestingOn struct {
PullRequest Push `yaml:"pull_request"`
Push *Push `yaml:"push,omitempty"`
WorkflowDispatch WorkflowDispatchTesting `yaml:"workflow_dispatch"`
}
type TestingWorkflow ¶ added in v1.30.3
type TestingWorkflow struct {
Name string `yaml:"name"`
Permissions Permissions `yaml:"permissions,omitempty"`
On TestingOn `yaml:"on"`
Jobs Jobs `yaml:"jobs"`
}
type Tests ¶ added in v1.28.0
type Tests struct {
GenerateTests bool `yaml:"generateTests" description:"Enables generation of tests"`
GenerateNewTests bool `yaml:"generateNewTests" description:"Enables generation of new tests for any new operations in the OpenAPI specification"`
SkipResponseBodyAssertions bool `` /* 135-byte string literal not displayed */
AdditionalProperties map[string]any `yaml:",inline" jsonschema:"-"` // Captures any additional properties that are not explicitly defined for backwards/forwards compatibility
// contains filtered or unexported fields
}
type TrackedFile ¶ added in v1.43.0
type TrackedFile = lockfile.TrackedFile
type TrackedFiles ¶ added in v1.43.0
type TrackedFiles = lockfile.TrackedFiles
type TransformerFunc ¶ added in v0.8.4
type UpgradeFunc ¶
type UsageSnippets ¶ added in v1.2.0
type UsageSnippets struct {
OptionalPropertyRendering OptionalPropertyRenderingOption `` /* 142-byte string literal not displayed */
SDKInitStyle SDKInitStyle `` /* 126-byte string literal not displayed */
ServerToShowInSnippets ServerIndex `yaml:"serverToShowInSnippets,omitempty"` // If unset, no server will be shown, if an integer, use as server_idx, else look for a matching id
AdditionalProperties map[string]any `yaml:",inline" jsonschema:"-"` // Captures any additional properties that are not explicitly defined for backwards/forwards compatibility
// contains filtered or unexported fields
}
type ValidateFunc ¶ added in v1.16.0
type VersioningStrategy ¶ added in v1.46.0
type VersioningStrategy string
VersioningStrategy controls how SDK versions are determined during generation
const ( // VersioningStrategyAutomatic automatically bumps the SDK version based on changes to the spec, config, or generator VersioningStrategyAutomatic VersioningStrategy = "automatic" // VersioningStrategyManual uses the version specified in gen.yaml as-is without automatic bumping VersioningStrategyManual VersioningStrategy = "manual" )
type WorkflowDispatch ¶ added in v0.4.2
type WorkflowDispatch struct {
Inputs Inputs `yaml:"inputs"`
}
type WorkflowDispatchEmpty ¶ added in v1.23.4
type WorkflowDispatchEmpty struct{}
type WorkflowDispatchTesting ¶ added in v1.30.3
type WorkflowDispatchTesting struct {
Inputs InputsTesting `yaml:"inputs"`
}