Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve description support on ToSchema fields #490

Merged
merged 1 commit into from
Feb 19, 2023

Conversation

juhaku
Copy link
Owner

@juhaku juhaku commented Feb 18, 2023

This commit fixes the existing implementation for field description and deprecated status. The implementation only worked for primitive type fields.

This PR adds correct support for following cases where the description and deprecated status will be correctly set for vec and map fields as well.

 struct Account {
     /// Database autogenerated id
     #[deprecated]
     id: i64,
     /// Users username
     #[deprecated]
     username: String,
     /// Role ids
     #[deprecated]
     role_ids: Vec<i32>,
     /// Users
     #[deprecated]
     users: Vec<User>,
     /// Map description
     #[deprecated]
     map: HashMap<String, String>
 }

Note this PR does not add support for description on $ref types.

Fixes #474, Relates #137

This commit fixes the existing implementation for field description and
deprecated status. The implementation only worked for primitive type
fields.

This PR adds correct support for following cases where the description
and deprecated status will be correctly set for vec and map fields as
well.
```rust
 struct Account {
     /// Database autogenerated id
     #[deprecated]
     id: i64,
     /// Users username
     #[deprecated]
     username: String,
     /// Role ids
     #[deprecated]
     role_ids: Vec<i32>,
     /// Users
     #[deprecated]
     users: Vec<User>,
     /// Map description
     #[deprecated]
     map: HashMap<String, String>
 }
```

Note this PR does not add support for description on `$ref` types.
@juhaku juhaku merged commit e06d1ef into master Feb 19, 2023
@juhaku juhaku deleted the improve-schema-field-descriptions branch February 19, 2023 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Released
Development

Successfully merging this pull request may close these issues.

Vec / array descriptions go to item instead of array
1 participant