Skip to content

Commit

Permalink
Merge branch 'main' into dsheridan/add-redirects-for-sdk-docs-ia
Browse files Browse the repository at this point in the history
  • Loading branch information
dannysheridan authored Nov 19, 2024
2 parents 8ab17ce + 339cc01 commit d8fa327
Show file tree
Hide file tree
Showing 108 changed files with 4,121 additions and 601 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"python.analysis.typeCheckingMode": "basic"
}
}
10 changes: 10 additions & 0 deletions api-yml.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,16 @@
}
]
},
"token-header": {
"oneOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"get-token": {
"$ref": "#/definitions/auth.OAuthGetTokenEndpointSchema"
},
Expand Down
20 changes: 20 additions & 0 deletions fern.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2656,6 +2656,26 @@
"type": "null"
}
]
},
"transport": {
"oneOf": [
{
"$ref": "#/definitions/service.ServiceTransport"
},
{
"type": "null"
}
]
},
"source": {
"oneOf": [
{
"$ref": "#/definitions/source.SourceSchema"
},
{
"type": "null"
}
]
}
},
"required": [
Expand Down
7 changes: 6 additions & 1 deletion fern/apis/fern-definition/definition/auth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ types:
scopes: optional<list<string>>
client-id-env: optional<string>
client-secret-env: optional<string>
token-prefix: optional<string>
token-prefix:
type: optional<string>
docs: Sets the token header value prefix. Defaults to 'Bearer'
token-header:
type: optional<string>
docs: Sets the token header key name. Defaults to 'Authorization'
get-token: OAuthGetTokenEndpointSchema
refresh-token: optional<OAuthRefreshTokenEndpointSchema>

Expand Down
2 changes: 2 additions & 0 deletions fern/apis/fern-definition/definition/service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ types:
errors: optional<ResponseErrorsSchema>
examples: optional<list<examples.ExampleEndpointCallSchema>>
pagination: optional<Pagination>
transport: optional<ServiceTransport>
source: optional<source.SourceSchema>

HttpMethodSchema:
enum:
Expand Down
18 changes: 17 additions & 1 deletion fern/pages/api-definition/fern-definition/auth.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,20 @@ If the `expires-in` property is set, the generated OAuth token provider will aut
Otherwise, it's assumed that the access token is valid indefinitely.

With this, all of the OAuth logic happens automatically in the generated SDKs. As long as you configure these settings, your
client will automatically retrieve an access token and refresh it as needed.
client will automatically retrieve an access token and refresh it as needed.

When using the docs playground, `token-header` and `token-prefix` can optionally be set to customize the header key name and
header value prefix, to match the expected format of the API auth scheme.

For example, the following would produce a header `Fern-Authorization: Fern-Bearer <token>`:

```yaml api.yml {5-6}
auth-schemes:
OAuthScheme:
scheme: oauth
type: client-credentials
token-header: Fern-Authorization
token-prefix: Fern-Bearer
get-token:
...
```
7 changes: 7 additions & 0 deletions fern/pages/changelogs/csharp-sdk/2024-11-19.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## 1.9.9
**`(feat):`** Add support for [Auto Pagination](https://buildwithfern.com/learn/sdks/features/auto-pagination).
When enabled, the endpoint methods will return a `Pager<T>` object that you can use to iterate over all items of an endpoint.
Additionally, you can use the `Pager<T>.AsPagesAsync` method to iterate over all pages of an endpoint.
The SDK will automatically make the necessary HTTP requests for you as you iterate over the items or the pages.


10 changes: 10 additions & 0 deletions generators-yml.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,16 @@
}
]
},
"token-header": {
"oneOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"get-token": {
"$ref": "#/definitions/fernDefinition.auth.OAuthGetTokenEndpointSchema"
},
Expand Down
74 changes: 44 additions & 30 deletions generators/csharp/codegen/src/AsIs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,47 @@ export const DATETIME_SERIALIZER_CLASS_NAME = "DateTimeSerializer";
export const CONSTANTS_CLASS_NAME = "Constants";
export const JSON_UTILS_CLASS_NAME = "JsonUtils";

export enum AsIsFiles {
GitIgnore = ".gitignore.Template",
CiYaml = "github-ci.yml",
CollectionItemSerializer = "CollectionItemSerializer.cs",
Constants = "Constants.cs",
DateTimeSerializer = "DateTimeSerializer.cs",
EnumConverter = "EnumConverter.Template.cs",
GrpcRequestOptions = "GrpcRequestOptions.Template.cs",
Headers = "Headers.Template.cs",
HeaderValue = "HeaderValue.Template.cs",
HttpMethodExtensions = "HttpMethodExtensions.cs",
JsonConfiguration = "JsonConfiguration.cs",
OneOfSerializer = "OneOfSerializer.cs",
RawClient = "RawClient.Template.cs",
RawClientTests = "RawClientTests.Template.cs",
RawGrpcClient = "RawGrpcClient.Template.cs",
EnumSerializer = "EnumSerializer.Template.cs",
EnumSerializerTests = "EnumSerializerTests.Template.cs",
StringEnum = "StringEnum.Template.cs",
StringEnumExtensions = "StringEnumExtensions.Template.cs",
StringEnumSerializer = "StringEnumSerializer.Template.cs",
StringEnumSerializerTests = "StringEnumSerializerTests.Template.cs",
TemplateCsProj = "Template.csproj",
TemplateTestCsProj = "Template.Test.csproj",
TemplateTestClientCs = "TemplateTestClient.cs",
UsingCs = "Using.cs",
Extensions = "Extensions.cs",
CustomProps = "Custom.props.Template",
TestCustomProps = "Test.Custom.props.Template"
}
export const AsIsFiles = {
CiYaml: "github-ci.yml",
CollectionItemSerializer: "CollectionItemSerializer.cs",
Constants: "Constants.cs",
CustomProps: "Custom.props.Template",
DateTimeSerializer: "DateTimeSerializer.cs",
EnumConverter: "EnumConverter.Template.cs",
EnumSerializer: "EnumSerializer.Template.cs",
Extensions: "Extensions.cs",
GitIgnore: ".gitignore.Template",
GrpcRequestOptions: "GrpcRequestOptions.Template.cs",
Headers: "Headers.Template.cs",
HeaderValue: "HeaderValue.Template.cs",
HttpMethodExtensions: "HttpMethodExtensions.cs",
JsonConfiguration: "JsonConfiguration.cs",
OneOfSerializer: "OneOfSerializer.cs",
Page: "Page.Template.cs",
Pager: "Pager.Template.cs",
RawClient: "RawClient.Template.cs",
RawGrpcClient: "RawGrpcClient.Template.cs",
StringEnum: "StringEnum.Template.cs",
StringEnumExtensions: "StringEnumExtensions.Template.cs",
StringEnumSerializer: "StringEnumSerializer.Template.cs",
TemplateCsProj: "Template.csproj",
UsingCs: "Using.cs",
Test: {
TestCustomProps: "test/Test.Custom.props.Template",
TemplateTestClientCs: "test/TemplateTestClient.cs",
TemplateTestCsProj: "test/Template.Test.csproj",
EnumSerializerTests: "test/EnumSerializerTests.Template.cs",
RawClientTests: "test/RawClientTests.Template.cs",
StringEnumSerializerTests: "test/StringEnumSerializerTests.Template.cs",
Pagination: [
"test/Pagination/GuidCursorTest.Template.cs",
"test/Pagination/HasNextPageOffsetTest.Template.cs",
"test/Pagination/IntOffsetTest.Template.cs",
"test/Pagination/LongOffsetTest.Template.cs",
"test/Pagination/NoRequestCursorTest.Template.cs",
"test/Pagination/NoRequestOffsetTest.Template.cs",
"test/Pagination/StepOffsetTest.Template.cs",
"test/Pagination/StringCursorTest.Template.cs"
]
}
};
19 changes: 19 additions & 0 deletions generators/csharp/codegen/src/asIs/Page.Template.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace <%= namespace%>;

/// <summary>
/// A single <see cref="Page{TItem}"/> of items from a request that may return
/// zero or more <see cref="Page{TItem}"/>s of items.
/// </summary>
/// <typeparam name="TItem">The type of items.</typeparam>
public class Page<TItem>
{
public Page(IReadOnlyList<TItem> items)
{
Items = items;
}

/// <summary>
/// Gets the items in this <see cref="Page{TItem}"/>.
/// </summary>
public IReadOnlyList<TItem> Items { get; }
}
Loading

0 comments on commit d8fa327

Please sign in to comment.