Project

swagger23

0.0
The project is in a healthy, maintained state
swagger23 converts Swagger 2.0 (OAS 2) API specifications into OpenAPI 3.0.3 (OAS 3) specifications. Accepts JSON or YAML input, produces JSON or YAML output. Works as a Ruby library (Swagger23.convert) or a standalone CLI tool (swagger23). Handles paths, parameters, requestBody, components/schemas, securitySchemes, servers, $ref rewriting, collectionFormat, x-nullable, discriminator, OAuth2 flows, and file uploads. No external runtime dependencies. Safe for large specs.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 13.0
~> 3.12

Runtime

>= 2.0
 Project Readme

swagger23

Gem Version License: MIT

A Ruby gem that converts Swagger 2.0 API specifications into OpenAPI 3.0.3 specifications.

Accepts JSON or YAML input, produces JSON or YAML output. Works as a Ruby library or a standalone CLI tool.


Requirements

  • Ruby ≥ 3.2

Installation

Add to your Gemfile:

gem "swagger23"

Then run:

bundle install

Or install globally:

gem install swagger23

Usage

CLI

swagger23 [INPUT [OUTPUT]]
Argument Description
INPUT Path to a Swagger 2.0 file (.json, .yaml, or .yml). Reads from stdin if omitted.
OUTPUT Path to write the OpenAPI 3.0 result. Format is determined by the file extension: .yaml / .yml → YAML, anything else → JSON. Writes JSON to stdout if omitted.

Options:

-v, --version   Print the gem version and exit.
-h, --help      Print this help message and exit.

Examples:

swagger23 petstore.json openapi.json
swagger23 petstore.yaml openapi.yaml
swagger23 petstore.yaml openapi.json
swagger23 petstore.json openapi.yaml

# Print to stdout
swagger23 petstore.json

# Pipe from stdin
cat petstore.yaml | swagger23
cat petstore.json | swagger23 > openapi.json

Ruby library

require "swagger23"

# Hash → Hash
swagger_hash = JSON.parse(File.read("petstore.json"))
openapi_hash = Swagger23.convert(swagger_hash)

# String (JSON or YAML) → JSON string
json_string = Swagger23.convert_string(File.read("swagger.yaml", encoding: "utf-8"))

# String (JSON or YAML) → YAML string
yaml_string = Swagger23.convert_to_yaml(File.read("swagger.json", encoding: "utf-8"))

# Parse only
hash = Swagger23.parse(source)

Running tests

bundle exec rspec

Contributing

  1. Fork github.com/Qew7/swagger23.
  2. Create a feature branch: git checkout -b my-feature.
  3. Add tests for your change.
  4. Make sure the full suite passes: bundle exec rspec.
  5. Submit a pull request.

Bug reports and feature requests are welcome on the issue tracker.


Author

Maxim Veysgeym — Ruby enthusiast, Moscow.


License

Released under the MIT License © 2026 Maxim Veysgeym.