Skip to content

#82 feat: add EntityError derive macro for OpenAPI error docs#92

Merged
RAprogramm merged 4 commits into81-security-configfrom
82-error-docs
Jan 7, 2026
Merged

#82 feat: add EntityError derive macro for OpenAPI error docs#92
RAprogramm merged 4 commits into81-security-configfrom
82-error-docs

Conversation

@RAprogramm
Copy link
Owner

Summary

  • New #[derive(EntityError)] macro for error enums
  • Parse #[status(code)] for HTTP status codes
  • Use doc comments as OpenAPI descriptions
  • Generate helper struct for response documentation

Usage

#[derive(Debug, Error, ToSchema, EntityError)]
pub enum UserError {
    /// User with this email already exists
    #[error("Email already exists")]
    #[status(409)]
    EmailExists,

    /// User not found
    #[error("User not found")]
    #[status(404)]
    NotFound,
}

// Generates UserErrorResponses struct

Test plan

  • 4 unit tests for error parsing
  • clippy clean
  • All 102 tests pass

Closes #82

- Create error.rs module with EntityError derive macro
- Parse #[status(code)] attributes for HTTP status codes
- Use doc comments as error descriptions
- Generate {Error}Responses struct with helper methods:
  - status_codes() - all error status codes
  - descriptions() - all error descriptions
  - utoipa_responses() - tuples for OpenAPI
- Add 4 unit tests for error parsing

Closes #82
- Wire up deprecated_in config to generate deprecated = true in utoipa
- Version is already supported via full_path_prefix()
- Add 5 unit tests for security scheme name mapping

Closes #83
@codecov
Copy link

codecov bot commented Jan 7, 2026

Codecov Report

❌ Patch coverage is 67.46988% with 27 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
crates/entity-derive-impl/src/error.rs 70.00% 24 Missing ⚠️
crates/entity-derive-impl/src/lib.rs 0.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@RAprogramm RAprogramm merged commit 9c923e4 into 81-security-config Jan 7, 2026
25 checks passed
@RAprogramm RAprogramm deleted the 82-error-docs branch January 7, 2026 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant