Skip to content
CAI
Software that uses CAICheck a score

ruby-grape/grape-swagger

64.2

Adequate · 20 September 2026

2.1k

lines of production code

Ruby

primary language

1

measurement over time

CAI band scale
CAI lens gauges

What this system is

This system is a Ruby gem that generates Swagger/OpenAPI documentation for Grape-based APIs. It provides comprehensive parsing of API routes, parameters, and entities to produce valid OpenAPI specifications, supporting both Swagger v2 and OpenAPI 3 formats. The library includes utilities for validating documentation, handling complex data types, and integrating with development workflows through Rake tasks and standardized testing infrastructure.

How it got here

2012 — Modernization and testing infrastructure

5 changes.

The project modernized its development environment by raising the minimum Ruby version, updating dependencies, and introducing RuboCop and RSpec configurations. It reorganized the library code into the GrapeSwagger namespace with deprecation aliases and replaced legacy test infrastructure with a new, comprehensive RSpec-based test suite.

2014–2015 — grape-swagger refactor and test expansion

4 changes.

The project underwent a major internal refactor to ensure compatibility with Grape 3.2+, modularizing documentation generation and parameter parsing logic. This architectural update was accompanied by the addition of comprehensive test coverage for Swagger v2 specification generation and the enhancement of the example application with Rack configuration and Postman integration.

2016 — API example and documentation refactoring

6 changes.

This period focused on enhancing the library's internal architecture by refactoring Swagger documentation generation into modular, single-responsibility classes. Comprehensive test coverage was added to verify core logic and edge cases, while new Rake tasks were introduced to automate the fetching and validation of OpenAPI documentation.

Features

Added example API with spline management and file upload endpoints

The example/api directory now includes a Grape-based API implementation featuring CRUD operations for 'splines' (resources with x, y, and reticulated attributes) and a file upload endpoint. The API uses grape-entity for structured JSON responses and defines specific HTTP status codes and documentation for each route.

example/api · high confidence

New Rake tasks for fetching and validating OpenAPI documentation

A new \OapiTasks\ class is introduced in \lib/grape-swagger/rake/oapi\_tasks.rb\, providing two Rake tasks under the \oapi\ namespace: \oapi:fetch\ and \oapi:validate\. The \fetch\ task generates OpenAPI documentation by making requests to the API routes, optionally saving the output to a JSON file. The \validate\ task invokes \fetch\ to generate the documentation and then uses the \swagger-cli\ to validate the resulting file, ensuring the API documentation is correct. The task initializer now accepts either an API class instance or a string representing the class name, which is then constantized.

lib/grape-swagger/rake · high confidence

Updated example app with Postman collection and Rack configuration

The example application now includes a new \config.ru\ file that configures the Rack environment, sets up CORS headers, mounts the API endpoints, and integrates the Swagger documentation. Additionally, a Postman collection file (\example\_requests.postman\_collection\) has been added, providing pre-configured requests for testing the API endpoints such as creating, reading, updating, and deleting splines.

example · high confidence

Architecture

Refactored documentation generation into modular classes

The internal logic for generating Swagger documentation has been reorganized from a monolithic structure into distinct, single-responsibility classes within the \lib/grape-swagger/doc\_methods\ directory. This refactoring introduces dedicated modules for handling specific aspects of the documentation: \BuildModelDefinition\ manages schema construction and discriminator support, \DataType\ standardizes type mapping and collection formats, \Extensions\ handles custom \x-\ extension injection, \MoveParams\ processes body parameter definitions, \ParseParams\ handles individual parameter parsing, and \PathString\ manages route path formatting. This change improves code maintainability and separation of concerns without altering the external API or user-facing documentation output.

_lib/grape-swagger/doc\methods · high confidence

Behavioural changes

Refactor grape-swagger into GrapeSwagger namespace with deprecation aliases

The library has been reorganized to reside within the \GrapeSwagger\ module, moving internal components like \SwaggerRouting\ and \SwaggerDocumentationAdder\ into this namespace. To maintain backward compatibility, top-level aliases are provided for existing code, but these are now marked as deprecated constants. This change ensures cleaner namespace isolation while preventing immediate breakage for downstream applications relying on the previous global constant names.

lib · high confidence

grape-swagger 2.3.0: major refactor and Grape 3.2+ compatibility

This release refactors the internal architecture of grape-swagger to improve maintainability and add support for Grape 3.2+. The documentation generation logic has been modularized into a dedicated \DocMethods\ module, and request parameter parsing is now handled by a pluggable \RequestParamParserRegistry\ with separate parsers for headers, route, and body parameters. These changes enable better handling of Grape 3.2+ features, such as variant types in path parameters, and provide a more robust foundation for future extensions.

lib/grape-swagger · high confidence

Test coverage

Added comprehensive test coverage for Swagger v2 documentation generation; Added comprehensive test coverage for core documentation generation components; Added test coverage for Swagger documentation edge cases; Added test fixtures for model parsers; Added test support infrastructure for GrapeSwagger; Initial test infrastructure and version verification; Removed legacy test infrastructure and placeholder tests.

Dependencies

Updates dependencies and raises minimum Ruby version to 3.1

The gemspec now requires Ruby 3.1 or higher and allows Grape versions from 2.1 up to (but not including) 5.0. The Gemfile has been modernized to use the gemspec for core dependencies and introduces conditional logic to support testing against various Grape versions, including the latest development head. Development and test dependencies have been updated to include Rack 3+ for Grape 2.0+, RuboCop 1.50, RSpec 3.9, and specific gems like \cgi\ and \ostruct\ for newer Ruby versions, while pinning \json\ below 3.0 for Ruby versions older than 3.2 to ensure compatibility.

(dependencies) · high confidence

Housekeeping

Introduces RuboCop configuration and RSpec settings

The project now includes a \.rubocop.yml\ file to enforce Ruby style guidelines (targeting Ruby 3.4) and a \.rspec\ file to standardize test execution with color, profiling, and documentation formatting. These files establish the development environment for code quality and testing consistency.

(repo-wide) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Baseline

  • First survey — no prior run to compare against. CAI 64.

Lenses

  • Code Health 97
  • Architecture 97
  • Maturity 54
  • Readiness 65
  • Security 69

Changes since last survey

  • 300 commits — 250 feature/other, 50 fixes

By area

  • (root) — 222 commits
  • lib/grape-swagger — 23 commits
  • (repo) — 20 commits
  • spec/swagger_v2 — 14 commits
  • .github/workflows — 8 commits
  • spec/lib — 4 commits
  • spec/support — 4 commits
  • lib/grape-swagger.rb — 2 commits
  • spec/issues — 2 commits
  • .github/dependabot.yml — 1 commit

Notable commits

  • fix: FIX description field (required) may be null (#656)
  • fix: FIX description field (required) may be null (#656)
  • fix: Fix CI by pinning json gem below 3.0 (#992)
  • fix: Fix Grape 3.1.0 and grape-swagger-entity 0.7.1 compatibility (#972)
  • fix: Fix Grape 3.2+ compatibility: desc kwargs, custom types, multi-type param recovery (#978)
  • fix: Fix README links (#895)
  • fix: Fix array of entities with nested entities (#683)
  • fix: Fix array of entities with nested entities (#683)
  • fix: Fix array_use_braces for body params (#757)
  • fix: Fix compatibility description in readme (#692)
  • fix: Fix compatibility description in readme (#692)
  • fix: Fix documentation of additionalProperties field when used with array parameters (#840)
  • fix: Fix documentation of false/nil default parameter values (#839)
  • fix: Fix example to work (#852)
  • fix: Fix examples link in README (#642)
  • fix: Fix examples link in README (#642)
  • fix: Fix handling of HTTP status codes from routes (#669)
  • fix: Fix handling of HTTP status codes from routes (#669)
  • fix: Fix is_array check for non-contiguous sub and parent entities (#691)
  • fix: Fix is_array check for non-contiguous sub and parent entities (#691)
  • …and 280 more

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

ruby-grape/grape-swagger was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 20 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 28c26807f7e2808b370960cbd434cca0cebd1c27 — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-b51f968c9b10.