Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Latest commit

 

History

History
20 lines (11 loc) · 1.07 KB

README.md

File metadata and controls

20 lines (11 loc) · 1.07 KB

⚠️ This repo has been deprecated in favor of https://github.com/opticdev/examples. ⚠️

openapi-gen-ruby-sinatra

This repo demonstrates generating an OpenAPI spec from a Sinatra app using the openapi-rspec gem. Despite using Sinatra for brevity, the generation method demonstrated here is applicable to Rails and likely other Rack-based frameworks.

When the RSpec tests are run, the OpenAPI file in doc/openapi.yml is created or updated.

Getting Started

The following steps assume you have Ruby and Bundler installed.

  1. bundle install
  2. OPENAPI=1 bundle exec rspec

Running the rspec command above will create or update doc/openapi.yml. Try deleting it, editing it, or changing the code and rerun the tests to produce updates. Since the OpenAPI spec is only generated from the tests, any new or changed endpoint needs test coverage to generate an accurate update.

Running the API

This isn't necessary for the tests or OpenAPI spec generation, but you can start the API server with ruby app.rb.