Skip to content

Fix psych disallowedclass error in ruby 3.1 #256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ipepe
Copy link
Contributor

@ipepe ipepe commented Jun 12, 2025

Fixes #249 by adding Date to permitted_classes of YAML.safe_load in RSpec::OpenAPI::SchemaFile#read.

Changes

  • allow Date and Time when reading YAML schema files
  • add regression test for SchemaFile

@ipepe ipepe force-pushed the fix-psych--disallowedclass-error-in-ruby-3.1 branch from a1d3f9b to ac89c4c Compare June 12, 2025 18:53
Copy link

codecov bot commented Jun 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.27%. Comparing base (099958e) to head (ac389d0).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #256   +/-   ##
=======================================
  Coverage   97.26%   97.27%           
=======================================
  Files          20       20           
  Lines         658      660    +2     
  Branches      148      148           
=======================================
+ Hits          640      642    +2     
  Misses         18       18           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines +6 to +7
require 'date'
require 'time'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nits]
require 'yaml' also loads Date. Time is available without requiring anything explicitly.

require 'spec_helper'

RSpec.describe RSpec::OpenAPI::SchemaFile do
describe '#read' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[imho]
How about adding unquoted dates or times to the OpenAPI schema in spec/apps/ instead of writing tests for the private method?

What should be tested is not whether unquoted dates or times are loaded, but whether the resulting OpenAPI schema output is correct—and whether it can be successfully loaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem loading openapi.yml after ruby update to 3.2.7
2 participants