Skip to content

Commit bcb5f81

Browse files
committed
add overrides info to project structure page
1 parent 49fec7c commit bcb5f81

File tree

3 files changed

+73
-3
lines changed

3 files changed

+73
-3
lines changed

fern/products/api-def/pages/project-structure.mdx

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ fern/
1818
└─ spec-file.yml # API definition file
1919
```
2020

21+
You can optionally add an `overrides.yml` file to further customize your API definition.
22+
2123
### `fern.config.json file`
2224

2325
Every fern folder has a single `fern.config.json` file. This file stores the organization and
@@ -38,8 +40,9 @@ determinism.
3840
The `generators.yml` file includes information about where your API definition file is located. It also [configures the SDKs](/sdks/overview/github) you're generating for your API.
3941

4042
```yaml title="generators.yml"
41-
api:
42-
path: ./path/to/openapi.yml
43+
api:
44+
specs:
45+
- openapi: spec-file.yml
4346
```
4447
4548
### API definition file
@@ -48,6 +51,61 @@ api:
4851

4952
For the other specification formats ([OpenAPI](/api-definitions/openapi/overview), [AsyncAPI](/api-definitions/asyncapi/overview), [OpenRPC](/api-definitions/openrpc/overview), and [gRPC](/api-definitions/grpc/overview)), you'll have a single self-contained specification file.
5053

54+
### `overrides.yml` file (optional)
55+
56+
Beyond the core files, you can optionally customize your API definition using overrides. A separate `overrides.yml` file allows you to customize your API definition without modifying the original spec file. This is useful when:
57+
58+
* Your API specification is auto-generated from server code
59+
* You need different configurations for SDKs versus documentation
60+
61+
When you run `fern generate`, Fern combines your original API specification with the overrides file.
62+
63+
To use overrides, [create an `overrides.yml` file](/api-definitions/openapi/extensions/method-names) in the folder that contains your API definition:
64+
65+
```bash {6}
66+
fern/
67+
├─ fern.config.json
68+
├─ generators.yml
69+
└─ spec-folder/
70+
├─ spec-file.yml
71+
└─ overrides.yml
72+
```
73+
74+
Reference your overrides file in your `generators.yml`:
75+
76+
```yaml title="generators.yml"
77+
api:
78+
specs:
79+
- openapi: spec-file.yml
80+
overrides: ./overrides.yml
81+
```
82+
83+
<Accordion title="Separate overrides for SDKs and Docs">
84+
85+
For separate SDK and documentation configurations, you can use different override files in separate folders with their own `generators.yml` files. Both `generators.yml` files can be identical except for pointing to different override files.
86+
87+
```bash
88+
fern/
89+
├─ fern.config.json
90+
├─ generators.yml
91+
└─ apis/
92+
├─ docs/ # Documentation configuration
93+
│ ├─ generators.yml
94+
│ └─ docs-overrides.yml # Documentation-specific overrides
95+
├─ sdks/ # SDK configuration
96+
│ ├─ generators.yml
97+
│ └─ sdk-overrides.yml # SDK-specific overrides
98+
└─ openapi/
99+
└─ openapi.yml # Original API specification
100+
```
101+
102+
</Accordion>
103+
51104
## Multiple API definitions
52105

53106
<Markdown src="/snippets/multiple-apis.mdx" />
107+
108+
### Docs configuration
109+
110+
APIs in docs are specified by [setting the `api-name` property](/docs/api-references/generate-api-ref#include-more-than-one-api-reference).
111+

fern/products/sdks/github-setup.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ See the [`generators.yml` reference page](/sdks/reference/generators-yml) for co
7878

7979
For information on how to structure your API definition files, see [Project structure (API Definitions)](/api-definitions/overview/project-structure).
8080

81+
### Optional: `overrides.yml` file
82+
83+
You can optionally add an `overrides.yml` file to customize your API definition without modifying the original spec file. For more information, see [Project structure (API Definitions)](/api-definitions/overview/project-structure#overrides).
84+
8185
## Child repository structure
8286

8387
Each SDK has its own repository with the following structure:

fern/snippets/multiple-apis.mdx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,12 @@ fern/
1515
├─ generators.yml # Required: points to API spec
1616
└─ openapi/
1717
├─ openapi.yml # API Definition file
18-
```
18+
```
19+
20+
### SDK generation
21+
22+
To [specify the API for SDK generation](/cli-api-reference/cli-reference/commands#api) use the `--api` flag:
23+
24+
```bash
25+
fern generate --api public-api
26+
```

0 commit comments

Comments
 (0)