Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

### Fixed

- Always use uppercase HTTP verbs (#149)

## [0.17.2] - 2025-04-14

### Fixed
Expand Down
3 changes: 2 additions & 1 deletion TypeContractor/Templates/EndpointTemplateDto.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
namespace TypeContractor.Templates;
namespace TypeContractor.Templates;

public record EndpointTemplateDto(
string Name,
bool IsObsolete,
string ObsoleteReason,
string HttpMethod,
string HttpMethodUppercase,
string ReturnType,
string? UnwrappedReturnType,
bool EnumerableReturnType,
Expand Down
12 changes: 7 additions & 5 deletions TypeContractor/TypeScript/ApiClientWriter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using HandlebarsDotNet;
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;
using TypeContractor.Helpers;
Expand All @@ -13,17 +14,17 @@
private static readonly Encoding _utf8WithoutBom = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false);
private static readonly Dictionary<EndpointMethod, string> _httpMethods = new()
{
{ EndpointMethod.GET, "get" },
{ EndpointMethod.POST, "post" },
{ EndpointMethod.PUT, "put" },
{ EndpointMethod.PATCH, "patch" },
{ EndpointMethod.DELETE, "delete" },
{ EndpointMethod.GET, "GET" },
{ EndpointMethod.POST, "POST" },
{ EndpointMethod.PUT, "PUT" },
{ EndpointMethod.PATCH, "PATCH" },
{ EndpointMethod.DELETE, "DELETE" },
};

[GeneratedRegex(@"([^\$])\{([A-Za-z0-9]+)\}")]
private static partial Regex RouteParameterRegex();

public string Write(ApiClient apiClient, IEnumerable<OutputType> allTypes, TypeScriptConverter converter, bool buildZodSchema, HandlebarsTemplate<object, ApiClientTemplateDto> template, Casing casing)

Check warning on line 27 in TypeContractor/TypeScript/ApiClientWriter.cs

View workflow job for this annotation

GitHub Actions / build

Argument type 'HandlebarsTemplate<object, ApiClientTemplateDto>' is not CLS-compliant

Check warning on line 27 in TypeContractor/TypeScript/ApiClientWriter.cs

View workflow job for this annotation

GitHub Actions / build

Argument type 'HandlebarsTemplate<object, ApiClientTemplateDto>' is not CLS-compliant

Check warning on line 27 in TypeContractor/TypeScript/ApiClientWriter.cs

View workflow job for this annotation

GitHub Actions / build

Argument type 'HandlebarsTemplate<object, ApiClientTemplateDto>' is not CLS-compliant

Check warning on line 27 in TypeContractor/TypeScript/ApiClientWriter.cs

View workflow job for this annotation

GitHub Actions / build

Argument type 'HandlebarsTemplate<object, ApiClientTemplateDto>' is not CLS-compliant
{
var _builder = new StringBuilder();
ArgumentNullException.ThrowIfNull(apiClient);
Expand Down Expand Up @@ -116,6 +117,7 @@
endpoint.Name,
endpoint.Obsolete is not null,
endpoint.Obsolete?.Reason ?? "",
method.ToLower(CultureInfo.InvariantCulture),
method,
returnType,
endpoint.UnwrappedReturnType?.Name,
Expand Down