All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
-
Feature: Add the
base-api-exception-class-name
andbase-exception-class-name
generator configuration. These control the class names of the genratedApiException
andException
class names (e.g.AcmeApiException
andAcmeException
).The configuration looks like the following:
- name: fernapi/fern-csharp-sdk version: 0.9.0 config: base-api-exception-class-name: AcmeApiException base-exception-class-name: AcmeException
- Feature: Support text response types.
- Feature: Support inheritance for inlined request bodies.
- Improvement: We now generate Exception types for all errors that are defined in the IR. Generated clients with an
error discrimination strategy of "status code" will throw one of these typed Exceptions based on the status code of
error responses. Example error type:
public sealed class UnauthorizedRequest(UnauthorizedRequestErrorBody body) : MyCompanyApiException("UnauthorizedRequest", 401, body) { public new UnauthorizedRequestErrorBody Body { get; } = body; }
-
Feature: Add support for
RequestOptions
. Users can now specify a variety of request-specific option overrides like the following:var user = client.GetUserAsync( new GetUserRequest { Username = "john.doe" }, new RequestOptions { BaseUrl = "https://localhost:3000" }).Result;
- Feature: Add support for
uint
,ulong
, andfloat
types. - Internal: Bump to IRv53.
-
Feature: Add support for
allow-multiple
query parameters, which are sent in theexplode
format. Given that optional lists are assigned a default, empty list, we use a simpleLINQ
expression to handle the serialization, which is shown below:_query["operand"] = request .Operand.Select(_value => JsonSerializer.Serialize(_value)) .ToList();
-
Improvement:
map<string, unknown>
types are now generated asDictionary<string, object?>
types so they can support explicitnull
values. Note that this does not affect everyunknown
type to be anobject?
since it would otherwise alter its required/optional characteristics.
- Improvement: Make datetime deserialization more lenient, and include milliseconds in datetime serialization.
- Improvement: Types are now generated with
set
accessors rather thaninit
accessors to improve flexibility of object construction.
-
Improvement: The C# generator now supports configuration to match namespaces directly to the full path of a file. This can lead to more imports being required to use the SDK, but can be helpful to avoid collisions.
- name: fernapi/fern-csharp-sdk version: 0.3.2 config: explicit-namespaces: true
- Improvement: Add header suppliers to
RawClient
constructor parameters.
- Break: Convert all usages
Guid
to bestring
since theGuid
class changes the underlying casing.
- Fix: MultURL environment classes now compile, previously there was a fix that broke compilation.
-
Break: The
Environments.cs
class is now renamed to be{OrgName}Environment
. For example, if your org name was Imdb then the environment class would beImdbEnvironment
. -
Feature: If the SDK has endpoints that each hit different URLs then the following class is generated.
public record AWSEnvironment { public static AWSEnvironment Production = new AWSEnvironment() { S3 = "https://s3.awsamazon.com", EC2 = "https://ec2.awsamazon.com" }; public static AWSEnvironment Staging = new AWSEnvironment() { S3 = "https://staging.s3.awsamazon.com", EC2 = "https://stagng.ec2.awsamazon.com" }; public required string S3 { get; init; } public required string EC2 { get; init; } }
- Improvement: More improvements to datetime serialization.
- Fix: Fixed a bug with serializing datetimes.
- Improvement: Stop generating empty serialization unit test files when there are no examples.
- Chore: Bump IR to 51.
- Feature: Generate serialization unit tests for models, as well as GH workflow to run them. These tests do not include instantiated object equality assertions, which should be included at a later time.
- Improvement: Enable generating unions with up to 32 types by adding the OneOf.Extended package.
- Fix: The generator now handles double optional fields properly and only adds a single
?
to the type.
- Feature: Add targets of .NET Standard 2.0 and .NET Framework 4.6.2.
- Fix: The generated
StringEnumSerializer
now avoids duplicate key errors. - Fix: Fixed a bug where generating root client requests causes generation to fail.
- Fix: Fixed forgotten closed parentheses when getting values from the environment.
- Fix: Fixed a bug where literal header names were generated incorrectly (as safe names rather than wire names).
- Fix: Other small fixes.
- Improvement: Constructor parameters initialized to
null
are now typed as nullable. - Improvement: Other small improvements.
- Fix: Base client requests are now generated, whereas previously they were skipped.
- Fix: Base client methods are now implemented rather than being empty.
- Fix: All
Core
files are now generated to the correspondingCore
namespace.
-
Improvement: The C# generator now supports configuration to specify extra dependencies. Below is an example of the
generators.yml
configuration:- name: fernapi/fern-csharp-sdk version: 0.0.33 config: extra-dependencies: moq: "0.23.4"
- Fix: Enum values are JSON serialized before they are sent to the server. For example, if the json value of an enum.
- Fix: The underlying HTTP client safely joins endpoint path with base url.
- Fix: The SDK now supports making bytes requests with Content Type
application/octet-stream
. - Fix: The SDK now supports api wide path parameters and joining them safely in
RawClient.cs
.
- Fix: The generated SDK now respects service base paths. Previously they were omitted.
- Improvement: Query parameter and header parameters with optional datetimes are now ISO 8601 encoded before making a request.
-
Fix: Discriminated unions are generated as
object
. Eventually these will be more type safe, but that will require partnering with existing customers to understand what a better DX looks like. -
Improvement: Header parameters are no longer required in the constructor so that the user doesn't have to provide redundant information.
- Improvement: Query parameter and header parameters are now ISO 8601 encoded before making a request.
- Improvement: Only publish a
.NET 6
compatible SDK. There are larger code changes that need to be made to be.NET 4+
compatible.
- Improvement: Publish a
.NET 4
compatible SDK
- Fix: Array and List fields are now generated as
IEnumerable<>
. Additionally, if the item type is aOneOf
, then a new core class calledCollectionItemSerializer
is used to deserialize the values.
-
Fix: Enum serializer is now added to enum declarations instead of enum references. This means that using a
JsonSerializer.serialize(myEnum)
will also provide the correct value. -
Fix:
OneOf
serializer is now added as aCore
class. It uses reflection to scan all the generic classes and see if there is an opportunity to deserialize into that particular class.
-
Fix: Enum serializer hands reading + writing enum string values. There is now no need to pass in a custom JsonSerializer option but instead the custom serialization will automatically be invoked with any JSONSerializaer.
-
Fix: Non-success status code errors are thrown with the stringified response body.
- Fix: generated GitHub workflows now run on
dotnet-version
8.x.
-
Fix: enable
nullable
on all csharp files.# nullable enable
-
Fix: make project
.net6
,.net7
and.net8
compatible.<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
- Fix: Misc. fixes including
.csproj
indentation, settingX-Fern-SDK-Name
to the top level namespace, and passing through serializer options when serializing JSON messages.
-
Fix: Inlined requests that are strictly bodies should be JSON serializable. To achieve this these types of inlined requests now have JSON annotations.
public class SearchRequest { [JsonPropertyName("query")] // added public string Query { get; init; } }
- Fix: The SDK now adds a
JsonEnumMemberStringEnumConverter
which readsEnumMember(Value="...")
annotations on enum values and appropriately serializes them as strings.
-
Fix: If a LICENSE is specified, the generator now packages the license in the
.csproj
file.<ItemGroup> <None Include="..\..\LICENSE" Pack="true" PackagePath=""/> </ItemGroup>
-
Improvement: The C# generator now generates an
Environments.cs
file which contains URLs for the different environments. If a default environment is present, then theBaseURL
inClientOptions.cs
will be initialized to this value.class Environments { public static string PRODUCTION = "https://api.production.com"; public static string STAGING = "https://api.staging.com"; }
- Fix: The C# generator now generates a proper
.csproj
file with version, GitHub url, and a reference to the SDK README.
- Improvement: The generated SDK now publishes Github Actions to build and publish the generated package to Nuget.
- Fix: When an inlined request body is entirely made up of request body properties, then the entire request can be serialized as the request body. This case was previously being overlooked.
- Fix: There were several fixes merged including supporting arbitrary nested clients, query parameter serialization, propert naming for async methods, and properly formatted solution files.