-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ceb311d
Showing
14 changed files
with
559 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: fern | ||
|
||
on: pull_request | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "18" | ||
|
||
- name: Install Fern | ||
run: npm install -g fern-api | ||
|
||
- name: Validate API configuration | ||
run: fern check | ||
|
||
preview-docs: | ||
needs: check | ||
runs-on: ubuntu-latest | ||
permissions: write-all | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "18" | ||
|
||
- name: Install Fern | ||
run: npm install -g fern-api | ||
|
||
- name: Generate preview URL | ||
id: generate-docs | ||
env: | ||
FERN_TOKEN: ${{ secrets.FERN_TOKEN }} | ||
run: | | ||
OUTPUT="$(fern generate --docs --preview)" | ||
echo "Command Output: $OUTPUT" | ||
URL=$(echo "$OUTPUT" | grep -oP 'Published docs to \K.*(?= \()') | ||
echo "Preview your docs: $URL" > preview_url.txt | ||
- name: Comment URL in PR | ||
uses: thollander/[email protected] | ||
with: | ||
filePath: preview_url.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: fern | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "18" | ||
|
||
- name: Install Fern | ||
run: npm install -g fern-api | ||
|
||
- name: Validate API configuration | ||
run: fern check | ||
|
||
publish-docs: | ||
needs: fern-check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "18" | ||
|
||
- name: Install Fern | ||
run: npm install -g fern-api | ||
|
||
- name: Publish Docs | ||
env: | ||
FERN_TOKEN: ${{ secrets.FERN_TOKEN }} | ||
run: fern generate --docs --log-level debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
<br/> | ||
<div align="center"> | ||
<a href="https://www.buildwithfern.com/?utm_source=github&utm_medium=readme&utm_campaign=docs-starter&utm_content=logo"> | ||
<img src="/fern/docs/assets/logo_light_mode.png" height="50" align="center" alt="header" /> | ||
</a> | ||
|
||
<br/> | ||
|
||
# Docs Starter | ||
|
||
Create beautiful documentation in under 5 minutes. Here's [an example!](https://your-organization.docs.buildwithfern.com) | ||
|
||
[![Discord](https://img.shields.io/badge/Join%20Our%20Community-black?logo=discord)](https://discord.com/invite/JkkXumPzcG) | ||
|
||
</div> | ||
|
||
--- | ||
|
||
## Customer Showcase | ||
|
||
Your docs can look this good: | ||
|
||
- [Flatfile's API Reference](https://reference.flatfile.com/api-reference/events/create-an-event) | ||
- [Sugeragent's Docs](https://docs.superagent.sh/) | ||
- [Credal's Docs](https://docs.credal.ai/) | ||
|
||
--- | ||
|
||
## Let's Get Started | ||
|
||
### Step 1: Use This Template | ||
|
||
1. Click on the "Use this template" button. | ||
2. Create a new repository. Name it anything you like, `docs` is a common naming choice. | ||
|
||
### Step 2: Open in Your Preferred IDE | ||
|
||
Clone your newly created repository and open it in your favorite integrated development environment (IDE) or code editor. | ||
|
||
### Step 3: Customize Organization Name | ||
|
||
In the fern.config.json file, replace the placeholder organization name with your actual organization name. For example: | ||
|
||
```json | ||
{ | ||
"organization": "YourOrganization", | ||
"version": "0.16.25" | ||
} | ||
``` | ||
|
||
Also, in the docs.yml file, update the docs URL to match your organization's naming convention. For example: | ||
|
||
```yml | ||
instances: | ||
- url: your-organization.docs.buildwithfern.com | ||
``` | ||
### Step 4: Generate Your Documentation | ||
1. Install the Fern CLI by running: | ||
```bash | ||
npm install -g fern-api | ||
``` | ||
|
||
1. Generate your documentation with the following command: | ||
|
||
```bash | ||
fern generate --docs | ||
``` | ||
|
||
You will be prompted to log in and connect your GitHub account. | ||
|
||
Once the documentation is generated, you will receive a URL where your documentation is published. For example: | ||
|
||
```shell | ||
┌─ | ||
│ ✓ your-organization.docs.buildwithfern.com | ||
└─ | ||
``` | ||
|
||
### Step 5: Choose an API definition format | ||
|
||
If you're using a [Fern Definition](https://docs.buildwithfern.com/api-definition/fern-definition/overview), you can edit the files within the [`definition`](/fern/definition/) folder. | ||
|
||
If you're using an [OpenAPI Specification](https://docs.buildwithfern.com/api-definition/openapi/extensions), then run the command: `fern generate`. You'll see a new folder created called `openapi` that contains your spec. You can edit this spec to make it your own OR copy and paste a spec you already have. Then, delete the `definition` folder. | ||
|
||
### Step 6: Customize Your Documentation | ||
|
||
Next, modify the markdown pages located in the [pages](fern/docs/pages/) directory. You can further tailor your documentation to match your brand by adjusting settings in the [docs.yml](fern/docs.yml) file. | ||
|
||
Fern has a built-in component library for you to use. [Explore the components.](https://docs.buildwithfern.com/generate-docs/component-library/) | ||
|
||
### Step 6: Set Up a Custom Domain | ||
|
||
If you wish to use a custom domain like `docs.your-organization.com` or a subdirectory like `your-organization.com/docs`, you can subscribe to the [Starter plan](https://buildwithfern.com/pricing). Once subscribed, update [docs.yml](fern/docs.yml) with the custom domain configuration: | ||
|
||
``` yaml | ||
- url: your-organization.docs.buildwithfern.com | ||
custom-domain: docs.your-organization.com | ||
``` | ||
### Step 7: Explore Advanced Features | ||
For advanced documentation features and options, visit the [Fern Docs](https://docs.buildwithfern.com/generate-docs). | ||
**Advanced features** include: | ||
- Versioning | ||
- Changelog | ||
- Multiple APIs | ||
- Custom background | ||
- Bring your own fonts | ||
Good luck creating beautiful and functional documentation! 🌿 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/fern-api/fern/main/fern.schema.json | ||
|
||
imports: | ||
movie: movie.yml | ||
|
||
service: | ||
auth: false | ||
base-path: /actors | ||
endpoints: | ||
listMovies: | ||
display-name: List Movies for an Actor | ||
docs: This endpoint will return a list of movies that Morgan Freeman (Actor ID `nm0000151`) has acted in. We'll list just 5 movies, because he's acted in over 153! | ||
method: GET | ||
path: /list-movies/{actorId} | ||
path-parameters: | ||
actorId: ActorId | ||
response: list<string> | ||
examples: | ||
- name: Morgan Freeman | ||
path-parameters: | ||
actorId: nm0000151 | ||
response: | ||
body: | ||
- "The Shawshank Redemption" | ||
- "The Power of One" | ||
- "Unforgiven" | ||
- "Outbreak" | ||
- "Se7en" | ||
|
||
types: | ||
ActorId: | ||
type: string | ||
docs: The unique identifier for an actor in the database | ||
|
||
errors: | ||
ActorDoesNotExistError: | ||
status-code: 404 | ||
type: ActorId |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
name: imdb-api | ||
error-discrimination: | ||
strategy: status-code | ||
auth: bearer | ||
environments: | ||
Sandbox: https://sandbox.example.com | ||
default-environment: Sandbox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/fern-api/fern/main/fern.schema.json | ||
|
||
service: | ||
auth: false | ||
base-path: /movies | ||
endpoints: | ||
create: | ||
docs: Add a movie to the database | ||
display-name: Create a Movie | ||
method: POST | ||
path: /create-movie | ||
request: CreateMovieRequest | ||
response: MovieId | ||
examples: | ||
- name: Shawshank Example | ||
request: | ||
title: The Shawshank Redemption | ||
rating: 9.3 | ||
response: | ||
body: tt0111161 | ||
|
||
get: | ||
docs: Retrieve a movie from the database based on the ID | ||
display-name: Get a Movie by ID | ||
method: GET | ||
path: /{id} | ||
path-parameters: | ||
id: MovieId | ||
response: Movie | ||
errors: | ||
- MovieDoesNotExistError | ||
examples: | ||
# Success response | ||
- path-parameters: | ||
id: tt9398640 | ||
response: | ||
body: | ||
id: tt9398640 | ||
title: "Between Two Ferns: The Movie" | ||
rating: 6.1 | ||
year: "2019" | ||
# Error response | ||
- path-parameters: | ||
id: tt1234 | ||
response: | ||
error: MovieDoesNotExistError | ||
body: tt1234 | ||
|
||
delete: | ||
display-name: Delete a Movie by ID | ||
method: DELETE | ||
path: /{id} | ||
path-parameters: | ||
id: MovieId | ||
examples: | ||
- path-parameters: | ||
id: tt2294629 | ||
errors: | ||
- MovieDoesNotExistError | ||
|
||
update: | ||
display-name: Update a Movie by ID | ||
method: PUT | ||
path: /{id} | ||
path-parameters: | ||
id: MovieId | ||
request: UpdateMovieRequest | ||
examples: | ||
- path-parameters: | ||
id: tt2294629 | ||
request: | ||
year: "2019" | ||
errors: | ||
- MovieDoesNotExistError | ||
types: | ||
MovieId: | ||
type: string | ||
docs: The unique identifier for a movie in the database | ||
|
||
Movie: | ||
properties: | ||
id: MovieId | ||
title: string | ||
rating: | ||
type: double | ||
docs: The rating scale out of ten stars | ||
year: string | ||
|
||
CreateMovieRequest: | ||
properties: | ||
title: string | ||
rating: double | ||
|
||
UpdateMovieRequest: | ||
properties: | ||
title: optional<string> | ||
rating: optional<double> | ||
year: optional<string> | ||
|
||
errors: | ||
MovieDoesNotExistError: | ||
status-code: 404 | ||
type: MovieId |
Oops, something went wrong.