Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove duplicated code. #618

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 1 addition & 41 deletions tools/code/integration.tests/Api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ static async ValueTask writeInformationFile(ApiName name, ApiType type, string p
var apiName = getApiName(name, revision, index);
var informationFile = ApiInformationFile.From(apiName, serviceDirectory);
var rootApiName = ApiName.GetRootName(name);
var dto = getDto(rootApiName, type, path, version, revision);
var dto = GetDto(rootApiName, type, path, version, revision);

await informationFile.WriteDto(dto, cancellationToken);
}
Expand Down Expand Up @@ -451,46 +451,6 @@ await specificationOption.IterTask(async x =>
await specificationFile.WriteSpecification(BinaryData.FromString(contents), cancellationToken);
});
}

static ApiDto getDto(ApiName name, ApiType type, string path, Option<ApiVersion> version, ApiRevision revision) =>
new ApiDto()
{
Properties = new ApiDto.ApiCreateOrUpdateProperties
{
// APIM sets the description to null when it imports for SOAP APIs.
DisplayName = name.ToString(),
Path = path,
ApiType = type switch
{
ApiType.Http => null,
ApiType.Soap => "soap",
ApiType.GraphQl => null,
ApiType.WebSocket => null,
_ => throw new NotSupportedException()
},
Type = type switch
{
ApiType.Http => "http",
ApiType.Soap => "soap",
ApiType.GraphQl => "graphql",
ApiType.WebSocket => "websocket",
_ => throw new NotSupportedException()
},
Protocols = type switch
{
ApiType.Http => ["http", "https"],
ApiType.Soap => ["http", "https"],
ApiType.GraphQl => ["http", "https"],
ApiType.WebSocket => ["ws", "wss"],
_ => throw new NotSupportedException()
},
ServiceUrl = revision.ServiceUri.ValueUnsafe()?.ToString(),
ApiRevisionDescription = revision.Description.ValueUnsafe(),
ApiRevision = $"{revision.Number.ToInt()}",
ApiVersion = version.Map(version => version.Version).ValueUnsafe(),
ApiVersionSetId = version.Map(version => $"/apiVersionSets/{version.VersionSetName}").ValueUnsafe()
}
};
}

public static void ConfigureValidatePublishedApis(IHostApplicationBuilder builder)
Expand Down