All Projects → kevindew → openapi3_parser

kevindew / openapi3_parser

Licence: MIT License
Open API 3 Parser/Validator for Ruby

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to openapi3 parser

openapi-schemas
JSON Schemas for every version of the OpenAPI Specification
Stars: ✭ 22 (-65.08%)
Mutual labels:  openapi, openapi-specification
go-openapi
OpenAPI Specification (OAS) 3.0 implementation for Go
Stars: ✭ 38 (-39.68%)
Mutual labels:  openapi, openapi-specification
Swurg
Parse OpenAPI documents into Burp Suite for automating OpenAPI-based APIs security assessments (approved by PortSwigger for inclusion in their official BApp Store).
Stars: ✭ 94 (+49.21%)
Mutual labels:  openapi, openapi-specification
oatts
DEPRECATED in favor of https://github.com/google/oatts
Stars: ✭ 26 (-58.73%)
Mutual labels:  openapi, openapi-specification
openapi
OpenAPI 3 Specification for golang
Stars: ✭ 18 (-71.43%)
Mutual labels:  openapi, openapi-specification
Springdoc Openapi
Library for OpenAPI 3 with spring-boot
Stars: ✭ 1,113 (+1666.67%)
Mutual labels:  openapi, openapi-specification
Redoc
📘 OpenAPI/Swagger-generated API Reference Documentation
Stars: ✭ 15,935 (+25193.65%)
Mutual labels:  openapi, openapi-specification
Apispec
A pluggable API specification generator. Currently supports the OpenAPI Specification (f.k.a. the Swagger specification)..
Stars: ✭ 831 (+1219.05%)
Mutual labels:  openapi, openapi-specification
openapi4j
OpenAPI 3 parser, JSON schema and request validator.
Stars: ✭ 92 (+46.03%)
Mutual labels:  openapi, openapi-specification
Flasgger
Easy OpenAPI specs and Swagger UI for your Flask API
Stars: ✭ 2,825 (+4384.13%)
Mutual labels:  openapi, openapi-specification
Connect Api Specification
This repository contains the OpenAPI specification as well as templates for generating SDKs for Square's APIs
Stars: ✭ 56 (-11.11%)
Mutual labels:  openapi, openapi-specification
OpenAlchemy
Define SQLAlchemy models using the OpenAPI specification.
Stars: ✭ 39 (-38.1%)
Mutual labels:  openapi, openapi-specification
Spectral
A flexible JSON/YAML linter for creating automated style guides, with baked in support for OpenAPI v2 & v3.
Stars: ✭ 876 (+1290.48%)
Mutual labels:  openapi, openapi-specification
Openapivalidators
Use Jest or Chai to assert that HTTP responses satisfy an OpenAPI spec
Stars: ✭ 77 (+22.22%)
Mutual labels:  openapi, openapi-specification
Swagger Core
Examples and server integrations for generating the Swagger API Specification, which enables easy access to your REST API
Stars: ✭ 6,898 (+10849.21%)
Mutual labels:  openapi, openapi-specification
Drf Yasg
Automated generation of real Swagger/OpenAPI 2.0 schemas from Django REST Framework code.
Stars: ✭ 2,523 (+3904.76%)
Mutual labels:  openapi, openapi-specification
Swagger Parser
Swagger Spec to Java POJOs
Stars: ✭ 468 (+642.86%)
Mutual labels:  openapi, openapi-specification
Oas Kit
Convert Swagger 2.0 definitions to OpenAPI 3.0 and resolve/validate/lint
Stars: ✭ 516 (+719.05%)
Mutual labels:  openapi, openapi-specification
Openapi Diff
Utility for comparing two OpenAPI specifications.
Stars: ✭ 208 (+230.16%)
Mutual labels:  openapi, openapi-specification
oas
OpenAPI Spec builder in go
Stars: ✭ 15 (-76.19%)
Mutual labels:  openapi, openapi-specification

OpenAPI 3 Parser

Build Status

This a Ruby based parser/validator for OpenAPI 3. It is used to convert an OpenAPI file (can be a local file, a URL, a string or even a Ruby hash) into an object graph with a simple API that follows the OpenAPI specification.

Basic example:

require "openapi3_parser"

document = Openapi3Parser.load_url("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml")

document.paths["/pets"].get.summary
# => "List all pets"

It aims to support 100% of the OpenAPI 3.0 specification, with key features being:

  • Supports loading a specification by path to a file, URL, Ruby file objects, and strings in YAML and JSON formats, it even supports loading via a Ruby hash;
  • Support for loading references from external files including URLs;
  • Handles recursive references;
  • All of OpenAPI specification mapped to Ruby objects, providing a natural Ruby interface that maps clearly to the specification;
  • OpenAPI files validated with a simple API to quickly and simply see all problems with a file
  • Built-in Markdown to HTML conversion;
  • Documentation for the API to navigate the OpenAPI nodes is available on rubydoc.info.

I've wrote a blog post reflecting on the decisions involved in building this parser in How to write an OpenAPI 3 parser.

Usage

Loading a specification

# by URL
Openapi3Parser.load_url("https://raw.githubusercontent.com/kevindew/openapi3_parser/main/spec/support/examples/petstore-expanded.yaml")

# by path to file
Openapi3Parser.load_file("spec/support/examples/uber.yaml")

# by File
Openapi3Parser.load(File.open("spec/support/examples/uber.yaml"))

# by String
Openapi3Parser.load('{ "openapi": "3.0.0", "info": { "title": "API", "version": "1.0.0" }, "paths": {}  }')

# by Hash
Openapi3Parser.load(openapi: "3.0.0", info: { title: "API", version: "1.0.0" }, paths: {})

Validating

document = Openapi3Parser.load(openapi: "3.0.0", info: {}, paths: {})
document.valid?
# => false
document.errors
# => Openapi3Parser::Validation::ErrorCollection(errors: {"#/info"=>["Missing required fields: title and version"]})

Traversing

document = Openapi3Parser.load_url("https://raw.githubusercontent.com/kevindew/openapi3_parser/main/spec/support/examples/petstore-expanded.yaml")

# by objects

document.info.terms_of_service
# => "http://swagger.io/terms/"

document.paths.keys
# => ["/pets", "/pets/{id}"]

document.paths["/pets"].get.parameters.map(&:name)
# => ["tags", "limit"]

# by hash syntax

document["info"]["termsOfService"]
=> "http://swagger.io/terms/"

document["paths"].keys
# => ["/pets", "/pets/{id}"]

document["paths"]["/pets"]["get"]["parameters"].map(&:name)
# => ["tags", "limit"]

# by a path to a node
document.node_at("#/paths/%2Fpets/get/operationId")
=> "findPets"

document.node_at("#/components/schemas/Pet/allOf/0/required/0")
=> "name"

# or combining

document.components.schemas["Pet"].node_at("#../NewPet")
=> Openapi3Parser::Node::Schema(#/components/schemas/NewPet)

You can learn more about the API on rubydoc.info

Installation

You can install this gem into your bundler application by adding this line to your Gemfile:

gem "openapi3_parser", "~> 0.9.0"

and then running $ bundle install

Or install the gem onto your machine via $ gem install openapi3_parser

Status

This is currently a work in progress and will remain so until it reaches 1.0.

See TODO for details of the features still to implement.

Licence

MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].