Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( //go:embed openapi-generator/templates // Templates contains different template files for different languages Templates embed.FS // SupportedLangs is supported languages SupportedLangs = map[string]bool{"go": true} //go:embed _scaffold // Scaffold is scaffold files for different languages Scaffold embed.FS // ScaffoldDir is scaffold dir name ScaffoldDir = "_scaffold" )
var ( // DefinitionKindToPascal is the map of definition kind to pascal case DefinitionKindToPascal = map[string]string{ v1beta1.ComponentDefinitionKind: "Component", v1beta1.TraitDefinitionKind: "Trait", v1beta1.WorkflowStepDefinitionKind: "WorkflowStep", v1beta1.PolicyDefinitionKind: "Policy", } // DefinitionKindToBaseType is the map of definition kind to base type DefinitionKindToBaseType = map[string]string{ v1beta1.ComponentDefinitionKind: "ComponentBase", v1beta1.TraitDefinitionKind: "TraitBase", v1beta1.WorkflowStepDefinitionKind: "WorkflowStepBase", v1beta1.PolicyDefinitionKind: "PolicyBase", } // DefinitionKindToStatement is the map of definition kind to statement DefinitionKindToStatement = map[string]*j.Statement{ v1beta1.ComponentDefinitionKind: j.Qual("common", "ApplicationComponent"), v1beta1.TraitDefinitionKind: j.Qual("common", "ApplicationTrait"), v1beta1.WorkflowStepDefinitionKind: j.Qual("v1beta1", "WorkflowStep"), v1beta1.PolicyDefinitionKind: j.Qual("v1beta1", "AppPolicy"), } )
Functions ¶
This section is empty.
Types ¶
type GenMeta ¶
type GenMeta struct { Output string Lang string Package string Template string File []string InitSDK bool Verbose bool // contains filtered or unexported fields }
GenMeta stores the metadata for generator.
func (*GenMeta) CreateScaffold ¶
CreateScaffold will create a scaffold for the given language. It will copy all files from embedded scaffold/{meta.Lang} to meta.Output.
func (*GenMeta) Init ¶
Init initializes the generator. It will validate the param, analyze the CUE files, read them to memory, mkdir for output.
func (*GenMeta) PrepareGeneratorAndTemplate ¶
PrepareGeneratorAndTemplate will make a copy of the embedded openapi-generator-cli and templates/{meta.Lang} to local
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator is used to generate SDK code from CUE template for one language.
func NewModifiableGenerator ¶
NewModifiableGenerator returns a new Generator with modifiers
func (*Generator) GenOpenAPISchema ¶
GenOpenAPISchema generates OpenAPI json schema from cue.Instance
func (*Generator) GenerateCode ¶
GenerateCode will call openapi-generator to generate code and modify it
type GoModifier ¶
type GoModifier struct {
// contains filtered or unexported fields
}
GoModifier is the Modifier for golang
func (*GoModifier) Modify ¶
func (m *GoModifier) Modify() error
Modify the modification of generated code