Skip to content

Commit

Permalink
Merge branch 'main' into revert-5220-revert-5196-chdeskur/sdk-restruc…
Browse files Browse the repository at this point in the history
…ture
  • Loading branch information
dannysheridan authored Nov 21, 2024
2 parents 7962791 + cf894f0 commit 60e1c01
Show file tree
Hide file tree
Showing 2,688 changed files with 118,607 additions and 31,492 deletions.
15 changes: 14 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
@coderabbitai summary
## Description
<!-- Provide a clear and concise description of the changes made in this PR -->

## Changes Made
<!-- List the main changes and updates implemented in this PR -->
-
-
-

## Testing
<!-- Describe how you tested these changes -->
- [ ] Unit tests added/updated
- [ ] Manual testing completed

Binary file removed .package.json.swp
Binary file not shown.
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
33 changes: 33 additions & 0 deletions fern.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1874,6 +1874,19 @@
}
]
},
"path-parameters": {
"oneOf": [
{
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/service.HttpPathParameterSchema"
}
},
{
"type": "null"
}
]
},
"query-parameters": {
"oneOf": [
{
Expand Down Expand Up @@ -2656,6 +2669,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
5 changes: 4 additions & 1 deletion 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 All @@ -72,6 +74,7 @@ types:
- commons.WithDocsSchema
properties:
content-type: optional<string>
path-parameters: optional<map<string, HttpPathParameterSchema>>
query-parameters: optional<map<string, HttpQueryParameterSchema>>
headers: optional<map<string, HttpHeaderSchema>>
body: optional<HttpRequestBodySchema>
Expand Down Expand Up @@ -189,4 +192,4 @@ types:
extends:
- commons.WithDocsSchema
properties:
error: string
error: string
6 changes: 6 additions & 0 deletions fern/apis/generators-yml/definition/generators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ types:
only-include-referenced-schemas:
type: optional<boolean>
docs: Whether to only include schemas referenced by endpoints in the generated SDK (i.e. a form of tree-shaking). Defaults to false.
inline-path-parameters:
type: optional<boolean>
docs: Whether to include path parameters within the generated in-lined request. Defaults to false.

UnionSettingsSchema:
enum:
Expand Down Expand Up @@ -228,6 +231,9 @@ types:
only-include-referenced-schemas:
type: optional<boolean>
docs: Whether to only include schemas referenced by endpoints in the generated SDK (i.e. a form of tree-shaking). Defaults to false.
inline-path-parameters:
type: optional<boolean>
docs: Whether to include path parameters within the generated in-lined request. Defaults to false.

OpenAPISpecSchema:
properties:
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:
...
```
4 changes: 4 additions & 0 deletions fern/pages/changelogs/cli/2024-11-20.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 0.45.0-rc49
**`(fix):`** Add 'list' to reserved keywords for use in PHP generator.


4 changes: 4 additions & 0 deletions fern/pages/changelogs/cli/2024-11-21.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 0.45.0-rc50
**`(fix):`** Increase max recursive depth allowed for example validation.


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.


4 changes: 4 additions & 0 deletions fern/pages/changelogs/csharp-sdk/2024-11-20.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 1.9.10
**`(feat):`** Add partial `JsonOptions.ConfigureJsonSerializerOptions` method to allow SDK maintainers to configure the `JsonSerializerOptions` used by the SDK.


3 changes: 3 additions & 0 deletions fern/pages/changelogs/go-sdk/2024-11-20.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 0.32.1
**`(internal):`** Improve the aesthetics of the generated code, and reduce the amount of repetition in each of the generated endpoints. This change has zero impact on the behavior of the generated SDK.

9 changes: 9 additions & 0 deletions fern/pages/changelogs/go-sdk/2024-11-21.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## 0.33.0
**`(feat):`** Add support for the `inlinePathParameters` configuration option, which generates path parameters in the generated request type (if any) instead of as separate positional parameters.
```yaml # generators.yml
- name: fern-api/fern-go-sdk
version: 0.33.0
config:
inlinePathParameters: true
```
3 changes: 3 additions & 0 deletions fern/pages/changelogs/php-sdk/2024-11-20.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 0.2.1
**`(fix):`** Override escaped method names in the generated client.

4 changes: 4 additions & 0 deletions fern/pages/changelogs/python-sdk/2024-11-19.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 4.3.7
**`(fix):`** Update multipart endpoint generation to propertly omit optional body parameters.


4 changes: 4 additions & 0 deletions fern/pages/changelogs/python-sdk/2024-11-20.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 4.3.8
**`(fix):`** Include content-type headers when available as part of endpoint request generation.


9 changes: 5 additions & 4 deletions fern/pages/sdks/publish-sdk/publish-your-sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,12 @@ This guide will walk you through how to publish public-facing SDKs through Fern.
```
</CodeBlocks>

### Configure `GitHub` location

<Warning>
To configure the Github integration you must (1) **create a Github repository** and (2) **install the [Fern GitHub App](https://github.com/apps/fern-api)**.
</Warning>
### Install GitHub app

To configure the Github integration you must (1) **create a Github repository** and (2) **install the [Fern GitHub App](https://github.com/apps/fern-api)**.

### Configure `GitHub` location

Once you've created the Github repository you must add it to your `generators.yml`:

Expand Down
30 changes: 30 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 Expand Up @@ -643,6 +653,16 @@
"type": "null"
}
]
},
"inline-path-parameters": {
"oneOf": [
{
"type": "boolean"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false
Expand Down Expand Up @@ -1314,6 +1334,16 @@
"type": "null"
}
]
},
"inline-path-parameters": {
"oneOf": [
{
"type": "boolean"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false
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.Template.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"
]
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@

namespace <%= namespace%>;

internal static class JsonOptions
internal static partial class JsonOptions
{
public static readonly JsonSerializerOptions JsonSerializerOptions;

static JsonOptions()
{
JsonSerializerOptions = new JsonSerializerOptions
var options = new JsonSerializerOptions
{
Converters = { new DateTimeSerializer(), new OneOfSerializer() },
WriteIndented = true,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
};
ConfigureJsonSerializerOptions(options);
JsonSerializerOptions = options;
}

static partial void ConfigureJsonSerializerOptions(JsonSerializerOptions defaultOptions);
}

internal static class JsonUtils
Expand Down
Loading

0 comments on commit 60e1c01

Please sign in to comment.