Skip to content

Commit

Permalink
Merge branch 'main' into chdeskur/api-key-injection
Browse files Browse the repository at this point in the history
  • Loading branch information
dannysheridan authored Nov 4, 2024
2 parents 6373a24 + 0eeebdb commit 95d1e86
Show file tree
Hide file tree
Showing 1,131 changed files with 35,779 additions and 304 deletions.
3 changes: 3 additions & 0 deletions fern/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,9 @@ navigation:
- page: Write Markdown in API Reference
icon: fa-regular fa-pencil
path: ./pages/fern-docs/content/api-ref-content.mdx
- page: Customize API Playground
icon: fa-regular fa-square-terminal
path: ./pages/fern-docs/content/customize-api-playground.mdx

- section: Integrations
slug: integrations
Expand Down
85 changes: 1 addition & 84 deletions fern/pages/changelogs/csharp-sdk/2024-10-30.mdx
Original file line number Diff line number Diff line change
@@ -1,86 +1,3 @@
## 1.8.5

**`(feat):`** Add forward-compatible enums.
Set `experimental-enable-forward-compatible-enums` to `true` in the configuration to generate forward-compatible enums.

With forward-compatible enums you can create and parse an enum value that is not predefined.

- Forward compatible enums are not compatible with the previously generated native enums.
This is a breaking change for the users of the generated SDK, but only users using switch-case statements are affected.
- Use the `Value` property to get the string value of the enum.
- For each value in the enum,
- a public static property is generated, which is an instance of the enum class,
- a public static property is generated within the nested `Values` class with the string value of the enum.

Here's a before and after for creating and parsing a resource with a predefined enum value and a custom enum value:

**Before**:

```csharp
var resource = client.CreateResource(new Resource { Id = "2", EnumProperty = MyEnum.Value2 } );
// The line below does not compile because the enum does not have a `Value3` value.
// resource = client.CreateResource(new Resource { Id = "3", EnumProperty = MyEnum.Value3 } );
resource = client.GetResource("3");
switch(resource.EnumProperty)
{
case MyEnum.Value1:
Console.WriteLine("Value1");
break;
case MyEnum.Value2:
Console.WriteLine("Value2");
break;
default:
// this will never be reached until the SDK is updated with the new enum value
Console.WriteLine("Unknown");
break;
}
if(resource.EnumProperty == MyEnum.Value1)
{
Console.WriteLine("Value1");
}
else if (resource.EnumProperty == MyEnum.Value2)
{
Console.WriteLine("Value2");
}
else
{
// this will never be reached until the SDK is updated with the new enum value
Console.WriteLine("Unknown");
}
```

No exception is thrown, but the output incorrectly shows `Value1` because .NET falls back to the first value in the enum.

**After**:

```csharp
var resource = client.CreateResource(new Resource { Id = "2", EnumProperty = MyEnum.Value2 } );
resource = client.CreateResource(new Resource { Id = "3", EnumProperty = MyEnum.Custom("value3") } );
resource = client.GetResource("3");
switch(resource.EnumProperty.Value)
{
case MyEnum.Values.Value1:
Console.WriteLine("Value1");
break;
case MyEnum.Values.Value2:
Console.WriteLine("Value2");
break;
default:
Console.WriteLine(resource.EnumProperty.Value);
break;
}
if(resource.EnumProperty == MyEnum.Value1)
{
Console.WriteLine("Value1");
}
else if (resource.EnumProperty == MyEnum.Value2)
{
Console.WriteLine("Value2");
}
else
{
Console.WriteLine(resource.EnumProperty.Value);
}
```

The output correctly shows `Value3`.
**`(feat):`** Add forward compatible enums. Set `experimental-enable-forward-compatible-enums` to `true` in the configuration to generate forward compatible enums.
4 changes: 2 additions & 2 deletions fern/pages/fern-docs/content/customize-api-playground.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Advanced configuration
description: Configure advanced settings like the server URLs reachable by the API playground and authentication with OAuth.
title: Customize your API Playground
description: Customize your API Playground Settings
---

If you subscribe to Fern's Pro or Enterprise Plans, you can customize your API Playground settings to suit your customers needs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2888,14 +2888,61 @@ func do() {
exports[`test definitions > grpc-proto-exhaustive 1`] = `
"package example
import (
context "context"
client "github.com/acme/acme-go/client"
option "github.com/acme/acme-go/option"
)
func do() {
client := client.NewClient(
option.WithAPIKey(
"<value>",
),
)
client.Dataservice.Foo(
context.TODO(),
)
}
------------------------
package example
import (
context "context"
client "github.com/acme/acme-go/client"
option "github.com/acme/acme-go/option"
)
func do() {
client := client.NewClient(
option.WithAPIKey(
"<value>",
),
)
client.Dataservice.Foo(
context.TODO(),
)
}
------------------------
package example
import (
context "context"
acme "github.com/acme/acme-go"
client "github.com/acme/acme-go/client"
option "github.com/acme/acme-go/option"
)
func do() {
client := client.NewClient()
client := client.NewClient(
option.WithAPIKey(
"<value>",
),
)
client.Dataservice.Upload(
context.TODO(),
&acme.UploadRequest{
Expand All @@ -2919,10 +2966,15 @@ import (
context "context"
acme "github.com/acme/acme-go"
client "github.com/acme/acme-go/client"
option "github.com/acme/acme-go/option"
)
func do() {
client := client.NewClient()
client := client.NewClient(
option.WithAPIKey(
"<value>",
),
)
client.Dataservice.Upload(
context.TODO(),
&acme.UploadRequest{
Expand Down Expand Up @@ -2991,10 +3043,15 @@ import (
context "context"
acme "github.com/acme/acme-go"
client "github.com/acme/acme-go/client"
option "github.com/acme/acme-go/option"
)
func do() {
client := client.NewClient()
client := client.NewClient(
option.WithAPIKey(
"<value>",
),
)
client.Dataservice.Delete(
context.TODO(),
&acme.DeleteRequest{},
Expand All @@ -3009,10 +3066,15 @@ import (
context "context"
acme "github.com/acme/acme-go"
client "github.com/acme/acme-go/client"
option "github.com/acme/acme-go/option"
)
func do() {
client := client.NewClient()
client := client.NewClient(
option.WithAPIKey(
"<value>",
),
)
client.Dataservice.Delete(
context.TODO(),
&acme.DeleteRequest{
Expand Down Expand Up @@ -3045,10 +3107,15 @@ import (
context "context"
acme "github.com/acme/acme-go"
client "github.com/acme/acme-go/client"
option "github.com/acme/acme-go/option"
)
func do() {
client := client.NewClient()
client := client.NewClient(
option.WithAPIKey(
"<value>",
),
)
client.Dataservice.Describe(
context.TODO(),
&acme.DescribeRequest{},
Expand All @@ -3063,10 +3130,15 @@ import (
context "context"
acme "github.com/acme/acme-go"
client "github.com/acme/acme-go/client"
option "github.com/acme/acme-go/option"
)
func do() {
client := client.NewClient()
client := client.NewClient(
option.WithAPIKey(
"<value>",
),
)
client.Dataservice.Describe(
context.TODO(),
&acme.DescribeRequest{
Expand All @@ -3089,10 +3161,15 @@ import (
context "context"
acme "github.com/acme/acme-go"
client "github.com/acme/acme-go/client"
option "github.com/acme/acme-go/option"
)
func do() {
client := client.NewClient()
client := client.NewClient(
option.WithAPIKey(
"<value>",
),
)
client.Dataservice.Fetch(
context.TODO(),
&acme.FetchRequest{},
Expand All @@ -3107,10 +3184,15 @@ import (
context "context"
acme "github.com/acme/acme-go"
client "github.com/acme/acme-go/client"
option "github.com/acme/acme-go/option"
)
func do() {
client := client.NewClient()
client := client.NewClient(
option.WithAPIKey(
"<value>",
),
)
client.Dataservice.Fetch(
context.TODO(),
&acme.FetchRequest{
Expand All @@ -3134,10 +3216,15 @@ import (
context "context"
acme "github.com/acme/acme-go"
client "github.com/acme/acme-go/client"
option "github.com/acme/acme-go/option"
)
func do() {
client := client.NewClient()
client := client.NewClient(
option.WithAPIKey(
"<value>",
),
)
client.Dataservice.List(
context.TODO(),
&acme.ListRequest{},
Expand All @@ -3152,10 +3239,15 @@ import (
context "context"
acme "github.com/acme/acme-go"
client "github.com/acme/acme-go/client"
option "github.com/acme/acme-go/option"
)
func do() {
client := client.NewClient()
client := client.NewClient(
option.WithAPIKey(
"<value>",
),
)
client.Dataservice.List(
context.TODO(),
&acme.ListRequest{
Expand Down Expand Up @@ -3183,10 +3275,15 @@ import (
context "context"
acme "github.com/acme/acme-go"
client "github.com/acme/acme-go/client"
option "github.com/acme/acme-go/option"
)
func do() {
client := client.NewClient()
client := client.NewClient(
option.WithAPIKey(
"<value>",
),
)
client.Dataservice.Query(
context.TODO(),
&acme.QueryRequest{
Expand All @@ -3203,10 +3300,15 @@ import (
context "context"
acme "github.com/acme/acme-go"
client "github.com/acme/acme-go/client"
option "github.com/acme/acme-go/option"
)
func do() {
client := client.NewClient()
client := client.NewClient(
option.WithAPIKey(
"<value>",
),
)
client.Dataservice.Query(
context.TODO(),
&acme.QueryRequest{
Expand Down Expand Up @@ -3316,10 +3418,15 @@ import (
context "context"
acme "github.com/acme/acme-go"
client "github.com/acme/acme-go/client"
option "github.com/acme/acme-go/option"
)
func do() {
client := client.NewClient()
client := client.NewClient(
option.WithAPIKey(
"<value>",
),
)
client.Dataservice.Update(
context.TODO(),
&acme.UpdateRequest{
Expand All @@ -3336,10 +3443,15 @@ import (
context "context"
acme "github.com/acme/acme-go"
client "github.com/acme/acme-go/client"
option "github.com/acme/acme-go/option"
)
func do() {
client := client.NewClient()
client := client.NewClient(
option.WithAPIKey(
"<value>",
),
)
client.Dataservice.Update(
context.TODO(),
&acme.UpdateRequest{
Expand Down
Loading

0 comments on commit 95d1e86

Please sign in to comment.