asyncapiversion

package
v1.28.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package asyncapiversion provides the version and schema format policy shared by the asyncapi document package and the jsonschema/asyncapi schema package.

It deliberately imports neither package so both can depend on it without an import cycle.

Index

Constants

View Source
const JSONSchemaDraft07 = "draft-07"

JSONSchemaDraft07 is the only JSON Schema version listed in the AsyncAPI schema formats table.

View Source
const Latest = "3.1.0"

Latest is the latest AsyncAPI Specification version supported, used as the default for new documents.

Variables

This section is empty.

Functions

func DefaultSchemaFormat

func DefaultSchemaFormat(asyncAPIVersion string) string

DefaultSchemaFormat returns the schema format assumed when a schema has no explicit `schemaFormat`, which is the native AsyncAPI Schema Object for the document's AsyncAPI version.

func IsSupported

func IsSupported(v string) bool

IsSupported returns true if the provided AsyncAPI version string is valid and belongs to a supported minor line.

func SupportedMinorVersions

func SupportedMinorVersions() []string

SupportedMinorVersions returns a copy of the `major.minor` AsyncAPI Specification versions supported. Any patch release (and permitted suffix) of a supported minor version is accepted, as the specification states the patch version is not considered by tooling.

func SupportedVersionPatterns

func SupportedVersionPatterns() []string

SupportedVersionPatterns returns the supported versions in a human readable form, e.g. `3.0.x`.

Types

type SchemaFormat

type SchemaFormat struct {
	// Raw is the authored value.
	Raw string
	// Kind is the schema language the media type names.
	Kind SchemaFormatKind
	// MediaType is the media type without parameters, e.g. `application/vnd.aai.asyncapi+json`.
	MediaType string
	// Version is the `version` media type parameter, if any.
	Version string
}

SchemaFormat is a parsed `schemaFormat` value.

func ParseSchemaFormat

func ParseSchemaFormat(s string) SchemaFormat

ParseSchemaFormat parses a `schemaFormat` value. It never fails: values that are not valid media types are reported with SchemaFormatKindInvalid and unrecognised media types as SchemaFormatKindCustom.

func (SchemaFormat) IsDraft07

func (f SchemaFormat) IsDraft07() bool

IsDraft07 returns true if the format is explicitly JSON Schema Draft 07 rather than the native AsyncAPI Schema Object.

func (SchemaFormat) IsJSONSchemaBased

func (f SchemaFormat) IsJSONSchemaBased() bool

IsJSONSchemaBased returns true if the format is a JSON Schema based format this module models with typed schema objects: the native AsyncAPI Schema Object for a supported AsyncAPI version or JSON Schema Draft 07.

func (SchemaFormat) IsStandardKind

func (f SchemaFormat) IsStandardKind() bool

IsStandardKind returns true if the format names one of the schema languages listed in the AsyncAPI schema formats tables. A custom format must not refer to one of these.

type SchemaFormatKind

type SchemaFormatKind string

SchemaFormatKind identifies the schema language named by a Multi Format Schema Object `schemaFormat`.

const (
	// SchemaFormatKindAsyncAPI is the native AsyncAPI Schema Object.
	SchemaFormatKindAsyncAPI SchemaFormatKind = "asyncapi"
	// SchemaFormatKindJSONSchema is JSON Schema.
	SchemaFormatKindJSONSchema SchemaFormatKind = "jsonschema"
	// SchemaFormatKindAvro is an Apache Avro schema.
	SchemaFormatKindAvro SchemaFormatKind = "avro"
	// SchemaFormatKindOpenAPI is an OpenAPI Schema Object.
	SchemaFormatKindOpenAPI SchemaFormatKind = "openapi"
	// SchemaFormatKindRAML is a RAML data type.
	SchemaFormatKindRAML SchemaFormatKind = "raml"
	// SchemaFormatKindProtobuf is a Protocol Buffers schema.
	SchemaFormatKindProtobuf SchemaFormatKind = "protobuf"
	// SchemaFormatKindCustom is any other (custom) schema format.
	SchemaFormatKindCustom SchemaFormatKind = "custom"
	// SchemaFormatKindInvalid is a value that is not a valid media type.
	SchemaFormatKindInvalid SchemaFormatKind = "invalid"
)

type Version

type Version struct {
	Major  int
	Minor  int
	Patch  int
	Suffix string
}

Version is a parsed AsyncAPI version string.

func Parse

func Parse(v string) (*Version, error)

Parse parses an AsyncAPI version string such as `3.1.0` or `3.0.0-rc1`.

func (Version) IsSupported

func (v Version) IsSupported() bool

IsSupported returns true if the version belongs to a supported minor line.

func (Version) MinorLine

func (v Version) MinorLine() string

MinorLine returns the `major.minor` line of the version.

func (Version) String

func (v Version) String() string

String returns the version string.

Jump to

Keyboard shortcuts

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