@@ -6,7 +6,7 @@ sidebar_label: Redocly config support
66# Redocly Config Support
77
88Qraft CLI can use a [ Redocly configuration file] ( https://redocly.com/docs/cli/configuration ) (` redocly.yaml ` )
9- to generate one or multiple API clients with custom settings and authentication rules. By integrating
9+ to generate one or multiple API clients with custom settings and authentication rules for both OpenAPI and AsyncAPI documents . By integrating
1010with Redocly's powerful configuration schema resolution, you can
1111streamline client generation across various services defined in your project.
1212
@@ -19,6 +19,17 @@ Qraft CLI integrates with Redocly's configuration framework to simplify API clie
1919- Centralize Qraft CLI options
2020- Configure [ authentication and header] ( https://redocly.com/docs/cli/configuration/reference/resolve ) definitions in one place
2121
22+ ### One config for OpenAPI and AsyncAPI
23+
24+ You can keep both modes in the same file:
25+
26+ - Use ` x-openapi-qraft ` for OpenAPI generation options (plugins and OpenAPI-specific flags).
27+ - Use ` x-asyncapi-qraft ` for AsyncAPI generation options (plugins and AsyncAPI-specific flags).
28+ - Both keys can be set globally and per API entry under ` apis.<name> ` .
29+ - Per-API options override global defaults.
30+
31+ This makes it possible to maintain one ` redocly.yaml ` for all services in a project while still using mode-specific plugin options.
32+
2233### Configuration Example: Redocly 🤝 Qraft
2334
2435Here's a basic example of a ` redocly.yaml ` configuration file:
@@ -29,6 +40,14 @@ x-openapi-qraft:
2940 plugin :
3041 tanstack-query-react : true # Generate React Query hooks for each API Client
3142 openapi-typescript : true # Generate TypeScript types for each API Client
43+ clean : true
44+
45+ # Qraft CLI global AsyncAPI config
46+ x-asyncapi-qraft :
47+ plugin :
48+ asyncapi-typescript : true
49+ asyncapi-types-file-name : asyncapi.ts
50+ clean : true
3251
3352apis :
3453 # Main API configuration
@@ -39,25 +58,19 @@ apis:
3958 output-dir : src/api # Output directory for a generated API client
4059 clean : true # Clean output directory before generation
4160
42- # Legacy API configuration
43- legacy :
44- root : ./legacy -openapi.json
61+ # Another OpenAPI entry
62+ payments :
63+ root : ./payments -openapi.json
4564 x-openapi-qraft :
46- output-dir : src/legacy-api
47- clean : true
48- # Filter services to only include user-related endpoints
49- filter-services :
50- - ' /users/**'
65+ output-dir : src/payments-api
66+ service-name-base : tags
5167
52-
53- # Event API (AsyncAPI)
54- events :
55- root : ./events-asyncapi.yaml
68+ # AsyncAPI entry
69+ hermes :
70+ root : ./asyncapi-hermes.yaml
5671 x-asyncapi-qraft :
57- plugin :
58- asyncapi-typescript : true
59- output-dir : src/events
60- clean : true
72+ output-dir : src/events/hermes
73+ asyncapi-types-file-name : schema.ts
6174` ` `
6275
6376### Generating from Redocly Configuration
@@ -168,6 +181,31 @@ apis:
168181 QraftPredefinedParameterValue: '../type-overrides/predefined-parameter-value.js'
169182` ` `
170183
184+ You can keep AsyncAPI entries in the same config with their own mode-specific options :
185+
186+ ` ` ` yaml
187+ apis:
188+ wallet:
189+ root: ./openapi-wallet.json
190+ x-openapi-qraft:
191+ output-dir: src/api/wallet
192+ queryable-write-operations: true
193+ create-api-client-fn:
194+ createAPIClient:
195+ filename: create-api-client
196+ services: all
197+ callbacks:
198+ - useQuery
199+ - useMutation
200+
201+ hermes:
202+ root: ./asyncapi-hermes.yaml
203+ x-asyncapi-qraft:
204+ output-dir: src/api/hermes
205+ asyncapi-types-file-name: asyncapi.ts
206+ alphabetize: true
207+ ` ` `
208+
171209# ## Generating multiple API client functions {#generating-multiple-api-client-functions}
172210
173211Qraft allows you to generate multiple _create API client functions_ with different parameters using the `--create-api-client-fn`
0 commit comments