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 ¶
ParseConfig takes in a byte array (of YAML), unmarshals into a Config struct, and validates the result
type DataSource ¶
type DataSource struct {
Read *OpenApiSpecLocation `yaml:"read"`
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"`
}
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.
type Resource ¶
type Resource struct {
Create *OpenApiSpecLocation `yaml:"create"`
Read *OpenApiSpecLocation `yaml:"read"`
Update *OpenApiSpecLocation `yaml:"update"`
Delete *OpenApiSpecLocation `yaml:"delete"`
SchemaOptions SchemaOptions `yaml:"schema"`
}
Resource generator config section.
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