Skip to content

Commit

Permalink
docs: Add migration guide
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Dygalo <[email protected]>
  • Loading branch information
Stranger6667 committed Sep 18, 2024
1 parent 74354df commit 18d01e8
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

## [Unreleased]

**Important:** This release includes several deprecations and renames. While backward compatibility is maintained for now, users are encouraged to update their code. See the [Migration Guide](MIGRATION.md) for details on transitioning to the new API.

### Added

- New draft-specific modules for easier version-targeted validation:
- `jsonschema::draft4`
- `jsonschema::draft6`
Expand Down
44 changes: 44 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Migration Guide

## Upgrading from 0.19.x to 0.20.0

### New Features

1. Draft-specific modules are now available:

```rust
// Old (0.19.x)
let validator = jsonschema::JSONSchema::options()
.with_draft(jsonschema::Draft2012)
.compile(&schema)
.expect("Invalid schema");

// New (0.20.0)
let validator = jsonschema::draft202012::new(&schema)
.expect("Invalid schema");
```

Available modules: `draft4`, `draft6`, `draft7`, `draft201909`, `draft202012`

2. Use the new `options()` function for easier customization:

```rust
// Old (0.19.x)
let options = jsonschema::JSONSchema::options();

// New (0.20.0)
let options = jsonschema::options();
```

### Deprecations and Renames

The following items have been renamed. While the old names are still supported in 0.20.0 for backward compatibility, it's recommended to update to the new names:

| Old Name (0.19.x) | New Name (0.20.0) |
|-------------------|-------------------|
| `CompilationOptions` | `ValidationOptions` |
| `JSONSchema` | `Validator` |
| `JSONPointer` | `JsonPointer` |
| `jsonschema::compile` | `jsonschema::validator_for` |
| `CompilationOptions::compile` | `ValidationOptions::build` |

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ $ jsonschema-cli schema.json -i instance.json

See more usage examples in the [documentation](https://docs.rs/jsonschema).

**Note:** If you're upgrading from a version prior to 0.20.0, please refer to our [Migration Guide](MIGRATION.md) for important changes and deprecations.

## Highlights

- 📚 Support for popular JSON Schema drafts
Expand Down

0 comments on commit 18d01e8

Please sign in to comment.