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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//! The OpenApiSplitter trait for splitting OpenAPI specifications.
use Serialize;
use OpenApi;
use SplitResult;
/// Trait for splitting an OpenAPI specification into multiple files.
///
/// Implementations of this trait define different strategies for organizing
/// schemas and other components into separate files for better modularity.
///
/// # Type Parameters
///
/// The associated type `Fragment` defines what type of content is extracted
/// into separate files. Common choices include:
///
/// * [`Components`](utoipa::openapi::Components) - Extract just the components section
/// * [`OpenApi`] - Extract complete sub-specifications
/// * Custom types implementing [`Serialize`]
///
/// # Implementing Custom Splitters
///
/// ```rust,ignore
/// use clawspec_core::split::{OpenApiSplitter, SplitResult, Fragment};
/// use utoipa::openapi::{Components, OpenApi};
/// use std::path::PathBuf;
///
/// struct MyCustomSplitter {
/// output_dir: PathBuf,
/// }
///
/// impl OpenApiSplitter for MyCustomSplitter {
/// type Fragment = Components;
///
/// fn split(&self, spec: OpenApi) -> SplitResult<Self::Fragment> {
/// // Analyze the spec and extract schemas
/// // Update refs in main spec to point to external files
/// // Return the modified main spec and fragments
/// todo!()
/// }
/// }
/// ```
///
/// # Built-in Implementations
///
/// * [`SplitSchemasByTag`](super::SplitSchemasByTag) - Split schemas based on which tags use them
/// * [`ExtractSchemasByPredicate`](super::ExtractSchemasByPredicate) - Extract schemas matching a predicate
/// Extension trait for convenient splitting of OpenAPI specifications.