JSON Schema Generator API - Ruby Gem

JSON Schema Generator is a tool for automatically generating JSON schemas from sample JSON data. It creates Draft-07 compatible schemas with type inference and format detection.

Installation

Add this line to your application's Gemfile:

gem 'apiverve_jsonschemagenerator'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_jsonschemagenerator

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_jsonschemagenerator'

# Initialize the client
client = APIVerve::Jsonschemagenerator::Client.new(api_key: "YOUR_API_KEY")

# Make a request
response = client.execute({
  json: [object Object],
  title: "User Schema"
})

# Print the response
puts response

Error Handling

begin
  response = client.execute({ json: [object Object], title: "User Schema" })
  puts response["data"]
rescue APIVerve::Jsonschemagenerator::ValidationError => e
  puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Jsonschemagenerator::APIError => e
  puts "API error: #{e.message}"
  puts "Status code: #{e.status_code}"
end

Debug Mode

# Enable debug logging
client = APIVerve::Jsonschemagenerator::Client.new(
  api_key: "YOUR_API_KEY",
  debug: true
)

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "User Schema",
    "type": "object",
    "properties": {
      "name": {
        "type": "string"
      },
      "age": {
        "type": "integer"
      },
      "email": {
        "type": "string",
        "format": "email"
      },
      "active": {
        "type": "boolean"
      }
    },
    "required": [
      "name",
      "age",
      "email",
      "active"
    ]
  }
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.