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

A demonstration generating an OpenAPI spec from integration tests

Notifications You must be signed in to change notification settings

opticdev/openapi-gen-ruby-sinatra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚠️ 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.

About

A demonstration generating an OpenAPI spec from integration tests

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages