private PathItem CreatePathItem(IEnumerable<ApiDescription> apiDescriptions, ISchemaRegistry schemaRegistry) { var pathItem = new PathItem(); // Group further by http method var perMethodGrouping = apiDescriptions .GroupBy(apiDesc => apiDesc.HttpMethod); foreach (var group in perMethodGrouping) { var httpMethod = group.Key; if (httpMethod == null) throw new NotSupportedException(string.Format( "Unbounded HTTP verbs for path '{0}'. Are you missing an HttpMethodAttribute?", group.First().RelativePathSansQueryString())); if (group.Count() > 1) throw new NotSupportedException(string.Format( "Multiple operations with path '{0}' and method '{1}'. Are you overloading action methods?", group.First().RelativePathSansQueryString(), httpMethod)); var apiDescription = group.Single(); switch (httpMethod) { case "GET": pathItem.Get = CreateOperation(apiDescription, schemaRegistry); break; case "PUT": pathItem.Put = CreateOperation(apiDescription, schemaRegistry); break; case "POST": pathItem.Post = CreateOperation(apiDescription, schemaRegistry); break; case "DELETE": pathItem.Delete = CreateOperation(apiDescription, schemaRegistry); break; case "OPTIONS": pathItem.Options = CreateOperation(apiDescription, schemaRegistry); break; case "HEAD": pathItem.Head = CreateOperation(apiDescription, schemaRegistry); break; case "PATCH": pathItem.Patch = CreateOperation(apiDescription, schemaRegistry); break; } } return pathItem; }
private PathItem CreatePathItem(IEnumerable <ApiDescription> apiDescriptions, ISchemaRegistry schemaRegistry) { var pathItem = new PathItem(); // Group further by http method var perMethodGrouping = apiDescriptions .GroupBy(apiDesc => apiDesc.HttpMethod); foreach (var group in perMethodGrouping) { var httpMethod = group.Key; if (httpMethod == null) { throw new NotSupportedException(string.Format( "Ambiguous HTTP method for action - {0}. " + "Actions require an explicit HttpMethod binding for Swagger", group.First().ActionDescriptor.DisplayName)); } if (group.Count() > 1) { throw new NotSupportedException(string.Format( "HTTP method \"{0}\" & path \"{1}\" overloaded by actions - {2}. " + "Actions require unique method/path combination for Swagger", httpMethod, group.First().RelativePathSansQueryString(), string.Join(",", group.Select(apiDesc => apiDesc.ActionDescriptor.DisplayName)))); } var apiDescription = group.Single(); switch (httpMethod) { case "GET": pathItem.Get = CreateOperation(apiDescription, schemaRegistry); break; case "PUT": pathItem.Put = CreateOperation(apiDescription, schemaRegistry); break; case "POST": pathItem.Post = CreateOperation(apiDescription, schemaRegistry); break; case "DELETE": pathItem.Delete = CreateOperation(apiDescription, schemaRegistry); break; case "OPTIONS": pathItem.Options = CreateOperation(apiDescription, schemaRegistry); break; case "HEAD": pathItem.Head = CreateOperation(apiDescription, schemaRegistry); break; case "PATCH": pathItem.Patch = CreateOperation(apiDescription, schemaRegistry); break; } } return(pathItem); }
private PathItem CreatePathItem(IEnumerable <ApiDescription> apiDescriptions, ISchemaRegistry schemaRegistry) { var pathItem = new PathItem(); // Group further by http method var perMethodGrouping = apiDescriptions .GroupBy(apiDesc => apiDesc.HttpMethod); foreach (var group in perMethodGrouping) { var httpMethod = group.Key; if (httpMethod == null) { throw new NotSupportedException(string.Format( "Unbounded HTTP verbs for path '{0}'. Are you missing an HttpMethodAttribute?", group.First().RelativePathSansQueryString())); } if (group.Count() > 1) { throw new NotSupportedException(string.Format( "Multiple operations with path '{0}' and method '{1}'. Are you overloading action methods?", group.First().RelativePathSansQueryString(), httpMethod)); } var apiDescription = group.Single(); switch (httpMethod) { case "GET": pathItem.Get = CreateOperation(apiDescription, schemaRegistry); break; case "PUT": pathItem.Put = CreateOperation(apiDescription, schemaRegistry); break; case "POST": pathItem.Post = CreateOperation(apiDescription, schemaRegistry); break; case "DELETE": pathItem.Delete = CreateOperation(apiDescription, schemaRegistry); break; case "OPTIONS": pathItem.Options = CreateOperation(apiDescription, schemaRegistry); break; case "HEAD": pathItem.Head = CreateOperation(apiDescription, schemaRegistry); break; case "PATCH": pathItem.Patch = CreateOperation(apiDescription, schemaRegistry); break; } } return(pathItem); }
private PathItem CreatePathItem(IEnumerable <ApiDescription> apiDescriptions, ISchemaRegistry schemaRegistry) { var pathItem = new PathItem(); // Group further by http method var perMethodGrouping = apiDescriptions .GroupBy(apiDesc => apiDesc.HttpMethod); foreach (var group in perMethodGrouping) { var httpMethod = group.Key; if (string.IsNullOrWhiteSpace(httpMethod)) { throw new NotSupportedException(string.Format( "Unbounded HTTP verbs for path '{0}'. Are you missing an HttpMethodAttribute?", group.First().RelativePathSansQueryString())); } ApiDescription apiDescription; if (group.Count() > 1) { apiDescription = _options.ResolveConflict(group.Select(x => x), httpMethod); } else { apiDescription = group.Single(); } switch (httpMethod) { case "GET": pathItem.Get = CreateOperation(apiDescription, schemaRegistry); break; case "PUT": pathItem.Put = CreateOperation(apiDescription, schemaRegistry); break; case "POST": pathItem.Post = CreateOperation(apiDescription, schemaRegistry); break; case "DELETE": pathItem.Delete = CreateOperation(apiDescription, schemaRegistry); break; case "OPTIONS": pathItem.Options = CreateOperation(apiDescription, schemaRegistry); break; case "HEAD": pathItem.Head = CreateOperation(apiDescription, schemaRegistry); break; case "PATCH": pathItem.Patch = CreateOperation(apiDescription, schemaRegistry); break; } } return(pathItem); }