当前位置: 首页>>代码示例>>C#>>正文


C# ApiDescription.RelativePathSansQueryString方法代码示例

本文整理汇总了C#中System.Web.Http.Description.ApiDescription.RelativePathSansQueryString方法的典型用法代码示例。如果您正苦于以下问题:C# ApiDescription.RelativePathSansQueryString方法的具体用法?C# ApiDescription.RelativePathSansQueryString怎么用?C# ApiDescription.RelativePathSansQueryString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.Http.Description.ApiDescription的用法示例。


在下文中一共展示了ApiDescription.RelativePathSansQueryString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ApiDescriptionToOperationSpec

        public OperationSpec ApiDescriptionToOperationSpec(ApiDescription apiDescription, ModelSpecRegistrar modelSpecRegistrar)
        {
            var apiPath = apiDescription.RelativePathSansQueryString();
            var paramSpecs = apiDescription.ParameterDescriptions
                .Select(paramDesc => CreateParameterSpec(paramDesc, apiPath, modelSpecRegistrar))
                .ToList();

            var operationSpec = new OperationSpec
            {
                Method = apiDescription.HttpMethod.Method,
                Nickname = apiDescription.Nickname(),
                Summary = apiDescription.Documentation,
                Parameters = paramSpecs,
                ResponseMessages = new List<ResponseMessageSpec>()
            };

            var returnType = apiDescription.ActionDescriptor.ReturnType;
            if (returnType == null)
            {
                operationSpec.Type = "void";
            }
            else
            {
                IEnumerable<ModelSpec> complexSpecs;
                var modelSpec = _modelSpecGenerator.TypeToModelSpec(returnType, out complexSpecs);

                modelSpecRegistrar.RegisterMany(complexSpecs);

                if (modelSpec.Type == "object")
                {
                    operationSpec.Type = modelSpec.Id;
                }
                else
                {
                    operationSpec.Type = modelSpec.Type;
                    operationSpec.Format = modelSpec.Format;
                    operationSpec.Items = modelSpec.Items;
                    operationSpec.Enum = modelSpec.Enum;
                }
            }

            foreach (var filter in _operationFilters)
            {
                filter.Apply(apiDescription, operationSpec, modelSpecRegistrar, _modelSpecGenerator);
            }

            // IOperationSpecFilter is obsolete - below is for back-compat
            var modelSpecMap = new ModelSpecMap(modelSpecRegistrar, _modelSpecGenerator);
            foreach (var filter in _operationSpecFilters)
            {
                filter.Apply(apiDescription, operationSpec, modelSpecMap);
            }

            return operationSpec;
        }
开发者ID:jfurie,项目名称:Swashbuckle,代码行数:55,代码来源:OperationSpecGenerator.cs

示例2: ApiDescriptionToOperation

        public Operation ApiDescriptionToOperation(ApiDescription apiDescription, Dictionary<string, DataType> complexModels)
        {
            var apiPath = apiDescription.RelativePathSansQueryString();
            var parameters = apiDescription.ParameterDescriptions
                .Select(paramDesc => CreateParameter(paramDesc, apiPath, complexModels))
                .ToList();

            var operation = new Operation
            {
                Method = apiDescription.HttpMethod.Method,
                Nickname = apiDescription.Nickname(),
                Summary = apiDescription.Documentation,
                Parameters = parameters,
                ResponseMessages = new List<ResponseMessage>()
            };

            var responseType = apiDescription.ActualResponseType();
            if (responseType == null)
            {
                operation.Type = "void";
            }
            else
            {
                IDictionary<string, DataType> complexModelsForResponseType;
                var dataType = _dataTypeGenerator.TypeToDataType(responseType, out complexModelsForResponseType);

                complexModels.Merge(complexModelsForResponseType);

                if (dataType.Type == "object")
                {
                    operation.Type = dataType.Id;
                }
                else
                {
                    operation.Type = dataType.Type;
                    operation.Format = dataType.Format;
                    operation.Items = dataType.Items;
                    operation.Enum = dataType.Enum;
                }
            }

            foreach (var filter in _operationFilters)
            {
                filter.Apply(operation, complexModels, _dataTypeGenerator, apiDescription);
            }

            return operation;
        }
开发者ID:kevynb,项目名称:Swashbuckle,代码行数:48,代码来源:OperationGenerator.cs

示例3: ApiDescriptionToOperation

        public Operation ApiDescriptionToOperation(ApiDescription apiDescription)
        {
            var apiPath = apiDescription.RelativePathSansQueryString();
            var parameters = apiDescription.ParameterDescriptions
                .Select(paramDesc => CreateParameter(paramDesc, apiPath))
                .ToList();

            var operation = new Operation
            {
                Method = apiDescription.HttpMethod.Method,
                Nickname = apiDescription.Nickname(),
                Summary = apiDescription.Documentation ?? "",
                Parameters = parameters,
                ResponseMessages = new List<ResponseMessage>(),
                Produces = apiDescription.SupportedResponseFormatters.SelectMany(d => d.SupportedMediaTypes.Select(t => t.MediaType)).ToList(),
                Consumes = apiDescription.SupportedRequestBodyFormatters.SelectMany(d => d.SupportedMediaTypes.Select(t => t.MediaType)).ToList()
            };

            var responseType = apiDescription.ActualResponseType();
            if (responseType == null)
            {
                operation.Type = "void";
            }
            else
            {
                var dataType = _dataTypeRegistry.GetOrRegister(responseType);
                if (dataType.Type == "object")
                {
                    operation.Type = dataType.Id;
                }
                else
                {
                    operation.Type = dataType.Type;
                    operation.Format = dataType.Format;
                    operation.Items = dataType.Items;
                    operation.Enum = dataType.Enum;
                }
            }

            foreach (var filter in _operationFilters)
            {
                filter.Apply(operation, _dataTypeRegistry, apiDescription);
            }

            return operation;
        }
开发者ID:AnthonyNeace,项目名称:Swashbuckle,代码行数:46,代码来源:OperationGenerator.cs

示例4: 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;
        }
开发者ID:shaunparsloe,项目名称:Swashbuckle,代码行数:35,代码来源:SwaggerGenerator.cs

示例5: 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;
        }
开发者ID:bigred8982,项目名称:Swashbuckle.OData,代码行数:46,代码来源:ODataSwaggerProvider.cs

示例6: GetParameterLocation

 private string GetParameterLocation(ApiDescription apiDesc, ApiParameterDescription paramDesc)
 {
     if (apiDesc.RelativePathSansQueryString().Contains("{" + paramDesc.Name + "}"))
         return "path";
     else if (paramDesc.Source == ApiParameterSource.FromBody && apiDesc.HttpMethod != HttpMethod.Get)
         return "body";
     else
         return "query";
 }
开发者ID:sk8tz,项目名称:Swashbuckle,代码行数:9,代码来源:SwaggerGenerator.cs


注:本文中的System.Web.Http.Description.ApiDescription.RelativePathSansQueryString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。