Rspec Openapi

screenshot of Rspec Openapi
rails

Generate OpenAPI schema from RSpec request specs

Overview

The rspec-openapi gem is a powerful tool designed for Ruby developers looking to generate OpenAPI specifications directly from RSpec request specs without the need for a special Domain-Specific Language (DSL). Unlike some existing solutions that create a barrier to reusing standard request specs, this gem enables a more seamless integration, allowing you to maintain existing test structures while generating comprehensive API documentation.

The gem also offers flexibility in customization and supports features that cater to complex schema definitions. Whether you're working on a large-scale application or a small project, rspec-openapi promises to simplify the process of documenting your APIs while preserving the manual adjustments whenever necessary.

Features

  • Seamless Integration: Generates OpenAPI specs from standard RSpec request specs without requiring any special DSL, making it easy to adopt.
  • Manual Modification Retention: Preserves any manual changes you make to the generated OpenAPI specs, ensuring that your adjustments aren’t lost during regeneration.
  • Support for $ref Mechanism: In version 0.7.0 and above, it supports the $ref mechanism to minimize redundancy in schemas, streamlining your API documentation.
  • Flexible Customizations: Overwrite attributes using RSpec metadata options, allowing for tailored documentation that suits your needs.
  • Multiple Examples Mode: Generate multiple named examples for the same endpoint, enhancing the documentation's clarity by showing varied responses.
  • Exclusion Capabilities: You can easily disable OpenAPI generation for specific specs by setting an openapi: false flag, giving you control over which parts of your API are documented.
  • Merge Behavior with Mixed Modes: Automatically merges example settings from different spec files, ensuring that all test cases are represented in the API documentation seamlessly.
  • Extensible Schema Updates: The gem’s schema update feature can be extended with manual adjustments, providing flexibility when automating documentation.
rails
Ruby on Rails

Ruby on Rails, often referred to as Rails, is an open-source web application framework written in Ruby. Known for its convention over configuration and don't repeat yourself (DRY) principles, Rails simplifies and accelerates the development of database-backed web applications.