File tree Expand file tree Collapse file tree 1 file changed +17
-16
lines changed Expand file tree Collapse file tree 1 file changed +17
-16
lines changed Original file line number Diff line number Diff line change @@ -145,18 +145,6 @@ def load_resource_spec(resource_spec_file): # pylint: disable=R # noqa: C901
145
145
LOG .debug ("Resource spec validation failed" , exc_info = True )
146
146
raise SpecValidationError (str (e )) from e
147
147
148
- min_max_keywords = {
149
- "minimum" ,
150
- "maximum" ,
151
- "minLength" ,
152
- "maxLength" ,
153
- "minProperties" ,
154
- "maxProperties" ,
155
- "minItems" ,
156
- "maxItems" ,
157
- "exclusiveMinimum" ,
158
- "exclusiveMaximum" ,
159
- }
160
148
try : # pylint: disable=R
161
149
for _key , schema in JsonSchemaFlattener (resource_spec ).flatten_schema ().items ():
162
150
for property_name , property_details in schema .get ("properties" , {}).items ():
@@ -168,44 +156,57 @@ def load_resource_spec(resource_spec_file): # pylint: disable=R # noqa: C901
168
156
try :
169
157
property_type = property_details ["type" ]
170
158
property_keywords = property_details .keys ()
171
- for types , allowed_keywords in [
159
+ keyword_mappings = [
172
160
(
173
161
{"integer" , "number" },
174
162
{
175
163
"minimum" ,
176
164
"maximum" ,
177
165
"exclusiveMinimum" ,
178
166
"exclusiveMaximum" ,
167
+ "multipleOf" ,
179
168
},
180
169
),
181
170
(
182
171
{"string" },
183
172
{
184
173
"minLength" ,
185
174
"maxLength" ,
175
+ "pattern" ,
186
176
},
187
177
),
188
178
(
189
179
{"object" },
190
180
{
191
181
"minProperties" ,
192
182
"maxProperties" ,
183
+ "additionalProperties" ,
184
+ "patternProperties" ,
193
185
},
194
186
),
195
187
(
196
188
{"array" },
197
189
{
198
190
"minItems" ,
199
191
"maxItems" ,
192
+ "additionalItems" ,
193
+ "uniqueItems" ,
200
194
},
201
195
),
202
- ]:
196
+ ]
197
+ type_specific_keywords = set ().union (
198
+ * (mapping [1 ] for mapping in keyword_mappings )
199
+ )
200
+ for types , allowed_keywords in keyword_mappings :
203
201
if (
204
202
property_type in types
205
- and min_max_keywords - allowed_keywords & property_keywords
203
+ and type_specific_keywords - allowed_keywords
204
+ & property_keywords
206
205
):
207
206
LOG .warning (
208
- "Incorrect min/max JSON schema keywords for type: %s for property: %s" ,
207
+ "Incorrect JSON schema keyword(s) %s for type: %s for property: %s" ,
208
+ type_specific_keywords - allowed_keywords
209
+ & property_keywords ,
209
210
property_type ,
210
211
property_name ,
211
212
)
You can’t perform that action at this time.
0 commit comments