You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/@v2/commands/split.md
+47-8Lines changed: 47 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,17 +3,41 @@
3
3
## Introduction
4
4
5
5
The `split` command takes an API description file and creates a [multi-file structure](https://redocly.com/docs/resources/multi-file-definitions/) out of it by extracting referenced parts into standalone, separate files.
6
-
Code samples, components, and paths are split from the root API description into separate files and folders.
7
-
The structure of the unbundled directory corresponds to the structure created by our [openapi-starter](https://github.com/Redocly/openapi-starter) tool.
8
6
The advantage of this approach is making smaller files that are easier to manage and a structure that makes reviewing simpler.
9
7
10
-
Use the [`bundle`](./bundle.md) command and supply the main file as the entrypoint to get your OpenAPI description in one file.
11
-
Many OpenAPI tools prefer a single file, but `split` and `bundle` allow you to manage your files easily for development, and then prepare a single file for other tools to consume.
The `split` command supports OpenAPI 3.x, AsyncAPI 2.x, and AsyncAPI 3.x descriptions. OpenAPI 2.x (Swagger) is not supported.
15
10
{% /admonition %}
16
11
12
+
The parts that get split depend on the type of API description:
13
+
14
+
**OpenAPI 3.x**
15
+
16
+
Components, paths, and webhooks are split from the root API description into separate files and folders.
17
+
The structure of the unbundled directory corresponds to the structure created by the [openapi-starter](https://github.com/Redocly/openapi-starter) tool.
18
+
19
+
-`paths/` - each path item is written to a separate file
20
+
-`webhooks/` - each webhook is written to a separate file (OpenAPI 3.1+)
21
+
-`components/` - schemas, responses, parameters, examples, headers, requestBodies, links, callbacks, and securitySchemes are each split into subdirectories
22
+
23
+
**AsyncAPI 2.x**
24
+
25
+
Channels and components are split from the root API description into separate files and folders.
26
+
27
+
-`channels/` - each channel is written to a separate file
28
+
-`components/` - schemas, messages, securitySchemes, parameters, correlationIds, messageTraits, operationTraits, serverBindings, channelBindings, operationBindings, and messageBindings are each split into subdirectories
29
+
30
+
**AsyncAPI 3.x**
31
+
32
+
Channels, operations, and components are split from the root API description into separate files and folders.
33
+
34
+
-`channels/` - each channel is written to a separate file
35
+
-`operations/` - each operation is written to a separate file
36
+
-`components/` - schemas, messages, securitySchemes, servers, serverVariables, parameters, replies, replyAddresses, correlationIds, messageTraits, operationTraits, tags, externalDocs, serverBindings, channelBindings, operationBindings, and messageBindings are each split into subdirectories
37
+
38
+
Use the [`bundle`](./bundle.md) command and supply the main file as the entrypoint to get your API description back in one file.
39
+
Many API tools prefer a single file, but `split` and `bundle` allow you to manage your files easily for development, and then prepare a single file for other tools to consume.
40
+
17
41
## Usage
18
42
19
43
```bash
@@ -36,7 +60,7 @@ redocly split --version
36
60
37
61
## Examples
38
62
39
-
### View successful split message
63
+
### Split an OpenAPI description
40
64
41
65
This `split` command "unbundles" the specified API description, as defined in `pet.yaml`, into the `openapi` output directory:
42
66
@@ -52,3 +76,18 @@ Document: pet.yaml is successfully split
52
76
53
77
pet.yaml: split processed in 33ms
54
78
</pre>
79
+
80
+
### Split an AsyncAPI description
81
+
82
+
The `split` command works the same way with AsyncAPI 2.x and AsyncAPI 3.x descriptions:
83
+
84
+
```bash
85
+
redocly split asyncapi.yaml --outDir=asyncapi
86
+
```
87
+
88
+
<pre>
89
+
Document: asyncapi.yaml is successfully split
90
+
and all related files are saved to the directory: asyncapi
0 commit comments