예제 #1
0
        public IActionResult Get()
        {
            var graphOpenApi = FilterOpenApiService.GetGraphOpenApiV1();

            WriteIndex(graphOpenApi, Response.Body);

            return(new EmptyResult());
        }
예제 #2
0
        public IActionResult Getv10()
        {
            var graphOpenApi = FilterOpenApiService.GetGraphOpenApiV1();

            Response.Headers["Content-Type"] = "text/html";
            WriteIndex(graphOpenApi, Response.Body);

            return(new EmptyResult());
        }
예제 #3
0
        public IActionResult Get(string version = "v1.0",
                                 [FromQuery] string operationIds   = null,
                                 [FromQuery] string tags           = null,
                                 [FromQuery] string openApiVersion = "2",
                                 [FromQuery] string title          = "Partial Graph API",
                                 [FromQuery] OpenApiStyle style    = OpenApiStyle.Plain,
                                 [FromQuery] string format         = "yaml")
        {
            OpenApiDocument graphOpenApi = null;

            switch (version)
            {
            case "v1.0":
                graphOpenApi = FilterOpenApiService.GetGraphOpenApiV1();
                break;

            case "beta":
                graphOpenApi = FilterOpenApiService.GetGraphOpenApiBeta();
                break;

            default:
                return(new NotFoundResult());
            }

            if (operationIds != null && tags != null)
            {
                return(new BadRequestResult());
            }

            Func <OpenApiOperation, bool> predicate = null;

            if (operationIds != null)
            {
                if (operationIds == "*")
                {
                    predicate = (o) => true;  // All operations
                }
                else
                {
                    var operationIdsArray = operationIds.Split(',');
                    predicate = (o) => operationIdsArray.Contains(o.OperationId);
                }
            }
            else if (tags != null)
            {
                var tagsArray = tags.Split(',');
                predicate = (o) => o.Tags.Any(t => tagsArray.Contains(t.Name));
            }
            else
            {
                return(new NotFoundResult());
            }

            var subsetOpenApiDocument = FilterOpenApiService.CreateFilteredDocument(title, version, graphOpenApi, predicate);

            FilterOpenApiService.CopyReferences(graphOpenApi, subsetOpenApiDocument);

            if (style == OpenApiStyle.PowerPlatform || style == OpenApiStyle.Powershell)
            {
                // Clone doc before making changes
                subsetOpenApiDocument = Clone(subsetOpenApiDocument);

                var anyOfRemover = new AnyOfRemover();
                var walker       = new OpenApiWalker(anyOfRemover);
                walker.Walk(subsetOpenApiDocument);
            }

            return(CreateResult(openApiVersion, subsetOpenApiDocument, format));
        }