Skip to content
An open source Open API Spec 3 Definition Parser
Branch: master
Clone or download
Latest commit d9a6b1c Mar 4, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin Init: Parser, Definition, Path, Endpoint Dec 19, 2017
lib Bump version for release Mar 4, 2019
spec Add custom errors Mar 4, 2019
.gitignore Add support for resolving remote references (#23) Feb 15, 2019
.rspec
.travis.yml
CODE_OF_CONDUCT.md Init: Parser, Definition, Path, Endpoint Dec 19, 2017
Gemfile
Gemfile.lock Bump version for release Mar 4, 2019
Guardfile
LICENSE.txt
README.md Add publishing documentation Apr 23, 2018
Rakefile
oas_parser.gemspec Add support for resolving remote references (#23) Feb 15, 2019

README.md

Open API Definition Parser

A Ruby parser for Open API Spec 3.0+ definitions.

Install

Install the gem:

$ gem install oas_parser

Or add it to your Gemfile:

gem 'oas_parser'

Usage

Here is a basic example of how you can traverse through an Open API Spec 3 Definition:

require 'oas_parser'

definition = OasParser::Definition.resolve('petstore.yml')
# => #<OasParser::Definition>

# Get a specific path
path = definition.path_by_path('/pets')
# => #<OasParser::Path>

# Get all paths.
definition.paths
# => [#<OasParser::Path>, ...]

# Get a specific endpoint by method
endpoint = path.endpoint_by_method('get')
# => #<OasParser::Endpoint>

# Get all endpoints
path.endpoints
# => [#<OasParser::Endpoint>, ...]

# Get endpoint description
endpoint.description
# => "Returns all pets from the system that the user has access to"

Checkout the tests and lib directory for more classes and methods.

Development

Run tests:

$ rspec

Publishing

Clone the repo and navigate to its directory:

$ cd oas-parser

Bump the latest version in oas_parser/lib/oas_parser/version.rb:

//old
module OasParser
  VERSION = '1.0.0'.freeze
end

//new
module OasParser
  VERSION = '1.1.0'.freeze
end

Build the gem:

$ gem build oas_parser.gemspec

This will create a oas_parser-1.1.0.gem file.

Push the gem to rubygems.org:

$ gem push oas_parser-1.1.0.gem

Verify the change was made by checking for the new version on rubygems.org

Contributing

Contributions are welcome, please follow GitHub Flow

You can’t perform that action at this time.