-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringSchemaRepresentable.swift
More file actions
47 lines (42 loc) · 1.15 KB
/
StringSchemaRepresentable.swift
File metadata and controls
47 lines (42 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//
// StringSchemaRepresentable.swift
// feather-openapi
//
// Created by Tibor Bödecs on 2026. 01. 22..
//
import OpenAPIKit30
/// Schema representation for string values.
public protocol StringSchemaRepresentable:
SchemaRepresentable,
ExampleProperty,
DefaultValueProperty,
AllowedValuesProperty
where
ExamplePropertyType == String,
DefaultValuePropertyType == String,
AllowedValuesPropertyType == String
{
}
extension StringSchemaRepresentable {
/// Builds a string JSON schema.
/// - Returns: The JSON schema.
public func openAPISchema() -> JSONSchema {
.string(
format: .generic,
required: `required`,
nullable: nullable,
permissions: nil,
deprecated: deprecated,
title: title,
description: description,
discriminator: nil,
externalDocs: nil,
minLength: nil,
maxLength: nil,
pattern: nil,
allowedValues: allowedValues?.map { .init($0) },
defaultValue: defaultValue.map { .init($0) },
example: example.map { .init($0) }
)
}
}