Skip to content
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

Ensure that ostruct is loaded #116

Merged
merged 1 commit into from
Apr 6, 2024
Merged

Ensure that ostruct is loaded #116

merged 1 commit into from
Apr 6, 2024

Conversation

jrmhaig
Copy link
Contributor

@jrmhaig jrmhaig commented Apr 5, 2024

Following an upgrade of the json gem we are seeing the following error:

.../.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/grape-swagger-rails-0.4.0/lib/grape-swagger-rails.rb:4:in `<module:GrapeSwaggerRails>': uninitialized constant GrapeSwaggerRails::OpenStruct (NameError)

  class Options < OpenStruct

It turns out that grape-swagger-rails depends on ostruct being required elsewhere in the app. This was being done for us by json and with version 2.7.2 ostruct has become optional. See flori/json#565

One solution is to add require 'ostruct' immediately prior to where it is used. This is done in this PR.

Another solution would be to not use OpenStruct as it is now discouraged - see https://docs.ruby-lang.org/en/3.0/OpenStruct.html#class-OpenStruct-label-Caveats

@grape-bot
Copy link

grape-bot commented Apr 5, 2024

1 Warning
⚠️ There're library changes, but not tests. That's OK as long as you're refactoring existing code.

Generated by 🚫 Danger

@dblock
Copy link
Member

dblock commented Apr 5, 2024

Thanks. This works, want to add a line to CHANGELOG? I'll merge and cut a release, been a while.

@dblock dblock mentioned this pull request Apr 6, 2024
@dblock dblock merged commit b45720f into ruby-grape:master Apr 6, 2024
13 of 16 checks passed
@dblock
Copy link
Member

dblock commented Apr 6, 2024

Merged, thanks. If you have more cycles, #115 is one that could use some attention :)

@dblock
Copy link
Member

dblock commented Apr 6, 2024

I fixed up the test matrix and release 0.5.0 with this change.

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.

3 participants