internal IEnumerable <Controller> CreateControllers() { return(Document.Paths .SelectMany(path => path.Value .Select(operation => new { Tag = operation.Value.Tags.First(), // dismiss further tags?! Operation = CreateOperation(path.Key.ToString(), operation.Key, operation.Value) })) .GroupBy(a => a.Tag, a => a.Operation, (tag, operations1) => new { Tag = tag, Operations = operations1 }) .LeftJoin(Document.Tags ?? Enumerable.Empty <SwaggerTag>(), a => a.Tag, tag => tag.Name, (a, tag) => new Controller() { Name = a.Tag, Description = tag?.Description, Host = $"{Document.Schemes.Select(scheme => scheme.ToString().ToLower()).LastOrDefault() ?? "http"}://{Document.Host}{(Document.BasePath == "/" ? "" : Document.BasePath)}", Operations = a.Operations.ToList() })); }