# Contributing to Clarify JSON Validator
Thank you for your interest in contributing to Clarify! We welcome contributions from everyone.
## Code of Conduct
This project adheres to a code of conduct. By participating, you are expected to uphold this code.
## How Can I Contribute?
### Reporting Bugs
Before creating bug reports, please check existing issues. When creating a bug report, include:
- A clear and descriptive title
- Steps to reproduce the issue
- Expected behavior
- Actual behavior
- Your environment (Rust version, OS, etc.)
- Code samples if applicable
### Suggesting Enhancements
Enhancement suggestions are tracked as GitHub issues. When creating an enhancement suggestion, include:
- A clear and descriptive title
- A detailed description of the proposed feature
- Examples of how the feature would be used
- Why this enhancement would be useful
### Pull Requests
1. Fork the repository
2. Create a new branch (`git checkout -b feature/amazing-feature`)
3. Make your changes
4. Run tests (`cargo test`)
5. Format your code (`cargo fmt`)
6. Run clippy (`cargo clippy`)
7. Commit your changes (`git commit -m 'Add some amazing feature'`)
8. Push to the branch (`git push origin feature/amazing-feature`)
9. Open a Pull Request
## Development Setup
```bash
# Clone the repository
git clone https://codeberg.org/luancosta/Clarify.git
cd Clarify
# Build the project
cargo build
# Run tests
cargo test
# Run examples
cargo run --example usage_example --features axum
```
## Coding Guidelines
### Rust Style
- Follow the official Rust style guide
- Use `cargo fmt` to format code
- Use `cargo clippy` to catch common mistakes
- Write documentation for public APIs
- Add tests for new features
### Commit Messages
- Use present tense ("Add feature" not "Added feature")
- Use imperative mood ("Move cursor to..." not "Moves cursor to...")
- Limit the first line to 72 characters
- Reference issues and pull requests when applicable
### Adding a New Language
To add support for a new language:
1. Update `src/json_validator/i18n.rs`:
```rust
pub enum Language {
En,
Pt,
Es, // Add new language
}
```
2. Add translations in `Messages::new()`:
```rust
let mut es = HashMap::new();
es.insert("missing_field_title", "Datos incompletos en la solicitud");
// ... add all translation keys
translations.insert(Language::Es, es);
```
3. Update `from_str()`:
```rust
match lang.to_lowercase().as_str() {
"pt" | "pt-br" => Language::Pt,
"es" | "es-es" => Language::Es, // Add new mapping
_ => Language::En,
}
```
4. Add documentation in `docs/[language_code]/README.md`
5. Update main README.md with the new language
### Testing
- Write unit tests for new functionality
- Ensure all tests pass before submitting
- Add integration tests for complex features
- Test with multiple Rust versions if possible
## Project Structure
```
Clarify/
├── src/
│ ├── lib.rs # Main library entry
│ ├── main.rs # Test examples
│ └── json_validator/
│ ├── mod.rs # Module exports
│ ├── error_types.rs # Error type definitions
│ ├── error_extractor.rs # Error parsing logic
│ ├── response_builder.rs # Response builder
│ └── i18n.rs # Internationalization
├── tests/
│ └── integration_tests.rs # Integration tests
├── examples/
│ └── usage_example.rs # Axum integration example
├── docs/
│ ├── en/ # English documentation
│ └── pt/ # Portuguese documentation
├── Cargo.toml
├── LICENSE
└── README.md
```
## Release Process
1. Update version in `Cargo.toml`
2. Update CHANGELOG.md
3. Create a git tag (`git tag -a v0.1.0 -m "Release v0.1.0"`)
4. Push tag (`git push origin v0.1.0`)
5. Publish to crates.io (`cargo publish`)
## Questions?
Feel free to open an issue for any questions or concerns.
## License
By contributing to Clarify, you agree that your contributions will be licensed under the MIT License.