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 property_names for object #1084

Merged
merged 1 commit into from
Oct 3, 2024
Merged

Conversation

juhaku
Copy link
Owner

@juhaku juhaku commented Oct 3, 2024

Add support for defining property_names of object such as a map. This commit allows users to define completely typed maps where value is defined via additional_properties and key is defined via property_names.

 #[derive(ToSchema)]
 enum Names {
     Foo,
     Bar,
 }

 struct Mapped(std::collections::BTreeMap<Names, String>);

 // will render to following json
 json!({
     "propertyNames": {
         "type": "string",
         "enum": ["Foo", "Bar"]
     },
     "additionalProperties": {
         "type": "string"
     },
     "type": "object"
 })

Closes #755

Add support for defining `property_names` of object such as a map. This
commit allows users to define completely typed maps where value is
defined via `additional_properties` and key is defined via
`property_names`.
```rust
 #[derive(ToSchema)]
 enum Names {
     Foo,
     Bar,
 }

 struct Mapped(std::collections::BTreeMap<Names, String>);

 // will render to following json
 json!({
     "propertyNames": {
         "type": "string",
         "enum": ["Foo", "Bar"]
     },
     "additionalProperties": {
         "type": "string"
     },
     "type": "object"
 })
```

Closes #755
@juhaku juhaku force-pushed the feature-property-names branch from ba68744 to 6ebacff Compare October 3, 2024 20:57
@juhaku juhaku merged commit 0a83458 into master Oct 3, 2024
22 checks passed
@juhaku juhaku deleted the feature-property-names branch October 3, 2024 21:08
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.

object propertyNames support
1 participant