public IDocument Build()

in src/Microsoft.Azure.Functions.Worker.Extensions.OpenApi/Document.cs [139:203]


        public IDocument Build(Assembly assembly, OpenApiVersionType version = OpenApiVersionType.V2)
        {
            if (GenericExtensions.IsNullOrDefault(this._strategy))
            {
                this._strategy = new DefaultNamingStrategy();
            }

            var paths = new OpenApiPaths();

            var tags = StringExtensions.ToArray(this._req.Query["tag"], ",");
            var methods = this._helper.GetHttpTriggerMethods(assembly, tags);
            foreach (var method in methods)
            {
                var trigger = this._helper.GetHttpTriggerAttribute(method);
                if (GenericExtensions.IsNullOrDefault(trigger))
                {
                    continue;
                }

                var function = this._helper.GetFunctionNameAttribute(method);
                if (GenericExtensions.IsNullOrDefault(function))
                {
                    continue;
                }

                var path = this._helper.GetHttpEndpoint(function, trigger);
                if (StringExtensions.IsNullOrWhiteSpace(path))
                {
                    continue;
                }

                var verb = this._helper.GetHttpVerb(trigger);

                var item = this._helper.GetOpenApiPath(path, paths);
                var operations = item.Operations;

                var operation = this._helper.GetOpenApiOperation(method, function, verb);
                if (GenericExtensions.IsNullOrDefault(operation))
                {
                    continue;
                }

                operation.Security = this._helper.GetOpenApiSecurityRequirement(method, this._strategy);
                operation.Parameters = this._helper.GetOpenApiParameters(method, trigger, this._strategy, this._collection, version);
                operation.RequestBody = this._helper.GetOpenApiRequestBody(method, this._strategy, this._collection, version);
                operation.Responses = this._helper.GetOpenApiResponses(method, this._strategy, this._collection, version);

                operations[verb] = operation;
                item.Operations = operations;

                paths[path] = item;
            }

            this.OpenApiDocument.Paths = paths;
            this.OpenApiDocument.Components.Schemas = this._helper.GetOpenApiSchemas(methods, this._strategy, this._collection);
            this.OpenApiDocument.Components.SecuritySchemes = this._helper.GetOpenApiSecuritySchemes(methods, this._strategy);
            // this.OpenApiDocument.SecurityRequirements = this.OpenApiDocument
            //                                                 .Paths
            //                                                 .SelectMany(p => p.Value.Operations.SelectMany(q => q.Value.Security))
            //                                                 .Where(p => !p.IsNullOrDefault())
            //                                                 .Distinct(new OpenApiSecurityRequirementComparer())
            //                                                 .ToList();

            return this;
        }