Thank you for your interest in contributing to RustAPI! We welcome contributions of all kinds - bug reports, feature requests, documentation improvements, and code contributions.
- Code of Conduct
- Getting Started
- Development Setup
- Making Changes
- Testing
- Code Style
- Pull Request Process
- Project Structure
- Release Process
- Getting Help
By participating in this project, you agree to maintain a respectful and inclusive environment for everyone.
To maintain repository stability and code quality, we enforce the following policies:
- Branch Protection: The
mainbranch is protected. Direct pushes are disabled. - Pull Requests: All changes must be submitted via Pull Request.
- Linear History: We use Squash Merges to keep the history clean and linear. Merge commits are disabled.
- Force Pushes: Force pushes to
mainare strictly prohibited.
New to open source? Check out these resources:
- Fork the repository - Click the "Fork" button on GitHub
- Clone your fork:
git clone https://github.com/YOUR-USERNAME/RustAPI.git cd RustAPI - Add upstream remote:
git remote add upstream https://github.com/Tuntii/RustAPI.git
- Create a new branch:
git checkout -b feature/your-feature-name
- Make your changes (see guidelines below)
- Test your changes:
cargo test --workspace cargo clippy --workspace -- -D warnings cargo fmt --all -- --check - Commit and push:
git add . git commit -m "feat: add awesome feature" git push origin feature/your-feature-name
- Create a Pull Request on GitHub
- Rust 1.75 or later - Install from rustup.rs
- Git - For version control
- Code editor - VS Code with rust-analyzer recommended
# Build all crates
cargo build --workspace
# Build with all features
cargo build --workspace --all-features
# Build specific crate
cargo build -p rustapi-core
# Build in release mode
cargo build --workspace --release# Run a specific example
cargo run -p hello-world
# List all examples
ls examples/- Look for issues labeled
good first issueorhelp wanted - Check the project board for planned features
- Feel free to propose new features in an issue first
- Check existing issues - Someone might already be working on it
- Discuss large changes - Open an issue to discuss your approach
- Keep PRs focused - One feature/fix per PR
- 🐛 Bug Fixes - Fix issues and add regression tests
- ✨ New Features - Add new functionality
- 📝 Documentation - Improve docs, add examples
- 🎨 Code Quality - Refactoring, performance improvements
- ✅ Tests - Add test coverage
- 🔧 Tooling - Improve build scripts, CI/CD
# Run all tests
cargo test --workspace
# Run tests with all features
cargo test --workspace --all-features
# Run tests for a specific crate
cargo test -p rustapi-core
# Run a specific test
cargo test test_name
# Run tests with output
cargo test -- --nocapture
# Run property tests (may take longer)
cargo test --workspace --release- Add unit tests in the same file as the code
- Add integration tests in
tests/directory - Use property-based testing with
proptestfor complex logic - Test error cases and edge cases
- Add doc tests for public APIs
Example:
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_feature() {
// Arrange
let input = setup_test_data();
// Act
let result = your_function(input);
// Assert
assert_eq!(result, expected);
}
}All code must be formatted with rustfmt:
# Format all code
cargo fmt --all
# Check formatting without making changes
cargo fmt --all -- --checkConfiguration is in rustfmt.toml.
All code must pass clippy checks:
# Run clippy on all crates
cargo clippy --workspace --all-features -- -D warnings
# Run clippy with specific lint levels
cargo clippy --workspace -- -W clippy::all -D warnings- Public APIs must have rustdoc comments
- Use
///for item documentation - Use
//!for module documentation - Include code examples in doc comments
- Doc examples must compile and run
Example:
/// Handles HTTP requests using the registered routes.
///
/// # Example
///
/// ```rust
/// use rustapi_rs::prelude::*;
///
/// #[rustapi_rs::get("/hello")]
/// async fn hello() -> &'static str {
/// "Hello, World!"
/// }
/// ```
pub async fn handle_request() { }- Use
snake_casefor functions, variables, modules - Use
PascalCasefor types, traits, enums - Use
SCREAMING_SNAKE_CASEfor constants - Prefix private items with underscore if unused
- Use descriptive names, avoid abbreviations
- Use
Result<T, E>for fallible operations - Use
thiserrorfor custom error types - Provide helpful error messages
- Document error conditions in rustdoc
- Provide helpful error messages
To ensure rustapi-rs remains stable and reliable, please follow these API design rules:
- Visibility: Prefer
pub(crate)by default. Only expose items that are intended for end-users. - Unsafe Code: avoid
unsafeunless absolutely necessary.- All
unsafeblocks must have a// SAFETY: ...comment explaining why it is safe. - Miri tests should be added for unsafe code.
- All
- SemVer: We strictly follow semantic versioning.
- Breaking changes to public APIs require a MAJOR version bump.
- Additions require a MINOR version bump.
- Patches must be backwards compatible.
Follow Conventional Commits:
feat: add new feature- New functionalityfix: resolve bug in router- Bug fixesdocs: update API documentation- Documentation changesrefactor: restructure handler logic- Code refactoringtest: add router tests- Test additions/changesperf: optimize route matching- Performance improvementschore: update dependencies- Maintenance tasksci: update GitHub Actions- CI/CD changes
Before submitting, ensure:
- Code follows style guidelines (
cargo fmt,cargo clippy) - All tests pass (
cargo test --workspace) - New tests added for new functionality
- Documentation updated (if applicable)
- Examples added/updated (if applicable)
- CHANGELOG.md updated (for significant changes)
- No breaking changes (or clearly documented)
- PR description explains what and why
When creating a PR, include:
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Related Issues
Fixes #123, Closes #456
## Testing
- Describe how you tested the changes
- Include relevant test commands
## Screenshots (if applicable)
Add screenshots for UI changes
## Checklist
- [ ] Tests pass locally
- [ ] Code is formatted
- [ ] Documentation updated- Automated checks run on your PR (tests, formatting, clippy)
- Maintainer review - May request changes
- Address feedback - Push updates to your branch
- Approval - Once approved, PR will be merged
- Merge - Squash merge to main branch
- Your changes will be in the next release
- You'll be credited in CHANGELOG.md
- Thank you for contributing! 🎉
- Write clear, concise commit messages
- Use present tense ("Add feature" not "Added feature")
- Use imperative mood ("Move cursor to..." not "Moves cursor to...")
- Reference issues when applicable (
Fixes #123,Closes #456) - Limit first line to 72 characters
- Add detailed description in commit body if needed
Good commit messages:
feat: add WebSocket support to core router
Implement WebSocket handler registration and upgrade logic.
Includes connection lifecycle management and message handling.
Fixes #123
fix: resolve path parameter parsing issue
Path parameters with special characters were not properly decoded.
Now using percent-decoding for all path params.
Closes #456
RustAPI/
├── crates/
│ ├── rustapi-rs/ # 🎯 Public-facing crate (re-exports)
│ ├── rustapi-core/ # ⚙️ Core HTTP engine and routing
│ ├── rustapi-macros/ # 🔧 Procedural macros (#[get], #[post], etc.)
│ ├── rustapi-validate/ # ✅ Validation integration (validator crate)
│ ├── rustapi-openapi/ # 📚 OpenAPI/Swagger documentation
│ ├── rustapi-extras/ # 🎁 Optional features (JWT, CORS, SQLx helpers)
│ ├── rustapi-toon/ # 🎨 TOON format support
│ ├── rustapi-ws/ # 🔌 WebSocket support
│ ├── rustapi-view/ # 🖼️ Template rendering (Tera)
│ └── cargo-rustapi/ # 📦 CLI tool
├── examples/ # 📖 Example applications
│ ├── hello-world/ # Basic example
│ ├── crud-api/ # CRUD operations
│ ├── auth-api/ # Authentication
│ ├── sqlx-crud/ # Database integration
│ ├── websocket/ # WebSocket example
│ └── ...
├── benches/ # 🏃 Performance benchmarks
├── docs/ # 📝 Documentation
├── scripts/ # 🛠️ Build and publish scripts
└── memories/ # 🧠 Project memory/context
rustapi-rs (public API)
├── rustapi-core (HTTP engine)
│ ├── rustapi-macros (proc macros)
│ └── rustapi-openapi (OpenAPI specs)
├── rustapi-validate (validation)
├── rustapi-extras (optional features)
├── rustapi-toon (TOON format)
├── rustapi-ws (WebSocket)
└── rustapi-view (templates)
- Adding HTTP features →
rustapi-core - Adding proc macros →
rustapi-macros - Adding validation →
rustapi-validate - Adding OpenAPI features →
rustapi-openapi - Adding optional features →
rustapi-extras - Adding examples →
examples/ - Adding tests → relevant crate's
tests/directory - Adding docs →
docs/or inline rustdoc
RustAPI follows Semantic Versioning:
- MAJOR (0.x.0) - Breaking changes
- MINOR (0.1.x) - New features, backwards compatible
- PATCH (0.1.x) - Bug fixes, backwards compatible
- Update version in
Cargo.toml(workspace.package.version) - Update all crate references to new version
- Update CHANGELOG.md with release notes
- Run full test suite:
cargo test --workspace --all-features - Build documentation:
cargo doc --workspace --all-features - Tag release:
git tag v0.1.x - Push tag:
git push origin v0.1.x - Publish crates:
./scripts/publish.ps1or./scripts/smart_publish.ps1 - Create GitHub release with changelog
- 📖 Documentation: docs/
- 💬 Discussions: GitHub Discussions
- 🐛 Issues: GitHub Issues
- 📧 Contact: Open an issue for questions
When reporting bugs, please include:
-
Environment:
- Rust version:
rustc --version - RustAPI version
- Operating system
- Rust version:
-
Description:
- What you expected to happen
- What actually happened
- Steps to reproduce
-
Code:
- Minimal reproduction code
- Relevant error messages
- Stack traces (if applicable)
Issue Template:
## Description
Brief description of the issue
## Environment
- Rust version: 1.75.0
- RustAPI version: 0.1.7
- OS: Windows 11
## Steps to Reproduce
1. Create a route with...
2. Call the endpoint...
3. See error...
## Expected Behavior
What should happen
## Actual Behavior
What actually happens
## Code
\```rust
// Minimal reproduction code
\```
## Error Messages
\```
// Error output
\```We welcome feature requests! Please:
- Check if the feature already exists or is planned
- Explain the use case and why it's valuable
- Consider if it fits the project's scope
- Be open to discussion about implementation
Do not open public issues for security vulnerabilities!
Please report security issues via:
- GitHub Security Advisories (preferred)
- Email to maintainers
All contributors will be:
- Listed in CHANGELOG.md for their contributions
- Credited in release notes
- Added to GitHub's contributors list
Special thanks to all our contributors! You can see them on the contributors page.
Your contributions help make RustAPI better for everyone. Whether you're fixing a typo, adding a feature, or reporting a bug - every contribution matters!
Happy coding! 🦀✨