예제 #1
0
        private ApiExplorerData CreateSerializableData(ApiDescription description)
        {
            var data = new ApiExplorerData()
            {
                GroupName = description.GroupName,
                HttpMethod = description.HttpMethod,
                RelativePath = description.RelativePath,
                ResponseType = description.ResponseType?.FullName,
            };

            foreach (var parameter in description.ParameterDescriptions)
            {
                var parameterData = new ApiExplorerParameterData()
                {
                    Name = parameter.Name,
                    Source = parameter.Source.Id,
                    Type = parameter.Type?.FullName,
                };

                if (parameter.RouteInfo != null)
                {
                    parameterData.RouteInfo = new ApiExplorerParameterRouteInfo()
                    {
                        ConstraintTypes = parameter.RouteInfo.Constraints?.Select(c => c.GetType().Name).ToArray(),
                        DefaultValue = parameter.RouteInfo.DefaultValue,
                        IsOptional = parameter.RouteInfo.IsOptional,
                    };
                }

                data.ParameterDescriptions.Add(parameterData);
            }

            foreach (var response in description.SupportedResponseFormats)
            {
                var responseData = new ApiExplorerResponseData()
                {
                    FormatterType = response.Formatter.GetType().FullName,
                    MediaType = response.MediaType.ToString(),
                };

                data.SupportedResponseFormats.Add(responseData);
            }

            return data;
        }
        private ApiExplorerData CreateSerializableData(ApiDescription description)
        {
            var data = new ApiExplorerData()
            {
                GroupName    = description.GroupName,
                HttpMethod   = description.HttpMethod,
                RelativePath = description.RelativePath,
                ResponseType = description.ResponseType?.FullName,
            };

            foreach (var parameter in description.ParameterDescriptions)
            {
                var parameterData = new ApiExplorerParameterData()
                {
                    Name   = parameter.Name,
                    Source = parameter.Source.Id,
                    Type   = parameter.Type?.FullName,
                };

                if (parameter.RouteInfo != null)
                {
                    parameterData.RouteInfo = new ApiExplorerParameterRouteInfo()
                    {
                        ConstraintTypes = parameter.RouteInfo.Constraints?.Select(c => c.GetType().Name).ToArray(),
                        DefaultValue    = parameter.RouteInfo.DefaultValue,
                        IsOptional      = parameter.RouteInfo.IsOptional,
                    };
                }

                data.ParameterDescriptions.Add(parameterData);
            }

            foreach (var response in description.SupportedResponseFormats)
            {
                var responseData = new ApiExplorerResponseData()
                {
                    FormatterType = response.Formatter.GetType().FullName,
                    MediaType     = response.MediaType.ToString(),
                };

                data.SupportedResponseFormats.Add(responseData);
            }

            return(data);
        }
예제 #3
0
        private ApiExplorerData CreateSerializableData(ApiDescription description)
        {
            var data = new ApiExplorerData()
            {
                GroupName    = description.GroupName,
                HttpMethod   = description.HttpMethod,
                RelativePath = description.RelativePath,
                ResponseType = description.ResponseType?.FullName,
            };

            foreach (var parameter in description.ParameterDescriptions)
            {
                var parameterData = new ApiExplorerParameterData()
                {
                    IsOptional     = parameter.IsOptional,
                    Name           = parameter.Name,
                    Source         = parameter.Source.ToString(),
                    Type           = parameter?.Type?.FullName,
                    ConstraintType = parameter?.Constraint?.GetType()?.Name,
                };

                data.ParameterDescriptions.Add(parameterData);
            }

            foreach (var response in description.SupportedResponseFormats)
            {
                var responseData = new ApiExplorerResponseData()
                {
                    FormatterType = response.Formatter.GetType().FullName,
                    MediaType     = response.MediaType.RawValue,
                };

                data.SupportedResponseFormats.Add(responseData);
            }

            return(data);
        }