Overview
OpenDocs uses JSON Schema$ref to organize documentation, making file structure flexible. Only opendocs.json is required—everything else can be referenced via $ref.
Using $ref
The$ref keyword (defined in RFC 3986) allows JSON documents to reference content in other locations using URI references. OpenDocs uses $ref to split large documentation sets across multiple files.
Basic syntax:
./projects/auth.json should contain a complete Project object.
For a comprehensive guide on $ref usage, see the Swagger $ref documentation.
Key Principle: File Organization is Flexible
Since OpenDocs relies on JSON Schema$ref, the physical directory structure and file naming conventions are completely flexible. You can organize your documentation files however you prefer:
- All content can be embedded in
opendocs.json - Content can be split across multiple files using
$ref - Files can be named and organized in any directory structure
- The only requirement is that
opendocs.jsonmust exist as the entry point
Example: Using $ref for Flexibility
File Structure
Documentation Set Layout
Since OpenDocs uses JSON Schema$ref, the physical file organization is irrelevant. The only required file is opendocs.json:
Organization Strategies
You can organize your Documentation Set in two main ways:- Monolithic - All content embedded in
opendocs.json - Distributed - Content split across multiple files using
$ref
Example: Monorepo Documentation Set
This example shows a monorepo with multiple projects. We’ll show both the monolithic approach (everything embedded) and the distributed approach (split using$ref).
Monolithic Approach
Everything in a singleopendocs.json file:
Distributed Approach
The same documentation split across multiple files using$ref:
opendocs.json:
File and Directory Naming
Since OpenDocs uses$ref, file names and directory structure are completely flexible. Use whatever organization makes sense for your project:
Best Practices
ID Conventions
Use consistent, predictable naming for IDs: Documentation Set IDs:lowercase-with-hyphens
- Example:
acme-platform-docs
lowercase-with-hyphens
- Example:
auth-service,web-sdk,shared-types
project-id#item-path
- Top-level:
auth-service#AuthController - Nested:
auth-service#AuthController#Login - Deep nesting:
auth-service#api#v2#AuthController#Login
- Use
#to separate OpenDocs components - Use
::for namespace-style IDs (Rust):serde::de::Deserialize - Use
.for package-style IDs (TypeScript):@acme/utils.StringHelper
Project Organization
- Use meaningful IDs -
auth-servicenotproj1 - Declare dependencies - Help tools understand relationships between projects
- Include versions - Track documentation evolution over time
Next Steps
- Learn about the OpenDocs Model to understand Projects, DocItems, and DocBlocks
- Explore the Design Principles behind OpenDocs
RFC Feedback
This file organization specification is part of the OpenDocs RFC. Please provide feedback on:- File organization patterns and use cases
$refusage and resolution strategies- ID naming conventions and best practices
- Any confusion or unclear aspects

