Updated script to allow no debug information. Added custom url generated files.

This commit is contained in:
Michael Yanni 2019-11-22 16:51:42 -08:00
Родитель 70b749e215
Коммит dabc504a97
4 изменённых файлов: 103 добавлений и 5 удалений

Просмотреть файл

@ -1,4 +1,5 @@
$ErrorActionPreference = "Stop"
param([switch]$NoDebug)
$ErrorActionPreference = 'Stop'
function Invoke-Block([scriptblock]$cmd) {
$cmd | Out-String | Write-Verbose
@ -19,13 +20,15 @@ function Invoke-Block([scriptblock]$cmd) {
$repoRoot = "$PSScriptRoot\.."
$testServerTestProject = Resolve-Path "$repoRoot\test\AutoRest.TestServer.Tests"
$testConfiguration = Resolve-Path "$testServerTestProject\readme.md"
$testServerSwagerPath = Resolve-Path "$repoRoot\node_modules\@autorest\test-server\__files\swagger"
$paths = "body-string", "body-complex"
$testServerSwaggerPath = Resolve-Path "$repoRoot\node_modules\@autorest\test-server\__files\swagger"
$paths = 'body-string', 'body-complex', 'custom-baseUrl'
$debugFlags = if($NoDebug) { '' } else { '--debug --verbose' }
foreach ($path in $paths)
{
$outputFolder = "$testServerTestProject\$path";
$inputFile = "$testServerSwagerPath\$path.json"
$inputFile = "$testServerSwaggerPath\$path.json"
$namespace = $path.Replace('-', '_')
Invoke-Block { npx autorest-beta --debug --verbose $testConfiguration --output-folder=$outputFolder --input-file=$inputFile --title=$path --namespace=$namespace }
$autoRestCommand = [scriptblock]::Create("npx autorest-beta $debugFlags $testConfiguration --output-folder=$outputFolder --input-file=$inputFile --title=$path --namespace=$namespace")
Invoke-Block $autoRestCommand
}

Просмотреть файл

@ -0,0 +1,49 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System.Text.Json;
namespace custom_baseUrl.Models.V100
{
public partial class Error
{
internal void Serialize(Utf8JsonWriter writer, bool includeName = true)
{
if (includeName)
{
writer.WriteStartObject("Error");
}
else
{
writer.WriteStartObject();
}
if (Status != null)
{
writer.WriteNumber("status", Status.Value);
}
if (Message != null)
{
writer.WriteString("message", Message);
}
writer.WriteEndObject();
}
internal static Error Deserialize(JsonElement element)
{
var result = new Error();
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("status"))
{
result.Status = property.Value.GetInt32();
continue;
}
if (property.NameEquals("message"))
{
result.Message = property.Value.GetString();
continue;
}
}
return result;
}
}
}

Просмотреть файл

@ -0,0 +1,11 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
namespace custom_baseUrl.Models.V100
{
public partial class Error
{
public int? Status { get; set; }
public string? Message { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,35 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
namespace custom_baseUrl.Operations.V100
{
public static class PathsOperations
{
public static async ValueTask<Response> GetEmptyAsync(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string accountName, string host = "host", CancellationToken cancellationToken = default)
{
using var scope = clientDiagnostics.CreateScope("custom_baseUrl.Operations.V100.GetEmpty");
scope.Start();
try
{
var request = pipeline.CreateRequest();
request.Method = RequestMethod.Get;
request.Uri.Reset(new Uri($"http://{accountName}{host}/customuri"));
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
cancellationToken.ThrowIfCancellationRequested();
return response;
}
catch (Exception e)
{
scope.Failed(e);
throw;
}
}
}
}