// ------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------ using System.Collections.Generic; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.OData.Common; using Microsoft.OpenApi.OData.Generator; namespace Microsoft.OpenApi.OData.Operation { /// /// Retrieve a metadata document "get" /// internal class MetadataGetOperationHandler : OperationHandler { /// public override OperationType OperationType => OperationType.Get; /// protected override void SetBasicInfo(OpenApiOperation operation) { // Summary operation.Summary = $"Get OData metadata (CSDL) document"; // OperationId if (Context.Settings.EnableOperationId) { string routePrefix = Context.Settings.PathPrefix ?? ""; if (Context.Settings.PathPrefix != null) { operation.OperationId = $"{routePrefix}.Get.Metadata"; } else { operation.OperationId = "Get.Metadata"; } } base.SetBasicInfo(operation); } /// protected override void SetResponses(OpenApiOperation operation) { OpenApiSchema schema = new OpenApiSchema { Type = "string" }; operation.Responses = new OpenApiResponses { { Constants.StatusCode200, new OpenApiResponse { Description = "Retrieved metadata document", Content = new Dictionary { { Constants.ApplicationXmlMediaType, new OpenApiMediaType { Schema = schema } } } } } }; operation.Responses.Add(Constants.StatusCodeDefault, Constants.StatusCodeDefault.GetResponse()); base.SetResponses(operation); } } }