The project is in a healthy, maintained state
This project was written to help convert structured outputs required for OpenAI to Gemini format.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

OpenAPI JSON Schema Converter

A Ruby gem for converting OpenAPI specifications to JSON Schema format.

Installation

Add this line to your application's Gemfile:

gem 'open_api_json_schema_converter'

And then execute:

bundle install

Or install it yourself as:

gem install open_api_json_schema_converter

Usage

Examples:

require 'open_api_json_schema_converter'

json_schema = {
  'type' => 'object',
  'properties' => {
    'name' => { 'type' => 'string' },
    'email' => { 'type' => ['string', 'null'] }
  }
}

result = OpenApiJsonSchemaConverter.convert(json_schema)

# Result:
# {
#   'type' => 'object',
#   'properties' => {
#     'name' => { 'type' => 'string' },
#     'email' => { 'type' => 'string', 'nullable' => true }
#   }
# }
require 'open_api_json_schema_converter'

json_schema = {
  'type' => 'object',
  'properties' => {
    'status' => {
      'const' => 'active',
      'description' => 'Account status'
    },
    'version' => {
      'const' => '1.0'
    }
  }
}

result = OpenApiJsonSchemaConverter.convert(json_schema)

# Result:
# {
#   'type' => 'object',
#   'properties' => {
#     'status' => {
#       'enum' => ['active'],
#       'description' => 'Account status'
#     },
#     'version' => {
#       'enum' => ['1.0']
#     }
#   }
# }

License

MIT