microsoft/kiota

Trailing slash in URL is dropped during generation

オープン

#4,291 opened on 2024/03/05

 (11 件のコメント) (1 件のリアクション) (0 人の担当者)C# (326 件のフォーク)auto 404
WIPhelp wantedtype:bug

Repository metrics

Stars
 (3,783 個のスター)
PR merge metrics
 (PR metrics pending)

説明

Hi there

Problem

We're working with an API which endpoints contain trailing slashes, for example {+baseUrl}/api/v1/app/{app_id}/msg/.

During the client generation, the trailing slash is dropped, and the generated client doesn't work as expected as all requests return a 404.

Repro

For reference, here's a link to the OpenAPI document used here: https://github.com/svix/svix-webhooks/blob/8d32e47e0484f5d0839bce364d8700d2c7457937/openapi.json#L7779

  1. Generate the .NET client
    kiota generate `
      --openapi https://raw.githubusercontent.com/svix/svix-webhooks/main/openapi.json `
      --output .\TrailingSlashDroppedIssue4291 `
      --language CSharp `
      --class-name SvixClient `
      --namespace-name SvixApiClient `
      --exclude-backward-compatible true `
      --serializer Microsoft.Kiota.Serialization.Json.JsonSerializationWriterFactory `
      --deserializer Microsoft.Kiota.Serialization.Json.JsonParseNodeFactory `
      --structured-mime-types application/json `
      --include-path '/api/v1/app/{app_id}/msg/#POST'
    
  2. See the missing trailing slashes in the constructor definitions in the TrailingSlashDroppedIssue4291\Api\V1\App\Item\Msg\MsgRequestBuilder.cs file
    public class MsgRequestBuilder : BaseRequestBuilder {
        public MsgRequestBuilder(Dictionary<string, object> pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/v1/app/{app_id}/msg{?with_content*}", pathParameters) {
        }
        public MsgRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/v1/app/{app_id}/msg{?with_content*}", rawUrl) {
        }
    }
    

Expected result

Kiota shouldn't manipulate paths defined in the OpenAPI document, or should provide an option to opt out of this behavior.

コントリビューターガイド