Serve Up Some Variables
The URLTemplate
type used for the OpenAPI.Server
urlTemplate
property now exposes information on the variables contained within it in two ways and will fail if the URL used to create it has malformed variables.
You can access an array of variable names within the template via the variables
property or an array of components (variables and constants) via the components
property.
You can now use the optional serverVariablesAreDefined
validation to assert that if a variable exists in the template for a Server Object's URL, then that same Server Object gives the variable a definition (See the OpenAPI Server Variable and the variables
property on the OpenAPIKit Server
type).
You can replace URL template variables with values to turn a template into a valid fully formed URL. The URLTemplate
type exposes a replacing(_:)
method for just this purpose. Once all variables have been replaced by constant values, you can use the url
property of URLTemplate
to attempt to retrieve a valid Foundation URL
if possible.
Other Additions
ValidationErrorCollection
now uses a newline separated list of its errors as its description (you can useString(describing: errors)
to get this description).- The
JSONSchema
type has a series of properties to check if a given schema is of a particular type.isBoolean
,isNumber
,isInteger
, etc. - A new
all(_:)
has been added to the validation helpers. This function accepts any number ofValidations
and produces a function of the type expected by acheck
clause of anotherValidation
. See the Validation Documentation for more.