Skip to content

Commit

Permalink
Merge branch 'main' into sbelkadi/FER-3743
Browse files Browse the repository at this point in the history
  • Loading branch information
sbelkadi authored Dec 12, 2024
2 parents 7dff811 + 186588d commit ea8bc8f
Show file tree
Hide file tree
Showing 2,263 changed files with 32,757 additions and 54,279 deletions.
9 changes: 2 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,7 @@ module.exports = {
ignoreRestSiblings: true
}
],
"@typescript-eslint/no-namespace": [
"error",
{
allowDeclarations: true
}
],
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/explicit-module-boundary-types": [
"error",
{
Expand Down Expand Up @@ -129,7 +124,7 @@ module.exports = {
{
files: ['**/*.test.ts', '**/*.spec.ts'],
rules: {
'no-console': 'off'
'no-console': 'off'
}
}
]
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ Postman Collections, Server boilerplate, etc.). To add a generator run `fern add
| `fernapi/fern-ruby-sdk` | ![Ruby Generator Version](https://img.shields.io/docker/v/fernapi/fern-ruby-sdk) | [cli.ts](./generators/ruby/sdk/src/cli.ts) |
| `fernapi/fern-go-sdk` | ![Go Generator Version](https://img.shields.io/docker/v/fernapi/fern-go-sdk) | [main.go](./generators/go/cmd/fern-go-sdk/main.go) |
| `fernapi/fern-csharp-sdk` | ![C# Generator Version](https://img.shields.io/docker/v/fernapi/fern-csharp-sdk) | [cli.ts](./generators/csharp/sdk/src/cli.ts) |
| `fernapi/fern-php-sdk` | ![PHP Generator Version](https://img.shields.io/docker/v/fernapi/fern-php-sdk) | [cli.ts](./generators/php/sdk/src/cli.ts) |

### Server-side Generators

Expand Down
4 changes: 4 additions & 0 deletions fern/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ navigation:
icon: fa-regular fa-file
path: ./pages/api-definition/fern-definition/endpoints/multipart.mdx
slug: multipart
- page: Bytes
path: ./pages/api-definition/fern-definition/endpoints/bytes.mdx
icon: fa-regular fa-server
slug: bytes
- page: Server Sent Events
icon: fa-regular fa-signal-stream
path: ./pages/api-definition/fern-definition/endpoints/sse.mdx
Expand Down
55 changes: 55 additions & 0 deletions fern/pages/api-definition/fern-definition/endpoints/bytes.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title: Binary Data and Files
subtitle: Use the `bytes` type to handle binary data in your API
---

<Note>
The `bytes` type allows you to handle binary data in both requests and responses.
</Note>

## Sending bytes

If your API needs to send a stream of bytes (i.e. typical for assets like audio, images and other files) then
you can use the `bytes` type in the Fern Definition to model this.

```yml audio.yml
service:
base-path: /audio
endpoints:
upload:
display-name: Upload audio
method: POST
path: /upload
content-type: application/octet-stream
request:
type: bytes
docs: The bytes of the MP3 file that you would like to upload
```
## Receiving bytes
On the other hand, if your API is returning a stream of bytes, then you can leverage the `bytes` type as a response.

```yml textToSpeech.yml
service:
base-path: /tts
endpoints:
upload:
display-name: Upload audio
method: POST
path: ""
request:
name: TTSRequest
body:
properties:
text:
type: string
docs: The text that you want converted to speach.
response:
type: bytes
docs: The bytes of the audio file.
```




2 changes: 1 addition & 1 deletion fern/pages/changelogs/cli/2024-12-05.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 0.45.3
**`(fix):`** Unknown schemas are no longer incorrectly marked as `additionalProperties: true`.
**`(fix):`** Unknown schemas are no longer incorrectly marked as `additionalProperties: true`.


4 changes: 4 additions & 0 deletions fern/pages/changelogs/cli/2024-12-10.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 0.45.4-rc1
**`(chore):`** Unknown schemas are no longer incorrectly marked as `additionalProperties: true`.


4 changes: 4 additions & 0 deletions fern/pages/changelogs/cli/2024-12-11.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 0.45.4
**`(fix):`** Defaults are no longer set on datetimes when converting to docs shapes.


4 changes: 4 additions & 0 deletions fern/pages/changelogs/cli/2024-12-12.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 0.46.0
**`(internal):`** No changes; promote `0.46.0-rc1` release candidate to minor version.


4 changes: 4 additions & 0 deletions fern/pages/changelogs/go-sdk/2024-12-12.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 0.34.0
**`(feat):`** Add support for sending the `User-Agent` header on every request. Go packages are uniquely identified by their full module path, so the `User-Agent` header is generated in the `<module>/<version>` format, e.g.
``` User-Agent: github.com/acme/acme-go/1.0.0 ```

4 changes: 4 additions & 0 deletions fern/pages/changelogs/java-model/2024-12-10.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 1.3.0
**`(chore):`** Bump IR version to latest (v53)


5 changes: 5 additions & 0 deletions fern/pages/changelogs/java-sdk/2024-12-10.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## 2.4.0
**`(feat):`** We now support overriding sdk package prefixes by adding a "package-prefix" key under the java-sdk generator
configuration.


4 changes: 4 additions & 0 deletions fern/pages/changelogs/java-sdk/2024-12-11.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 2.7.0
**`(feat):`** Apply Content-Type header from endpoint definition in SDK generator.


4 changes: 4 additions & 0 deletions fern/pages/changelogs/java-spring/2024-12-10.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 1.3.0
**`(chore):`** Bump IR version to latest (v53)


2 changes: 1 addition & 1 deletion fern/pages/docs/building-your-docs/custom-css-js.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ check out the [Global Configuration](/learn/docs/getting-started/global-configur
Customize the behavior of your Docs site by injecting custom JavaScript globally. Add a `custom.js` file and include it in your `fern/` project:

<CodeBlock title="Add the styles.css file">
<CodeBlock title="Add the custom.js file">
```bash {5}
fern/
├─ openapi/
Expand Down
22 changes: 13 additions & 9 deletions fern/pages/sdks/comparison/speakeasy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ walk through the different capabilities of Fern and Speakeasy.

### 1. Fern is an all-in-one: SDKs + Docs

If you choose Speakeasy, you'll have to find a separate docs vendor such as ReadMe. With Fern, you'll be able to generate SDKs and
If you choose Speakeasy, you can integrate with third-party documentation providers or use its native Scalar integration. With Fern, you'll be able to generate SDKs and
Docs with embedded code snippets.

<Frame caption="API Docs with SDK code snippets (generated by Fern)">
Expand All @@ -21,8 +21,8 @@ Fern's SDKs are battle-tested and have been downloaded millions of times.

| Language | Fern | Speakeasy |
| ---------- | ------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------- |
| TypeScript | **93k** weekly downloads ([Cohere](https://www.npmjs.com/package/cohere-ai)) | **5k** weekly downloads ([Unstructured](https://www.npmjs.com/package/unstructured-client)) |
| Python | **5 million** lifetime downloads ([ElevenLabs](https://github.com/elevenlabs/elevenlabs-python)) | **194k** lifetime downloads ([Airbyte](https://github.com/airbytehq/airbyte-api-python-sdk)) |
| TypeScript | **120k** weekly downloads ([Cohere](https://www.npmjs.com/package/cohere-ai)) | **85k** weekly downloads ([Mistral AI](https://www.npmjs.com/package/@mistralai/mistralai)) |
| Python | **6 million** lifetime downloads ([ElevenLabs](https://pepy.tech/projects/ElevenLabs)) | **17 million** lifetime downloads ([Unstructured](https://pepy.tech/projects/unstructured-client)) |

### 3. Fern offers more Generally Available SDK languages.

Expand All @@ -33,7 +33,11 @@ Fern's SDKs are battle-tested and have been downloaded millions of times.
| Java |||
| Go |||
| C# |||
| PHP |||
| Terraform |||
| Ruby || ❌ (Alpha) |
| Unity || ❌ (Beta) |


### 4. Speakeasy generates Terraform providers.

Expand All @@ -49,7 +53,7 @@ is blocked if any failures are encountered.
<img src="./fern-tests.png" />
</Frame>

On the other hand, Speakeasy produces no tests in their SDKs ([example](https://github.com/airbytehq/airbyte-api-python-sdk)).
On the other hand, Speakeasy supports contract testing, server mocking, and API sequence testing to streamline development workflows. ([example](https://www.speakeasy.com/docs/testing)).

### 6. Fern supports OAuth + DPoP.

Expand All @@ -58,8 +62,8 @@ On the other hand, Speakeasy produces no tests in their SDKs ([example](https://
| `Bearer` |||
| `Basic` |||
| Custom Headers |||
| `OAuth` Client Credentials || 🏗️ Partial |
| `OAuth` Refresh || 🏗️ Partial |
| `OAuth` Client Credentials || |
| `OAuth` Refresh || |
| DPop (Proof of possession) |||

### 7. Fern's file structure is resource based.
Expand Down Expand Up @@ -91,6 +95,6 @@ behavior.

| Feature | Fern | Speakeasy |
| ---------------- | ---- | --------- |
| Auth Override || |
| Timeout Override || |
| Retry Override || |
| Auth Override || |
| Timeout Override || |
| Retry Override || |
2 changes: 2 additions & 0 deletions fern/pages/sdks/publish-sdk/publish-your-sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ This guide will walk you through how to publish public-facing SDKs through Fern.
```
</CodeBlocks>
Here are the [latest versions of each generator](https://github.com/fern-api/fern?tab=readme-ov-file#-generators).
### Configure `output` location

In order to setup publishing your SDK, you'll need to configure
Expand Down
29 changes: 0 additions & 29 deletions generators/browser-compatible-base/src/utils/getSdkVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,3 @@ export function getSdkVersion(config: FernGeneratorExec.GeneratorConfig): string
}
});
}

export function getPackageName(config: FernGeneratorExec.GeneratorConfig): string | undefined {
return config.output.mode._visit<string | undefined>({
publish: (gpc: FernGeneratorExec.GeneratorPublishConfig) =>
gpc.publishTarget?._visit({
maven: (mrc: FernGeneratorExec.MavenRegistryConfigV2) => mrc.coordinate,
npm: (nrc: FernGeneratorExec.NpmRegistryConfigV2) => nrc.packageName,
pypi: (prc: FernGeneratorExec.PypiRegistryConfig) => prc.packageName,
rubygems: (rgrc: FernGeneratorExec.RubyGemsRegistryConfig) => rgrc.packageName,
nuget: (nrc: FernGeneratorExec.NugetRegistryConfig) => nrc.packageName,
postman: () => undefined,
_other: () => undefined
}),
downloadFiles: () => undefined,
github: (gom: FernGeneratorExec.GithubOutputMode) =>
gom.publishInfo?._visit({
maven: (mrc: FernGeneratorExec.MavenGithubPublishInfo) => mrc.coordinate,
npm: (nrc: FernGeneratorExec.NpmGithubPublishInfo) => nrc.packageName,
pypi: (prc: FernGeneratorExec.PypiGithubPublishInfo) => prc.packageName,
rubygems: (rgrc: FernGeneratorExec.RubyGemsGithubPublishInfo) => rgrc.packageName,
nuget: (nrc: FernGeneratorExec.NugetGithubPublishInfo) => nrc.packageName,
postman: () => undefined,
_other: () => undefined
}),
_other: () => {
throw new Error("Unrecognized output mode.");
}
});
}
4 changes: 2 additions & 2 deletions generators/go-v2/ast/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
"@fern-api/browser-compatible-base-generator": "workspace:*",
"@fern-api/core-utils": "workspace:*",
"@fern-api/path-utils": "workspace:*",
"@fern-fern/ir-sdk": "^53.23.0",
"@fern-fern/ir-sdk": "^53.24.0",
"zod": "^3.22.3"
},
"devDependencies": {
"@fern-api/browser-compatible-base-generator": "workspace:*",
"@fern-api/core-utils": "workspace:*",
"@fern-api/path-utils": "workspace:*",
"@fern-fern/ir-sdk": "^53.23.0",
"@fern-fern/ir-sdk": "^53.24.0",
"@types/jest": "^29.5.12",
"depcheck": "^1.4.6",
"eslint": "^8.56.0",
Expand Down
61 changes: 48 additions & 13 deletions generators/go-v2/dynamic-snippets/build.cjs
Original file line number Diff line number Diff line change
@@ -1,30 +1,48 @@
const { NodeModulesPolyfillPlugin } = require('@esbuild-plugins/node-modules-polyfill');
const { NodeGlobalsPolyfillPlugin } = require('@esbuild-plugins/node-globals-polyfill');
const packageJson = require("./package.json");
const tsup = require('tsup');
const { writeFile, rename } = require("fs/promises");
const { writeFile, mkdir } = require("fs/promises");
const path = require("path");

main();

async function main() {
await tsup.build({
const config = {
entry: ['src/**/*.ts', '!src/__test__'],
format: ['cjs'],
clean: true,
target: "es2017",
minify: true,
dts: true,
outDir: 'dist',
target: "es2017",
external: [
// Test dependencies should not be included in the published package.
'@fern-api/go-formatter',
],
esbuildPlugins: [
NodeModulesPolyfillPlugin(),
NodeGlobalsPolyfillPlugin({
process: true,
buffer: true,
util: true
})
],
tsconfig: "./build.tsconfig.json"
};

await tsup.build({
...config,
format: ['cjs'],
outDir: 'dist/cjs',
clean: true,
});

process.chdir(path.join(__dirname, "dist"));
await tsup.build({
...config,
format: ['esm'],
outDir: 'dist/esm',
clean: false,
});

// The module expects the imports defined in the index.d.ts file.
await rename("index.d.cts", "index.d.ts");
await mkdir(path.join(__dirname, "dist"), { recursive: true });
process.chdir(path.join(__dirname, "dist"));

await writeFile(
"package.json",
Expand All @@ -33,9 +51,26 @@ async function main() {
name: packageJson.name,
version: process.argv[2] || packageJson.version,
repository: packageJson.repository,
main: "index.cjs",
types: "index.d.ts",
files: ["index.cjs", "index.d.ts"]
type: "module",
exports: {
// Conditional exports for ESM and CJS.
"import": {
"types": "./esm/index.d.ts",
"default": "./esm/index.js"
},
"require": {
"types": "./cjs/index.d.cts",
"default": "./cjs/index.cjs"
}
},
// Fallback for older tooling or direct imports.
main: "./cjs/index.cjs",
module: "./esm/index.js",
types: "./cjs/index.d.cts",
files: [
"cjs",
"esm"
]
},
undefined,
2
Expand Down
4 changes: 3 additions & 1 deletion generators/go-v2/dynamic-snippets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@
"dist": "pnpm compile && node build.cjs"
},
"devDependencies": {
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
"@fern-api/browser-compatible-base-generator": "workspace:*",
"@fern-api/core-utils": "workspace:*",
"@fern-api/fern-definition-schema": "workspace:*",
"@fern-api/go-ast": "workspace:*",
"@fern-api/go-formatter": "workspace:*",
"@fern-api/path-utils": "workspace:*",
"@fern-fern/ir-sdk": "^53.23.0",
"@fern-fern/ir-sdk": "^53.24.0",
"@types/jest": "^29.5.12",
"depcheck": "^1.4.6",
"eslint": "^8.56.0",
Expand Down
Loading

0 comments on commit ea8bc8f

Please sign in to comment.