Skip to content

Commit

Permalink
Changed generator version numbers (#342)
Browse files Browse the repository at this point in the history
* Changed generator version numbers

* Use quiet mode off

* Trying github actions change

* Debug the check markdown links github action

* fix typos

* fix typos

* Apostrophe

* troubleshoot github action markdown files

* fix images

* Links updated

* fix image links

* doc revisions

* update jest tests

* prettier-ignore statements

* more prettier fixes

* /

* add file path to config for markdown links

* working on it

* update test

* prettier ignore

* check all markdown

* fix readme links

* fix links last time?

* remove /
  • Loading branch information
dannysheridan authored Jul 6, 2022
1 parent 58d7207 commit bde7779
Show file tree
Hide file tree
Showing 45 changed files with 1,168 additions and 271 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
# Danny trying this out! July 4, 2022

name: Check Markdown links

on: push

# prettier-ignore
jobs:
markdown-link-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
folder-path: "docs"
use-quiet-mode: "yes"
# config-file: "mlc_config.json"
- uses: actions/checkout@master
- uses: gaurav-nelson/github-action-markdown-link-check@v1
855 changes: 670 additions & 185 deletions .pnp.cjs

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 5 additions & 5 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Fern reads in your [Fern API Definition](#what-is-a-fern-api-definition), invokes remote [generators](#what-are-fern-generators), and creates clients, server stubs, and interactive documentation for your API.

- **Client libraries**: one generated SDK for each supported platform and language that's automatically published to a registry (e.g., npm, maven, pypi)!
- **Client libraries**: one generated SDK for each supported platform and language that's automatically published to a registry (e.g., NPM, Maven, PyPI)!

- **Servers**: get server stubs for your API so all you need to do is implement the server logic.

Expand All @@ -22,20 +22,20 @@ Write your [Fern API Definition](#what-is-a-fern-api-definition) before writing

### 2. Best-in-class code generation

Ferrari makes luxury sports cars. Fern generates kick-ass code. It is designed to optimize for high quality code generation. Generated code is **idiomatic** (i.e., it follows the convention of the language) and **strongly typed** (i.e., the types of variables and objects are explicitly specified).
Ferrari makes luxury sports cars. Fern generates kick-ass code. It is designed to optimize for high-quality code generation. Generated code is **idiomatic** (i.e., it follows the convention of the language) and **strongly typed** (i.e., the types of variables and objects are explicitly specified).

### 3. Iterate faster

With an API definition, development projects that involve multiple engineers/teams (e.g., backend, web, mobile) can proceed much faster. Frontend teams can immediately start building components regardless of whether or not the backend is ready.

## What is a Fern API Definition?

A [**Fern API Definition**](definition.md) is a set of YAML files that describe your API.
A [**Fern API Definition**](markdown_files/definition.md#what-is-a-fern-api-definition) is a set of YAML files that describe your API.

## What are Fern Generators?

[**Generators**](generators.md) convert a Fern API Definition into clients, servers, and documentation.
[**Generators**](markdown_files/generators.md) convert a Fern API Definition into clients, servers, and documentation.

## How is this different than OpenAPI?

Fern is optimized for [kick-ass codegen](faq.md#1-how-is-fern-different-than-openapi-fka-swagger).
Fern is optimized for [kick-ass codegen](markdown_files/faq.md#_1-how-is-fern-different-than-openapi-fka-swagger).
17 changes: 6 additions & 11 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,15 @@

- Getting started

- [Tutorial: IMDb](imdb.md)
- [CLI](cli.md)
- [Tutorial: IMDb](markdown_files/imdb.md)
- [CLI](markdown_files/cli.md)

- Concepts

- [Fern API Definition](definition.md)
- [Generators](generators.md)
- [Types](types.md)
- [Services](services.md)
- [Errors](errors.md)
- [IDs](ids.md)
- [Imports](imports.md)
- [Fern API Definition](markdown_files/definition.md)
- [Generators](markdown_files/generators.md)

- Reference

- [FAQs](faq.md)
p
- [FAQs](markdown_files/faq.md)
- [Join the Discord](https://discord.gg/JkkXumPzcG)
Binary file removed docs/assets/postman-testing.png
Binary file not shown.
Binary file removed docs/assets/server.ts error message.png
Binary file not shown.
21 changes: 0 additions & 21 deletions docs/faq.md

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions docs/markdown_files/faq.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Frequently Asked Questions

## 1. How is Fern different than OpenAPI (f.k.a Swagger)?

- **Higher-quality code generation**: Fern is more restrictive in what you can model, enabling idiomatic, easy-to-use code generation.

- **Protocol agnostic**: Fern lets you define RESTful services alongside WebSocket subscriptions.

- **Ease of use**: Fern runs code generators remotely and manages publishing packages to registries (e.g., NPM, Maven, PyPI). You get a dependency that you can start using right away.

## 2. How does remote code generation work?

Code generators run remotely in the cloud. They take a set of Fern API Definition YAML files, run the generators listed in `.fernrc.yml, and produce generated files as an output. Files can output locally (i.e., seen in the file system of your IDE) or remotely (i.e., in a package manager like NPM, Maven, or PyPI).

### Generating clients

![client generators](../assets/diagrams/frontend-diagram.png)

### Generating servers

![server generators](../assets/diagrams/backend-diagram.png)
File renamed without changes.
File renamed without changes.
4 changes: 1 addition & 3 deletions docs/generators.md → docs/markdown_files/generators.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
## Fern Generators

Generators
# Fern Generators

| **Name** | **Description** | **CLI Command** | **Library** |
| :--------: | :------------------------------------------------------------------------------------------: | :-----------------: | :------------------------------------------------------------------------------------------------: |
Expand Down
5 changes: 2 additions & 3 deletions docs/ids.md → docs/markdown_files/ids.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ ids:
type: integer
```
## Key benefit of IDs
## The key benefit of IDs
Without IDs, developers can accidentally send a string/number of the wrong ID to an endpoint and the compiler doesn't know the difference. This can lead to bugs in production.
With branded types `MovieId` is defined as:
With branded types, `MovieId` is defined as:

```typescript
export type MovieId = string & { __MovieId: void };
Expand Down
49 changes: 25 additions & 24 deletions docs/imdb.md → docs/markdown_files/imdb.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Create a new folder for this tutorial and `cd` into it. Let's create a new npm p

```bash
npm init -y
npm install typescript ts-node express @types/express
npm install typescript express @types/express ts-node
```

This will set us up for a new TypeScript backend repo. We'll also install fern:
Expand Down Expand Up @@ -52,11 +52,10 @@ fern.config.json

</details>

## Step 3: Add generators
## Step 3: Add TypeScript generator

```bash
fern add typescript
fern add postman
```

<br>
Expand All @@ -71,37 +70,28 @@ fern add postman
-generators: []
+generators:
+ - name: fernapi/fern-typescript
+ version: 0.0.101
+ version: x.x.xxx
+ generate: true
+ config:
+ mode: server
+ - name: fernapi/fern-postman
+ version: 0.0.6
+ generate:
+ enabled: true
+ output: ./generated-postman.json
```

</details>

## Step 4: Run generators

```bash
fern generate
```
## Step 4: Run the generator

In terminal, you'll see `Published @imdb-fern/api-server@x.x.x` which we'll add as a dependency.
In the terminal, you'll see `Published @imdb-fern/imdb-api-server@x.x.x` which we'll add as a dependency. By default, Fern publishes dependencies to a private registry.

```bash
# Teach npm about the Fern private registry
npm config set --location project @imdb-fern:registry https://npm-dev.buildwithfern.com/

npm install @imdb-fern/api-server@x.x.x
```

In your files, you'll also see a `generated-postman.json` that we'll import to Postman later.

## Step 5: Implement the server

We'll create a new file `server.ts` in the root of our project. This will be a simple express server that servers our IMDb API.
We'll create a new file `server.ts` at the root of our project. This will be a simple express server that serves our IMDb API.

```ts
// server.ts
Expand All @@ -117,13 +107,13 @@ app.use(
})
);

console.log("Listening on port 8080!");
console.log("Listening for requests...");
app.listen(8080);
```

Our IDE will give us red lines indicating that we need to add missing properties.

![server.ts error message](assets/tutorial/server.ts%20error%20message.png)
![server.ts error message](../assets/tutorial/server.ts%20error%20message.png)

You can implement the missing methods, for example:

Expand All @@ -149,23 +139,34 @@ You can implement the missing methods, for example:
+ }
}))

console.log("Listening on port 8080!");
console.log("Listening for requests...");
app.listen(8080);
```

## Step 6: Run the server

```bash
./node_modules/.bin/ts-node server.ts
npx ts-node server.ts
```

In the terminal, you should see `Listening for requests...`

## Step 6: Add the Postman generator

```bash
fern add postman
fern generate
```

In the `api/` folder you'll see `collection.json` that we'll import to Postman.

## Step 7: Hit the server from Postman

Open Postman and File -> Import `api/generated-postman.json` that we generated in Step 4.
Open Postman and File -> Import `api/generated-postman/collection.json`.

Select the `createMovie` endpoint and hit `Send`. You should get a response back from your server **`iron-man-3`**.

![postman-testing](assets/tutorial/postman-testing.png)
![postman-testing](../assets/tutorial/postman-testing.png)

## Step 8: Celebrate

Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions docs/services.md → docs/markdown_files/services.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Defining a service

This page is about defining a REST service, which communciates over HTTP.
This page is about defining a REST service, which communicates over HTTP.

_If you're interested in defining a realtime API (e.g. over WebSocket), you'll likely want to [define a channel](channels.md) instead._
_If you're interested in \_defining a \_real-time_ API (_e.g. over WebSocket), you'll likely want to [define a channel](channels.md) instead._

A service consists of **endpoints**. Each endpoint has a path and an associated HTTP method (e.g. `GET`, `POST`).

## Requests and responses

Endpoints can optionally provided requests and responses, which are used as the HTTP message body.
Endpoints can optionally provide requests and responses, which are used as the HTTP message body.

```diff-yaml diff-highlight
types:
Expand Down Expand Up @@ -124,7 +124,7 @@ Every endpoint can specify [errors](errors.md) - i.e. responses that indicate th

## Authentication

Services require authentication. Currently, Fern only supports bearer tokens using the via the `Authorization` header.
Services require authentication. Currently, Fern only supports bearer tokens using the `Authorization` header.

```diff-yaml diff-highlight
types:
Expand Down
File renamed without changes.
Empty file removed mlc_config.json
Empty file.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"husky": "^7.0.4",
"immer": "^9.0.15",
"is-ci": "^3.0.1",
"jest": "^28.1.1",
"jest": "^28.1.2",
"lint-staged": "^12.3.7",
"lodash": "^4.17.21",
"mrlint": "^0.0.36",
Expand Down
4 changes: 2 additions & 2 deletions packages/add-generator/src/addGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { GeneratorInvocationSchema, WorkspaceDefinitionSchema } from "@fern-api/

const JAVA_GENERATOR_INVOCATION: GeneratorInvocationSchema = {
name: "fernapi/fern-java",
version: "0.0.45",
version: "0.0.55",
generate: true,
config: {
packagePrefix: "com",
Expand All @@ -12,7 +12,7 @@ const JAVA_GENERATOR_INVOCATION: GeneratorInvocationSchema = {

const TYPESCRIPT_GENERATOR_INVOCATION: GeneratorInvocationSchema = {
name: "fernapi/fern-typescript",
version: "0.0.117",
version: "0.0.123",
generate: true,
config: {
mode: "server",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ exports[`fern add 1`] = `
definition: src
generators:
- name: fernapi/fern-java
version: 0.0.45
version: 0.0.55
generate: true
config:
packagePrefix: com
mode: client_and_server
- name: fernapi/fern-typescript
version: 0.0.117
version: 0.0.123
generate: true
config:
mode: server
Expand Down
Loading

0 comments on commit bde7779

Please sign in to comment.