Nswag client doesn't correctly generate Method for DELETE endpoint

16 Views Asked by At

This is the code generate by Nswag client for the Endpoint [http://localhost:5272/api/DbSupplier/{id}]. In this code I notice that id is not appended to url. So when it execute it throws an error. Does Any one has an idea how to get fix this ?

public virtual async System.Threading.Tasks.Task DbSupplierDELETEAsync(System.Guid id)
{
    if (id == null)
        throw new System.ArgumentNullException("id");

    var client_ = _httpClient;
    var disposeClient_ = false;
    try
    {
        using (var request_ = new System.Net.Http.HttpRequestMessage())
        {
            request_.Method = new System.Net.Http.HttpMethod("DELETE");

            var urlBuilder_ = new System.Text.StringBuilder();
            if (!string.IsNullOrEmpty(_baseUrl))
                urlBuilder_.Append(_baseUrl);

            // Operation Path: "api/DbSupplier/{Id}"
            urlBuilder_.Append("api/DbSupplier/");

            PrepareRequest(client_, request_, urlBuilder_);

            var url_ = urlBuilder_.ToString();
            request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);

            PrepareRequest(client_, request_, url_);

            var response_ = await client_.SendAsync(request_,
                HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
            // .....
        }
    }
    finally { }
}

This is the REST API endpoint

[HttpDelete("{Id}")]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<ActionResult> Delete([FromRoute] Guid id)
{
    await _mediator.Send(new DeleteDbSupplierCommand { Id = id });
    return NoContent();
}

now every time I generate this file I have to manually change this line urlBuilder_.Append("api/DbSupplier/") to urlBuilder_.Append("api/DbSupplier/" + id); How to fix this in Nswag Generator?

Thank you !

0

There are 0 best solutions below