Skip to content

Ruby

The following section covers the components of Ruby frameworks and their library components that NightVision’s API Discovery capability can detect and use to generate OpenAPI documentation. If a component that you use is not supported, please get in touch with our support team at support@nightviz.ai, and we can add this as a new feature.

Library ComponentDescription
ActionController::BaseThe base class for all controllers in Rails, providing shared functionality such as rendering and redirects.
ActionController::ParametersProvides a way to handle strong parameters to prevent unwanted attributes from being used in ActiveRecord operations.
ActionDispatch::Routing::RouteSetManages the routing rules in a Rails application and is responsible for mapping incoming requests to controllers and actions.
resourcesDefines standard RESTful routes for a collection of resources, including actions like index, create, new, edit, show, update, and destroy.
resourceSimilar to resources, but used for a singular resource which doesn’t require index or create routes.
namespaceGroups controllers under a specific namespace and routes the incoming requests accordingly.
memberA routing method that adds more routes to a single resource using standard HTTP verbs which act on a specific member.
collectionA routing method that adds additional routes to a collection of resources, not just a single resource.
getDefines a route for a GET request to a specified path mapped to a controller action.
postDefines a route for a POST request to a specified path which typically handles the creation of a resource.
putDefines a route for a PUT request to a specified path which typically handles the updating of a resource.
patchDefines a route for a PATCH request, often used interchangeably with PUT, to update a specific resource.
deleteDefines a route for a DELETE request to remove a specific resource.
drawMethod used within the routes.rb file to draw routes using a block of routing definitions.

Library ComponentDescription
Grape::DSL::Routing::ClassMethodsClass that provides major part of Grape routing related DSL
resourceSimilar to resources, but used for a singular resource which doesn’t require index or create routes.
namespaceGroups controllers under a specific namespace and routes the incoming requests accordingly.
getDefines a route for a GET request to a specified path mapped to a controller action.
postDefines a route for a POST request to a specified path which typically handles the creation of a resource.
putDefines a route for a PUT request to a specified path which typically handles the updating of a resource.
patchDefines a route for a PATCH request, often used interchangeably with PUT, to update a specific resource.
deleteDefines a route for a DELETE request to remove a specific resource.
mountMounts another Grape API or Rack application at a specified path within the current API.
versionSpecifies the API version, allowing you to define versioned routes and handle different versions of your API endpoints.
paramsDefines parameters for the route, specifying expected inputs and validations.
prefixSets a prefix for all routes within the API, effectively changing the base path for all endpoints.

NightVision reads authentication guards on Ruby routes and records them as OpenAPI security schemes. See the Framework Support Index for how schemes and the x-unsound marker are represented.

Controller before_action filters are followed, including inheritance from parent controllers and skip_before_action, with the only: and except: options scoping which actions a filter guards:

Library ComponentOpenAPI Security Scheme
before_action :authenticate_user! (Devise) and session-based login filtersSession cookie
http_basic_authenticate_withHTTP basic
authenticate_or_request_with_http_token and the HTTP token familyHTTP bearer
authenticate_or_request_with_http_digestHTTP digest

Convention-named authentication filters (for example require_login, require_authentication, require_user) are recognized as session guards and flagged x-unsound, as is a Devise classification that is corroborated only by naming.

Library ComponentOpenAPI Security Scheme
http_basicHTTP basic
http_digestHTTP digest
A before/before_validation block that enforces authenticationHTTP bearer or basic, flagged x-unsound

Grape mounted and namespaced APIs inherit the guards of their enclosing scope.

Role and scope names are not extracted for Ruby, so no x-roles are emitted.