Skip to content

Deprecation warning in Rails 6 project #70

@biske

Description

@biske

I have a Rails 6 application and the initializer for open api. Here's the content:

# frozen_string_literal: true

require 'open_api'

OpenApi::Config.class_eval do
  # Part 1: configs of this gem
  self.file_output_path = 'public/open_api'

  # Part 2: config (DSL) for generating OpenApi info
  open_api :v1, base_doc_classes: [Api::V1::BaseController]
  info version: '1.0.0', title: 'Petstore API'
  server 'http://localhost:3000', desc: 'Local server for personal use'
  # bearer_auth :Authorization

  OpenApi.write_docs
end

When the application is loaded (running bin/rspec for example) it displays the warning:

OpenApi loaded
OpenApi `v1.json` has been generated.

DEPRECATION WARNING: Initialization autoloaded the constants Api, Api::V1, ApiErrorHandler, Api::V1::BaseController, Api::V1::Clients, ApplicationHelper, ApplicationController, InheritedResources::Base, Api::V1::Clients::UsersController, Api::V1::PasswordsController, Api::V1::ServiceProfessionals, Api::V1::ServiceProfessionals::UsersController, Api::V1::SessionsController, Api::V1::SocialsController, Api::V1::SpecializationsController, Api::V1::UsersController, ActionText::ContentHelper, and ActionText::TagHelper.

Being able to do this is deprecated. Autoloading during initialization is going
to be an error condition in future versions of Rails.

Reloading does not reboot the application, and therefore code executed during
initialization does not run again. So, if you reload Api, for example,
the expected changes won't be reflected in that stale Module object.

These autoloaded constants have been unloaded.

Please, check the "Autoloading and Reloading Constants" guide for solutions.
(called from <top (required)> at /app/config/environment.rb:7)

Is there a way to solve this? From my perspective, it doesn't make any problem since the specification file is generated only once, but still I'm raising it here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions