-
Notifications
You must be signed in to change notification settings - Fork 37
JSONSchemaContext
A schema context stores information about a schema. All schemas can have the contextual information in this protocol.
public protocol JSONSchemaContext
The format of the schema as a string value.
var formatString: String?
This can be set even when a schema type has
not be specified. If a type has been specified,
a type-safe format can be used and retrieved
via the jsonTypeFormat
property.
true
if values for this schema are required, false
if they
are optional (and can therefore be omitted from request/response data).
var required: Bool
true
if values for this schema can be null
.
var nullable: Bool
Get the title, if specified. If unspecified, returns nil
.
var title: String?
Get the description, if specified. If unspecified, returns nil
.
var description: String?
An object used to discriminate upon the options for a child object's schema in a polymorphic context.
var discriminator: OpenAPI.Discriminator?
Discriminators are only applicable when used in conjunction with
allOf
, anyOf
, or oneOf
.
Still, they need to be supported on the
JSONSchema.Context
(which is not used with those three special
schema types) because the specification states that a discriminator can
be placed on a parent object (one level up from an allOf
, anyOf
,
or oneOf
) as a way to reduce redundancy.
See OpenAPI Discriminator Object.
Get the external docs, if specified. If unspecified, returns nil
.
var externalDocs: OpenAPI.ExternalDocumentation?
The OpenAPI spec calls this "enum"
var allowedValues: [AnyCodable]?
If not specified, it is assumed that any
value of the given format is allowed.
NOTE: I would like the array of allowed
values to have the type Format.SwiftType
but this is not tractable because I also
want to be able to automatically turn any
Swift type that will get encoded as
something compatible with Format.SwiftType
into an allowed value.
The OpenAPI spec calls this "default"
var defaultValue: AnyCodable?
If specified, this value indicates the value the
property will take on if no value is explicitly given
by the client.
NOTE: I would like the default value to have
the type Format.SwiftType
but this is not
tractable because I also want to be able to
automatically turn any Swift type that will get
encoded as something compatible with
Format.SwiftType
into a default.
Get an example, if specified. If unspecified, returns nil
.
var example: AnyCodable?
true
if this schema can only be read from and is therefore
unsupported for request data.
var readOnly: Bool
true
if this schema can only be written to and is therefore
unavailable in response data.
var writeOnly: Bool
true
if this schema is deprecated, false
otherwise.
var deprecated: Bool
.
Types
- AnyCodable
- DereferencedContent
- DereferencedContentEncoding
- DereferencedDocument
- DereferencedDocument.Route
- DereferencedHeader
- DereferencedJSONSchema
- DereferencedJSONSchema.ArrayContext
- DereferencedJSONSchema.ObjectContext
- DereferencedOperation
- DereferencedOperation.ResponseOutcome
- DereferencedParameter
- DereferencedPathItem
- DereferencedPathItem.Endpoint
- DereferencedRequest
- DereferencedResponse
- DereferencedSchemaContext
- DereferencedSecurityRequirement
- DereferencedSecurityRequirement.ScopedScheme
- Either
- EitherDecodeNoTypesMatchedError
- EitherDecodeNoTypesMatchedError.IndividualFailure
- ErrorCategory
- ErrorCategory.KeyValue
- InconsistencyError
- JSONReference
- JSONReference.InternalReference
- JSONReference.Path
- JSONReference.PathComponent
- JSONSchema
- JSONSchema.ArrayContext
- JSONSchema.CoreContext
- JSONSchema.CoreContext.Permissions
- JSONSchema.IntegerContext
- JSONSchema.IntegerContext.Bound
- JSONSchema.NumericContext
- JSONSchema.NumericContext.Bound
- JSONSchema.ObjectContext
- JSONSchema.StringContext
- JSONSchemaResolutionError
- JSONType
- JSONTypeFormat
- JSONTypeFormat.AnyFormat
- JSONTypeFormat.ArrayFormat
- JSONTypeFormat.BooleanFormat
- JSONTypeFormat.IntegerFormat
- JSONTypeFormat.IntegerFormat.Extended
- JSONTypeFormat.NumberFormat
- JSONTypeFormat.ObjectFormat
- JSONTypeFormat.StringFormat
- JSONTypeFormat.StringFormat.Extended
- OpenAPI
- OpenAPI.CallbackURL
- OpenAPI.ComponentKey
- OpenAPI.Components
- OpenAPI.Components.ReferenceCycleError
- OpenAPI.Components.ReferenceError
- OpenAPI.Content
- OpenAPI.Content.Encoding
- OpenAPI.ContentType
- OpenAPI.Discriminator
- OpenAPI.Document
- OpenAPI.Document.Info
- OpenAPI.Document.Info.Contact
- OpenAPI.Document.Info.License
- OpenAPI.Document.Route
- OpenAPI.Document.Version
- OpenAPI.Error
- OpenAPI.Error.Decoding
- OpenAPI.Error.Decoding.Document
- OpenAPI.Error.Decoding.Document.Context
- OpenAPI.Error.Decoding.Operation
- OpenAPI.Error.Decoding.Operation.Context
- OpenAPI.Error.Decoding.Path
- OpenAPI.Error.Decoding.Path.Context
- OpenAPI.Error.Decoding.Request
- OpenAPI.Error.Decoding.Request.Context
- OpenAPI.Error.Decoding.Response
- OpenAPI.Error.Decoding.Response.Context
- OpenAPI.Example
- OpenAPI.ExternalDocumentation
- OpenAPI.Header
- OpenAPI.HttpMethod
- OpenAPI.Link
- OpenAPI.OAuthFlows
- OpenAPI.OAuthFlows.AuthorizationCode
- OpenAPI.OAuthFlows.ClientCredentials
- OpenAPI.OAuthFlows.CommonFields
- OpenAPI.OAuthFlows.Implicit
- OpenAPI.OAuthFlows.Password
- OpenAPI.Operation
- OpenAPI.Operation.ResponseOutcome
- OpenAPI.Parameter
- OpenAPI.Parameter.Context
- OpenAPI.Parameter.Context.Location
- OpenAPI.Parameter.SchemaContext
- OpenAPI.Parameter.SchemaContext.Style
- OpenAPI.Path
- OpenAPI.PathItem
- OpenAPI.PathItem.Endpoint
- OpenAPI.Request
- OpenAPI.Response
- OpenAPI.Response.StatusCode
- OpenAPI.Response.StatusCode.Range
- OpenAPI.RuntimeExpression
- OpenAPI.RuntimeExpression.Source
- OpenAPI.SecurityScheme
- OpenAPI.SecurityScheme.Location
- OpenAPI.SecurityScheme.SecurityType
- OpenAPI.SecurityScheme.SecurityType.Name
- OpenAPI.Server
- OpenAPI.Server.Variable
- OpenAPI.Tag
- OpenAPI.XML
- OrderedDictionary
- OrderedDictionary.Iterator
- ResolvedDocument
- ResolvedEndpoint
- ResolvedRoute
- URLTemplate
- URLTemplate.Component
- Validation
- ValidationContext
- ValidationError
- ValidationErrorCollection
- Validator
- Validator.CodingKey
Protocols
Global Functions
Extensions
- Array
- Bool
- Dictionary
- Double
- Float
- Int
- Int32
- Int64
- OpenAPI.Callbacks
- OpenAPI.Content.Encoding
- OpenAPI.Document.Info
- OpenAPI.Document.Info.Contact
- OpenAPI.Document.Info.License
- OpenAPI.Error.Decoding
- OpenAPI.Error.Decoding.Document
- OpenAPI.Error.Decoding.Operation
- OpenAPI.Error.Decoding.Path
- OpenAPI.Error.Decoding.Request
- OpenAPI.Error.Decoding.Response
- OpenAPI.OAuthFlows.AuthorizationCode
- OpenAPI.OAuthFlows.ClientCredentials
- OpenAPI.OAuthFlows.CommonFields
- OpenAPI.OAuthFlows.Implicit
- OpenAPI.OAuthFlows.Password
- OpenAPI.Parameter.Context
- OpenAPI.Parameter.SchemaContext
- OpenAPI.Response.StatusCode
- OpenAPI.Server.Variable
- Optional
- String
- URL
- UUID