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

Add support for free form additional properties #495

Merged
merged 2 commits into from
Feb 20, 2023

Conversation

juhaku
Copy link
Owner

@juhaku juhaku commented Feb 20, 2023

Add support for free form additional properties which are used to define map field value types. This commit adds free form support for ToSchema and IntoParams with following syntax.

 #[derive(ToSchema)]
 struct Map {
     #[schema(additional_properties)]
     map: HashMap<String, String>,
 }

 #[derive(IntoParams)]
 struct Map {
     #[param(additional_properties)]
     map: HashMap<String, String>,
 }

The above declarations would render in OpenAPI as seen below.

type: object
additionalProperties: true

Fixes #316

Add support for free form additional properties which are used to define
map field value types. This commit adds free form support for `ToSchema`
and `IntoParams` with following syntax.
```rust
 #[derive(ToSchema)]
 struct Map {
     #[schema(additional_properties)]
     map: HashMap<String, String>,
 }

 #[derive(IntoParams)]
 struct Map {
     #[param(additional_properties)]
     map: HashMap<String, String>,
 }
```
@juhaku juhaku merged commit 746431d into master Feb 20, 2023
@juhaku juhaku deleted the add-free-form-additional-properties branch February 20, 2023 19:23
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.

Support free-form additionalProperties
1 participant