rspec-openapi icon indicating copy to clipboard operation
rspec-openapi copied to clipboard

Problem loading openapi.yml after ruby update to 3.2.7

Open ipepe opened this issue 7 months ago • 12 comments
trafficstars

After we updated Ruby from 3.1.4 to 3.2.7 in our project, we noticed that openapi is failing while generating documentation from tests because there is an error of:

Psych::DisallowedClass:
   Tried to load unspecified class: Date

Relatable stack overflow error https://stackoverflow.com/questions/76825550/tried-to-load-unspecified-class-date-psychdisallowedclass-while-updating-th

We fixed it by monkey patching:

RSpec::OpenAPI::SchemaFile.class_eval do
  def read
    return {} unless File.exist?(@path)

    require 'date'

    RSpec::OpenAPI::KeyTransformer.symbolize(YAML.safe_load(File.read(@path), permitted_classes: [Date])) # this can also parse JSON
  end
end

But I also see that there are tests for ruby 3.3 in https://github.com/exoego/rspec-openapi/blob/master/.github/workflows/test.yml#L26 which is confusing because it would seem that they should not be passing. I can submit a PR with change like in the monkey patch but am I the only one that noticed this error while upgrading Ruby?

ipepe avatar Mar 27 '25 13:03 ipepe