Skip to content

DereferencedJSONSchema

mattpolzin edited this page Jun 11, 2021 · 5 revisions

DereferencedJSONSchema

A JSONSchema type that guarantees none of its nodes are references.

@dynamicMemberLookup
public enum DereferencedJSONSchema: Equatable, JSONSchemaContext 

Inheritance

Equatable, JSONSchemaContext

Nested Type Aliases

CoreContext

public typealias CoreContext<Format: OpenAPIFormat> = JSONSchema.CoreContext<Format>

NumericContext

public typealias NumericContext = JSONSchema.NumericContext

IntegerContext

public typealias IntegerContext = JSONSchema.IntegerContext

StringContext

public typealias StringContext = JSONSchema.StringContext

Enumeration Cases

boolean

case boolean(CoreContext<JSONTypeFormat.BooleanFormat>)

number

case number(CoreContext<JSONTypeFormat.NumberFormat>, NumericContext)

integer

case integer(CoreContext<JSONTypeFormat.IntegerFormat>, IntegerContext)

string

case string(CoreContext<JSONTypeFormat.StringFormat>, StringContext)

object

indirect case object(CoreContext<JSONTypeFormat.ObjectFormat>, ObjectContext)

array

indirect case array(CoreContext<JSONTypeFormat.ArrayFormat>, ArrayContext)

all

indirect case all(of: [DereferencedJSONSchema], core: CoreContext<JSONTypeFormat.AnyFormat>)

one

indirect case one(of: [DereferencedJSONSchema], core: CoreContext<JSONTypeFormat.AnyFormat>)

any

indirect case any(of: [DereferencedJSONSchema], core: CoreContext<JSONTypeFormat.AnyFormat>)

not

indirect case not(DereferencedJSONSchema, core: CoreContext<JSONTypeFormat.AnyFormat>)

fragment

Schemas without a type.

case fragment(CoreContext<JSONTypeFormat.AnyFormat>)

Properties

jsonSchema

Get the JSONSchema representation of this dereferenced schema.

public var jsonSchema: JSONSchema 

This will not necessarily be the same schema that was used to create this dereferenced schema if there was one.

It is always possible to represent a DereferencedJSONSchema as a JSONSchema, although the reverse is not true.

formatString

public var formatString: String? 

required

public var required: Bool 

nullable

public var nullable: Bool 

title

public var title: String? 

description

public var description: String? 

discriminator

public var discriminator: OpenAPI.Discriminator? 

externalDocs

public var externalDocs: OpenAPI.ExternalDocumentation? 

allowedValues

public var allowedValues: [AnyCodable]? 

defaultValue

public var defaultValue: AnyCodable? 

example

public var example: AnyCodable? 

readOnly

public var readOnly: Bool 

writeOnly

public var writeOnly: Bool 

deprecated

public var deprecated: Bool 

objectContext

Get the context specific to an object schema. If not an object schema, returns nil.

public var objectContext: ObjectContext? 

arrayContext

Get the context specific to an array schema. If not an array schema, returns nil.

public var arrayContext: ArrayContext? 

Methods

simplified()

Get a simplified DereferencedJSONSchema.

public func simplified() throws -> DereferencedJSONSchema 

A fully simplified JSON Schema is both dereferenced and also reduced to a more normal form where possible.

As an example, many compound schemas can be simplified.

{
    "allOf": [
        { "type": "object", "description": "Hello World" },
        {
            "properties": [
                "name": { "type": "string" }
            ]
        }
    ]
}

simplifies to ->

{
    "type": "object",
    "description": "Hello World",
    "properties": [
        "name": { "type": "string" }
    ]
}

You can create simplified schemas from the DereferencedJSONSchema type with the simplified() method or you can create simplified schemas from the JSONSchema type with the simplified(given:) method (which combines dereferencing and resolving by taking the OpenAPI.Components as input).

Types
Protocols
Global Functions
Extensions
Clone this wiki locally