Skip to content

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

  1. Checkout the bmarjanovic/fix-invalid-prod-json-schema-definition branch
  2. Run the rails console
  3. 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
  1. 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.

Edited by Peter Leitzen

Merge request reports