2019-01-13 18:28:41 -08:00
|
|
|
//
|
|
|
|
|
// PrimitiveTypes.swift
|
|
|
|
|
// JSONAPIOpenAPI
|
|
|
|
|
//
|
|
|
|
|
// Created by Mathew Polzin on 01/13/19.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
|
|
Notable omissions in this library's default offerings:
|
|
|
|
|
|
|
|
|
|
Base 64 encoded characters:
|
|
|
|
|
.string(.byte)
|
|
|
|
|
|
|
|
|
|
Any sequence of octets:
|
|
|
|
|
.string(.binary)
|
|
|
|
|
|
|
|
|
|
RFC3339 full-date:
|
|
|
|
|
.string(.date)
|
|
|
|
|
|
|
|
|
|
RFC3339 date-time:
|
|
|
|
|
.string(.dateTime)
|
|
|
|
|
|
|
|
|
|
A hint to UIs to obscure input:
|
|
|
|
|
.string(.password)
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
2019-01-14 21:17:07 -08:00
|
|
|
extension Optional: OpenAPINodeType where Wrapped: OpenAPINodeType {
|
|
|
|
|
static public var openAPINode: OpenAPI.JSONNode {
|
|
|
|
|
return Wrapped.openAPINode.optionalNode()
|
2019-01-13 18:28:41 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-14 21:17:07 -08:00
|
|
|
extension String: OpenAPINodeType {
|
|
|
|
|
static public var openAPINode: OpenAPI.JSONNode {
|
|
|
|
|
return .string(.init(format: .generic,
|
|
|
|
|
required: true),
|
|
|
|
|
.init())
|
2019-01-13 18:28:41 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-14 21:17:07 -08:00
|
|
|
extension Bool: OpenAPINodeType {
|
|
|
|
|
static public var openAPINode: OpenAPI.JSONNode {
|
|
|
|
|
return .boolean(.init(format: .generic,
|
|
|
|
|
required: true))
|
2019-01-13 18:28:41 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-14 21:17:07 -08:00
|
|
|
extension Array: OpenAPINodeType where Element: OpenAPINodeType {
|
|
|
|
|
static public var openAPINode: OpenAPI.JSONNode {
|
|
|
|
|
return .array(.init(format: .generic,
|
|
|
|
|
required: true),
|
|
|
|
|
.init(items: Element.openAPINode))
|
2019-01-13 18:28:41 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-14 21:17:07 -08:00
|
|
|
extension Double: OpenAPINodeType {
|
|
|
|
|
static public var openAPINode: OpenAPI.JSONNode {
|
|
|
|
|
return .number(.init(format: .double,
|
|
|
|
|
required: true),
|
|
|
|
|
.init())
|
2019-01-13 18:28:41 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-14 21:17:07 -08:00
|
|
|
extension Float: OpenAPINodeType {
|
|
|
|
|
static public var openAPINode: OpenAPI.JSONNode {
|
|
|
|
|
return .number(.init(format: .float,
|
|
|
|
|
required: true),
|
|
|
|
|
.init())
|
2019-01-13 18:28:41 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-14 21:17:07 -08:00
|
|
|
extension Int: OpenAPINodeType {
|
|
|
|
|
static public var openAPINode: OpenAPI.JSONNode {
|
|
|
|
|
return .integer(.init(format: .generic,
|
|
|
|
|
required: true),
|
|
|
|
|
.init())
|
2019-01-13 18:28:41 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-14 21:17:07 -08:00
|
|
|
extension Int32: OpenAPINodeType {
|
|
|
|
|
static public var openAPINode: OpenAPI.JSONNode {
|
|
|
|
|
return .integer(.init(format: .int32,
|
|
|
|
|
required: true),
|
|
|
|
|
.init())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extension Int64: OpenAPINodeType {
|
|
|
|
|
static public var openAPINode: OpenAPI.JSONNode {
|
|
|
|
|
return .integer(.init(format: .int64,
|
|
|
|
|
required: true),
|
|
|
|
|
.init())
|
2019-01-13 18:28:41 -08:00
|
|
|
}
|
|
|
|
|
}
|