talira

Seamlessly adds a Swagger to Rails-based API's

open sourceMITself-hostablefree

rswag extends rspec-rails request specs with a DSL that describes each API operation (path, parameters, request body, responses and their schemas) and runs it as a test. Once the tests pass, a rake task writes the OpenAPI 3.0 file from them, so the documentation can't drift from what the API does. rswag-api serves the file as JSON or YAML and rswag-ui embeds swagger-ui to explore and try the API. The project is looking for maintainers.

Problems it solves

  • our API documentation keeps going out of date with what the code does
  • generate an OpenAPI spec from tests for a Rails API
  • test every API endpoint's response against its documented schema
  • serve interactive API docs where people can try requests
  • write API tests and API docs once instead of twice
  • an OpenAPI file produced by passing API tests, so the docs and anything generated from it match the API
  • document several versions of our Rails API side by side
  • check request and response examples in the docs are real

Features

  • RSpec DSL for paths, operations, parameters and responses
  • response validation against JSON schemas
  • OpenAPI 3.0 file generation (rake rswag:specs:swaggerize)
  • oneOf, anyOf and allOf schemas
  • several API documents and versions
  • JSON and YAML endpoints (rswag-api)
  • embedded swagger-ui (rswag-ui)

Alternatives

The same job

These do what rswag does.

  1. ReadMe Build docs that developers love and AI can actually read
  2. Mintlify The documentation platform for agents
  3. GitBook GitBook keeps docs accurate, for both people and AI
  4. Stoplight Design, document, and build APIs faster

Compare rswag with the top 3