From 976c185449e3ab231d319fa058272a13c8320ac7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 28 Jan 2026 19:43:24 +0000 Subject: [PATCH 1/7] Initial plan From c64e86deb9c2a62ae48f21d3e882f16f491e1756 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 28 Jan 2026 19:59:10 +0000 Subject: [PATCH 2/7] Fix optional contentType issue in emitter - change scope from Constant to Method for optional Content-Type headers Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> --- .../emitter/src/lib/operation-converter.ts | 6 +++ .../RestClientProviderTests.cs | 45 +++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/packages/http-client-csharp/emitter/src/lib/operation-converter.ts b/packages/http-client-csharp/emitter/src/lib/operation-converter.ts index 5342d1f9132..e1960b0eea8 100644 --- a/packages/http-client-csharp/emitter/src/lib/operation-converter.ts +++ b/packages/http-client-csharp/emitter/src/lib/operation-converter.ts @@ -841,6 +841,12 @@ function getParameterScope( return InputParameterScope.Method; } + // Optional Content-Type headers should be Method scope, not Constant + // even if they have a constant type, so they can be conditionally set + if (type.kind === "constant" && p.optional && isContentType(p)) { + return InputParameterScope.Method; + } + return type.kind === "constant" ? InputParameterScope.Constant : p.isApiVersionParam diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/RestClientProviders/RestClientProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/RestClientProviders/RestClientProviderTests.cs index 57185131052..1804b6d98f2 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/RestClientProviders/RestClientProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/RestClientProviders/RestClientProviderTests.cs @@ -1374,5 +1374,50 @@ private static IEnumerable ValidateApiVersionPathParameterTestCase ], parameters: [endpointParameter, enumApiVersionParameter])); } + + [Test] + public void ValidateOptionalContentTypeHeader() + { + // Test that optional Content-Type header is treated as optional parameter, not as constant + var bodyModel = InputFactory.Model("BodyModel", properties: + [ + InputFactory.Property("name", InputPrimitiveType.String, isRequired: true) + ]); + + var contentTypeParameter = InputFactory.HeaderParameter( + "contentType", + InputFactory.Literal.String("application/json"), + isRequired: false, // Optional + defaultValue: InputFactory.Constant.String("application/json"), + serializedName: "Content-Type", + isContentType: true, + scope: InputParameterScope.Constant); + + var bodyParameter = InputFactory.BodyParameter("body", bodyModel, isRequired: false); + + var inputServiceMethod = InputFactory.BasicServiceMethod("TestMethod", + InputFactory.Operation("TestOperation", + parameters: + [ + contentTypeParameter, + bodyParameter + ], + responses: + [ + InputFactory.OperationResponse([204]) + ])); + + var inputClient = InputFactory.Client("TestClient", methods: [inputServiceMethod]); + var clientProvider = new ClientProvider(inputClient); + var restClientProvider = new MockClientProvider(inputClient, clientProvider); + var writer = new TypeProviderWriter(restClientProvider); + var file = writer.Write(); + + // Print the actual output for manual verification + TestContext.Out.WriteLine("=== Generated Code ==="); + TestContext.Out.WriteLine(file.Content); + + Assert.AreEqual(Helpers.GetExpectedFromFile(), file.Content); + } } } From 5a19aa9526c5ac161371630a1e933279e1ec2915 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 28 Jan 2026 20:04:33 +0000 Subject: [PATCH 3/7] Add tests for optional Content-Type header fix Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> --- .../test/Unit/operation-converter.test.ts | 72 +++++++++++++++++++ .../RestClientProviderTests.cs | 9 +-- 2 files changed, 77 insertions(+), 4 deletions(-) diff --git a/packages/http-client-csharp/emitter/test/Unit/operation-converter.test.ts b/packages/http-client-csharp/emitter/test/Unit/operation-converter.test.ts index d91f0cd31c1..95d9c4a21ed 100644 --- a/packages/http-client-csharp/emitter/test/Unit/operation-converter.test.ts +++ b/packages/http-client-csharp/emitter/test/Unit/operation-converter.test.ts @@ -366,5 +366,77 @@ describe("Operation Converter", () => { strictEqual(response.bodyType, undefined); }); }); + + describe("Optional Content-Type header", () => { + it("Optional body should have Content-Type with Method scope", async () => { + const program = await typeSpecCompile( + ` + model BodyModel { + name: string; + } + + @post + op withOptionalBody(@body body?: BodyModel): void; + `, + runner, + ); + const context = createEmitterContext(program); + const sdkContext = await createCSharpSdkContext(context); + const root = createModel(sdkContext); + + strictEqual(root.clients.length, 1); + strictEqual(root.clients[0].methods.length, 1); + + const method = root.clients[0].methods[0]; + ok(method); + + // validate operation + const operation = method.operation; + ok(operation); + + // Find Content-Type parameter + const contentTypeParam = operation.parameters.find((p) => p.name === "contentType"); + ok(contentTypeParam, "Content-Type parameter should exist"); + strictEqual(contentTypeParam.kind, "header"); + strictEqual(contentTypeParam.serializedName, "Content-Type"); + strictEqual(contentTypeParam.optional, true, "Content-Type should be optional"); + strictEqual(contentTypeParam.scope, "Method", "Content-Type should have Method scope for optional body"); + }); + + it("Required body should have Content-Type with Constant scope", async () => { + const program = await typeSpecCompile( + ` + model BodyModel { + name: string; + } + + @post + op withRequiredBody(@body body: BodyModel): void; + `, + runner, + ); + const context = createEmitterContext(program); + const sdkContext = await createCSharpSdkContext(context); + const root = createModel(sdkContext); + + strictEqual(root.clients.length, 1); + strictEqual(root.clients[0].methods.length, 1); + + const method = root.clients[0].methods[0]; + ok(method); + + // validate operation + const operation = method.operation; + ok(operation); + + // Find Content-Type parameter + const contentTypeParam = operation.parameters.find((p) => p.name === "contentType"); + ok(contentTypeParam, "Content-Type parameter should exist"); + strictEqual(contentTypeParam.kind, "header"); + strictEqual(contentTypeParam.serializedName, "Content-Type"); + strictEqual(contentTypeParam.optional, false, "Content-Type should be required"); + strictEqual(contentTypeParam.scope, "Constant", "Content-Type should have Constant scope for required body"); + }); + }); }); }); diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/RestClientProviders/RestClientProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/RestClientProviders/RestClientProviderTests.cs index 1804b6d98f2..f949806403c 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/RestClientProviders/RestClientProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/RestClientProviders/RestClientProviderTests.cs @@ -1378,7 +1378,7 @@ private static IEnumerable ValidateApiVersionPathParameterTestCase [Test] public void ValidateOptionalContentTypeHeader() { - // Test that optional Content-Type header is treated as optional parameter, not as constant + // Test that optional Content-Type header with Method scope is handled correctly var bodyModel = InputFactory.Model("BodyModel", properties: [ InputFactory.Property("name", InputPrimitiveType.String, isRequired: true) @@ -1391,7 +1391,7 @@ public void ValidateOptionalContentTypeHeader() defaultValue: InputFactory.Constant.String("application/json"), serializedName: "Content-Type", isContentType: true, - scope: InputParameterScope.Constant); + scope: InputParameterScope.Method); // Method scope for optional Content-Type var bodyParameter = InputFactory.BodyParameter("body", bodyModel, isRequired: false); @@ -1413,11 +1413,12 @@ public void ValidateOptionalContentTypeHeader() var writer = new TypeProviderWriter(restClientProvider); var file = writer.Write(); - // Print the actual output for manual verification TestContext.Out.WriteLine("=== Generated Code ==="); TestContext.Out.WriteLine(file.Content); - Assert.AreEqual(Helpers.GetExpectedFromFile(), file.Content); + // Verify that contentType parameter is included as a method parameter + Assert.IsTrue(file.Content.Contains("string contentType"), + "Content-Type should be a method parameter for optional body"); } } } From 119d93c5a9e984593eb72160a09a9946ebc7c90c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 28 Jan 2026 20:28:52 +0000 Subject: [PATCH 4/7] Correct fix: Keep optional Content-Type as constants, prevent enum transformation Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> --- .../emitter/src/lib/operation-converter.ts | 8 +------- .../emitter/src/lib/type-converter.ts | 10 ++++++++++ .../emitter/test/Unit/operation-converter.test.ts | 6 ++++-- .../src/Providers/RestClientProvider.cs | 11 +++++++++-- .../RestClientProviders/RestClientProviderTests.cs | 12 +++++++----- 5 files changed, 31 insertions(+), 16 deletions(-) diff --git a/packages/http-client-csharp/emitter/src/lib/operation-converter.ts b/packages/http-client-csharp/emitter/src/lib/operation-converter.ts index e1960b0eea8..44e39d78574 100644 --- a/packages/http-client-csharp/emitter/src/lib/operation-converter.ts +++ b/packages/http-client-csharp/emitter/src/lib/operation-converter.ts @@ -479,7 +479,7 @@ function fromHeaderParameter( p: SdkHeaderParameter, rootApiVersions: string[], ): InputHeaderParameter { - const parameterType = fromSdkType(sdkContext, p.type); + const parameterType = fromSdkType(sdkContext, p.type, p); const retVar: InputHeaderParameter = { kind: "header", @@ -841,12 +841,6 @@ function getParameterScope( return InputParameterScope.Method; } - // Optional Content-Type headers should be Method scope, not Constant - // even if they have a constant type, so they can be conditionally set - if (type.kind === "constant" && p.optional && isContentType(p)) { - return InputParameterScope.Method; - } - return type.kind === "constant" ? InputParameterScope.Constant : p.isApiVersionParam diff --git a/packages/http-client-csharp/emitter/src/lib/type-converter.ts b/packages/http-client-csharp/emitter/src/lib/type-converter.ts index f6b31db5578..f2cb5294ff3 100644 --- a/packages/http-client-csharp/emitter/src/lib/type-converter.ts +++ b/packages/http-client-csharp/emitter/src/lib/type-converter.ts @@ -107,8 +107,18 @@ export function fromSdkType( retVar = fromSdkArrayType(sdkContext, sdkType); break; case "constant": + // Don't transform optional Content-Type headers into enums - keep them as constants + const isContentTypeHeader = + sdkProperty && + "kind" in sdkProperty && + sdkProperty.kind === "header" && + "serializedName" in sdkProperty && + typeof sdkProperty.serializedName === "string" && + sdkProperty.serializedName.toLocaleLowerCase() === "content-type"; + if ( sdkProperty && + !isContentTypeHeader && (sdkProperty.optional || sdkProperty?.type.kind === "nullable") && sdkProperty?.type.kind !== "boolean" && sdkType.valueType.kind !== "boolean" diff --git a/packages/http-client-csharp/emitter/test/Unit/operation-converter.test.ts b/packages/http-client-csharp/emitter/test/Unit/operation-converter.test.ts index 95d9c4a21ed..7af2ed9a3a7 100644 --- a/packages/http-client-csharp/emitter/test/Unit/operation-converter.test.ts +++ b/packages/http-client-csharp/emitter/test/Unit/operation-converter.test.ts @@ -368,7 +368,7 @@ describe("Operation Converter", () => { }); describe("Optional Content-Type header", () => { - it("Optional body should have Content-Type with Method scope", async () => { + it("Optional body should have Content-Type remain as Constant (not transformed to enum)", async () => { const program = await typeSpecCompile( ` model BodyModel { @@ -400,7 +400,8 @@ describe("Operation Converter", () => { strictEqual(contentTypeParam.kind, "header"); strictEqual(contentTypeParam.serializedName, "Content-Type"); strictEqual(contentTypeParam.optional, true, "Content-Type should be optional"); - strictEqual(contentTypeParam.scope, "Method", "Content-Type should have Method scope for optional body"); + strictEqual(contentTypeParam.scope, "Constant", "Content-Type should remain Constant scope"); + strictEqual(contentTypeParam.type.kind, "constant", "Content-Type should remain a constant type, not transformed to enum"); }); it("Required body should have Content-Type with Constant scope", async () => { @@ -436,6 +437,7 @@ describe("Operation Converter", () => { strictEqual(contentTypeParam.serializedName, "Content-Type"); strictEqual(contentTypeParam.optional, false, "Content-Type should be required"); strictEqual(contentTypeParam.scope, "Constant", "Content-Type should have Constant scope for required body"); + strictEqual(contentTypeParam.type.kind, "constant", "Content-Type should be a constant type"); }); }); }); diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/RestClientProvider.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/RestClientProvider.cs index 2ed3406ed73..440b45265df 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/RestClientProvider.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/RestClientProvider.cs @@ -761,7 +761,7 @@ private void GetParamInfo(Dictionary paramMap, InputO } } - if (inputParam.Scope == InputParameterScope.Constant && !(operation.IsMultipartFormData && inputParam is InputHeaderParameter headerParameter && headerParameter.IsContentType)) + if (inputParam.Scope == InputParameterScope.Constant && !(inputParam is InputHeaderParameter headerParameter && headerParameter.IsContentType && (!inputParam.IsRequired || operation.IsMultipartFormData))) { valueExpression = Literal((inputParam.Type as InputLiteralType)?.Value); serializationFormat = ScmCodeModelGenerator.Instance.TypeFactory.GetSerializationFormat(inputParam.Type); @@ -925,7 +925,14 @@ internal static List GetMethodParameters( if (inputParam.Scope != InputParameterScope.Method) { - if (inputParam is not InputBodyParameter && + // Allow optional Content-Type headers to be included as method parameters + // even though they have Constant scope + bool isOptionalContentType = inputParam is InputHeaderParameter headerParam && + headerParam.IsContentType && + !inputParam.IsRequired; + + if (!isOptionalContentType && + inputParam is not InputBodyParameter && !(inputParam is InputMethodParameter { Location: InputRequestLocation.Body })) { continue; diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/RestClientProviders/RestClientProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/RestClientProviders/RestClientProviderTests.cs index f949806403c..d1b2671e946 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/RestClientProviders/RestClientProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/RestClientProviders/RestClientProviderTests.cs @@ -1378,7 +1378,7 @@ private static IEnumerable ValidateApiVersionPathParameterTestCase [Test] public void ValidateOptionalContentTypeHeader() { - // Test that optional Content-Type header with Method scope is handled correctly + // Test that optional Content-Type header with Constant scope is handled correctly var bodyModel = InputFactory.Model("BodyModel", properties: [ InputFactory.Property("name", InputPrimitiveType.String, isRequired: true) @@ -1391,7 +1391,7 @@ public void ValidateOptionalContentTypeHeader() defaultValue: InputFactory.Constant.String("application/json"), serializedName: "Content-Type", isContentType: true, - scope: InputParameterScope.Method); // Method scope for optional Content-Type + scope: InputParameterScope.Constant); // Constant scope for optional Content-Type var bodyParameter = InputFactory.BodyParameter("body", bodyModel, isRequired: false); @@ -1415,10 +1415,12 @@ public void ValidateOptionalContentTypeHeader() TestContext.Out.WriteLine("=== Generated Code ==="); TestContext.Out.WriteLine(file.Content); - - // Verify that contentType parameter is included as a method parameter - Assert.IsTrue(file.Content.Contains("string contentType"), + + // Verify that contentType parameter is included as a method parameter (not treated as constant) + Assert.IsTrue(file.Content.Contains("string contentType"), "Content-Type should be a method parameter for optional body"); + Assert.IsTrue(file.Content.Contains("contentType != null"), + "Content-Type should be conditionally set when optional"); } } } From b5b327699503c833cb11bf5bcc63a27feca2dcb4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 28 Jan 2026 20:42:36 +0000 Subject: [PATCH 5/7] Revert generator changes to RestClientProvider.cs as requested Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> --- .../src/Providers/RestClientProvider.cs | 11 +---- .../RestClientProviderTests.cs | 48 ------------------- 2 files changed, 2 insertions(+), 57 deletions(-) diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/RestClientProvider.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/RestClientProvider.cs index 440b45265df..2ed3406ed73 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/RestClientProvider.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/RestClientProvider.cs @@ -761,7 +761,7 @@ private void GetParamInfo(Dictionary paramMap, InputO } } - if (inputParam.Scope == InputParameterScope.Constant && !(inputParam is InputHeaderParameter headerParameter && headerParameter.IsContentType && (!inputParam.IsRequired || operation.IsMultipartFormData))) + if (inputParam.Scope == InputParameterScope.Constant && !(operation.IsMultipartFormData && inputParam is InputHeaderParameter headerParameter && headerParameter.IsContentType)) { valueExpression = Literal((inputParam.Type as InputLiteralType)?.Value); serializationFormat = ScmCodeModelGenerator.Instance.TypeFactory.GetSerializationFormat(inputParam.Type); @@ -925,14 +925,7 @@ internal static List GetMethodParameters( if (inputParam.Scope != InputParameterScope.Method) { - // Allow optional Content-Type headers to be included as method parameters - // even though they have Constant scope - bool isOptionalContentType = inputParam is InputHeaderParameter headerParam && - headerParam.IsContentType && - !inputParam.IsRequired; - - if (!isOptionalContentType && - inputParam is not InputBodyParameter && + if (inputParam is not InputBodyParameter && !(inputParam is InputMethodParameter { Location: InputRequestLocation.Body })) { continue; diff --git a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/RestClientProviders/RestClientProviderTests.cs b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/RestClientProviders/RestClientProviderTests.cs index d1b2671e946..57185131052 100644 --- a/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/RestClientProviders/RestClientProviderTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/RestClientProviders/RestClientProviderTests.cs @@ -1374,53 +1374,5 @@ private static IEnumerable ValidateApiVersionPathParameterTestCase ], parameters: [endpointParameter, enumApiVersionParameter])); } - - [Test] - public void ValidateOptionalContentTypeHeader() - { - // Test that optional Content-Type header with Constant scope is handled correctly - var bodyModel = InputFactory.Model("BodyModel", properties: - [ - InputFactory.Property("name", InputPrimitiveType.String, isRequired: true) - ]); - - var contentTypeParameter = InputFactory.HeaderParameter( - "contentType", - InputFactory.Literal.String("application/json"), - isRequired: false, // Optional - defaultValue: InputFactory.Constant.String("application/json"), - serializedName: "Content-Type", - isContentType: true, - scope: InputParameterScope.Constant); // Constant scope for optional Content-Type - - var bodyParameter = InputFactory.BodyParameter("body", bodyModel, isRequired: false); - - var inputServiceMethod = InputFactory.BasicServiceMethod("TestMethod", - InputFactory.Operation("TestOperation", - parameters: - [ - contentTypeParameter, - bodyParameter - ], - responses: - [ - InputFactory.OperationResponse([204]) - ])); - - var inputClient = InputFactory.Client("TestClient", methods: [inputServiceMethod]); - var clientProvider = new ClientProvider(inputClient); - var restClientProvider = new MockClientProvider(inputClient, clientProvider); - var writer = new TypeProviderWriter(restClientProvider); - var file = writer.Write(); - - TestContext.Out.WriteLine("=== Generated Code ==="); - TestContext.Out.WriteLine(file.Content); - - // Verify that contentType parameter is included as a method parameter (not treated as constant) - Assert.IsTrue(file.Content.Contains("string contentType"), - "Content-Type should be a method parameter for optional body"); - Assert.IsTrue(file.Content.Contains("contentType != null"), - "Content-Type should be conditionally set when optional"); - } } } From f3b27f33d8c33cdfbc5709c72cc38ae6c32de9db Mon Sep 17 00:00:00 2001 From: jolov Date: Wed, 28 Jan 2026 13:44:23 -0800 Subject: [PATCH 6/7] revert --- .../http-client-csharp/emitter/src/lib/operation-converter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/http-client-csharp/emitter/src/lib/operation-converter.ts b/packages/http-client-csharp/emitter/src/lib/operation-converter.ts index 44e39d78574..5342d1f9132 100644 --- a/packages/http-client-csharp/emitter/src/lib/operation-converter.ts +++ b/packages/http-client-csharp/emitter/src/lib/operation-converter.ts @@ -479,7 +479,7 @@ function fromHeaderParameter( p: SdkHeaderParameter, rootApiVersions: string[], ): InputHeaderParameter { - const parameterType = fromSdkType(sdkContext, p.type, p); + const parameterType = fromSdkType(sdkContext, p.type); const retVar: InputHeaderParameter = { kind: "header", From f2c03d0fd7823005361db21e3370b35e436c259b Mon Sep 17 00:00:00 2001 From: jolov Date: Wed, 28 Jan 2026 13:48:47 -0800 Subject: [PATCH 7/7] format --- .../test/Unit/operation-converter.test.ts | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/packages/http-client-csharp/emitter/test/Unit/operation-converter.test.ts b/packages/http-client-csharp/emitter/test/Unit/operation-converter.test.ts index 7af2ed9a3a7..bf8958e71a9 100644 --- a/packages/http-client-csharp/emitter/test/Unit/operation-converter.test.ts +++ b/packages/http-client-csharp/emitter/test/Unit/operation-converter.test.ts @@ -389,19 +389,27 @@ describe("Operation Converter", () => { const method = root.clients[0].methods[0]; ok(method); - + // validate operation const operation = method.operation; ok(operation); - + // Find Content-Type parameter const contentTypeParam = operation.parameters.find((p) => p.name === "contentType"); ok(contentTypeParam, "Content-Type parameter should exist"); strictEqual(contentTypeParam.kind, "header"); strictEqual(contentTypeParam.serializedName, "Content-Type"); strictEqual(contentTypeParam.optional, true, "Content-Type should be optional"); - strictEqual(contentTypeParam.scope, "Constant", "Content-Type should remain Constant scope"); - strictEqual(contentTypeParam.type.kind, "constant", "Content-Type should remain a constant type, not transformed to enum"); + strictEqual( + contentTypeParam.scope, + "Constant", + "Content-Type should remain Constant scope", + ); + strictEqual( + contentTypeParam.type.kind, + "constant", + "Content-Type should remain a constant type, not transformed to enum", + ); }); it("Required body should have Content-Type with Constant scope", async () => { @@ -425,19 +433,27 @@ describe("Operation Converter", () => { const method = root.clients[0].methods[0]; ok(method); - + // validate operation const operation = method.operation; ok(operation); - + // Find Content-Type parameter const contentTypeParam = operation.parameters.find((p) => p.name === "contentType"); ok(contentTypeParam, "Content-Type parameter should exist"); strictEqual(contentTypeParam.kind, "header"); strictEqual(contentTypeParam.serializedName, "Content-Type"); strictEqual(contentTypeParam.optional, false, "Content-Type should be required"); - strictEqual(contentTypeParam.scope, "Constant", "Content-Type should have Constant scope for required body"); - strictEqual(contentTypeParam.type.kind, "constant", "Content-Type should be a constant type"); + strictEqual( + contentTypeParam.scope, + "Constant", + "Content-Type should have Constant scope for required body", + ); + strictEqual( + contentTypeParam.type.kind, + "constant", + "Content-Type should be a constant type", + ); }); }); });