Sha256: 9c680c6e2cca14f250d0e1bf3daff067ded1c78327391c0d2bd5e67d4af9e984

Contents?: true

Size: 706 Bytes

Versions: 14

Compression:

Stored size: 706 Bytes

Contents

require "json-schema"

class Swagalicious
  class ExtendedSchema < JSON::Schema::Draft4
    def initialize
      super
      @attributes["type"] = ExtendedTypeAttribute
      @uri                = URI.parse("http://tempuri.org/swagalicious/extended_schema")
      @names              = ["http://tempuri.org/swagalicious/extended_schema"]
    end
  end

  class ExtendedTypeAttribute < JSON::Schema::TypeV4Attribute
    def self.validate(current_schema, data, fragments, processor, validator, options={})
      return if data.nil? && (current_schema.schema["null"] == true || current_schema.schema["nullable"] == true)
      super
    end
  end

  JSON::Validator.register_validator(ExtendedSchema.new)
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
swagalicious-2.0.0 lib/swagalicious/extended_schema.rb
swagalicious-1.1.2 lib/swagalicious/extended_schema.rb
swagalicious-1.1.1 lib/swagalicious/extended_schema.rb
swagalicious-1.1.0 lib/swagalicious/extended_schema.rb
swagalicious-1.0.0 lib/swagalicious/extended_schema.rb
swagalicious-0.5.3 lib/swagalicious/extended_schema.rb
swagalicious-0.5.2 lib/swagalicious/extended_schema.rb
swagalicious-0.5.1 lib/swagalicious/extended_schema.rb
swagalicious-0.5.0 lib/swagalicious/extended_schema.rb
swagalicious-0.4.9 lib/swagalicious/extended_schema.rb
swagalicious-0.4.8 lib/swagalicious/extended_schema.rb
swagalicious-0.4.7 lib/swagalicious/extended_schema.rb
swagalicious-0.4.6 lib/swagalicious/extended_schema.rb
swagalicious-0.4.5 lib/swagalicious/extended_schema.rb