add support for semver crate (#238)
--------- Co-authored-by: Omar Tawfik <15987992+OmarTawfik@users.noreply.github.com>
This commit is contained in:
parent
1ac9d19a24
commit
0303f0334e
8 changed files with 65 additions and 0 deletions
12
schemars/tests/expected/semver.json
Normal file
12
schemars/tests/expected/semver.json
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "SemverTypes",
|
||||
"type": "object",
|
||||
"required": ["version"],
|
||||
"properties": {
|
||||
"version": {
|
||||
"type": "string",
|
||||
"pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"
|
||||
}
|
||||
}
|
||||
}
|
15
schemars/tests/semver.rs
Normal file
15
schemars/tests/semver.rs
Normal file
|
@ -0,0 +1,15 @@
|
|||
mod util;
|
||||
use schemars::JsonSchema;
|
||||
use semver::Version;
|
||||
use util::*;
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(JsonSchema)]
|
||||
struct SemverTypes {
|
||||
version: Version,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn semver_types() -> TestResult {
|
||||
test_default_generated_schema::<SemverTypes>("semver")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue