rust_json_schema 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Cargo.lock +319 -1
- data/README.md +23 -9
- data/ext/rust_json_schema/Cargo.toml +2 -1
- data/ext/rust_json_schema/src/lib.rs +102 -24
- data/lib/rust_json_schema/version.rb +1 -1
- data/lib/rust_json_schema.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bef6e21b9050d5bd5a7734725db6453436984d9321e247b9eb880f3d33c9656e
|
4
|
+
data.tar.gz: 412a4aaccb9aebb656fcd7bd13a04b1bce922e11e7abb7d0ffa8e71fce0bdbcb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8d5f9ae2557cbfc71a18fd61436615c3f2428bb1df3fb6e42955d34c1dbb6bd55d6b6a109d09d0a1f169f7c697337aae45881332c9842bdbb3281c04e7b2c0d
|
7
|
+
data.tar.gz: 16456292b2c5a0ed09bcda58c72e51f1c5e212227c0f0923bc7984101af4a5b972a36dff874b64c477ec00dabf7cbb4929e4be9df380d354f60e61c2049bb5f2
|
data/Cargo.lock
CHANGED
@@ -307,6 +307,27 @@ version = "1.0.1"
|
|
307
307
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
308
308
|
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
309
309
|
|
310
|
+
[[package]]
|
311
|
+
name = "errno"
|
312
|
+
version = "0.3.3"
|
313
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
314
|
+
checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd"
|
315
|
+
dependencies = [
|
316
|
+
"errno-dragonfly",
|
317
|
+
"libc",
|
318
|
+
"windows-sys 0.48.0",
|
319
|
+
]
|
320
|
+
|
321
|
+
[[package]]
|
322
|
+
name = "errno-dragonfly"
|
323
|
+
version = "0.1.2"
|
324
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
325
|
+
checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
|
326
|
+
dependencies = [
|
327
|
+
"cc",
|
328
|
+
"libc",
|
329
|
+
]
|
330
|
+
|
310
331
|
[[package]]
|
311
332
|
name = "fancy-regex"
|
312
333
|
version = "0.11.0"
|
@@ -317,12 +338,33 @@ dependencies = [
|
|
317
338
|
"regex",
|
318
339
|
]
|
319
340
|
|
341
|
+
[[package]]
|
342
|
+
name = "fastrand"
|
343
|
+
version = "2.0.0"
|
344
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
345
|
+
checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764"
|
346
|
+
|
320
347
|
[[package]]
|
321
348
|
name = "fnv"
|
322
349
|
version = "1.0.7"
|
323
350
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
324
351
|
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
325
352
|
|
353
|
+
[[package]]
|
354
|
+
name = "foreign-types"
|
355
|
+
version = "0.3.2"
|
356
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
357
|
+
checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
|
358
|
+
dependencies = [
|
359
|
+
"foreign-types-shared",
|
360
|
+
]
|
361
|
+
|
362
|
+
[[package]]
|
363
|
+
name = "foreign-types-shared"
|
364
|
+
version = "0.1.1"
|
365
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
366
|
+
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
|
367
|
+
|
326
368
|
[[package]]
|
327
369
|
name = "form_urlencoded"
|
328
370
|
version = "1.2.1"
|
@@ -510,6 +552,33 @@ dependencies = [
|
|
510
552
|
"want",
|
511
553
|
]
|
512
554
|
|
555
|
+
[[package]]
|
556
|
+
name = "hyper-rustls"
|
557
|
+
version = "0.24.2"
|
558
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
559
|
+
checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590"
|
560
|
+
dependencies = [
|
561
|
+
"futures-util",
|
562
|
+
"http",
|
563
|
+
"hyper",
|
564
|
+
"rustls",
|
565
|
+
"tokio",
|
566
|
+
"tokio-rustls",
|
567
|
+
]
|
568
|
+
|
569
|
+
[[package]]
|
570
|
+
name = "hyper-tls"
|
571
|
+
version = "0.5.0"
|
572
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
573
|
+
checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
|
574
|
+
dependencies = [
|
575
|
+
"bytes",
|
576
|
+
"hyper",
|
577
|
+
"native-tls",
|
578
|
+
"tokio",
|
579
|
+
"tokio-native-tls",
|
580
|
+
]
|
581
|
+
|
513
582
|
[[package]]
|
514
583
|
name = "idna"
|
515
584
|
version = "0.5.0"
|
@@ -618,6 +687,12 @@ dependencies = [
|
|
618
687
|
"windows-sys 0.48.0",
|
619
688
|
]
|
620
689
|
|
690
|
+
[[package]]
|
691
|
+
name = "linux-raw-sys"
|
692
|
+
version = "0.4.7"
|
693
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
694
|
+
checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128"
|
695
|
+
|
621
696
|
[[package]]
|
622
697
|
name = "lock_api"
|
623
698
|
version = "0.4.11"
|
@@ -695,6 +770,24 @@ dependencies = [
|
|
695
770
|
"windows-sys 0.48.0",
|
696
771
|
]
|
697
772
|
|
773
|
+
[[package]]
|
774
|
+
name = "native-tls"
|
775
|
+
version = "0.2.11"
|
776
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
777
|
+
checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e"
|
778
|
+
dependencies = [
|
779
|
+
"lazy_static",
|
780
|
+
"libc",
|
781
|
+
"log",
|
782
|
+
"openssl",
|
783
|
+
"openssl-probe",
|
784
|
+
"openssl-sys",
|
785
|
+
"schannel",
|
786
|
+
"security-framework",
|
787
|
+
"security-framework-sys",
|
788
|
+
"tempfile",
|
789
|
+
]
|
790
|
+
|
698
791
|
[[package]]
|
699
792
|
name = "nom"
|
700
793
|
version = "7.1.3"
|
@@ -812,6 +905,50 @@ version = "1.19.0"
|
|
812
905
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
813
906
|
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
|
814
907
|
|
908
|
+
[[package]]
|
909
|
+
name = "openssl"
|
910
|
+
version = "0.10.62"
|
911
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
912
|
+
checksum = "8cde4d2d9200ad5909f8dac647e29482e07c3a35de8a13fce7c9c7747ad9f671"
|
913
|
+
dependencies = [
|
914
|
+
"bitflags 2.4.1",
|
915
|
+
"cfg-if",
|
916
|
+
"foreign-types",
|
917
|
+
"libc",
|
918
|
+
"once_cell",
|
919
|
+
"openssl-macros",
|
920
|
+
"openssl-sys",
|
921
|
+
]
|
922
|
+
|
923
|
+
[[package]]
|
924
|
+
name = "openssl-macros"
|
925
|
+
version = "0.1.1"
|
926
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
927
|
+
checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
|
928
|
+
dependencies = [
|
929
|
+
"proc-macro2",
|
930
|
+
"quote",
|
931
|
+
"syn",
|
932
|
+
]
|
933
|
+
|
934
|
+
[[package]]
|
935
|
+
name = "openssl-probe"
|
936
|
+
version = "0.1.5"
|
937
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
938
|
+
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
|
939
|
+
|
940
|
+
[[package]]
|
941
|
+
name = "openssl-sys"
|
942
|
+
version = "0.9.98"
|
943
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
944
|
+
checksum = "c1665caf8ab2dc9aef43d1c0023bd904633a6a05cb30b0ad59bec2ae986e57a7"
|
945
|
+
dependencies = [
|
946
|
+
"cc",
|
947
|
+
"libc",
|
948
|
+
"pkg-config",
|
949
|
+
"vcpkg",
|
950
|
+
]
|
951
|
+
|
815
952
|
[[package]]
|
816
953
|
name = "parking_lot"
|
817
954
|
version = "0.12.1"
|
@@ -830,7 +967,7 @@ checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e"
|
|
830
967
|
dependencies = [
|
831
968
|
"cfg-if",
|
832
969
|
"libc",
|
833
|
-
"redox_syscall",
|
970
|
+
"redox_syscall 0.4.1",
|
834
971
|
"smallvec",
|
835
972
|
"windows-targets 0.48.5",
|
836
973
|
]
|
@@ -859,6 +996,12 @@ version = "0.1.0"
|
|
859
996
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
860
997
|
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
|
861
998
|
|
999
|
+
[[package]]
|
1000
|
+
name = "pkg-config"
|
1001
|
+
version = "0.3.27"
|
1002
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1003
|
+
checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964"
|
1004
|
+
|
862
1005
|
[[package]]
|
863
1006
|
name = "powerfmt"
|
864
1007
|
version = "0.2.0"
|
@@ -913,6 +1056,15 @@ version = "0.1.2"
|
|
913
1056
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
914
1057
|
checksum = "a35802679f07360454b418a5d1735c89716bde01d35b1560fc953c1415a0b3bb"
|
915
1058
|
|
1059
|
+
[[package]]
|
1060
|
+
name = "redox_syscall"
|
1061
|
+
version = "0.3.5"
|
1062
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1063
|
+
checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29"
|
1064
|
+
dependencies = [
|
1065
|
+
"bitflags 1.3.2",
|
1066
|
+
]
|
1067
|
+
|
916
1068
|
[[package]]
|
917
1069
|
name = "redox_syscall"
|
918
1070
|
version = "0.4.1"
|
@@ -966,26 +1118,48 @@ dependencies = [
|
|
966
1118
|
"http",
|
967
1119
|
"http-body",
|
968
1120
|
"hyper",
|
1121
|
+
"hyper-rustls",
|
1122
|
+
"hyper-tls",
|
969
1123
|
"ipnet",
|
970
1124
|
"js-sys",
|
971
1125
|
"log",
|
972
1126
|
"mime",
|
1127
|
+
"native-tls",
|
973
1128
|
"once_cell",
|
974
1129
|
"percent-encoding",
|
975
1130
|
"pin-project-lite",
|
1131
|
+
"rustls",
|
1132
|
+
"rustls-pemfile",
|
976
1133
|
"serde",
|
977
1134
|
"serde_json",
|
978
1135
|
"serde_urlencoded",
|
979
1136
|
"system-configuration",
|
980
1137
|
"tokio",
|
1138
|
+
"tokio-native-tls",
|
1139
|
+
"tokio-rustls",
|
981
1140
|
"tower-service",
|
982
1141
|
"url",
|
983
1142
|
"wasm-bindgen",
|
984
1143
|
"wasm-bindgen-futures",
|
985
1144
|
"web-sys",
|
1145
|
+
"webpki-roots",
|
986
1146
|
"winreg",
|
987
1147
|
]
|
988
1148
|
|
1149
|
+
[[package]]
|
1150
|
+
name = "ring"
|
1151
|
+
version = "0.17.7"
|
1152
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1153
|
+
checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74"
|
1154
|
+
dependencies = [
|
1155
|
+
"cc",
|
1156
|
+
"getrandom",
|
1157
|
+
"libc",
|
1158
|
+
"spin",
|
1159
|
+
"untrusted",
|
1160
|
+
"windows-sys 0.48.0",
|
1161
|
+
]
|
1162
|
+
|
989
1163
|
[[package]]
|
990
1164
|
name = "rust_json_schema"
|
991
1165
|
version = "0.1.0"
|
@@ -993,6 +1167,7 @@ dependencies = [
|
|
993
1167
|
"jsonschema",
|
994
1168
|
"magnus",
|
995
1169
|
"rb-sys",
|
1170
|
+
"reqwest",
|
996
1171
|
"serde_json",
|
997
1172
|
]
|
998
1173
|
|
@@ -1008,18 +1183,104 @@ version = "1.1.0"
|
|
1008
1183
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1009
1184
|
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
1010
1185
|
|
1186
|
+
[[package]]
|
1187
|
+
name = "rustix"
|
1188
|
+
version = "0.38.13"
|
1189
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1190
|
+
checksum = "d7db8590df6dfcd144d22afd1b83b36c21a18d7cbc1dc4bb5295a8712e9eb662"
|
1191
|
+
dependencies = [
|
1192
|
+
"bitflags 2.4.1",
|
1193
|
+
"errno",
|
1194
|
+
"libc",
|
1195
|
+
"linux-raw-sys",
|
1196
|
+
"windows-sys 0.48.0",
|
1197
|
+
]
|
1198
|
+
|
1199
|
+
[[package]]
|
1200
|
+
name = "rustls"
|
1201
|
+
version = "0.21.10"
|
1202
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1203
|
+
checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba"
|
1204
|
+
dependencies = [
|
1205
|
+
"log",
|
1206
|
+
"ring",
|
1207
|
+
"rustls-webpki",
|
1208
|
+
"sct",
|
1209
|
+
]
|
1210
|
+
|
1211
|
+
[[package]]
|
1212
|
+
name = "rustls-pemfile"
|
1213
|
+
version = "1.0.4"
|
1214
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1215
|
+
checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c"
|
1216
|
+
dependencies = [
|
1217
|
+
"base64",
|
1218
|
+
]
|
1219
|
+
|
1220
|
+
[[package]]
|
1221
|
+
name = "rustls-webpki"
|
1222
|
+
version = "0.101.7"
|
1223
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1224
|
+
checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765"
|
1225
|
+
dependencies = [
|
1226
|
+
"ring",
|
1227
|
+
"untrusted",
|
1228
|
+
]
|
1229
|
+
|
1011
1230
|
[[package]]
|
1012
1231
|
name = "ryu"
|
1013
1232
|
version = "1.0.16"
|
1014
1233
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1015
1234
|
checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c"
|
1016
1235
|
|
1236
|
+
[[package]]
|
1237
|
+
name = "schannel"
|
1238
|
+
version = "0.1.23"
|
1239
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1240
|
+
checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534"
|
1241
|
+
dependencies = [
|
1242
|
+
"windows-sys 0.52.0",
|
1243
|
+
]
|
1244
|
+
|
1017
1245
|
[[package]]
|
1018
1246
|
name = "scopeguard"
|
1019
1247
|
version = "1.2.0"
|
1020
1248
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1021
1249
|
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
1022
1250
|
|
1251
|
+
[[package]]
|
1252
|
+
name = "sct"
|
1253
|
+
version = "0.7.1"
|
1254
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1255
|
+
checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414"
|
1256
|
+
dependencies = [
|
1257
|
+
"ring",
|
1258
|
+
"untrusted",
|
1259
|
+
]
|
1260
|
+
|
1261
|
+
[[package]]
|
1262
|
+
name = "security-framework"
|
1263
|
+
version = "2.9.2"
|
1264
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1265
|
+
checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de"
|
1266
|
+
dependencies = [
|
1267
|
+
"bitflags 1.3.2",
|
1268
|
+
"core-foundation",
|
1269
|
+
"core-foundation-sys",
|
1270
|
+
"libc",
|
1271
|
+
"security-framework-sys",
|
1272
|
+
]
|
1273
|
+
|
1274
|
+
[[package]]
|
1275
|
+
name = "security-framework-sys"
|
1276
|
+
version = "2.9.1"
|
1277
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1278
|
+
checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a"
|
1279
|
+
dependencies = [
|
1280
|
+
"core-foundation-sys",
|
1281
|
+
"libc",
|
1282
|
+
]
|
1283
|
+
|
1023
1284
|
[[package]]
|
1024
1285
|
name = "seq-macro"
|
1025
1286
|
version = "0.3.5"
|
@@ -1106,6 +1367,12 @@ dependencies = [
|
|
1106
1367
|
"windows-sys 0.48.0",
|
1107
1368
|
]
|
1108
1369
|
|
1370
|
+
[[package]]
|
1371
|
+
name = "spin"
|
1372
|
+
version = "0.9.8"
|
1373
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1374
|
+
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
|
1375
|
+
|
1109
1376
|
[[package]]
|
1110
1377
|
name = "strsim"
|
1111
1378
|
version = "0.10.0"
|
@@ -1144,6 +1411,19 @@ dependencies = [
|
|
1144
1411
|
"libc",
|
1145
1412
|
]
|
1146
1413
|
|
1414
|
+
[[package]]
|
1415
|
+
name = "tempfile"
|
1416
|
+
version = "3.8.0"
|
1417
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1418
|
+
checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef"
|
1419
|
+
dependencies = [
|
1420
|
+
"cfg-if",
|
1421
|
+
"fastrand",
|
1422
|
+
"redox_syscall 0.3.5",
|
1423
|
+
"rustix",
|
1424
|
+
"windows-sys 0.48.0",
|
1425
|
+
]
|
1426
|
+
|
1147
1427
|
[[package]]
|
1148
1428
|
name = "time"
|
1149
1429
|
version = "0.3.31"
|
@@ -1203,6 +1483,26 @@ dependencies = [
|
|
1203
1483
|
"windows-sys 0.48.0",
|
1204
1484
|
]
|
1205
1485
|
|
1486
|
+
[[package]]
|
1487
|
+
name = "tokio-native-tls"
|
1488
|
+
version = "0.3.1"
|
1489
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1490
|
+
checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2"
|
1491
|
+
dependencies = [
|
1492
|
+
"native-tls",
|
1493
|
+
"tokio",
|
1494
|
+
]
|
1495
|
+
|
1496
|
+
[[package]]
|
1497
|
+
name = "tokio-rustls"
|
1498
|
+
version = "0.24.1"
|
1499
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1500
|
+
checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081"
|
1501
|
+
dependencies = [
|
1502
|
+
"rustls",
|
1503
|
+
"tokio",
|
1504
|
+
]
|
1505
|
+
|
1206
1506
|
[[package]]
|
1207
1507
|
name = "tokio-util"
|
1208
1508
|
version = "0.7.10"
|
@@ -1269,6 +1569,12 @@ dependencies = [
|
|
1269
1569
|
"tinyvec",
|
1270
1570
|
]
|
1271
1571
|
|
1572
|
+
[[package]]
|
1573
|
+
name = "untrusted"
|
1574
|
+
version = "0.9.0"
|
1575
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1576
|
+
checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
|
1577
|
+
|
1272
1578
|
[[package]]
|
1273
1579
|
name = "url"
|
1274
1580
|
version = "2.5.0"
|
@@ -1292,6 +1598,12 @@ version = "1.6.1"
|
|
1292
1598
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1293
1599
|
checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560"
|
1294
1600
|
|
1601
|
+
[[package]]
|
1602
|
+
name = "vcpkg"
|
1603
|
+
version = "0.2.15"
|
1604
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1605
|
+
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
1606
|
+
|
1295
1607
|
[[package]]
|
1296
1608
|
name = "version_check"
|
1297
1609
|
version = "0.9.4"
|
@@ -1389,6 +1701,12 @@ dependencies = [
|
|
1389
1701
|
"wasm-bindgen",
|
1390
1702
|
]
|
1391
1703
|
|
1704
|
+
[[package]]
|
1705
|
+
name = "webpki-roots"
|
1706
|
+
version = "0.25.3"
|
1707
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
1708
|
+
checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10"
|
1709
|
+
|
1392
1710
|
[[package]]
|
1393
1711
|
name = "windows-sys"
|
1394
1712
|
version = "0.48.0"
|
data/README.md
CHANGED
@@ -4,13 +4,15 @@
|
|
4
4
|
|
5
5
|
`rust_json_schema` is a Ruby wrapper gem for Rust's [jsonschema-rs crate](https://github.com/Stranger6667/jsonschema-rs).
|
6
6
|
|
7
|
-
|
7
|
+
The minimum Ruby version required by this gem is 3.0, due to the runtime Rust libraries that make the extensions possible (and easy).
|
8
8
|
|
9
|
-
|
9
|
+
This gem ships with precompiled binaries for Linux and macOS. Check the available gems on [Rubygems](https://rubygems.org/gems/rust_json_schema). Precompiled binaries do not exist for non-standard rubies like JRuby or TruffleRuby, nor do they exist for Windows. I will review and accept PRs if you would like to work on adding these build targets.
|
10
|
+
|
11
|
+
[rusty_json_schema](https://github.com/driv3r/rusty_json_schema) is a direct source of inspiration. Now that [bundler has explicit support for rust-backed Ruby gems](https://bundler.io/blog/2023/01/31/rust-gem-skeleton.html) as of early 2023, the Rust library code is a lot simpler that it previously needed to be, largely thanks to [magnus crate](https://github.com/matsadler/magnus) and the [rb-sys gem](https://github.com/oxidize-rb/rb-sys/tree/main/gem), and by extension, the [oxidize-rb team](https://github.com/oxidize-rb).
|
10
12
|
|
11
|
-
|
13
|
+
## Warning
|
12
14
|
|
13
|
-
|
15
|
+
My experience with Rust is limited, but this gem does have tests, and it is deployed in production. Please confirm that the gem is working as expected before using it in any production-critical situation. If you are using this gem in a production environment, and have any comments or feedback, I would love to hear about it.
|
14
16
|
|
15
17
|
## Installation
|
16
18
|
|
@@ -25,7 +27,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
25
27
|
## Usage
|
26
28
|
|
27
29
|
```ruby
|
28
|
-
|
30
|
+
schema = <<~JSON
|
29
31
|
{
|
30
32
|
"properties": {
|
31
33
|
"foo": { "type": "string" },
|
@@ -36,6 +38,12 @@ validator = RustJSONSchema::Validator.new(<<~JSON)
|
|
36
38
|
}
|
37
39
|
JSON
|
38
40
|
|
41
|
+
validator = RustJSONSchema::Validator.new(
|
42
|
+
schema,
|
43
|
+
draft: :draft7,
|
44
|
+
with_meta_schemas: false
|
45
|
+
)
|
46
|
+
|
39
47
|
errors = validator.validate('{ "foo": 1, "bar": "wadus" }')
|
40
48
|
# => [
|
41
49
|
# 'path "/bar": "wadus" is not of type "number"',
|
@@ -44,15 +52,21 @@ errors = validator.validate('{ "foo": 1, "bar": "wadus" }')
|
|
44
52
|
# ]
|
45
53
|
```
|
46
54
|
|
55
|
+
### Options
|
56
|
+
|
57
|
+
- `:draft` - Select the JSON schema draft number to use. Valid options are `draft4`, `draft6`, `draft7`, `draft201909`, and `draft202012`. Supported drafts are entirely determined by the `jsonschema` crate. The default draft is also determined by the crate. If new versions of the crate support additional draft versions, a code change in this gem will be required. I'm open to PRs to solve this problem - I don't know enough Rust to tell if it's easily done. *Both `draft201909` and `draft202012` are reported to have "some keywords not implemented", so use them at your own risk.*
|
58
|
+
- `:with_meta_schemas` - See [docs.rs/jsonschema CompilationOptions with_meta_schemas](https://docs.rs/jsonschema/0.17.1/jsonschema/struct.CompilationOptions.html#method.with_meta_schemas). `false` by default.
|
59
|
+
|
60
|
+
Any additional options provided by the `jsonschema` crate are options I do not understand or may not make sense to implement in a wrapper library such as this.
|
61
|
+
|
62
|
+
`RustJSONSchema::Validator#options` is provided and will return a Hash containing configuration options from the underlying Rust library. While I make an effort for them to look similar, or identical, to the options passed into the `Validator` initializer, the initializer arguments and the returned Hash should not be considered one-to-one. It exists as a way to confirm the configuration of the underlying schema validator instance.
|
63
|
+
|
47
64
|
### Errors
|
48
65
|
|
49
66
|
- All errors are subclasses of `RustJSONSchema::Error`.
|
50
67
|
- Calling `RustJSONSchema::Validator#new`, `#validate` or `#valid?` with a string which is not valid JSON will raise `RustJSONSchema::JSONParseError`.
|
51
68
|
- Calling `RustJSONSchema::Validator#new` with an invalid schema will raise `RustJSONSchema::SchemaParseError`.
|
52
|
-
|
53
|
-
## TODO
|
54
|
-
|
55
|
-
- Support passing options as `jsonschema-rs` does
|
69
|
+
- Calling `RustJSONSchema::Validator#new` with an invalid draft version value will raise `RustJSONSchema::InvalidOptionsError`.
|
56
70
|
|
57
71
|
## Development
|
58
72
|
|
@@ -10,7 +10,8 @@ publish = false
|
|
10
10
|
crate-type = ["cdylib"]
|
11
11
|
|
12
12
|
[dependencies]
|
13
|
-
jsonschema = "0.17.1"
|
13
|
+
jsonschema = { version = "0.17.1", features = ["draft201909", "draft202012"] }
|
14
|
+
reqwest = { version = "*", features = ["rustls-tls"] }
|
14
15
|
magnus = "0.6"
|
15
16
|
serde_json = "1.0"
|
16
17
|
rb-sys = { version = "*", default-features = false, features = ["ruby-static"] }
|
@@ -1,46 +1,96 @@
|
|
1
|
+
extern crate serde_json;
|
2
|
+
|
3
|
+
use jsonschema::{Draft, JSONSchema};
|
1
4
|
use magnus::{
|
2
|
-
exception::ExceptionClass,
|
3
|
-
|
5
|
+
exception::ExceptionClass,
|
6
|
+
function,
|
7
|
+
gc::register_mark_object,
|
8
|
+
method,
|
9
|
+
prelude::*,
|
10
|
+
scan_args::{get_kwargs, scan_args},
|
11
|
+
value::Lazy,
|
12
|
+
wrap, Error, RHash, RModule, Ruby, StaticSymbol, Value,
|
4
13
|
};
|
5
14
|
|
6
|
-
extern crate serde_json;
|
7
|
-
use jsonschema::JSONSchema;
|
8
|
-
|
9
15
|
#[wrap(class = "RustJSONSchema::Validator")]
|
10
16
|
struct Validator {
|
11
17
|
schema: JSONSchema,
|
18
|
+
draft: Draft,
|
19
|
+
with_meta_schemas: bool,
|
12
20
|
}
|
13
21
|
|
14
22
|
impl Validator {
|
15
|
-
fn new(
|
23
|
+
fn new(args: &[Value]) -> Result<Validator, Error> {
|
24
|
+
let args = scan_args::<_, (), (), (), _, ()>(args)?;
|
25
|
+
let (json,): (String,) = args.required;
|
26
|
+
let kwargs = get_kwargs::<_, (), (Option<Value>, Option<bool>), ()>(
|
27
|
+
args.keywords,
|
28
|
+
&[],
|
29
|
+
&["draft", "with_meta_schemas"],
|
30
|
+
)?;
|
31
|
+
let (draft_arg, with_meta_schemas_arg): (Option<Value>, Option<bool>) = kwargs.optional;
|
32
|
+
|
33
|
+
let draft = match draft_arg {
|
34
|
+
Some(draft) => match draft.to_string().to_lowercase().as_str() {
|
35
|
+
"draft4" => Draft::Draft4,
|
36
|
+
"draft6" => Draft::Draft6,
|
37
|
+
"draft7" => Draft::Draft7,
|
38
|
+
"draft201909" => Draft::Draft201909,
|
39
|
+
"draft202012" => Draft::Draft202012,
|
40
|
+
_ => {
|
41
|
+
return Err(Error::new(
|
42
|
+
Self::ruby().get_inner(&INVALID_OPTIONS_ERROR),
|
43
|
+
format!("invalid draft: '{}'", draft.to_string()),
|
44
|
+
))
|
45
|
+
}
|
46
|
+
},
|
47
|
+
None => jsonschema::Draft::default(),
|
48
|
+
};
|
49
|
+
|
50
|
+
let with_meta_schemas = match with_meta_schemas_arg {
|
51
|
+
Some(with_meta_schemas) => with_meta_schemas,
|
52
|
+
None => false,
|
53
|
+
};
|
54
|
+
|
16
55
|
let value: serde_json::Value = match serde_json::from_str(&json) {
|
17
56
|
Ok(value) => value,
|
18
57
|
Err(error) => {
|
19
|
-
return Err(
|
58
|
+
return Err(Error::new(
|
20
59
|
Self::ruby().get_inner(&JSON_PARSE_ERROR),
|
21
60
|
error.to_string(),
|
22
61
|
))
|
23
62
|
}
|
24
63
|
};
|
25
64
|
|
26
|
-
let schema =
|
65
|
+
let mut schema = JSONSchema::options();
|
66
|
+
schema.with_draft(draft);
|
67
|
+
|
68
|
+
if with_meta_schemas {
|
69
|
+
schema.with_meta_schemas();
|
70
|
+
}
|
71
|
+
|
72
|
+
let schema = match schema.compile(&value) {
|
27
73
|
Ok(schema) => schema,
|
28
74
|
Err(error) => {
|
29
|
-
return Err(
|
75
|
+
return Err(Error::new(
|
30
76
|
Self::ruby().get_inner(&SCHEMA_PARSE_ERROR),
|
31
77
|
error.to_string(),
|
32
78
|
))
|
33
79
|
}
|
34
80
|
};
|
35
81
|
|
36
|
-
Ok(Validator {
|
82
|
+
Ok(Validator {
|
83
|
+
schema,
|
84
|
+
draft,
|
85
|
+
with_meta_schemas,
|
86
|
+
})
|
37
87
|
}
|
38
88
|
|
39
|
-
fn is_valid(&self, json: String) -> Result<bool,
|
89
|
+
fn is_valid(&self, json: String) -> Result<bool, Error> {
|
40
90
|
let value: serde_json::Value = match serde_json::from_str(&json) {
|
41
91
|
Ok(value) => value,
|
42
92
|
Err(error) => {
|
43
|
-
return Err(
|
93
|
+
return Err(Error::new(
|
44
94
|
Self::ruby().get_inner(&JSON_PARSE_ERROR),
|
45
95
|
error.to_string(),
|
46
96
|
));
|
@@ -50,11 +100,31 @@ impl Validator {
|
|
50
100
|
Ok(self.schema.is_valid(&value))
|
51
101
|
}
|
52
102
|
|
53
|
-
fn
|
103
|
+
fn options(&self) -> Result<RHash, Error> {
|
104
|
+
let options = RHash::new();
|
105
|
+
|
106
|
+
options
|
107
|
+
.aset(
|
108
|
+
StaticSymbol::new("draft"),
|
109
|
+
StaticSymbol::new(format!("{:?}", self.draft).to_lowercase()),
|
110
|
+
)
|
111
|
+
.unwrap();
|
112
|
+
|
113
|
+
options
|
114
|
+
.aset(
|
115
|
+
StaticSymbol::new("with_meta_schemas"),
|
116
|
+
self.with_meta_schemas,
|
117
|
+
)
|
118
|
+
.unwrap();
|
119
|
+
|
120
|
+
Ok(options)
|
121
|
+
}
|
122
|
+
|
123
|
+
fn validate(&self, json: String) -> Result<Vec<String>, Error> {
|
54
124
|
let value: serde_json::Value = match serde_json::from_str(&json) {
|
55
125
|
Ok(value) => value,
|
56
126
|
Err(error) => {
|
57
|
-
return Err(
|
127
|
+
return Err(Error::new(
|
58
128
|
Self::ruby().get_inner(&JSON_PARSE_ERROR),
|
59
129
|
error.to_string(),
|
60
130
|
))
|
@@ -89,9 +159,7 @@ static JSON_PARSE_ERROR: Lazy<ExceptionClass> = Lazy::new(|ruby| {
|
|
89
159
|
.unwrap()
|
90
160
|
.const_get("JSONParseError")
|
91
161
|
.unwrap();
|
92
|
-
|
93
|
-
// redefined) and also not moved under compacting GC.
|
94
|
-
register_mark_object(ex);
|
162
|
+
register_mark_object(ex); // avoid GC
|
95
163
|
ex
|
96
164
|
});
|
97
165
|
|
@@ -102,21 +170,31 @@ static SCHEMA_PARSE_ERROR: Lazy<ExceptionClass> = Lazy::new(|ruby| {
|
|
102
170
|
.unwrap()
|
103
171
|
.const_get("SchemaParseError")
|
104
172
|
.unwrap();
|
105
|
-
|
106
|
-
|
107
|
-
|
173
|
+
register_mark_object(ex); // avoid GC
|
174
|
+
ex
|
175
|
+
});
|
176
|
+
|
177
|
+
static INVALID_OPTIONS_ERROR: Lazy<ExceptionClass> = Lazy::new(|ruby| {
|
178
|
+
let ex = ruby
|
179
|
+
.class_object()
|
180
|
+
.const_get::<_, RModule>("RustJSONSchema")
|
181
|
+
.unwrap()
|
182
|
+
.const_get("InvalidOptionsError")
|
183
|
+
.unwrap();
|
184
|
+
register_mark_object(ex); // avoid GC
|
108
185
|
ex
|
109
186
|
});
|
110
187
|
|
111
188
|
#[magnus::init]
|
112
|
-
fn init(ruby: &Ruby) -> Result<(),
|
189
|
+
fn init(ruby: &Ruby) -> Result<(), Error> {
|
113
190
|
let module = ruby.define_module("RustJSONSchema")?;
|
114
|
-
let class = module.define_class("Validator", ruby.class_object())?;
|
115
|
-
|
116
|
-
class.define_singleton_method("new", function!(Validator::new, 1))?;
|
117
191
|
|
192
|
+
// RustJSONSchema::Validator
|
193
|
+
let class = module.define_class("Validator", ruby.class_object())?;
|
194
|
+
class.define_singleton_method("new", function!(Validator::new, -1))?;
|
118
195
|
class.define_method("valid?", method!(Validator::is_valid, 1))?;
|
119
196
|
class.define_method("validate", method!(Validator::validate, 1))?;
|
197
|
+
class.define_method("options", method!(Validator::options, 0))?;
|
120
198
|
|
121
199
|
// Ensure defined at load time
|
122
200
|
Lazy::force(&JSON_PARSE_ERROR, ruby);
|
data/lib/rust_json_schema.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rust_json_schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taylor Thurlow
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|