Use Mintlify.Core to programmatically create, validate, and manage Mintlify docs.json configurations in C# with full type safety and IntelliSense support
Mintlify.Core is a comprehensive .NET library that provides strongly-typed models, validation, and management tools for Mintlify documentation configurations. Built by the
CloudNimble team and used by DotNetDocs, it enables C# developers to programmatically generate, modify, and validate docs.json files with full IntelliSense support.
The root configuration object representing the complete docs.json schema:
Copy
Ask AI
public class DocsJsonConfig{ [NotNull] public string Name { get; set; } // Required [NotNull] public string Theme { get; set; } // Required: mint, maple, palm, etc. [NotNull] public ColorsConfig Colors { get; set; } // Required: Primary color minimum [NotNull] public NavigationConfig Navigation { get; set; } // Required public string? Description { get; set; } // SEO description public LogoConfig? Logo { get; set; } // Light/dark logos public FaviconConfig? Favicon { get; set; } // Favicon paths public FooterConfig? Footer { get; set; } // Footer configuration public NavbarConfig? Navbar { get; set; } // Top navigation public ApiConfig? Api { get; set; } // API playground settings public SeoConfig? Seo { get; set; } // SEO settings public AppearanceConfig? Appearance { get; set; } // Light/dark mode public StylingConfig? Styling { get; set; } // Custom CSS/styling public IntegrationsConfig? Integrations { get; set; } // Analytics, support, etc. // ... and 10+ more optional configuration properties}
All required properties are marked with [NotNull] and will generate compiler warnings if not set. Use the DocsJsonValidator to catch configuration issues at runtime.
Defines the documentation structure with support for pages, groups, tabs, anchors, and more:
Copy
Ask AI
public class NavigationConfig{ public List<object>? Pages { get; set; } // Mix of strings and GroupConfig public List<GroupConfig>? Groups { get; set; } // Named groups public List<TabConfig>? Tabs { get; set; } // Top-level tabs public List<AnchorConfig>? Anchors { get; set; } // Sidebar anchors public List<DropdownConfig>? Dropdowns { get; set; } // Dropdown menus public List<LanguageConfig>? Languages { get; set; } // Language switcher public List<VersionConfig>? Versions { get; set; } // Version switcher public GlobalNavigationConfig? Global { get; set; } // Global nav items}
Pages Property: The Pages property is polymorphic - it can contain both string (page paths) and GroupConfig objects (nested groups):
Copy
Ask AI
config.Navigation.Pages = new List<object>{ "index", // Simple page reference "quickstart", new GroupConfig // Nested group { Group = "Guides", Pages = new List<object> { "guides/intro", "guides/advanced" } }};
public class GroupConfig{ [NotNull] public string Group { get; set; } // Group title (required) public List<object>? Pages { get; set; } // Nested pages/groups public IconConfig? Icon { get; set; } // Group icon public string? Tag { get; set; } // Badge text (e.g., "NEW", "BETA") public string? Root { get; set; } // Root page URL public bool? Hidden { get; set; } // Hide from navigation public ApiSpecConfig? OpenApi { get; set; } // OpenAPI spec path public ApiSpecConfig? AsyncApi { get; set; } // AsyncAPI spec path}
Nested Groups: Groups can contain other groups for hierarchical navigation:
Copy
Ask AI
new GroupConfig{ Group = "API Reference", Pages = new List<object> { "api/overview", new GroupConfig { Group = "Authentication", Pages = new List<object> { "api/auth/oauth", "api/auth/api-keys" } } }}
Theme color configuration with hex color validation:
Copy
Ask AI
public class ColorsConfig{ [NotNull] public string Primary { get; set; } = "#000000"; // Required public string? Light { get; set; } // Light mode accent (used in dark mode) public string? Dark { get; set; } // Dark mode accent (used in light mode)}
All colors must be valid hex format: #RRGGBB or #RGB. The validator will catch invalid formats.
var manager = new DocsJsonManager();// Load from filemanager = new DocsJsonManager("path/to/docs.json");manager.Load();// Load from stringmanager.Load(jsonString);// Load from config objectmanager.Load(docsConfig);// Save back to filemanager.Save();manager.Save("path/to/output.json");
Create Default Configuration
Copy
Ask AI
var config = DocsJsonManager.CreateDefault("Project Name", "maple");// Returns a DocsJsonConfig with sensible defaults:// - Basic Getting Started and API Reference groups// - Default color scheme// - Standard navigation structure
// Load base configurationmanager.Load(baseConfig);// Merge another configurationmanager.Merge(otherConfig, combineBaseProperties: true);// Merge just navigation from a filemanager.MergeNavigation("external-docs.json");// Merge navigation from a config objectmanager.MergeNavigation(externalConfig.Navigation);
Add Pages Safely
Copy
Ask AI
// Add page to navigation rootmanager.AddPage(manager.Configuration.Navigation.Pages, "new-page");// Add page to specific group pathmanager.AddPage("Getting Started/Tutorials", "tutorial-1");// Add page to group with duplicate detectionvar group = manager.FindOrCreateGroup(pages, "My Group");if (manager.AddPageToGroup(group, "my-page")){ Console.WriteLine("Page added successfully");}else{ Console.WriteLine("Page already exists, skipped");}
Check Known Paths
Copy
Ask AI
// The manager tracks all added paths internallyif (manager.IsPathKnown("api-reference/index")){ Console.WriteLine("This page is already in navigation");}
var config = new DocsJsonConfig{ Name = "", // Invalid: empty Theme = "custom", // Invalid: not a valid theme Colors = new ColorsConfig { Primary = "blue" } // Invalid: not hex format};var errors = validator.Validate(config);// Returns:// - "Name is required."// - "Invalid theme 'custom'. Valid themes are: mint, maple, palm, willow, linden, almond, aspen"// - "Primary color 'blue' must be a valid hex color (e.g., #FF0000 or #F00)."
using System.Text.Json;using Mintlify.Core;// Serialize with proper formattingvar json = JsonSerializer.Serialize(config, MintlifyConstants.JsonSerializerOptions);// Deserialize with proper type handlingvar config = JsonSerializer.Deserialize<DocsJsonConfig>(json, MintlifyConstants.JsonSerializerOptions);
var manager = new DocsJsonManager();// Create base configurationvar baseConfig = DocsJsonManager.CreateDefault("Multi-Project Docs", "maple");manager.Load(baseConfig);// Add Project A navigationvar projectANav = new NavigationConfig{ Pages = new List<object> { new GroupConfig { Group = "Project A", Pages = new List<object> { "project-a/overview", "project-a/api" } } }};manager.MergeNavigation(projectANav);// Add Project B navigationvar projectBNav = new NavigationConfig{ Pages = new List<object> { new GroupConfig { Group = "Project B", Pages = new List<object> { "project-b/overview", "project-b/api" } } }};manager.MergeNavigation(projectBNav);manager.Save("docs.json");
// Create custom navigation for a specific directoryvar customGroup = new GroupConfig{ Group = "Advanced Topics", Icon = new IconConfig { Name = "graduation-cap" }, Pages = new List<object> { "advanced/architecture", "advanced/performance", new GroupConfig { Group = "Security", Pages = new List<object> { "advanced/security/authentication", "advanced/security/authorization" } } }};// Serialize to navigation.jsonvar json = JsonSerializer.Serialize(customGroup, MintlifyConstants.JsonSerializerOptions);File.WriteAllText("docs/advanced/navigation.json", json);