From bf594f36941bcb5024bd7f6f2a6d714827cc1ef7 Mon Sep 17 00:00:00 2001 From: Konstantin Kostiuk Date: Thu, 14 Mar 2024 18:36:06 +0200 Subject: [PATCH] Drop JSON Type Definition JTD was replaced with Sorbet. Signed-off-by: Konstantin Kostiuk --- Gemfile | 1 - Gemfile.lock | 2 - lib/engines/hckinstall/hckinstall.jtd.json | 7 - lib/engines/hcktest/drivers/jtd.json | 30 -- lib/engines/hcktest/hcktest.jtd.json | 6 - lib/engines/hcktest/platforms/jtd.json | 59 ---- sorbet/rbi/gems/jtd@0.1.6.rbi | 393 --------------------- spec/json_validation_spec.rb | 35 -- spec/srb_json_load_spec.rb | 2 - 9 files changed, 535 deletions(-) delete mode 100644 lib/engines/hckinstall/hckinstall.jtd.json delete mode 100644 lib/engines/hcktest/drivers/jtd.json delete mode 100644 lib/engines/hcktest/hcktest.jtd.json delete mode 100644 lib/engines/hcktest/platforms/jtd.json delete mode 100644 sorbet/rbi/gems/jtd@0.1.6.rbi delete mode 100644 spec/json_validation_spec.rb diff --git a/Gemfile b/Gemfile index 850f1329..8ad897db 100644 --- a/Gemfile +++ b/Gemfile @@ -25,7 +25,6 @@ end group :test do gem 'code-scanning-rubocop' - gem 'jtd' gem 'rspec' gem 'rubocop' end diff --git a/Gemfile.lock b/Gemfile.lock index 6a83411e..c1e7d8b3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -55,7 +55,6 @@ GEM i18n (1.14.4) concurrent-ruby (~> 1.0) json (2.7.1) - jtd (0.1.6) jwt (2.2.3) language_server-protocol (3.17.0.3) little-plugger (1.1.4) @@ -199,7 +198,6 @@ DEPENDENCIES dotenv dropbox_api filelock - jtd mono_logger octokit openssl diff --git a/lib/engines/hckinstall/hckinstall.jtd.json b/lib/engines/hckinstall/hckinstall.jtd.json deleted file mode 100644 index 69da7327..00000000 --- a/lib/engines/hckinstall/hckinstall.jtd.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "properties": { - "hck_setup_scripts_path": { "type": "string" }, - "answer_files": { "elements": { "type": "string" } }, - "install_timeout": { "type": "uint16" } - } -} diff --git a/lib/engines/hcktest/drivers/jtd.json b/lib/engines/hcktest/drivers/jtd.json deleted file mode 100644 index 25bb31f8..00000000 --- a/lib/engines/hcktest/drivers/jtd.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "definitions": { - "command_info": { - "properties": { - "desc": { "type": "string" }, - "run": { "type": "string" } - } - } - }, - "properties": { - "name": { "type": "string" }, - "device": { "type": "string" }, - "install_method": { "enum": [ "PNP", "no-drv", "custom" ] }, - "type": { "type": "int32" }, - "support": { "type": "boolean" } - }, - "optionalProperties": { - "inf": { "type": "string" }, - "sys": { "type": "string" }, - "install_cert": { "type": "boolean" }, - "install_command": { "type": "string" }, - "s3_state": { "type": "boolean" }, - "s4_state": { "type": "boolean" }, - "enlightenments_state": { "type": "boolean" }, - "pretestcommands": { "elements": { "ref": "command_info" } }, - "extra_software": { "elements": { "type": "string" } }, - "reject_test_names": { "elements": { "type": "string" } }, - "select_test_names": { "elements": { "type": "string" } } - } -} diff --git a/lib/engines/hcktest/hcktest.jtd.json b/lib/engines/hcktest/hcktest.jtd.json deleted file mode 100644 index 44001a03..00000000 --- a/lib/engines/hcktest/hcktest.jtd.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "properties": { - "playlists_path": { "type": "string" }, - "filters_path": { "type": "string" } - } -} diff --git a/lib/engines/hcktest/platforms/jtd.json b/lib/engines/hcktest/platforms/jtd.json deleted file mode 100644 index 92ac5069..00000000 --- a/lib/engines/hcktest/platforms/jtd.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "discriminator": "setupmanager", - "mapping": { - "physhck": { - "properties": { - "name": { "type": "string" }, - "kit": { "type": "string" }, - "clients": { - "properties": { - "c1": { "ref": "physhck_client" } - }, - "optionalProperties": { - "c2": { "ref": "physhck_client" } - } - } - } - }, - "qemuhck": { - "properties": { - "name": { "type": "string" }, - "kit": { "type": "string" }, - "st_image": { "type": "string" }, - "clients": { - "properties": { - "c1": { "ref": "qemuhck_client" } - }, - "optionalProperties": { - "c2": { "ref": "qemuhck_client" } - } - } - }, - "optionalProperties": { - "cpu": { "type": "string" }, - "machine_type": { "enum": [ "q35", "pc" ] }, - "fw_type": { "enum": [ "uefi", "bios" ] }, - "viommu_state": { "type": "boolean" }, - "enlightenments_state": { "type": "boolean" }, - "device_extra": { "type": "string" } - } - } - }, - "definitions": { - "physhck_client": { - "properties": { - "name": { "type": "string" }, - "winrm_port": { "type": "string" } - } - }, - "qemuhck_client": { - "properties": { - "name": { "type": "string" }, - "cpus": { "type": "string" }, - "memory_gb": { "type": "uint16" }, - "winrm_port": { "type": "string" }, - "image": { "type": "string" } - } - } - } -} diff --git a/sorbet/rbi/gems/jtd@0.1.6.rbi b/sorbet/rbi/gems/jtd@0.1.6.rbi deleted file mode 100644 index f18206a6..00000000 --- a/sorbet/rbi/gems/jtd@0.1.6.rbi +++ /dev/null @@ -1,393 +0,0 @@ -# typed: true - -# DO NOT EDIT MANUALLY -# This is an autogenerated file for types exported from the `jtd` gem. -# Please instead update this file by running `bin/tapioca gem jtd`. - -# JTD is an implementation of JSON Type Definition validation for Ruby. -# -# source://jtd//lib/jtd/schema.rb#1 -module JTD - class << self - # Validates +instance+ against +schema+ according to the JSON Type Definition - # specification. - # - # Returns a list of ValidationError. If there are no validation errors, then - # the returned list will be empty. - # - # By default, all errors are returned, and an unlimited number of references - # will be followed. If you are running #validate against schemas that may - # return a lot of errors, or which may contain circular references, then this - # can cause performance issues or stack overflows. - # - # To mitigate this risk, consider using +options+, which must be an instance - # of ValidationOptions, to limit the number of errors returned or references - # followed. - # - # If ValidationOptions#max_depth is reached, then #validate will raise a - # MaxDepthExceededError. - # - # The return value of #validate is not well-defined if the schema is not - # valid, i.e. Schema#verify raises an error. - # - # source://jtd//lib/jtd/validate.rb#24 - def validate(schema, instance, options = T.unsafe(nil)); end - - # source://jtd//lib/jtd/validate.rb#354 - def validate_int(state, instance, min, max); end - - # source://jtd//lib/jtd/validate.rb#152 - def validate_with_state(state, schema, instance, parent_tag = T.unsafe(nil)); end - end -end - -# Error raised from JTD::validate if the number of references followed exceeds -# ValidationOptions#max_depth. -# -# source://jtd//lib/jtd/validate.rb#110 -class JTD::MaxDepthExceededError < ::StandardError - # Constructs a new MaxDepthExceededError. - # - # @return [MaxDepthExceededError] a new instance of MaxDepthExceededError - # - # source://jtd//lib/jtd/validate.rb#112 - def initialize(msg = T.unsafe(nil)); end -end - -# source://jtd//lib/jtd/validate.rb#147 -class JTD::MaxErrorsReachedError < ::StandardError; end - -# Represents a JSON Type Definition schema. -# -# source://jtd//lib/jtd/schema.rb#3 -class JTD::Schema - # source://jtd//lib/jtd/schema.rb#4 - def additional_properties; end - - # source://jtd//lib/jtd/schema.rb#4 - def additional_properties=(_arg0); end - - # source://jtd//lib/jtd/schema.rb#4 - def definitions; end - - # source://jtd//lib/jtd/schema.rb#4 - def definitions=(_arg0); end - - # source://jtd//lib/jtd/schema.rb#4 - def discriminator; end - - # source://jtd//lib/jtd/schema.rb#4 - def discriminator=(_arg0); end - - # source://jtd//lib/jtd/schema.rb#4 - def elements; end - - # source://jtd//lib/jtd/schema.rb#4 - def elements=(_arg0); end - - # source://jtd//lib/jtd/schema.rb#4 - def enum; end - - # source://jtd//lib/jtd/schema.rb#4 - def enum=(_arg0); end - - # Returns the form that the schema takes on. - # - # The return value will be one of :empty, :ref:, :type, :enum, :elements, - # :properties, :values, or :discriminator. - # - # If the schema is not well-formed, i.e. calling #verify on it raises an - # error, then the return value of #form is not well-defined. - # - # source://jtd//lib/jtd/schema.rb#209 - def form; end - - # source://jtd//lib/jtd/schema.rb#4 - def mapping; end - - # source://jtd//lib/jtd/schema.rb#4 - def mapping=(_arg0); end - - # source://jtd//lib/jtd/schema.rb#4 - def metadata; end - - # source://jtd//lib/jtd/schema.rb#4 - def metadata=(_arg0); end - - # source://jtd//lib/jtd/schema.rb#4 - def nullable; end - - # source://jtd//lib/jtd/schema.rb#4 - def nullable=(_arg0); end - - # source://jtd//lib/jtd/schema.rb#4 - def optional_properties; end - - # source://jtd//lib/jtd/schema.rb#4 - def optional_properties=(_arg0); end - - # source://jtd//lib/jtd/schema.rb#4 - def properties; end - - # source://jtd//lib/jtd/schema.rb#4 - def properties=(_arg0); end - - # source://jtd//lib/jtd/schema.rb#4 - def ref; end - - # source://jtd//lib/jtd/schema.rb#4 - def ref=(_arg0); end - - # source://jtd//lib/jtd/schema.rb#4 - def type; end - - # source://jtd//lib/jtd/schema.rb#4 - def type=(_arg0); end - - # source://jtd//lib/jtd/schema.rb#4 - def values; end - - # source://jtd//lib/jtd/schema.rb#4 - def values=(_arg0); end - - # Raises a TypeError or ArgumentError if the Schema is not correct according - # to the JSON Type Definition specification. - # - # See the JSON Type Definition specification for more details, but a high - # level #verify checks such things as: - # - # 1. Making sure each of the attributes of the Schema are of the right type, - # 2. The Schema uses a valid combination of JSON Type Definition keywords, - # 3. The Schema isn't ambiguous or unsatisfiable. - # 4. The Schema doesn't make references to nonexistent definitions. - # - # If root is specified, then that root is assumed to contain the schema - # being verified. By default, the Schema is considered its own root, which - # is usually the desired behavior. - # - # source://jtd//lib/jtd/schema.rb#103 - def verify(root = T.unsafe(nil)); end - - private - - # source://jtd//lib/jtd/schema.rb#284 - def check_type(key, classes); end - - class << self - # Constructs a Schema from a Hash like the kind produced by JSON#parse. - # - # In other words, #from_hash is meant to be used to convert some parsed JSON - # into a Schema. - # - # If hash isn't a Hash or contains keys that are illegal for JSON Type - # Definition, then #from_hash will raise a TypeError. - # - # If the properties of hash are not of the correct type for a JSON Type - # Definition schema (for example, if the "elements" property of hash is - # non-nil, but not a hash), then #from_hash may raise a NoMethodError. - # - # @raise [TypeError] - # - # source://jtd//lib/jtd/schema.rb#31 - def from_hash(hash); end - end -end - -# source://jtd//lib/jtd/schema.rb#223 -JTD::Schema::KEYWORDS = T.let(T.unsafe(nil), Array) - -# source://jtd//lib/jtd/schema.rb#241 -JTD::Schema::TYPES = T.let(T.unsafe(nil), Array) - -# source://jtd//lib/jtd/schema.rb#257 -JTD::Schema::VALID_FORMS = T.let(T.unsafe(nil), Array) - -# The version of the +jtd+ gem you are using. -# -# source://jtd//lib/jtd/version.rb#3 -JTD::VERSION = T.let(T.unsafe(nil), String) - -# Represents a single JSON Type Definition validation error. -# -# ValidationError does not extend StandardError; it is not a Ruby exception. -# It is a plain old Ruby object. -# -# Every ValidationError has two attributes: -# -# * +instance_path+ is an array of strings. It represents the path to the part -# of the +instance+ passed to JTD::validate that was rejected. -# -# * +schema_path+ is an array of strings. It represents the path to the part -# of the +schema+ passed to JTD::validate that rejected the instance at -# +instance_path+. -# -# source://jtd//lib/jtd/validate.rb#96 -class JTD::ValidationError < ::Struct - class << self - # Constructs a new ValidationError from the standard JSON representation of - # a validation error in JSON Type Definition. - # - # source://jtd//lib/jtd/validate.rb#100 - def from_hash(hash); end - end -end - -# Options you can pass to JTD::validate. -# -# source://jtd//lib/jtd/validate.rb#43 -class JTD::ValidationOptions - # Construct a new set of ValidationOptions with the given +max_depth+ and - # +max_errors+. - # - # See the documentation for +max_depth+ and +max_errors+ for what their - # default values of 0 mean. - # - # @return [ValidationOptions] a new instance of ValidationOptions - # - # source://jtd//lib/jtd/validate.rb#77 - def initialize(max_depth: T.unsafe(nil), max_errors: T.unsafe(nil)); end - - # The maximum number of references to follow before aborting validation. You - # can use this to prevent a stack overflow when validating schemas that - # potentially have infinite loops, such as this one: - # - # { - # "definitions": { - # "loop": { "ref": "loop" } - # }, - # "ref": "loop" - # } - # - # The default value for +max_depth+ is 0, which indicates that no max depth - # should be imposed at all. - # - # source://jtd//lib/jtd/validate.rb#57 - def max_depth; end - - # The maximum number of references to follow before aborting validation. You - # can use this to prevent a stack overflow when validating schemas that - # potentially have infinite loops, such as this one: - # - # { - # "definitions": { - # "loop": { "ref": "loop" } - # }, - # "ref": "loop" - # } - # - # The default value for +max_depth+ is 0, which indicates that no max depth - # should be imposed at all. - # - # source://jtd//lib/jtd/validate.rb#57 - def max_depth=(_arg0); end - - # The maximum number of errors to return. You can use this to have - # JTD::validate have better performance if you don't have any use for errors - # beyond a certain count. - # - # For instance, if all you care about is whether or not there are any - # validation errors at all, you can set +max_errors+ to 1. If you're - # presenting validation errors in an interface that can't show more than 5 - # errors, set +max_errors+ to 5. - # - # The default value for +max_errors+ is 0, which indicates that all errors - # will be returned. - # - # source://jtd//lib/jtd/validate.rb#70 - def max_errors; end - - # The maximum number of errors to return. You can use this to have - # JTD::validate have better performance if you don't have any use for errors - # beyond a certain count. - # - # For instance, if all you care about is whether or not there are any - # validation errors at all, you can set +max_errors+ to 1. If you're - # presenting validation errors in an interface that can't show more than 5 - # errors, set +max_errors+ to 5. - # - # The default value for +max_errors+ is 0, which indicates that all errors - # will be returned. - # - # source://jtd//lib/jtd/validate.rb#70 - def max_errors=(_arg0); end -end - -# source://jtd//lib/jtd/validate.rb#119 -class JTD::ValidationState - # Returns the value of attribute errors. - # - # source://jtd//lib/jtd/validate.rb#120 - def errors; end - - # Sets the attribute errors - # - # @param value the value to set the attribute errors to. - # - # source://jtd//lib/jtd/validate.rb#120 - def errors=(_arg0); end - - # Returns the value of attribute instance_tokens. - # - # source://jtd//lib/jtd/validate.rb#120 - def instance_tokens; end - - # Sets the attribute instance_tokens - # - # @param value the value to set the attribute instance_tokens to. - # - # source://jtd//lib/jtd/validate.rb#120 - def instance_tokens=(_arg0); end - - # Returns the value of attribute options. - # - # source://jtd//lib/jtd/validate.rb#120 - def options; end - - # Sets the attribute options - # - # @param value the value to set the attribute options to. - # - # source://jtd//lib/jtd/validate.rb#120 - def options=(_arg0); end - - # source://jtd//lib/jtd/validate.rb#126 - def pop_instance_token; end - - # source://jtd//lib/jtd/validate.rb#134 - def pop_schema_token; end - - # @raise [MaxErrorsReachedError] - # - # source://jtd//lib/jtd/validate.rb#138 - def push_error; end - - # source://jtd//lib/jtd/validate.rb#122 - def push_instance_token(token); end - - # source://jtd//lib/jtd/validate.rb#130 - def push_schema_token(token); end - - # Returns the value of attribute root_schema. - # - # source://jtd//lib/jtd/validate.rb#120 - def root_schema; end - - # Sets the attribute root_schema - # - # @param value the value to set the attribute root_schema to. - # - # source://jtd//lib/jtd/validate.rb#120 - def root_schema=(_arg0); end - - # Returns the value of attribute schema_tokens. - # - # source://jtd//lib/jtd/validate.rb#120 - def schema_tokens; end - - # Sets the attribute schema_tokens - # - # @param value the value to set the attribute schema_tokens to. - # - # source://jtd//lib/jtd/validate.rb#120 - def schema_tokens=(_arg0); end -end diff --git a/spec/json_validation_spec.rb b/spec/json_validation_spec.rb deleted file mode 100644 index 2871e6fc..00000000 --- a/spec/json_validation_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'json' -require 'jtd' - -describe 'json_validation' do - Dir['./**/*.json'].each do |json_file| - next if json_file.include? 'jtd.json' - - - name = File.basename(json_file, '.json') - dir = File.dirname(json_file) - it json_file.to_s do - json_schema_candidates = [ - "#{dir}/#{name}.jtd.json", - "#{dir}/jtd.json", - ] - - json_schemas = json_schema_candidates.filter_map do |f| - JSON.load_file(f) - rescue Errno::ENOENT - end - - if json_schemas.empty? - pending("NO SCHEMA FOR #{name} -> #{json_schema_candidates}") - raise - end - - json_data = JSON.load_file(json_file) - schema = JTD::Schema.from_hash(json_schemas.first) - schema.verify() - - result = JTD::validate(schema, json_data) - expect(result).to eq([]) - end - end -end diff --git a/spec/srb_json_load_spec.rb b/spec/srb_json_load_spec.rb index df2a8bc6..fa980ef7 100644 --- a/spec/srb_json_load_spec.rb +++ b/spec/srb_json_load_spec.rb @@ -8,8 +8,6 @@ describe 'srb_json_load' do Dir['./**/*.json'].each do |json_file| - next if json_file.include? 'jtd.json' - it json_file.to_s do pair = JSON_TYPES_MAP.find { File.fnmatch(_1[0], json_file) }