autorest icon indicating copy to clipboard operation
autorest copied to clipboard

Generated code sets x-ms-client-request-id even when a custom one is present

Open bitsforthought opened this issue 11 years ago • 2 comments

Given Swagger for an operation that includes a header parameter marked with the custom x-ms-client-request-id extension, AutoRest generates C# code like this:

        // Set Headers
        httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Guid.NewGuid().ToString());
        if (this.Client.AcceptLanguage != null)
        {
            if (httpRequest.Headers.Contains("accept-language"))
            {
                httpRequest.Headers.Remove("accept-language");
            }
            httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage);
        }
        if (clientRequestId != null)
        {
            if (httpRequest.Headers.Contains("client-request-id"))
            {
                httpRequest.Headers.Remove("client-request-id");
            }
            httpRequest.Headers.TryAddWithoutValidation("client-request-id", clientRequestId);
        }

The first line to set the x-ms-client-request-id header should not be present.

bitsforthought avatar Nov 11 '15 01:11 bitsforthought

This is fixed now

stankovski avatar Feb 06 '16 01:02 stankovski

Thanks!

bitsforthought avatar Feb 08 '16 19:02 bitsforthought