Skip to content

Trailing slash in URL is dropped during generation #4291

Open
@mderriey

Description

@mderriey

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    WIPhelp wantedIssue caused by core project dependency modules or librarytype:bugA broken experience

    Type

    No type

    Projects

    Status

    In Progress 🚧

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions