Fix production JSON schema
What does this MR do and why?
We are fixing invalid production schemas.
See https://gitlab.com/gitlab-org/gitlab/-/issues/351904
How to set up and validate locally
- Checkout the
bmarjanovic/fix-invalid-prod-json-schema-definition
branch - Run the
rails console
- Execute the following script
Click to expand
require "json"
require "json_schemer"
require "open-uri"
validator = JSON.parse(open("https://json-schema.org/draft-07/schema").read)
schema_validator = JSONSchemer.schema(validator)
dirs = `find . -name "*.json" | grep schema | grep -vE "node_modules|spec" | xargs dirname | sort | uniq`.split("\n")
valid, invalid = dirs.map { |dir| Dir.glob("#{dir}/**/*.json").partition { |schema| schema_validator.valid?(JSON.parse(File.read(schema))) } }.inject([[], []]) { |(vs, ivs), (valid, invalid)| [vs + valid, ivs + invalid] }
invalid
- Validate there are no invalid schemas
🎉
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Peter Leitzen