From 197b7095fd1433dad2797c8fbd18822c13f03863 Mon Sep 17 00:00:00 2001 From: m-nash <64171366+m-nash@users.noreply.github.com> Date: Mon, 19 Aug 2024 13:56:06 -0700 Subject: [PATCH] Http payload media type (#4209) Fixes https://github.com/microsoft/typespec/issues/3980 --- .../eng/scripts/Generate.ps1 | 41 +- .../Providers/ScmMethodProviderCollection.cs | 7 + .../src/Properties/launchSettings.json | 5 + .../Http/Payload/MediaType/MediaTypeTests.cs | 42 ++ .../payload/media-type/Configuration.json | 6 + .../payload/media-type/Payload.MediaType.sln | 48 ++ .../src/Generated/MediaTypeClient.cs | 20 + .../src/Generated/MediaTypeClientOptions.cs | 12 + .../media-type/src/Generated/StringBody.cs | 49 ++ .../media-type/src/Payload.MediaType.csproj | 16 + .../http/payload/media-type/tspCodeModel.json | 426 ++++++++++++++++++ 11 files changed, 654 insertions(+), 18 deletions(-) create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Payload/MediaType/MediaTypeTests.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/Configuration.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/Payload.MediaType.sln create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/src/Generated/MediaTypeClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/src/Generated/MediaTypeClientOptions.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/src/Generated/StringBody.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/src/Payload.MediaType.csproj create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/tspCodeModel.json diff --git a/packages/http-client-csharp/eng/scripts/Generate.ps1 b/packages/http-client-csharp/eng/scripts/Generate.ps1 index aea65f016a..d9654e9c9c 100644 --- a/packages/http-client-csharp/eng/scripts/Generate.ps1 +++ b/packages/http-client-csharp/eng/scripts/Generate.ps1 @@ -1,7 +1,8 @@ #Requires -Version 7.0 param( $filter, - [bool]$Stubbed = $true + [bool]$Stubbed = $true, + [bool]$LaunchOnly = $false ) Import-Module "$PSScriptRoot\Generation.psm1" -DisableNameChecking -Force; @@ -9,28 +10,30 @@ Import-Module "$PSScriptRoot\Generation.psm1" -DisableNameChecking -Force; $packageRoot = Resolve-Path (Join-Path $PSScriptRoot '..' '..') $solutionDir = Join-Path $packageRoot 'generator' -Refresh-Build +if (-not $LaunchOnly) { + Refresh-Build -if ($null -eq $filter -or $filter -eq "Unbranded-TypeSpec") { - Write-Host "Generating UnbrandedTypeSpec" -ForegroundColor Cyan - $testProjectsLocalDir = Join-Path $packageRoot 'generator' 'TestProjects' 'Local' + if ($null -eq $filter -or $filter -eq "Unbranded-TypeSpec") { + Write-Host "Generating UnbrandedTypeSpec" -ForegroundColor Cyan + $testProjectsLocalDir = Join-Path $packageRoot 'generator' 'TestProjects' 'Local' - $unbrandedTypespecTestProject = Join-Path $testProjectsLocalDir "Unbranded-TypeSpec" - $unbrandedTypespecTestProject = $unbrandedTypespecTestProject + $unbrandedTypespecTestProject = Join-Path $testProjectsLocalDir "Unbranded-TypeSpec" + $unbrandedTypespecTestProject = $unbrandedTypespecTestProject - Invoke (Get-TspCommand "$unbrandedTypespecTestProject/Unbranded-TypeSpec.tsp" $unbrandedTypespecTestProject) + Invoke (Get-TspCommand "$unbrandedTypespecTestProject/Unbranded-TypeSpec.tsp" $unbrandedTypespecTestProject) - # exit if the generation failed - if ($LASTEXITCODE -ne 0) { - exit $LASTEXITCODE - } + # exit if the generation failed + if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE + } - Write-Host "Building UnbrandedTypeSpec" -ForegroundColor Cyan - Invoke "dotnet build $packageRoot/generator/TestProjects/Local/Unbranded-TypeSpec/src/UnbrandedTypeSpec.csproj" + Write-Host "Building UnbrandedTypeSpec" -ForegroundColor Cyan + Invoke "dotnet build $packageRoot/generator/TestProjects/Local/Unbranded-TypeSpec/src/UnbrandedTypeSpec.csproj" - # exit if the generation failed - if ($LASTEXITCODE -ne 0) { - exit $LASTEXITCODE + # exit if the generation failed + if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE + } } } @@ -59,7 +62,6 @@ $failingSpecs = @( Join-Path 'http' 'parameters' 'spread' Join-Path 'http' 'payload' 'content-negotiation' Join-Path 'http' 'payload' 'json-merge-patch' - Join-Path 'http' 'payload' 'media-type' Join-Path 'http' 'payload' 'multipart' Join-Path 'http' 'payload' 'pageable' Join-Path 'http' 'resiliency' 'srv-driven' @@ -135,6 +137,9 @@ foreach ($directory in $directories) { } $cadlRanchLaunchProjects.Add(($folders -join "-"), ("TestProjects/CadlRanch/$($subPath.Replace([System.IO.Path]::DirectorySeparatorChar, '/'))")) + if ($LaunchOnly) { + continue + } Write-Host "Generating $subPath" -ForegroundColor Cyan Invoke (Get-TspCommand $specFile $generationDir $stubbed) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/ScmMethodProviderCollection.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/ScmMethodProviderCollection.cs index 1e694f6b04..cc48ad6e5d 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/ScmMethodProviderCollection.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/ScmMethodProviderCollection.cs @@ -125,6 +125,13 @@ private IReadOnlyList GetParamConversions(IReadOnlyList Test(async (host) => + { + var response1 = await new MediaTypeClient(host, null).GetStringBodyClient().SendAsTextAsync("{cat}"); + Assert.AreEqual(200, response1.GetRawResponse().Status); + }); + + [CadlRanchTest] + public Task GetAsText() => Test(async (host) => + { + var response2 = await new MediaTypeClient(host, null).GetStringBodyClient().GetAsTextAsync(); + Assert.AreEqual("{cat}", response2.Value); + }); + + [CadlRanchTest] + [Ignore("https://github.com/microsoft/typespec/issues/4208")] + public Task SendAsJson() => Test(async (host) => + { + var response3 = await new MediaTypeClient(host, null).GetStringBodyClient().SendAsJsonAsync("foo"); + Assert.AreEqual(200, response3.GetRawResponse().Status); + }); + + [CadlRanchTest] + [Ignore("https://github.com/microsoft/typespec/issues/4208")] + public Task GetAsJson() => Test(async (host) => + { + var response4 = await new MediaTypeClient(host, null).GetStringBodyClient().GetAsJsonAsync(); + Assert.AreEqual("foo", response4.Value); + }); + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/Configuration.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/Configuration.json new file mode 100644 index 0000000000..5cf01e5b76 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/Configuration.json @@ -0,0 +1,6 @@ +{ + "output-folder": ".", + "namespace": "Payload.MediaType", + "library-name": "Payload.MediaType", + "use-model-reader-writer": true +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/Payload.MediaType.sln b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/Payload.MediaType.sln new file mode 100644 index 0000000000..5da10c9ad7 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/Payload.MediaType.sln @@ -0,0 +1,48 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Payload.MediaType", "src\Payload.MediaType.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/src/Generated/MediaTypeClient.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/src/Generated/MediaTypeClient.cs new file mode 100644 index 0000000000..6aee71cdbf --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/src/Generated/MediaTypeClient.cs @@ -0,0 +1,20 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; + +namespace Payload.MediaType +{ + public partial class MediaTypeClient + { + public MediaTypeClient() : this(new Uri("http://localhost:3000"), new MediaTypeClientOptions()) => throw null; + + public MediaTypeClient(Uri endpoint, MediaTypeClientOptions options) => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual StringBody GetStringBodyClient() => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/src/Generated/MediaTypeClientOptions.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/src/Generated/MediaTypeClientOptions.cs new file mode 100644 index 0000000000..34c7b715a6 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/src/Generated/MediaTypeClientOptions.cs @@ -0,0 +1,12 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; + +namespace Payload.MediaType +{ + public partial class MediaTypeClientOptions : ClientPipelineOptions + { + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/src/Generated/StringBody.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/src/Generated/StringBody.cs new file mode 100644 index 0000000000..b4eab994ec --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/src/Generated/StringBody.cs @@ -0,0 +1,49 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading.Tasks; + +namespace Payload.MediaType +{ + public partial class StringBody + { + protected StringBody() => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual ClientResult SendAsText(BinaryContent content, RequestOptions options) => throw null; + + public virtual Task SendAsTextAsync(BinaryContent content, RequestOptions options) => throw null; + + public virtual ClientResult SendAsText(string text) => throw null; + + public virtual Task SendAsTextAsync(string text) => throw null; + + public virtual ClientResult GetAsText(RequestOptions options) => throw null; + + public virtual Task GetAsTextAsync(RequestOptions options) => throw null; + + public virtual ClientResult GetAsText() => throw null; + + public virtual Task> GetAsTextAsync() => throw null; + + public virtual ClientResult SendAsJson(BinaryContent content, RequestOptions options) => throw null; + + public virtual Task SendAsJsonAsync(BinaryContent content, RequestOptions options) => throw null; + + public virtual ClientResult SendAsJson(string text) => throw null; + + public virtual Task SendAsJsonAsync(string text) => throw null; + + public virtual ClientResult GetAsJson(RequestOptions options) => throw null; + + public virtual Task GetAsJsonAsync(RequestOptions options) => throw null; + + public virtual ClientResult GetAsJson() => throw null; + + public virtual Task> GetAsJsonAsync() => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/src/Payload.MediaType.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/src/Payload.MediaType.csproj new file mode 100644 index 0000000000..c63aebd443 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/src/Payload.MediaType.csproj @@ -0,0 +1,16 @@ + + + This is the Payload.MediaType client library for developing .NET applications with rich experience. + SDK Code Generation Payload.MediaType + 1.0.0-beta.1 + Payload.MediaType + netstandard2.0 + latest + true + + + + + + + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/tspCodeModel.json new file mode 100644 index 0000000000..3f9a768f0d --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/tspCodeModel.json @@ -0,0 +1,426 @@ +{ + "$id": "1", + "Name": "Payload.MediaType", + "ApiVersions": [], + "Enums": [], + "Models": [], + "Clients": [ + { + "$id": "2", + "Name": "MediaTypeClient", + "Description": "Test the payload with different media types and different types of the payload itself.", + "Operations": [], + "Protocol": { + "$id": "3" + }, + "Parameters": [ + { + "$id": "4", + "Name": "endpoint", + "NameInRequest": "endpoint", + "Type": { + "$id": "5", + "Kind": "url", + "Name": "url", + "CrossLanguageDefinitionId": "TypeSpec.url" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": true, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client", + "DefaultValue": { + "$id": "6", + "Type": { + "$id": "7", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string" + }, + "Value": "http://localhost:3000" + } + } + ], + "Decorators": [] + }, + { + "$id": "8", + "Name": "StringBody", + "Operations": [ + { + "$id": "9", + "Name": "sendAsText", + "ResourceName": "StringBody", + "Accessibility": "public", + "Parameters": [ + { + "$id": "10", + "Name": "endpoint", + "NameInRequest": "endpoint", + "Type": { + "$id": "11", + "Kind": "url", + "Name": "url", + "CrossLanguageDefinitionId": "TypeSpec.url" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": true, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client", + "DefaultValue": { + "$id": "12", + "Type": { + "$id": "13", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string" + }, + "Value": "http://localhost:3000" + } + }, + { + "$id": "14", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Type": { + "$id": "15", + "Kind": "constant", + "ValueType": { + "$id": "16", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Value": "text/plain", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [] + }, + { + "$id": "17", + "Name": "text", + "NameInRequest": "text", + "Type": { + "$id": "18", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [] + } + ], + "Responses": [ + { + "$id": "19", + "StatusCodes": [ + 200 + ], + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Text", + "Uri": "{endpoint}", + "Path": "/payload/media-type/string-body/sendAsText", + "RequestMediaTypes": [ + "text/plain" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Payload.MediaType.StringBody.sendAsText", + "Decorators": [] + }, + { + "$id": "20", + "Name": "getAsText", + "ResourceName": "StringBody", + "Accessibility": "public", + "Parameters": [ + { + "$ref": "10" + }, + { + "$id": "21", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "22", + "Kind": "constant", + "ValueType": { + "$id": "23", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Value": "text/plain", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [] + } + ], + "Responses": [ + { + "$id": "24", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$id": "25", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "BodyMediaType": "Json", + "Headers": [ + { + "$id": "26", + "Name": "contentType", + "NameInResponse": "content-type", + "Type": { + "$id": "27", + "Kind": "constant", + "ValueType": { + "$id": "28", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Value": "text/plain", + "Decorators": [] + } + } + ], + "IsErrorResponse": false, + "ContentTypes": [ + "text/plain" + ] + } + ], + "HttpMethod": "GET", + "RequestBodyMediaType": "None", + "Uri": "{endpoint}", + "Path": "/payload/media-type/string-body/getAsText", + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Payload.MediaType.StringBody.getAsText", + "Decorators": [] + }, + { + "$id": "29", + "Name": "sendAsJson", + "ResourceName": "StringBody", + "Accessibility": "public", + "Parameters": [ + { + "$ref": "10" + }, + { + "$id": "30", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Type": { + "$id": "31", + "Kind": "constant", + "ValueType": { + "$id": "32", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Value": "application/json", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [] + }, + { + "$id": "33", + "Name": "text", + "NameInRequest": "text", + "Type": { + "$id": "34", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [] + } + ], + "Responses": [ + { + "$id": "35", + "StatusCodes": [ + 200 + ], + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false + } + ], + "HttpMethod": "POST", + "RequestBodyMediaType": "Text", + "Uri": "{endpoint}", + "Path": "/payload/media-type/string-body/sendAsJson", + "RequestMediaTypes": [ + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Payload.MediaType.StringBody.sendAsJson", + "Decorators": [] + }, + { + "$id": "36", + "Name": "getAsJson", + "ResourceName": "StringBody", + "Accessibility": "public", + "Parameters": [ + { + "$ref": "10" + }, + { + "$id": "37", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "38", + "Kind": "constant", + "ValueType": { + "$id": "39", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Value": "application/json", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [] + } + ], + "Responses": [ + { + "$id": "40", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$id": "41", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "BodyMediaType": "Json", + "Headers": [ + { + "$id": "42", + "Name": "contentType", + "NameInResponse": "content-type", + "Type": { + "$id": "43", + "Kind": "constant", + "ValueType": { + "$id": "44", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Value": "application/json", + "Decorators": [] + } + } + ], + "IsErrorResponse": false, + "ContentTypes": [ + "application/json" + ] + } + ], + "HttpMethod": "GET", + "RequestBodyMediaType": "None", + "Uri": "{endpoint}", + "Path": "/payload/media-type/string-body/getAsJson", + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Payload.MediaType.StringBody.getAsJson", + "Decorators": [] + } + ], + "Protocol": { + "$id": "45" + }, + "Parent": "MediaTypeClient", + "Parameters": [ + { + "$ref": "10" + } + ], + "Decorators": [] + } + ] +}