Skip to content

#80 feat: add example attribute parsing for OpenAPI schemas#90

Merged
RAprogramm merged 8 commits intodevfrom
80-examples-support
Jan 7, 2026
Merged

#80 feat: add example attribute parsing for OpenAPI schemas#90
RAprogramm merged 8 commits intodevfrom
80-examples-support

Conversation

@RAprogramm
Copy link
Owner

Summary

  • Add #[example = ...] attribute parsing for OpenAPI schema examples
  • Support string, integer, float, and boolean literals
  • Support negative numbers

Usage

#[field(create, response)]
#[example = "user@example.com"]
pub email: String,

#[field(response)]
#[example = 25]
pub age: i32,

Test plan

  • 8 unit tests for parsing
  • clippy clean
  • All tests pass

Closes #80

- Add example.rs module for parsing #[example = ...] attributes
- Support string, integer, float, and boolean literals
- Support negative numbers
- Add ExampleValue enum with to_tokens() and to_schema_attr()
- Add example field to FieldDef with accessor methods
- Include 8 unit tests for parsing

Closes #80
- Add security field to CommandDef for per-command override
- Parse security = "..." option in #[command(...)] attributes
- Support "none" value to make specific commands public
- Update handler generation to use command security with priority:
  1. Command-level security override
  2. Entity-level public commands list
  3. Entity-level default security
- Add security_scheme_name helper for mapping schemes
- Add 3 unit tests for security parsing

Closes #81
- 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 84.02778% with 23 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...tity-derive-impl/src/entity/parse/field/example.rs 87.40% 17 Missing ⚠️
...rates/entity-derive-impl/src/entity/parse/field.rs 33.33% 6 Missing ⚠️

📢 Thoughts on this report? Let us know!

@RAprogramm RAprogramm merged commit 9c923e4 into dev Jan 7, 2026
45 checks passed
@RAprogramm RAprogramm deleted the 80-examples-support 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