config

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package config contains the types, parsing, and validation logic for the YAML generator configuration

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttributeOptions

type AttributeOptions struct {
	// Aliases are a map, with the key being a parameter name in an OpenAPI operation and the value being the new name (alias).
	Aliases map[string]string `yaml:"aliases"`
	// Overrides are a map, with the key being an attribute location (dot-separated for nested attributes) and the value being overrides to apply to the attribute.
	Overrides map[string]Override `yaml:"overrides"`
}

AttributeOptions generator config section. This section is used to modify the output of specific attributes.

func (*AttributeOptions) Validate

func (s *AttributeOptions) Validate() error

type Config

type Config struct {
	Provider    Provider              `yaml:"provider"`
	Resources   map[string]Resource   `yaml:"resources"`
	DataSources map[string]DataSource `yaml:"data_sources"`
}

Config represents a YAML generator config.

func ParseConfig

func ParseConfig(bytes []byte) (*Config, error)

ParseConfig takes in a byte array (of YAML), unmarshals into a Config struct, and validates the result

func (Config) Validate

func (c Config) Validate() error

type DataSource

type DataSource struct {
	Read          *OpenApiSpecLocation `yaml:"read"`
	SDK           string               `yaml:"sdk"`
	SchemaOptions SchemaOptions        `yaml:"schema"`
}

DataSource generator config section.

func (DataSource) Validate

func (d DataSource) Validate() error

type OpenApiSpecLocation

type OpenApiSpecLocation struct {
	// Matches the path key for a path item (refer to [OAS Paths Object]).
	//
	// [OAS Paths Object]: https://spec.openapis.org/oas/v3.1.0#paths-object
	Path string `yaml:"path"`
	// Matches the operation method in a path item: GET, POST, etc (refer to [OAS Path Item Object]).
	//
	// [OAS Path Item Object]: https://spec.openapis.org/oas/v3.1.0#pathItemObject
	Method string `yaml:"method"`
}

OpenApiSpecLocation defines a location in an OpenAPI spec for an API operation.

func (*OpenApiSpecLocation) Validate

func (o *OpenApiSpecLocation) Validate() error

type Override

type Override struct {
	// Description overrides the description that was mapped/merged from the OpenAPI specification.
	Description string `yaml:"description"`
	// ComputedOptionalRequired overrides the inferred value from the OpenAPI specification.
	ComputedOptionalRequired string `yaml:"computed_optional_required"`
}

Override generator config section.

type Provider

type Provider struct {
	Name      string `yaml:"name"`
	SchemaRef string `yaml:"schema_ref"`

	// TODO: At some point, this should probably be refactored to work with the SchemaOptions struct
	// Ignores are a slice of strings, representing an attribute location to ignore during mapping (dot-separated for nested attributes).
	Ignores []string `yaml:"ignores"`
}

Provider generator config section.

func (Provider) Validate

func (p Provider) Validate() error

type Resource

type Resource struct {
	Create        *OpenApiSpecLocation   `yaml:"create"`
	Read          *OpenApiSpecLocation   `yaml:"read"`
	Update        []*OpenApiSpecLocation `yaml:"update"`
	Delete        *OpenApiSpecLocation   `yaml:"delete"`
	SDK           string                 `yaml:"sdk"`
	SchemaOptions SchemaOptions          `yaml:"schema"`
}

Resource generator config section.

func (Resource) Validate

func (r Resource) Validate() error

type SchemaOptions

type SchemaOptions struct {
	// Ignores are a slice of strings, representing an attribute location to ignore during mapping (dot-separated for nested attributes).
	Ignores          []string         `yaml:"ignores"`
	AttributeOptions AttributeOptions `yaml:"attributes"`
}

SchemaOptions generator config section. This section contains options for modifying the output of the generator.

func (*SchemaOptions) Validate

func (s *SchemaOptions) Validate() error

Jump to

Keyboard shortcuts

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