lib/utils.rb
def generate_json_schema(obj)

      # JSON Schema spec: http://json-schema.org/latest/json-schema-validation.html
      schema_hash = {}
      schema_hash['$schema'] = @site.config['json_schema_schema_uri']
      schema_hash['title'] = @title if @title
      schema_hash['description'] = Jekyll::sanatize_json_string(obj['description']) if obj.include?('description')
      schema_hash['type'] = 'object'

      required_properties = []
      schema_hash['properties'] = DeepClone.clone obj['body']['application/x-www-form-urlencoded']['formParameters']
      schema_hash['properties'].each do |name, param|
        if param.include?('required')
          required_properties << name if param['required'] == true
          param.delete('required')
        end

        if param.include?('description')
          param['description'] = Jekyll::sanatize_json_string(param['description']) 
        end

        # Repeat and displayName are not supported keywords in JSON Schema
        param.delete('repeat')
        param.delete('displayName')
      end
      schema_hash['required'] = required_properties if not required_properties.empty?
      
      JSON.pretty_generate(schema_hash)
    end
def generate_json_schema(obj)

      # JSON Schema spec: http://json-schema.org/latest/json-schema-validation.html
      schema_hash = {}
      schema_hash['$schema'] = @site.config['json_schema_schema_uri']
      schema_hash['title'] = @title if @title
      schema_hash['description'] = Jekyll::sanatize_json_string(obj['description']) if obj.include?('description')
      schema_hash['type'] = 'object'

      required_properties = []
      schema_hash['properties'] = DeepClone.clone obj['body']['application/x-www-form-urlencoded']['formParameters']
      schema_hash['properties'].each do |name, param|
        if param.include?('required')
          required_properties << name if param['required'] == true
          param.delete('required')
        end

        if param.include?('description')
          param['description'] = Jekyll::sanatize_json_string(param['description']) 
        end

        # Repeat and displayName are not supported keywords in JSON Schema
        param.delete('repeat')
        param.delete('displayName')
      end
      schema_hash['required'] = required_properties if not required_properties.empty?
      
      JSON.pretty_generate(schema_hash)
    end
Creates JSON Schema - as a string - based on obj['body']['application/x-www-form-urlencoded']['formParameters']