config

package module
v1.43.1 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: MIT Imports: 16 Imported by: 4

README

sdk-gen-config

How to Release

  1. Open a PR and get your changes in main
  2. Once the changes are in main create a tag from the main branch
    1. pull main locally: git pull origin main
    2. Use the command to tag : git tag v15.48.0-pre2
    3. Push the tag: git push origin v15.48.0-pre2
  3. Create a release on GitHub using the new tag.
    1. go to releases
    2. click on Draft a new release
    3. use the tag you pushed, add release title , release notes , check set at latest release
    4. click Publish release

Documentation

Index

Constants

View Source
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

View Source
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 FormatGithubSecret(secret string) string

func FormatGithubSecretName added in v1.14.8

func FormatGithubSecretName(name string) string

func GetConfigChecksum added in v1.5.0

func GetConfigChecksum(dir string, opts ...Option) (string, error)

func GetTemplateVersion added in v1.6.1

func GetTemplateVersion(dir, target string, opts ...Option) (string, error)

func SaveConfig added in v1.5.0

func SaveConfig(dir string, cfg *Configuration, opts ...Option) error

func SaveLockFile added in v1.5.0

func SaveLockFile(dir string, lf *LockFile, 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
}

func Load

func Load(dir string, opts ...Option) (*Config, error)

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 Examples added in v1.20.0

type Examples = lockfile.Examples

type FS added in v1.10.0

type FS interface {
	fs.ReadFileFS
	fs.StatFS
	WriteFile(name string, data []byte, perm os.FileMode) error
}

type Fixes added in v1.4.0

type Fixes struct {
	NameResolutionDec2023                bool           `yaml:"nameResolutionDec2023,omitempty" description:"Enables name resolution fixes from December 2023"`
	NameResolutionFeb2025                bool           `yaml:"nameResolutionFeb2025" description:"Enables name resolution fixes from February 2025"`
	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"`
	SharedErrorComponentsApr2025         bool           ``                              /* 242-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

func (f *Fixes) UnmarshalYAML(unmarshal func(interface{}) error) error

type Force added in v0.4.2

type Force struct {
	Description string `yaml:"description"`
	Type        string `yaml:"type"`
	Default     bool   `yaml:"default"`
}

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 */
	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"`

	// 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,omitempty"`

	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 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 Job added in v0.4.2

type Job struct {
	Uses    string            `yaml:"uses"`
	With    map[string]any    `yaml:"with,omitempty"`
	Secrets map[string]string `yaml:"secrets,omitempty"`
}

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"`
}

type LanguageConfig

type LanguageConfig struct {
	Version string         `yaml:"version" description:"SDK version"`
	Cfg     map[string]any `yaml:",inline" jsonschema:"-"`
	// contains filtered or unexported fields
}

type LockFile added in v1.5.0

type LockFile = lockfile.LockFile

func LoadLockfile added in v1.43.0

func LoadLockfile(data []byte, fileSystem FS) (*LockFile, error)

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 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 WithFileSystem(fs FS) Option

func WithLanguageDefaultFunc

func WithLanguageDefaultFunc(f GetLanguageDefaultFunc) Option

func WithLanguages added in v0.0.4

func WithLanguages(langs ...string) Option

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 Permissions struct {
	Checks       string `yaml:"checks,omitempty"`
	Contents     string `yaml:"contents,omitempty"`
	PullRequests string `yaml:"pull-requests,omitempty"`
	Statuses     string `yaml:"statuses,omitempty"`
	IDToken      string `yaml:"id-token,omitempty"`
}

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 */

	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

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 PublishOn added in v0.4.2

type PublishOn struct {
	Push             Push                   `yaml:"push"`
	WorkflowDispatch *WorkflowDispatchEmpty `yaml:"workflow_dispatch,omitempty"`
}

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 Push added in v0.4.2

type Push struct {
	Branches []string `yaml:"branches"`
	Paths    []string `yaml:"paths"`
}

type PushCodeSamplesOnly added in v1.14.11

type PushCodeSamplesOnly struct {
	Description string `yaml:"description"`
	Type        string `yaml:"type"`
	Default     bool   `yaml:"default"`
}

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 Schedule added in v0.4.2

type Schedule struct {
	Cron string `yaml:"cron"`
}

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 SetVersion struct {
	Description string `yaml:"description"`
	Type        string `yaml:"type"`
}

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 Target added in v1.15.0

type Target struct {
	Description string `yaml:"description"`
	Type        string `yaml:"type"`
}

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 TransformerFunc func(*Config) (*Config, error)

type UpgradeFunc

type UpgradeFunc func(target, template, oldVersion, newVersion string, cfg map[string]any) (map[string]any, error)

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 ValidateFunc func(Config) error

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"`
}

Directories

Path Synopsis
tools
schema-gen command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL