Skip to content

Problem loading openapi.yml after ruby update to 3.2.7 #249

Open
@ipepe

Description

@ipepe

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?

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