bundler

package
v0.30.2 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: MIT Imports: 20 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidModel = errors.New("invalid model")

ErrInvalidModel is returned when the model is not usable.

Functions

func BundleBytes

func BundleBytes(bytes []byte, configuration *datamodel.DocumentConfiguration) ([]byte, error)

BundleBytes will take a byte slice of an OpenAPI specification and return a bundled version of it. This is useful for when you want to take a specification with external references, and you want to bundle it into a single document.

This function will 'resolve' all references in the specification and return a single document. The resulting document will be a valid OpenAPI specification, containing no references.

Circular references will not be resolved and will be skipped.

func BundleBytesComposed added in v0.22.0

func BundleBytesComposed(bytes []byte, configuration *datamodel.DocumentConfiguration, compositionConfig *BundleCompositionConfig) ([]byte, error)

BundleBytesComposed will take a byte slice of an OpenAPI specification and return a composed bundled version of it. this is the same as BundleBytes, but it will compose the bundling instead of inline it.

Composed means that every external file will have references lifted out and added to the `components` section of the document. Names will be preserved where possible, conflicts will dealt with by using a delimiter and appending a number.

func BundleBytesWithConfig added in v0.30.0

func BundleBytesWithConfig(bytes []byte, configuration *datamodel.DocumentConfiguration, bundleConfig *BundleInlineConfig) ([]byte, error)

BundleBytesWithConfig will take a byte slice of an OpenAPI specification and return a bundled version of it, with additional configuration options for inline bundling behavior.

Use the BundleInlineConfig to enable features like ResolveDiscriminatorExternalRefs which copies external schemas referenced by discriminator mappings to the root document's components section.

func BundleDocument

func BundleDocument(model *v3.Document) ([]byte, error)

BundleDocument will take a v3.Document and return a bundled version of it. This is useful for when you want to take a document that has been built from a specification with external references, and you want to bundle it into a single document.

This function will 'resolve' all references in the specification and return a single document. The resulting document will be a valid OpenAPI specification, containing no references.

Circular references will not be resolved and will be skipped.

func BundleDocumentComposed added in v0.22.0

func BundleDocumentComposed(model *v3.Document, compositionConfig *BundleCompositionConfig) ([]byte, error)

BundleDocumentComposed will take a v3.Document and return a composed bundled version of it. Composed means that every external file will have references lifted out and added to the `components` section of the document. Names will be preserved where possible, conflicts will be appended with a number. If the type of the reference cannot be determined, it will be added to the `components` section as a `Schema` type, a warning will be logged. The document model will be mutated permanently.

Circular references will not be resolved and will be skipped.

func BundleDocumentWithConfig added in v0.30.0

func BundleDocumentWithConfig(model *v3.Document, bundleConfig *BundleInlineConfig) ([]byte, error)

BundleDocumentWithConfig will take a v3.Document and return a bundled version of it, with additional configuration options for inline bundling behavior.

Use the BundleInlineConfig to enable features like ResolveDiscriminatorExternalRefs which copies external schemas referenced by discriminator mappings to the root document's components section.

func DetectOpenAPIComponentType added in v0.22.0

func DetectOpenAPIComponentType(node *yaml.Node) (string, bool)

DetectOpenAPIComponentType attempts to determine what type of OpenAPI component a node represents. It returns the component type as a string (schema, response, parameter, etc.) and a boolean indicating whether the type was successfully detected.

Types

type BundleCompositionConfig added in v0.22.0

type BundleCompositionConfig struct {
	Delimiter string // Delimiter is used to separate clashing names. Defaults to `__`.
}

BundleCompositionConfig is used to configure the composition of OpenAPI documents when using BundleDocumentComposed.

type BundleInlineConfig added in v0.30.0

type BundleInlineConfig struct {
	// ResolveDiscriminatorExternalRefs when true, copies external schemas referenced
	// by discriminator mappings to the root document's components section.
	// This ensures the bundled output is valid and self-contained when discriminators
	// in external files reference other schemas in those external files.
	// Default: false (preserves existing behavior of keeping external refs as-is)
	ResolveDiscriminatorExternalRefs bool
}

BundleInlineConfig provides configuration options for inline bundling.

Jump to

Keyboard shortcuts

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