Documentation
¶
Index ¶
- Variables
- func BundleBytes(bytes []byte, configuration *datamodel.DocumentConfiguration) ([]byte, error)
- func BundleBytesComposed(bytes []byte, configuration *datamodel.DocumentConfiguration, ...) ([]byte, error)
- func BundleDocument(model *v3.Document) ([]byte, error)
- func BundleDocumentComposed(model *v3.Document, compositionConfig *BundleCompositionConfig) ([]byte, error)
- func DetectOpenAPIComponentType(node *yaml.Node) (string, bool)
- type BundleCompositionConfig
Constants ¶
This section is empty.
Variables ¶
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.
func BundleDocument ¶
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 DetectOpenAPIComponentType ¶ added in v0.22.0
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.