private IEnumerable <Tuple <string, PathItem> > BuildPaths(
            string resource, SchemaRegistry registry, IEnumerable <PolicyMemberBinding> bindings)
        {
            return(bindings.Select(x =>
            {
                var requestType = x.Key as Type;
                if (requestType == null || requestType.IsAbstract ||
                    requestType.ContainsGenericParameters)
                {
                    return null;
                }
                var responseType = x.Dispatcher.LogicalReturnType;
                var handler = x.Dispatcher.Owner.HandlerType;
                var assembly = requestType.Assembly.GetName();
                var tag = $"{assembly.Name} - {assembly.Version}";
                var requestSchema = GetMessageSchema(registry, requestType);
                var responseSchema = GetMessageSchema(registry, responseType);
                var requestPath = HttpOptionsExtensions.GetRequestPath(requestType);

                var requestSummary = GetReferencedSchema(registry,
                                                         registry.GetOrRegister(requestType))?.description;

                var handlerAssembly = handler.Assembly.GetName();
                var handlerNotes = $"Handled by {handler.FullName} in {handlerAssembly.Name} - {handlerAssembly.Version}";

                var operation = new Operation
                {
                    summary = requestSummary,
                    operationId = requestType.FullName,
                    description = handlerNotes,
                    tags = new List <string> {
                        tag
                    },
                    consumes = JsonFormats,
                    produces = JsonFormats,
                    parameters = new List <Parameter>
                    {
                        new Parameter
                        {
                            @in = "body",
                            name = "message",
                            description = "request to process",
                            schema = requestSchema,
                            required = true
                        }
                    },
                    responses = new Dictionary <string, Response>
                    {
                        {
                            "200", new Response
                            {
                                description = "OK",
                                schema = responseSchema
                            }
                        }
                    }
                };

                if (Operations != null && Operations.GetInvocationList()
                    .Cast <Func <Operation, bool> >()
                    .Any(op => !op(operation)))
                {
                    return null;
                }

                return Tuple.Create($"/{resource}/{requestPath}", new PathItem
                {
                    post = operation
                });
            }).Where(p => p != null));
        }
        private IEnumerable <Tuple <string, OpenApiPathItem> > BuildPaths(
            string resource, DocumentFilterContext context,
            IEnumerable <PolicyMemberBinding> bindings)
        {
            var validationErrorsSchema = context.SchemaGenerator.GenerateSchema(
                typeof(ValidationErrors[]), context.SchemaRepository);

            validationErrorsSchema.Example = CreateExampleJson(new[]
            {
                new ValidationErrors
                {
                    PropertyName = "SomeProperty",
                    Errors       = new [] { "'Some Property' is required" },
                    Nested       = new []
                    {
                        new ValidationErrors
                        {
                            PropertyName = "NestedProperty",
                            Errors       = new [] { "'Nested Property' not in range" }
                        }
                    }
                }
            });

            return(bindings.Select(x =>
            {
                var requestType = x.Key as Type;
                if (requestType == null || requestType.IsAbstract ||
                    requestType.ContainsGenericParameters)
                {
                    return null;
                }

                var responseType = x.Dispatcher.LogicalReturnType;
                var handler = x.Dispatcher.Owner.HandlerType;
                var assembly = requestType.Assembly.GetName();
                var tag = $"{assembly.Name} - {assembly.Version}";
                var requestSchema = GetMessageSchema(requestType, context);
                var responseSchema = GetMessageSchema(responseType, context);
                var requestPath = HttpOptionsExtensions.GetRequestPath(requestType);
                var handlerAssembly = handler.Assembly.GetName();
                var handlerNotes = $"Handled by {handler.FullName} in {handlerAssembly.Name} - {handlerAssembly.Version}";

                var operation = new OpenApiOperation
                {
                    Summary = requestSchema.Description,
                    OperationId = requestType.FullName,
                    Description = handlerNotes,
                    Tags = new List <OpenApiTag> {
                        new() { Name = tag }
                    },
                    RequestBody = new OpenApiRequestBody
                    {
                        Description = "request to process",
                        Content = JsonFormats.Select(f =>
                                                     new { Format = f, Media = new OpenApiMediaType
                                                           {
                                                               Schema = requestSchema,
                                                               Example = requestSchema.Example
                                                           } }).ToDictionary(f => f.Format, f => f.Media),
                        Required = true
                    },
                    Responses =
                    {
                        {
                            "200", new OpenApiResponse
                            {
                                Description = "OK",
                                Content = JsonFormats.Select(f =>
                                                             new   { Format = f, Media = new OpenApiMediaType
                                                                     {
                                                                         Schema = responseSchema,
                                                                         Example = responseSchema.Example
                                                                     } }).ToDictionary(f => f.Format, f => f.Media)
                            }
                        },