Documentation
¶
Overview ¶
Package gen implements the OpenAPI Generator generation pipeline: it parses an OpenAPI spec, assembles codegen models/operations, renders them through the generator's Mustache templates, and writes the resulting files (plus per-folder index files and .openapi-generator metadata) to disk.
It is deliberately independent of the CLI: callers build an Options value and call Generate. cmd/openapi-generator wires cobra flags and a config file onto Options and reports the returned error.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶
Generate runs the full pipeline for opts: parse the spec, assemble models/operations, render templates, and write the generated files, index files, and .openapi-generator metadata to opts.OutputDir.
func PrintDartFetchConfigHelp ¶
func PrintDartFetchConfigHelp()
PrintDartFetchConfigHelp prints the dart-fetch additional config options to stdout (used by the "config-help" CLI command).
func PrintTypeScriptFetchConfigHelp ¶
func PrintTypeScriptFetchConfigHelp()
PrintTypeScriptFetchConfigHelp prints the typescript-fetch additional config options to stdout (used by the "config-help" CLI command).
Types ¶
type Options ¶
type Options struct {
// InputSpec is a local file path or an http(s) URL to the OpenAPI
// document to generate from.
InputSpec string
// OutputDir is the directory generated files are written to.
OutputDir string
// GeneratorName selects the target generator: "typescript-fetch" or
// "dart-fetch".
GeneratorName string
// TemplateDir, if set, overrides the embedded templates with templates
// loaded from this filesystem directory.
TemplateDir string
// AdditionalProperties holds "key=value" generator options, as passed
// via the CLI's --additional-properties flag.
AdditionalProperties []string
// SkipValidation disables OpenAPI spec validation.
SkipValidation bool
// Verbose enables progress logging to stdout.
Verbose bool
// Version is the openapi-generator version string embedded in
// generated metadata (.openapi-generator/VERSION, generatorVersion).
Version string
}
Options configures a single generation run.
type ValidationResult ¶
type ValidationResult struct {
// Errors are problems that make the spec invalid: it could not be
// loaded, or kin-openapi validation rejected it.
Errors []string
// Warnings are recommendations that do not invalidate the spec, such
// as models declared under components/schemas but never referenced.
Warnings []string
}
ValidationResult holds the outcome of validating an OpenAPI document.
func Validate ¶
func Validate(inputSpec string) ValidationResult
Validate loads inputSpec (a local file path or an http(s) URL) and returns its validation errors and warnings. A spec that cannot be loaded at all is reported as a single error rather than a failure, so callers can treat every outcome uniformly.