Documentation
¶
Overview ¶
Package oas31 contains an implementation of the OAS v3.1 JSON Schema specification https://spec.openapis.org/oas/v3.1.0#schema-object
Index ¶
- func Validate(ctx context.Context, schema JSONSchema, opts ...validation.Option) []error
- type Discriminator
- type ExclusiveMaximum
- type ExclusiveMinimum
- type ExternalDocumentation
- type JSONSchema
- type Reference
- type Schema
- func (s *Schema) GetAdditionalProperties() JSONSchema
- func (s *Schema) GetAllOf() []JSONSchema
- func (s *Schema) GetAnchor() string
- func (s *Schema) GetAnyOf() []JSONSchema
- func (s *Schema) GetConst() values.Value
- func (s *Schema) GetContains() JSONSchema
- func (s *Schema) GetDefault() values.Value
- func (s *Schema) GetDependentSchemas() *sequencedmap.Map[string, JSONSchema]
- func (s *Schema) GetDeprecated() bool
- func (s *Schema) GetDescription() string
- func (s *Schema) GetDiscriminator() *Discriminator
- func (s *Schema) GetElse() JSONSchema
- func (s *Schema) GetEnum() []values.Value
- func (s *Schema) GetExample() values.Value
- func (s *Schema) GetExamples() []values.Value
- func (s *Schema) GetExclusiveMaximum() ExclusiveMaximum
- func (s *Schema) GetExclusiveMinimum() ExclusiveMinimum
- func (s *Schema) GetExtensions() *extensions.Extensions
- func (s *Schema) GetExternalDocs() *ExternalDocumentation
- func (s *Schema) GetFormat() string
- func (s *Schema) GetIf() JSONSchema
- func (s *Schema) GetItems() JSONSchema
- func (s *Schema) GetMaxContains() *int64
- func (s *Schema) GetMaxItems() *int64
- func (s *Schema) GetMaxLength() *int64
- func (s *Schema) GetMaxProperties() *int64
- func (s *Schema) GetMaximum() *float64
- func (s *Schema) GetMinContains() *int64
- func (s *Schema) GetMinItems() *int64
- func (s *Schema) GetMinLength() *int64
- func (s *Schema) GetMinProperties() *int64
- func (s *Schema) GetMinimum() *float64
- func (s *Schema) GetMultipleOf() *float64
- func (s *Schema) GetNot() JSONSchema
- func (s *Schema) GetNullable() bool
- func (s *Schema) GetOneOf() []JSONSchema
- func (s *Schema) GetPattern() string
- func (s *Schema) GetPatternProperties() *sequencedmap.Map[string, JSONSchema]
- func (s *Schema) GetPrefixItems() []JSONSchema
- func (s *Schema) GetProperties() *sequencedmap.Map[string, JSONSchema]
- func (s *Schema) GetPropertyNames() JSONSchema
- func (s *Schema) GetReadOnly() bool
- func (s *Schema) GetRef() string
- func (s *Schema) GetRequired() []string
- func (s *Schema) GetSchema() string
- func (s *Schema) GetThen() JSONSchema
- func (s *Schema) GetTitle() string
- func (s *Schema) GetType() []SchemaType
- func (s *Schema) GetUnevaluatedItems() JSONSchema
- func (s *Schema) GetUnevaluatedProperties() JSONSchema
- func (s *Schema) GetUniqueItems() bool
- func (s *Schema) GetWriteOnly() bool
- func (s *Schema) GetXML() *XML
- func (js *Schema) Validate(ctx context.Context, opts ...validation.Option) []error
- type SchemaType
- type Type
- type XML
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Validate ¶ added in v0.2.2
func Validate(ctx context.Context, schema JSONSchema, opts ...validation.Option) []error
Types ¶
type Discriminator ¶
type Discriminator struct { marshaller.Model[core.Discriminator] // PropertyName is the name of the property in the payload that will hold the discriminator value. PropertyName string // Mapping is an object to hold mappings between payload values and schema names or references. Mapping *sequencedmap.Map[string, string] // Extensions provides a list of extensions to the Discriminator object. Extensions *extensions.Extensions }
Discriminator is used to aid in serialization, deserialization, and validation of the oneOf, anyOf and allOf schemas.
func (*Discriminator) GetExtensions ¶ added in v0.2.2
func (d *Discriminator) GetExtensions() *extensions.Extensions
GetExtensions returns the value of the Extensions field. Returns nil if not set.
func (*Discriminator) GetMapping ¶ added in v0.2.2
func (d *Discriminator) GetMapping() *sequencedmap.Map[string, string]
GetMapping returns the value of the Mapping field. Returns nil if not set.
func (*Discriminator) GetPropertyName ¶ added in v0.2.2
func (d *Discriminator) GetPropertyName() string
GetPropertyName returns the value of the PropertyName field. Returns empty string if not set.
func (*Discriminator) Validate ¶ added in v0.2.2
func (d *Discriminator) Validate(ctx context.Context, opts ...validation.Option) []error
Validate will validate the Discriminator object according to the OpenAPI Specification.
type ExclusiveMaximum ¶
func NewExclusiveMaximumFromBool ¶
func NewExclusiveMaximumFromBool(value bool) ExclusiveMaximum
func NewExclusiveMaximumFromFloat64 ¶
func NewExclusiveMaximumFromFloat64(value float64) ExclusiveMaximum
type ExclusiveMinimum ¶
func NewExclusiveMinimumFromBool ¶
func NewExclusiveMinimumFromBool(value bool) ExclusiveMinimum
func NewExclusiveMinimumFromFloat64 ¶
func NewExclusiveMinimumFromFloat64(value float64) ExclusiveMinimum
type ExternalDocumentation ¶ added in v0.2.2
type ExternalDocumentation struct { marshaller.Model[core.ExternalDocumentation] // Description is a description of the target documentation. May contain CommonMark syntax. Description *string // URL is the URL for the target documentation. URL string // Extensions provides a list of extensions to the ExternalDocumentation object. Extensions *extensions.Extensions }
ExternalDocumentation allows referencing external documentation for the associated object.
func (*ExternalDocumentation) GetDescription ¶ added in v0.2.2
func (e *ExternalDocumentation) GetDescription() string
GetDescription returns the value of the Description field. Returns an empty string if not set.
func (*ExternalDocumentation) GetExtensions ¶ added in v0.2.2
func (e *ExternalDocumentation) GetExtensions() *extensions.Extensions
GetExtensions returns the value of the Extensions field. Returns nil if not set.
func (*ExternalDocumentation) GetURL ¶ added in v0.2.2
func (e *ExternalDocumentation) GetURL() string
GetURL returns the value of the URL field. Returns an empty string if not set.
func (*ExternalDocumentation) Validate ¶ added in v0.2.2
func (e *ExternalDocumentation) Validate(ctx context.Context, opts ...validation.Option) []error
Validate will validate the ExternalDocumentation object according to the OpenAPI Specification.
type JSONSchema ¶
func NewJSONSchemaFromBool ¶
func NewJSONSchemaFromBool(value bool) JSONSchema
func NewJSONSchemaFromSchema ¶
func NewJSONSchemaFromSchema(value *Schema) JSONSchema
func NewJSONSchemaOrBoolFromBool ¶
func NewJSONSchemaOrBoolFromBool(value bool) JSONSchema
func NewJSONSchemaOrBoolFromJSONSchema ¶
func NewJSONSchemaOrBoolFromJSONSchema(value Schema) JSONSchema
type Schema ¶
type Schema struct { marshaller.Model[core.Schema] Ref *string ExclusiveMaximum ExclusiveMaximum ExclusiveMinimum ExclusiveMinimum // Type represents the type of a schema either an array of types or a single type. Type Type AllOf []JSONSchema OneOf []JSONSchema AnyOf []JSONSchema Discriminator *Discriminator Examples []values.Value PrefixItems []JSONSchema Contains JSONSchema MinContains *int64 MaxContains *int64 If JSONSchema Else JSONSchema Then JSONSchema DependentSchemas *sequencedmap.Map[string, JSONSchema] PatternProperties *sequencedmap.Map[string, JSONSchema] PropertyNames JSONSchema UnevaluatedItems JSONSchema UnevaluatedProperties JSONSchema Items JSONSchema Anchor *string Not JSONSchema Properties *sequencedmap.Map[string, JSONSchema] Title *string MultipleOf *float64 Maximum *float64 Minimum *float64 MaxLength *int64 MinLength *int64 Pattern *string Format *string MaxItems *int64 MinItems *int64 UniqueItems *bool MaxProperties *int64 MinProperties *int64 Required []string Enum []values.Value AdditionalProperties JSONSchema Description *string Default values.Value Const values.Value Nullable *bool ReadOnly *bool WriteOnly *bool ExternalDocs *ExternalDocumentation Example values.Value Deprecated *bool Schema *string XML *XML Extensions *extensions.Extensions }
func (*Schema) GetAdditionalProperties ¶ added in v0.2.2
func (s *Schema) GetAdditionalProperties() JSONSchema
GetAdditionalProperties returns the value of the AdditionalProperties field. Returns nil if not set.
func (*Schema) GetAllOf ¶ added in v0.2.2
func (s *Schema) GetAllOf() []JSONSchema
GetAllOf returns the value of the AllOf field. Returns nil if not set.
func (*Schema) GetAnchor ¶ added in v0.2.2
GetAnchor returns the value of the Anchor field. Returns empty string if not set.
func (*Schema) GetAnyOf ¶ added in v0.2.2
func (s *Schema) GetAnyOf() []JSONSchema
GetAnyOf returns the value of the AnyOf field. Returns nil if not set.
func (*Schema) GetConst ¶ added in v0.2.2
GetConst returns the value of the Const field. Returns nil if not set.
func (*Schema) GetContains ¶ added in v0.2.2
func (s *Schema) GetContains() JSONSchema
GetContains returns the value of the Contains field. Returns nil if not set.
func (*Schema) GetDefault ¶ added in v0.2.2
GetDefault returns the value of the Default field. Returns nil if not set.
func (*Schema) GetDependentSchemas ¶ added in v0.2.2
func (s *Schema) GetDependentSchemas() *sequencedmap.Map[string, JSONSchema]
GetDependentSchemas returns the value of the DependentSchemas field. Returns nil if not set.
func (*Schema) GetDeprecated ¶ added in v0.2.2
GetDeprecated returns the value of the Deprecated field. Returns false if not set.
func (*Schema) GetDescription ¶ added in v0.2.2
GetDescription returns the value of the Description field. Returns empty string if not set.
func (*Schema) GetDiscriminator ¶ added in v0.2.2
func (s *Schema) GetDiscriminator() *Discriminator
GetDiscriminator returns the value of the Discriminator field. Returns nil if not set.
func (*Schema) GetElse ¶ added in v0.2.2
func (s *Schema) GetElse() JSONSchema
GetElse returns the value of the Else field. Returns nil if not set.
func (*Schema) GetEnum ¶ added in v0.2.2
GetEnum returns the value of the Enum field. Returns nil if not set.
func (*Schema) GetExample ¶ added in v0.2.2
GetExample returns the value of the Example field. Returns nil if not set.
func (*Schema) GetExamples ¶ added in v0.2.2
GetExamples returns the value of the Examples field. Returns nil if not set.
func (*Schema) GetExclusiveMaximum ¶ added in v0.2.2
func (s *Schema) GetExclusiveMaximum() ExclusiveMaximum
GetExclusiveMaximum returns the value of the ExclusiveMaximum field. Returns nil if not set.
func (*Schema) GetExclusiveMinimum ¶ added in v0.2.2
func (s *Schema) GetExclusiveMinimum() ExclusiveMinimum
GetExclusiveMinimum returns the value of the ExclusiveMinimum field. Returns nil if not set.
func (*Schema) GetExtensions ¶ added in v0.2.2
func (s *Schema) GetExtensions() *extensions.Extensions
GetExtensions returns the value of the Extensions field. Returns nil if not set.
func (*Schema) GetExternalDocs ¶ added in v0.2.2
func (s *Schema) GetExternalDocs() *ExternalDocumentation
GetExternalDocs returns the value of the ExternalDocs field. Returns nil if not set.
func (*Schema) GetFormat ¶ added in v0.2.2
GetFormat returns the value of the Format field. Returns empty string if not set.
func (*Schema) GetIf ¶ added in v0.2.2
func (s *Schema) GetIf() JSONSchema
GetIf returns the value of the If field. Returns nil if not set.
func (*Schema) GetItems ¶ added in v0.2.2
func (s *Schema) GetItems() JSONSchema
GetItems returns the value of the Items field. Returns nil if not set.
func (*Schema) GetMaxContains ¶ added in v0.2.2
GetMaxContains returns the value of the MaxContains field. Returns nil if not set.
func (*Schema) GetMaxItems ¶ added in v0.2.2
GetMaxItems returns the value of the MaxItems field. Returns nil if not set.
func (*Schema) GetMaxLength ¶ added in v0.2.2
GetMaxLength returns the value of the MaxLength field. Returns nil if not set.
func (*Schema) GetMaxProperties ¶ added in v0.2.2
GetMaxProperties returns the value of the MaxProperties field. Returns nil if not set.
func (*Schema) GetMaximum ¶ added in v0.2.2
GetMaximum returns the value of the Maximum field. Returns nil if not set.
func (*Schema) GetMinContains ¶ added in v0.2.2
GetMinContains returns the value of the MinContains field. Returns nil if not set.
func (*Schema) GetMinItems ¶ added in v0.2.2
GetMinItems returns the value of the MinItems field. Returns nil if not set.
func (*Schema) GetMinLength ¶ added in v0.2.2
GetMinLength returns the value of the MinLength field. Returns nil if not set.
func (*Schema) GetMinProperties ¶ added in v0.2.2
GetMinProperties returns the value of the MinProperties field. Returns nil if not set.
func (*Schema) GetMinimum ¶ added in v0.2.2
GetMinimum returns the value of the Minimum field. Returns nil if not set.
func (*Schema) GetMultipleOf ¶ added in v0.2.2
GetMultipleOf returns the value of the MultipleOf field. Returns nil if not set.
func (*Schema) GetNot ¶ added in v0.2.2
func (s *Schema) GetNot() JSONSchema
GetNot returns the value of the Not field. Returns nil if not set.
func (*Schema) GetNullable ¶ added in v0.2.2
GetNullable returns the value of the Nullable field. Returns false if not set.
func (*Schema) GetOneOf ¶ added in v0.2.2
func (s *Schema) GetOneOf() []JSONSchema
GetOneOf returns the value of the OneOf field. Returns nil if not set.
func (*Schema) GetPattern ¶ added in v0.2.2
GetPattern returns the value of the Pattern field. Returns empty string if not set.
func (*Schema) GetPatternProperties ¶ added in v0.2.2
func (s *Schema) GetPatternProperties() *sequencedmap.Map[string, JSONSchema]
GetPatternProperties returns the value of the PatternProperties field. Returns nil if not set.
func (*Schema) GetPrefixItems ¶ added in v0.2.2
func (s *Schema) GetPrefixItems() []JSONSchema
GetPrefixItems returns the value of the PrefixItems field. Returns nil if not set.
func (*Schema) GetProperties ¶ added in v0.2.2
func (s *Schema) GetProperties() *sequencedmap.Map[string, JSONSchema]
GetProperties returns the value of the Properties field. Returns nil if not set.
func (*Schema) GetPropertyNames ¶ added in v0.2.2
func (s *Schema) GetPropertyNames() JSONSchema
GetPropertyNames returns the value of the PropertyNames field. Returns nil if not set.
func (*Schema) GetReadOnly ¶ added in v0.2.2
GetReadOnly returns the value of the ReadOnly field. Returns false if not set.
func (*Schema) GetRef ¶ added in v0.2.2
GetRef returns the value of the Ref field. Returns empty string if not set.
func (*Schema) GetRequired ¶ added in v0.2.2
GetRequired returns the value of the Required field. Returns nil if not set.
func (*Schema) GetSchema ¶ added in v0.2.2
GetSchema returns the value of the Schema field. Returns empty string if not set.
func (*Schema) GetThen ¶ added in v0.2.2
func (s *Schema) GetThen() JSONSchema
GetThen returns the value of the Then field. Returns nil if not set.
func (*Schema) GetTitle ¶ added in v0.2.2
GetTitle returns the value of the Title field. Returns empty string if not set.
func (*Schema) GetType ¶ added in v0.2.2
func (s *Schema) GetType() []SchemaType
GetType will resolve the type of the schema to an array of the types represented by this schema.
func (*Schema) GetUnevaluatedItems ¶ added in v0.2.2
func (s *Schema) GetUnevaluatedItems() JSONSchema
GetUnevaluatedItems returns the value of the UnevaluatedItems field. Returns nil if not set.
func (*Schema) GetUnevaluatedProperties ¶ added in v0.2.2
func (s *Schema) GetUnevaluatedProperties() JSONSchema
GetUnevaluatedProperties returns the value of the UnevaluatedProperties field. Returns nil if not set.
func (*Schema) GetUniqueItems ¶ added in v0.2.2
GetUniqueItems returns the value of the UniqueItems field. Returns false if not set.
func (*Schema) GetWriteOnly ¶ added in v0.2.2
GetWriteOnly returns the value of the WriteOnly field. Returns false if not set.
type SchemaType ¶ added in v0.2.2
type SchemaType string
const ( SchemaTypeArray SchemaType = "array" SchemaTypeBoolean SchemaType = "boolean" SchemaTypeInteger SchemaType = "integer" SchemaTypeNumber SchemaType = "number" SchemaTypeNull SchemaType = "null" SchemaTypeObject SchemaType = "object" SchemaTypeString SchemaType = "string" )
type Type ¶
type Type = *values.EitherValue[[]SchemaType, []marshaller.Node[string], SchemaType, string]
Type represents the type of a schema either an array of types or a single type.
func NewTypeFromArray ¶
func NewTypeFromArray(value []SchemaType) Type
func NewTypeFromString ¶
func NewTypeFromString(value SchemaType) Type
type XML ¶ added in v0.2.2
type XML struct { marshaller.Model[core.XML] // Name replaces the name of the element/attribute used for the described schema property. Name *string // Namespace defines a URI of the namespace definition. Value MUST be in the form of an absolute URI. Namespace *string // Prefix to be used for the name. Prefix *string // Attribute determines whether the property definition creates an attribute. Attribute *bool // Wrapped determines whether the property definition is wrapped. Wrapped *bool // Extensions provides a list of extensions to the XML object. Extensions *extensions.Extensions }
XML represents the metadata of a schema describing a XML element.
func (*XML) GetAttribute ¶ added in v0.2.2
GetAttribute returns the value of the Attribute field. Returns empty string if not set.
func (*XML) GetExtensions ¶ added in v0.2.2
func (x *XML) GetExtensions() *extensions.Extensions
GetExtensions returns the value of the Extensions field. Returns nil if not set.
func (*XML) GetName ¶ added in v0.2.2
GetName returns the value of the Name field. Returns empty string if not set.
func (*XML) GetNamespace ¶ added in v0.2.2
GetNamespace returns the value of the Namespace field. Returns empty string if not set.
func (*XML) GetPrefix ¶ added in v0.2.2
GetPrefix returns the value of the Prefix field. Returns empty string if not set.
func (*XML) GetWrapped ¶ added in v0.2.2
GetWrapped returns the value of the Wrapped field. Returns empty string if not set.