Skip to content

Commit

Permalink
merge from main
Browse files Browse the repository at this point in the history
  • Loading branch information
Swimburger committed Dec 12, 2024
2 parents 73d2dad + 186588d commit 6ec6fa2
Show file tree
Hide file tree
Showing 1,132 changed files with 198 additions and 42,994 deletions.
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/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 ```

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 || |
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.");
}
});
}
3 changes: 3 additions & 0 deletions generators/go/internal/generator/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,9 @@ func (f *fileWriter) writePlatformHeaders(
f.P(fmt.Sprintf("headers.Set(%q, %q)", sdkConfig.PlatformHeaders.Language, goLanguageHeader))
f.P(fmt.Sprintf("headers.Set(%q, %q)", sdkConfig.PlatformHeaders.SdkName, moduleConfig.Path))
f.P(fmt.Sprintf("headers.Set(%q, %q)", sdkConfig.PlatformHeaders.SdkVersion, sdkVersion))
if sdkConfig.PlatformHeaders.UserAgent != nil {
f.P(fmt.Sprintf("headers.Set(%q, %q)", sdkConfig.PlatformHeaders.UserAgent.Header(), sdkConfig.PlatformHeaders.UserAgent.Value))
}
f.P("return headers")
f.P("}")
}
Expand Down
12 changes: 12 additions & 0 deletions generators/go/sdk/versions.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
- version: 0.34.0
changelogEntry:
- type: feat
summary: >-
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
```
irVersion: 53
- version: 0.33.0
changelogEntry:
- type: feat
Expand Down
5 changes: 5 additions & 0 deletions generators/python-v2/ast/src/PythonFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ export class PythonFile extends AstNode {
const usedNames = this.getInitialUsedNames();

references.forEach((reference) => {
// Skip star imports since we should never override their import alias
if (reference instanceof StarImport) {
return;
}

const name = reference.alias ?? reference.name;
const fullyQualifiedModulePath = reference.getFullyQualifiedModulePath();

Expand Down
7 changes: 5 additions & 2 deletions generators/python-v2/ast/src/__test__/PythonFile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,10 @@ describe("PythonFile", () => {
const file = python.file({
path: ["root"],
comments: [python.comment({ docs: "flake8: noqa: F401, F403" })],
imports: [python.starImport({ modulePath: ["root", "my_module"] })],
imports: [
python.starImport({ modulePath: ["root", "my_module_a"] }),
python.starImport({ modulePath: ["root", "my_module_b"] })
],
statements: [
python.field({
name: "my_id",
Expand All @@ -314,7 +317,7 @@ describe("PythonFile", () => {

file.write(writer);
expect(await writer.toStringFormatted()).toMatchSnapshot();
expect(file.getReferences()).toHaveLength(2);
expect(file.getReferences()).toHaveLength(3);
});

it("Write duplicative import names", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ exports[`PythonFile > Write star imports 1`] = `
"# flake8: noqa: F401, F403
from uuid import UUID
from .my_module import *
from .my_module_a import *
from .my_module_b import *
my_id = UUID("1234")
"
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

14 changes: 14 additions & 0 deletions packages/cli/cli/versions.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
- changelogEntry:
- summary: |
Add support for setting the `User-Agent` header value for Go generators.
type: fix
irVersion: 53
version: 0.46.1

- changelogEntry:
- summary: |
No changes; promote `0.46.0-rc1` release candidate to minor version.
type: internal
irVersion: 53
version: 0.46.0

- changelogEntry:
- summary: |
* Set `inline: true` for inline enums imported from OpenAPI.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ async function getGithubLicense({
});
}

// TODO: This is where we should add support for Go and PHP.
function getGithubPublishInfo(
output: generatorsYml.GeneratorOutputSchema,
maybeGroupLevelMetadata: OutputMetadata | undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ export function getPackageName({
}: {
generatorInvocation: GeneratorInvocation;
}): string | undefined {
if (generatorInvocation.language === "go") {
return getGoPackageName(generatorInvocation);
}
return generatorInvocation.outputMode._visit<string | undefined>({
downloadFiles: () => undefined,
github: (val) =>
Expand Down Expand Up @@ -164,3 +167,18 @@ export function getPackageName({
_other: () => undefined
});
}

/**
* Go doesn't use a central package manager; the Go Module Proxy simply uses the name
* of the GitHub repository.
*/
function getGoPackageName(generatorInvocation: GeneratorInvocation): string | undefined {
return generatorInvocation.outputMode._visit<string | undefined>({
downloadFiles: () => undefined,
github: (val) => `github.com/${val.owner}/${val.repo}`,
githubV2: (val) => `github.com/${val.owner}/${val.repo}`,
publish: () => undefined,
publishV2: () => undefined,
_other: () => undefined
});
}

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 6ec6fa2

Please sign in to comment.