| 1 | use serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Valuerust-analyzer cargo serde_json 1.0.145 value/Value#; |
| 2 | use subresourcesrust-analyzer cargo referencing 0.37.4 specification/subresources/::SubresourceIteratorrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIterator#; |
| 3 | |
| 4 | mod draft201909rust-analyzer cargo referencing 0.37.4 specification/draft201909/; |
| 5 | mod draft4rust-analyzer cargo referencing 0.37.4 specification/draft4/; |
| 6 | mod draft6rust-analyzer cargo referencing 0.37.4 specification/draft6/; |
| 7 | mod draft7rust-analyzer cargo referencing 0.37.4 specification/draft7/; |
| 8 | mod idsrust-analyzer cargo referencing 0.37.4 specification/ids/; |
| 9 | mod subresourcesrust-analyzer cargo referencing 0.37.4 specification/subresources/; |
| 10 | |
| 11 | use craterust-analyzer cargo referencing 0.37.4 crate/::{ |
| 12 | anchorsrust-analyzer cargo referencing 0.37.4 anchors/, |
| 13 | resourcerust-analyzer cargo referencing 0.37.4 resource/::InnerResourcePtrrust-analyzer cargo referencing 0.37.4 resource/InnerResourcePtr#, |
| 14 | vocabulariesrust-analyzer cargo referencing 0.37.4 vocabularies/::{VocabularySetrust-analyzer cargo referencing 0.37.4 vocabularies/VocabularySet#, DRAFT_2019_09_VOCABULARIESrust-analyzer cargo referencing 0.37.4 vocabularies/DRAFT_2019_09_VOCABULARIES., DRAFT_2020_12_VOCABULARIESrust-analyzer cargo referencing 0.37.4 vocabularies/DRAFT_2020_12_VOCABULARIES.}, |
| 15 | Anchorrust-analyzer cargo referencing 0.37.4 anchors/Anchor#, Errorrust-analyzer cargo referencing 0.37.4 error/Error#, Resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolver#, Resourcerust-analyzer cargo referencing 0.37.4 resource/Resource#, ResourceRefrust-analyzer cargo referencing 0.37.4 resource/ResourceRef#, Segmentsrust-analyzer cargo referencing 0.37.4 segments/Segments#, |
| 16 | }; |
| 17 | |
| 18 | /// JSON Schema specification versions. |
| 19 | #[non_exhaustive] |
| 20 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:)] |
| 21 | pub enum Draftrust-analyzer cargo referencing 0.37.4 specification/Draft# { |
| 22 | /// JSON Schema Draft 4 |
| 23 | Draft4rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft4#, |
| 24 | /// JSON Schema Draft 6 |
| 25 | Draft6rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft6#, |
| 26 | /// JSON Schema Draft 7 |
| 27 | Draft7rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft7#, |
| 28 | /// JSON Schema Draft 2019-09 |
| 29 | Draft201909rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft201909#, |
| 30 | /// JSON Schema Draft 2020-12 |
| 31 | #[defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/default:] |
| 32 | Draft202012rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft202012#, |
| 33 | /// Internal use only: Represents custom/unrecognized meta-schemas. |
| 34 | /// Do not use directly. Custom meta-schemas are resolved automatically |
| 35 | /// when registered in the Registry. |
| 36 | #[doc(hidden)] |
| 37 | Unknownrust-analyzer cargo referencing 0.37.4 specification/Draft#Unknown#, |
| 38 | } |
| 39 | |
| 40 | impl Draftrust-analyzer cargo referencing 0.37.4 specification/Draft# { |
| 41 | #[must_use] |
| 42 | pub fn create_resourcerust-analyzer cargo referencing 0.37.4 specification/impl#[Draft]create_resource().(self, contents: Valuerust-analyzer cargo serde_json 1.0.145 value/Value#) -> Resourcerust-analyzer cargo referencing 0.37.4 resource/Resource# { |
| 43 | Resourcerust-analyzer cargo referencing 0.37.4 resource/Resource#::newrust-analyzer cargo referencing 0.37.4 resource/impl#[Resource]new().(contents, self) |
| 44 | } |
| 45 | #[must_use] |
| 46 | pub fn create_resource_refrust-analyzer cargo referencing 0.37.4 specification/impl#[Draft]create_resource_ref().(self, contents: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#) -> ResourceRefrust-analyzer cargo referencing 0.37.4 resource/ResourceRef#<'_> { |
| 47 | ResourceRefrust-analyzer cargo referencing 0.37.4 resource/ResourceRef#::newrust-analyzer cargo referencing 0.37.4 resource/impl#[`ResourceRef<'a>`]new().(contents, self) |
| 48 | } |
| 49 | /// Detect what specification could be applied to the given contents. |
| 50 | /// |
| 51 | /// Returns `Draft::Unknown` for custom/unknown `$schema` values. |
| 52 | /// Validation of custom meta-schemas happens during registry building. |
| 53 | #[must_use] |
| 54 | pub fn detectrust-analyzer cargo referencing 0.37.4 specification/impl#[Draft]detect().(self, contents: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#) -> Draftrust-analyzer cargo referencing 0.37.4 specification/Draft# { |
| 55 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(schema) = contents |
| 56 | .as_objectrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]as_object().() |
| 57 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|contents| contents.getrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]get().("$schema")) |
| 58 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|schema| schema.as_strrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]as_str().()) |
| 59 | { |
| 60 | match schema.trim_end_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_end_matches().('#') { |
| 61 | // Accept both HTTPS and HTTP for all known drafts |
| 62 | "https://json-schema.org/draft/2020-12/schema" |
| 63 | | "http://json-schema.org/draft/2020-12/schema" => Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft202012rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft202012#, |
| 64 | "https://json-schema.org/draft/2019-09/schema" |
| 65 | | "http://json-schema.org/draft/2019-09/schema" => Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft201909rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft201909#, |
| 66 | "https://json-schema.org/draft-07/schema" |
| 67 | | "http://json-schema.org/draft-07/schema" => Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft7rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft7#, |
| 68 | "https://json-schema.org/draft-06/schema" |
| 69 | | "http://json-schema.org/draft-06/schema" => Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft6rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft6#, |
| 70 | "https://json-schema.org/draft-04/schema" |
| 71 | | "http://json-schema.org/draft-04/schema" => Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft4rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft4#, |
| 72 | // Custom/unknown meta-schemas return Unknown |
| 73 | // Validation of custom meta-schemas happens during registry building |
| 74 | _ => Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Unknownrust-analyzer cargo referencing 0.37.4 specification/Draft#Unknown#, |
| 75 | } |
| 76 | } else { |
| 77 | self |
| 78 | } |
| 79 | } |
| 80 | pub(craterust-analyzer cargo referencing 0.37.4 crate/) fn id_ofrust-analyzer cargo referencing 0.37.4 specification/impl#[Draft]id_of().(self, contents: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str> { |
| 81 | match self { |
| 82 | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft4rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft4# => idsrust-analyzer cargo referencing 0.37.4 specification/ids/::legacy_idrust-analyzer cargo referencing 0.37.4 specification/ids/legacy_id().(contents), |
| 83 | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft6rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft6# | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft7rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft7# => idsrust-analyzer cargo referencing 0.37.4 specification/ids/::legacy_dollar_idrust-analyzer cargo referencing 0.37.4 specification/ids/legacy_dollar_id().(contents), |
| 84 | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft201909rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft201909# | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft202012rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft202012# | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Unknownrust-analyzer cargo referencing 0.37.4 specification/Draft#Unknown# => idsrust-analyzer cargo referencing 0.37.4 specification/ids/::dollar_idrust-analyzer cargo referencing 0.37.4 specification/ids/dollar_id().(contents), |
| 85 | } |
| 86 | } |
| 87 | pub fn subresources_ofrust-analyzer cargo referencing 0.37.4 specification/impl#[Draft]subresources_of().(self, contents: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#) -> impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#> { |
| 88 | match contents.as_objectrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]as_object().() { |
| 89 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(schema) => { |
| 90 | let object_iter = match self { |
| 91 | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft4rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft4# => draft4rust-analyzer cargo referencing 0.37.4 specification/draft4/::object_iterrust-analyzer cargo referencing 0.37.4 specification/draft4/object_iter()., |
| 92 | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft6rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft6# => draft6rust-analyzer cargo referencing 0.37.4 specification/draft6/::object_iterrust-analyzer cargo referencing 0.37.4 specification/draft6/object_iter()., |
| 93 | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft7rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft7# => draft7rust-analyzer cargo referencing 0.37.4 specification/draft7/::object_iterrust-analyzer cargo referencing 0.37.4 specification/draft7/object_iter()., |
| 94 | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft201909rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft201909# => draft201909rust-analyzer cargo referencing 0.37.4 specification/draft201909/::object_iterrust-analyzer cargo referencing 0.37.4 specification/draft201909/object_iter()., |
| 95 | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft202012rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft202012# | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Unknownrust-analyzer cargo referencing 0.37.4 specification/Draft#Unknown# => subresourcesrust-analyzer cargo referencing 0.37.4 specification/subresources/::object_iterrust-analyzer cargo referencing 0.37.4 specification/subresources/object_iter()., |
| 96 | }; |
| 97 | SubresourceIteratorrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIterator#::Objectrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIterator#Object#(schema.iterrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]iter().().flat_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#flat_map().(object_iter)) |
| 98 | } |
| 99 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => SubresourceIteratorrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIterator#::Emptyrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIterator#Empty#, |
| 100 | } |
| 101 | } |
| 102 | pub(craterust-analyzer cargo referencing 0.37.4 crate/) fn anchorsrust-analyzer cargo referencing 0.37.4 specification/impl#[Draft]anchors().(self, contents: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#) -> impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = Anchorrust-analyzer cargo referencing 0.37.4 anchors/Anchor#> { |
| 103 | match self { |
| 104 | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft4rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft4# => anchorsrust-analyzer cargo referencing 0.37.4 anchors/::legacy_anchor_in_idrust-analyzer cargo referencing 0.37.4 anchors/legacy_anchor_in_id().(self, contents), |
| 105 | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft6rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft6# | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft7rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft7# => anchorsrust-analyzer cargo referencing 0.37.4 anchors/::legacy_anchor_in_dollar_idrust-analyzer cargo referencing 0.37.4 anchors/legacy_anchor_in_dollar_id().(self, contents), |
| 106 | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft201909rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft201909# => anchorsrust-analyzer cargo referencing 0.37.4 anchors/::anchor_2019rust-analyzer cargo referencing 0.37.4 anchors/anchor_2019().(self, contents), |
| 107 | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft202012rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft202012# | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Unknownrust-analyzer cargo referencing 0.37.4 specification/Draft#Unknown# => anchorsrust-analyzer cargo referencing 0.37.4 anchors/::anchorrust-analyzer cargo referencing 0.37.4 anchors/anchor().(self, contents), |
| 108 | } |
| 109 | } |
| 110 | pub(craterust-analyzer cargo referencing 0.37.4 crate/) fn maybe_in_subresourcerust-analyzer cargo referencing 0.37.4 specification/impl#[Draft]maybe_in_subresource().<'r>( |
| 111 | self, |
| 112 | segments: &Segmentsrust-analyzer cargo referencing 0.37.4 segments/Segments#, |
| 113 | resolver: &Resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolver#<'r>, |
| 114 | subresource: &InnerResourcePtrrust-analyzer cargo referencing 0.37.4 resource/InnerResourcePtr#, |
| 115 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolver#<'r>, Errorrust-analyzer cargo referencing 0.37.4 error/Error#> { |
| 116 | match self { |
| 117 | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft4rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft4# => draft4rust-analyzer cargo referencing 0.37.4 specification/draft4/::maybe_in_subresourcerust-analyzer cargo referencing 0.37.4 specification/draft4/maybe_in_subresource().(segments, resolver, subresource), |
| 118 | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft6rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft6# => draft6rust-analyzer cargo referencing 0.37.4 specification/draft6/::maybe_in_subresourcerust-analyzer cargo referencing 0.37.4 specification/draft6/maybe_in_subresource().(segments, resolver, subresource), |
| 119 | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft7rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft7# => draft7rust-analyzer cargo referencing 0.37.4 specification/draft7/::maybe_in_subresourcerust-analyzer cargo referencing 0.37.4 specification/draft7/maybe_in_subresource().(segments, resolver, subresource), |
| 120 | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft201909rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft201909# => { |
| 121 | draft201909rust-analyzer cargo referencing 0.37.4 specification/draft201909/::maybe_in_subresourcerust-analyzer cargo referencing 0.37.4 specification/draft201909/maybe_in_subresource().(segments, resolver, subresource) |
| 122 | } |
| 123 | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft202012rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft202012# | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Unknownrust-analyzer cargo referencing 0.37.4 specification/Draft#Unknown# => { |
| 124 | subresourcesrust-analyzer cargo referencing 0.37.4 specification/subresources/::maybe_in_subresourcerust-analyzer cargo referencing 0.37.4 specification/subresources/maybe_in_subresource().(segments, resolver, subresource) |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | /// Identifies known JSON schema keywords per draft. |
| 129 | #[must_use] |
| 130 | pub fn is_known_keywordrust-analyzer cargo referencing 0.37.4 specification/impl#[Draft]is_known_keyword().(&self, keyword: &str) -> bool { |
| 131 | match keyword { |
| 132 | "$ref" |
| 133 | | "$schema" |
| 134 | | "additionalItems" |
| 135 | | "additionalProperties" |
| 136 | | "allOf" |
| 137 | | "anyOf" |
| 138 | | "dependencies" |
| 139 | | "enum" |
| 140 | | "exclusiveMaximum" |
| 141 | | "exclusiveMinimum" |
| 142 | | "format" |
| 143 | | "items" |
| 144 | | "maxItems" |
| 145 | | "maxLength" |
| 146 | | "maxProperties" |
| 147 | | "maximum" |
| 148 | | "minItems" |
| 149 | | "minLength" |
| 150 | | "minProperties" |
| 151 | | "minimum" |
| 152 | | "multipleOf" |
| 153 | | "not" |
| 154 | | "oneOf" |
| 155 | | "pattern" |
| 156 | | "patternProperties" |
| 157 | | "properties" |
| 158 | | "required" |
| 159 | | "type" |
| 160 | | "uniqueItems" => true, |
| 161 | |
| 162 | "id" if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq().==rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq(). rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq().Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft4rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft4# => true, |
| 163 | |
| 164 | "$id" | "const" | "contains" | "propertyNames" |
| 165 | if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft6rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft6# || *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq().==rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq(). rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq().Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Unknownrust-analyzer cargo referencing 0.37.4 specification/Draft#Unknown# => |
| 166 | { |
| 167 | true |
| 168 | } |
| 169 | |
| 170 | "contentEncoding" | "contentMediaType" |
| 171 | if matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self, Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft6rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft6# | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft7rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft7#) => |
| 172 | { |
| 173 | true |
| 174 | } |
| 175 | |
| 176 | "else" | "if" | "then" if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft7rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft7# || *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq().==rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq(). rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq().Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Unknownrust-analyzer cargo referencing 0.37.4 specification/Draft#Unknown# => true, |
| 177 | |
| 178 | "$anchor" |
| 179 | | "$defs" |
| 180 | | "$recursiveAnchor" |
| 181 | | "$recursiveRef" |
| 182 | | "dependentRequired" |
| 183 | | "dependentSchemas" |
| 184 | | "maxContains" |
| 185 | | "minContains" |
| 186 | | "prefixItems" |
| 187 | | "unevaluatedItems" |
| 188 | | "unevaluatedProperties" |
| 189 | if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft201909rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft201909# || *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq().==rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq(). rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq().Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Unknownrust-analyzer cargo referencing 0.37.4 specification/Draft#Unknown# => |
| 190 | { |
| 191 | true |
| 192 | } |
| 193 | |
| 194 | "$dynamicAnchor" | "$dynamicRef" |
| 195 | if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq().==rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq(). rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq().Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft202012rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft202012# || *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq().==rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq(). rust-analyzer cargo referencing 0.37.4 specification/impl#[Draft][`PartialEq<Self>`]eq().Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Unknownrust-analyzer cargo referencing 0.37.4 specification/Draft#Unknown# => |
| 196 | { |
| 197 | true |
| 198 | } |
| 199 | |
| 200 | _ => false, |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | pub(craterust-analyzer cargo referencing 0.37.4 crate/) fn default_vocabulariesrust-analyzer cargo referencing 0.37.4 specification/impl#[Draft]default_vocabularies().(self) -> VocabularySetrust-analyzer cargo referencing 0.37.4 vocabularies/VocabularySet# { |
| 205 | match self { |
| 206 | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft4rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft4# | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft6rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft6# | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft7rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft7# => VocabularySetrust-analyzer cargo referencing 0.37.4 vocabularies/VocabularySet#::newrust-analyzer cargo referencing 0.37.4 vocabularies/impl#[VocabularySet]new().(), |
| 207 | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft201909rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft201909# => VocabularySetrust-analyzer cargo referencing 0.37.4 vocabularies/VocabularySet#::from_knownrust-analyzer cargo referencing 0.37.4 vocabularies/impl#[VocabularySet]from_known().(DRAFT_2019_09_VOCABULARIESrust-analyzer cargo referencing 0.37.4 vocabularies/DRAFT_2019_09_VOCABULARIES.), |
| 208 | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft202012rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft202012# | Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Unknownrust-analyzer cargo referencing 0.37.4 specification/Draft#Unknown# => { |
| 209 | VocabularySetrust-analyzer cargo referencing 0.37.4 vocabularies/VocabularySet#::from_knownrust-analyzer cargo referencing 0.37.4 vocabularies/impl#[VocabularySet]from_known().(DRAFT_2020_12_VOCABULARIESrust-analyzer cargo referencing 0.37.4 vocabularies/DRAFT_2020_12_VOCABULARIES.) |
| 210 | } |
| 211 | } |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | #[cfg(test)] |
| 216 | mod testsrust-analyzer cargo referencing 0.37.4 specification/tests/ { |
| 217 | use craterust-analyzer cargo referencing 0.37.4 crate/::Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#; |
| 218 | use serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::jsonrust-analyzer cargo serde_json 1.0.145 macros/json!; |
| 219 | use test_caserust-analyzer cargo test-case 3.3.1 crate/::test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:; |
| 220 | |
| 221 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"$schema": "https://json-schema.org/draft/2020-12/schema"}), Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft202012rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft202012#; "detect Draft 2020-12")] |
| 222 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"$schema": "https://json-schema.org/draft/2020-12/schema#"}), Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft202012rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft202012#; "detect Draft 2020-12 with fragment")] |
| 223 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"$schema": "https://json-schema.org/draft/2019-09/schema"}), Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft201909rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft201909#; "detect Draft 2019-09")] |
| 224 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"$schema": "http://json-schema.org/draft-07/schema"}), Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft7rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft7#; "detect Draft 7")] |
| 225 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"$schema": "https://json-schema.org/draft-07/schema"}), Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft7rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft7#; "detect Draft 7 https")] |
| 226 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"$schema": "http://json-schema.org/draft-06/schema"}), Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft6rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft6#; "detect Draft 6")] |
| 227 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"$schema": "https://json-schema.org/draft-06/schema"}), Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft6rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft6#; "detect Draft 6 https")] |
| 228 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"$schema": "http://json-schema.org/draft-04/schema"}), Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft4rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft4#; "detect Draft 4")] |
| 229 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"$schema": "https://json-schema.org/draft-04/schema"}), Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft4rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft4#; "detect Draft 4 https")] |
| 230 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({}), Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft7rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft7#; "default to Draft 7 when no $schema")] |
| 231 | fn test_detectrust-analyzer cargo referencing 0.37.4 specification/tests/test_detect().(contents: &serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, expected: Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#) { |
| 232 | let result = Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft7rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft7#.detectrust-analyzer cargo referencing 0.37.4 specification/impl#[Draft]detect().(contents); |
| 233 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(result, expected); |
| 234 | } |
| 235 | |
| 236 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 237 | fn test_unknown_specificationrust-analyzer cargo referencing 0.37.4 specification/tests/test_unknown_specification().() { |
| 238 | let draft = Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft7rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft7#.detectrust-analyzer cargo referencing 0.37.4 specification/impl#[Draft]detect().(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"$schema": "invalid"})); |
| 239 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(draft, Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Unknownrust-analyzer cargo referencing 0.37.4 specification/Draft#Unknown#); |
| 240 | } |
| 241 | |
| 242 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft4rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft4#; "Draft 4 stays Draft 4")] |
| 243 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft6rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft6#; "Draft 6 stays Draft 6")] |
| 244 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft7rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft7#; "Draft 7 stays Draft 7")] |
| 245 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft201909rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft201909#; "Draft 2019-09 stays Draft 2019-09")] |
| 246 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft202012rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft202012#; "Draft 2020-12 stays Draft 2020-12")] |
| 247 | fn test_detect_no_changerust-analyzer cargo referencing 0.37.4 specification/tests/test_detect_no_change().(draft: Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#) { |
| 248 | let contents = jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({}); |
| 249 | let result = draft.detectrust-analyzer cargo referencing 0.37.4 specification/impl#[Draft]detect().(&contents); |
| 250 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(result, draft); |
| 251 | } |
| 252 | } |