-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExampleRepresentable.swift
More file actions
45 lines (40 loc) · 1.09 KB
/
Copy pathExampleRepresentable.swift
File metadata and controls
45 lines (40 loc) · 1.09 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
//
// ExampleRepresentable.swift
// feather-openapi
//
// Created by Tibor Bödecs on 2026. 01. 21.
//
import OpenAPIKit30
/// Describes an OpenAPI example with defaults.
public protocol ExampleRepresentable:
OpenAPIExampleRepresentable,
Identifiable,
DescriptionProperty,
VendorExtensionsProperty
{
/// Short summary of the example.
var summary: String? { get }
/// Example payload value.
var value: AnyCodable { get }
}
extension ExampleRepresentable {
/// Creates a reference wrapper for this example.
/// - Returns: An example reference.
public func reference() -> ExampleReference<Self> {
.init(self)
}
/// Builds an OpenAPI example object or reference.
/// - Returns: The OpenAPI example representation.
public func openAPIExample() -> Either<
JSONReference<OpenAPI.Example>, OpenAPI.Example
> {
.init(
.init(
summary: summary,
description: description,
value: .init(value),
vendorExtensions: vendorExtensions
)
)
}
}