Skip to content

Commit

Permalink
Add SchemaGenerator::definitions_mut()
Browse files Browse the repository at this point in the history
  • Loading branch information
GREsau committed Mar 20, 2021
1 parent 6a3bba1 commit 94d7537
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog

## **In-dev** - [0.8.1]
### Added:
- `SchemaGenerator::definitions_mut()` which returns a mutable reference to the generator's schema definitions

### Changed:
- Deriving JsonSchema on enums now sets `additionalProperties` to false on generated schemas wherever serde doesn't accept unknown properties. This includes non-unit variants of externally tagged enums, and struct-style variants of all enums that have the `deny_unknown_fields` attribute.

Expand Down
8 changes: 8 additions & 0 deletions schemars/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,14 @@ impl SchemaGenerator {
&self.definitions
}

/// Mutably borrows the collection of all [referenceable](JsonSchema::is_referenceable) schemas that have been generated.
///
/// The keys of the returned `Map` are the [schema names](JsonSchema::schema_name), and the values are the schemas
/// themselves.
pub fn definitions_mut(&mut self) -> &mut Map<String, Schema> {
&mut self.definitions
}

/// Returns the collection of all [referenceable](JsonSchema::is_referenceable) schemas that have been generated,
/// leaving an empty map in its place.
///
Expand Down

0 comments on commit 94d7537

Please sign in to comment.