本文整理汇总了C#中System.Web.Http.Description.ApiDescription.IsObsolete方法的典型用法代码示例。如果您正苦于以下问题:C# ApiDescription.IsObsolete方法的具体用法?C# ApiDescription.IsObsolete怎么用?C# ApiDescription.IsObsolete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Http.Description.ApiDescription
的用法示例。
在下文中一共展示了ApiDescription.IsObsolete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateOperation
private Operation CreateOperation(ApiDescription apiDescription, SchemaRegistry schemaRegistry)
{
Contract.Requires(apiDescription != null);
Contract.Requires(schemaRegistry != null);
Contract.Requires(apiDescription.ParameterDescriptions != null);
var edmModel = ((ODataRoute)apiDescription.Route).GetEdmModel();
var parameters = apiDescription.ParameterDescriptions
.Select(paramDesc =>
{
var inPath = apiDescription.RelativePathSansQueryString().Contains("{" + paramDesc.Name + "}");
var swaggerApiParameterDescription = paramDesc as SwaggerApiParameterDescription;
return swaggerApiParameterDescription != null
? CreateParameter(swaggerApiParameterDescription, inPath, schemaRegistry, edmModel)
: CreateParameter(paramDesc, inPath, schemaRegistry, edmModel);
})
.ToList();
var responses = new Dictionary<string, Response>();
var responseType = apiDescription.ResponseType();
if (responseType == null || responseType == typeof(void))
responses.Add("204", new Response { description = "No Content" });
else
responses.Add("200", new Response { description = "OK", schema = schemaRegistry.GetOrRegisterResponseType(edmModel, responseType) });
var operation = new Operation
{
summary = apiDescription.Documentation,
tags = new[] { _options.GroupingKeySelector(apiDescription) },
operationId = apiDescription.OperationId(),
produces = apiDescription.Produces()?.ToList(),
consumes = apiDescription.Consumes()?.ToList(),
parameters = parameters.Any() ? parameters : null, // parameters can be null but not empty
responses = responses,
deprecated = apiDescription.IsObsolete()
};
foreach (var filter in _options.OperationFilters)
{
Contract.Assume(filter != null);
filter.Apply(operation, schemaRegistry, apiDescription);
}
return operation;
}
示例2: CreateOperation
private Operation CreateOperation(ApiDescription apiDescription, SchemaRegistry schemaRegistry)
{
var parameters = apiDescription.ParameterDescriptions
.Select(paramDesc =>
{
var inPath = apiDescription.RelativePathSansQueryString().Contains("{" + paramDesc.Name + "}");
return CreateParameter(paramDesc, inPath, schemaRegistry);
})
.ToList();
var responses = new Dictionary<string, Response>();
var responseType = apiDescription.ResponseType();
if (responseType == null)
responses.Add("204", new Response { description = "No Content" });
else
responses.Add("200", new Response { description = "OK", schema = schemaRegistry.GetOrRegister(responseType) });
var operation = new Operation
{
tags = new [] { _options.GroupingKeySelector(apiDescription) },
operationId = apiDescription.FriendlyId(),
produces = apiDescription.Produces().ToList(),
consumes = apiDescription.Consumes().ToList(),
parameters = parameters.Any() ? parameters : null, // parameters can be null but not empty
responses = responses,
deprecated = apiDescription.IsObsolete()
};
foreach (var filter in _options.OperationFilters)
{
filter.Apply(operation, schemaRegistry, apiDescription);
}
return operation;
}
示例3: CreateOperation
private Operation CreateOperation(ApiDescription apiDesc, SchemaRegistry schemaRegistry)
{
var parameters = apiDesc.ParameterDescriptions
.Select(paramDesc =>
{
string location = GetParameterLocation(apiDesc, paramDesc);
return CreateParameter(location, paramDesc, schemaRegistry);
})
.ToList();
var responses = new Dictionary<string, Response>();
var responseType = apiDesc.ResponseType();
if (responseType == null || responseType == typeof(void))
responses.Add("204", new Response { description = "No Content" });
else
responses.Add("200", new Response { description = "OK", schema = schemaRegistry.GetOrRegister(responseType) });
var operation = new Operation
{
tags = new [] { _options.GroupingKeySelector(apiDesc) },
operationId = apiDesc.FriendlyId(),
produces = apiDesc.Produces().ToList(),
consumes = apiDesc.Consumes().ToList(),
parameters = parameters.Any() ? parameters : null, // parameters can be null but not empty
responses = responses,
deprecated = apiDesc.IsObsolete()
};
foreach (var filter in _options.OperationFilters)
{
filter.Apply(operation, schemaRegistry, apiDesc);
}
return operation;
}