generator

package
v0.0.0-...-a9c74d5 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2024 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanAndRecreateWorkingDirectory

func CleanAndRecreateWorkingDirectory(path string) error

func EnsureWorkingDirectoryExists

func EnsureWorkingDirectoryExists(path string) error

Types

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

func NewGenerator

func NewGenerator(settings Settings) Generator

func (*Generator) Generate

func (s *Generator) Generate(input ServiceGeneratorInput) error

func (*Generator) GenerateCommonTypes

func (s *Generator) GenerateCommonTypes(input VersionGeneratorInput) error

func (*Generator) GenerateForVersion

func (s *Generator) GenerateForVersion(input VersionGeneratorInput) error

type GeneratorData

type GeneratorData struct {
	// contains filtered or unexported fields
}

type ServiceGeneratorInput

type ServiceGeneratorInput struct {
	CommonTypes     models.CommonTypes
	OutputDirectory string
	ResourceDetails models.APIResource
	ResourceName    string
	ServiceDetails  models.Service
	ServiceName     string
	Source          models.SourceDataOrigin
	Type            models.SourceDataType
	VersionDetails  models.APIVersion
	VersionName     string
}

type Settings

type Settings struct {
	// Whether model structs should have an `OmitDiscriminatedValue` field, to allow the caller to omit the
	// discriminated type value when marhalling. Used in Microsoft Graph for buggy APIs that don't parse this.
	AllowOmittingDiscriminatedValue bool

	// CanonicalApiVersions is a map of API version names to use in the SDK, where the key is the SDK-friendly
	// name, and the value is the upstream API version. Used in Microsoft Graph to translate `v1.0` to `stable`.
	CanonicalApiVersions map[string]string

	// CommonTypesPackageName is the name of the Go package that should be output with common models, constants
	// and resource IDs. Each API version will get a package below this containing the respective types. Used
	// in Microsoft Graph. Could be used in Resource Manager or other SDKs.
	CommonTypesPackageName string

	// DeleteExistingResourcesForVersion toggles whether any existing resources within a given API version should
	// be removed prior to generating. This is not compatible when more than one SourceDataType is being used to
	// generate an SDK. Used in Microsoft Graph because breaking removals are allowed.
	DeleteExistingResourcesForVersion bool

	// GenerateDescriptionsForModels enables nicely-formatted Go comments for model fields to be generated.
	GenerateDescriptionsForModels bool

	// RecurseParentModels is a behavioral toggle for discriminated types. When true, the full ancestry for child
	// models will be output in the SDK. When false, only the youngest ancestor containing the necessary type
	// information will be output. Used in Microsoft Graph to properly express model inheritance.
	RecurseParentModels bool

	// VersionsToGenerateCommonTypes is a map of API versions to SourceDataOrigin, to specify the API versions
	// for which common types should be generated. This is necessary because common types are enumerated separately
	// from service definitions. Used in Microsoft Graph.
	VersionsToGenerateCommonTypes map[string]models.SourceDataOrigin
	// contains filtered or unexported fields
}

func (*Settings) CanonicalApiVersion

func (s *Settings) CanonicalApiVersion(version string) *string

func (*Settings) ShouldUseNewBaseLayer

func (s *Settings) ShouldUseNewBaseLayer(serviceName, version string) bool

func (*Settings) UseOldBaseLayerFor

func (s *Settings) UseOldBaseLayerFor(serviceNames ...string)

type VersionGeneratorData

type VersionGeneratorData struct {
	GeneratorData
	// contains filtered or unexported fields
}

type VersionGeneratorInput

type VersionGeneratorInput struct {
	CommonTypes     models.CommonTypes
	OutputDirectory string
	Resources       map[string]models.APIResource
	ServiceName     string
	Source          models.SourceDataOrigin
	Type            models.SourceDataType
	UseNewBaseLayer bool
	VersionName     string
}

Jump to

Keyboard shortcuts

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