-
Notifications
You must be signed in to change notification settings - Fork 46
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
Fix: OpenAPI warnings #270
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
29b1b63
Fix: Send FactoryBot examples to JbuilderSchema for proper attributes…
newstler d42ca60
Fix for unwrapped parameters in examples
newstler 5ff77b5
Fix Standard
newstler 786d295
Fix id type in paths
newstler 8fb890c
Upgrade Ruby to 3.2.2
newstler 76d2f7f
Hacked Jbuilder to correct action_text values
newstler 84e0a2e
Rename Jbuilder Hacks module to ValuesTransformer
newstler b1126d5
Updated jbuilder-schema
newstler c6cbef4
Fix: namespaced model names transform to undercored
newstler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,4 +46,4 @@ RUBY VERSION | |
ruby 3.2.2p53 | ||
|
||
BUNDLED WITH | ||
2.3.8 | ||
2.4.12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
require "jbuilder" | ||
|
||
module ValuesTransformer | ||
def _set_value(key, value) | ||
value = value.body if value.is_a?(ActionText::RichText) | ||
|
||
super(key, value) | ||
end | ||
end | ||
|
||
::Jbuilder.prepend ValuesTransformer |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reminds me of the comment in the Transformer about rich text attributes
bullet_train-core/bullet_train-super_scaffolding/lib/scaffolding/transformer.rb
Line 1140 in aad0748
We skip trix editor attributes when super scaffolding jbuilder files, but should we add the body somehow over there in the transformer as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, anyway those attributes are exposed for
ScaffoldingCompletelyConcreteTangibleThing
whenHIDE_THINGS
is not enabled. So this Jbuilder hack lets us showActionText::RichText
attributes properly (asstring
instead of whole object). I think if those were skipped before, now they can be added. Also, if there are any other attributes that should be exposed differently in Jbuilder, they might also be added to this file.I afraid I didn't fully understand what you meant by
should we add the body somehow over there in the transformer as well?
:)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just wasn't sure how we should handle rich text attributes with the API, but after looking into it a bit, I'm thinking I'll make a different PR to return the
ActionText::RichText
object as a whole instead of just the body (that seems to make the most sense to me). As far as what we return, I think we can leave the decision up to Andrew. I'm fine with how things are now though. Thanks!Here is an example of
bar
as a trix editor attribute:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, that data in API feels completely useless for me, as it is the internal ActionText stuff, and as an API user I can't do anything with that, it's only clutters up the information.
Also, I am pretty sure warnings were there as when we create a record, we send
bar
as a string. And I'm not sure we now support different types of same attribute for Attributes and Parameters. Should we?What about the case when some code gets data from one API endpoint and redirects it to another? It will take manual work in the middle to clarify this data..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I didn't consider this. I hadn't run the the ActionText::RichText API object against the OpenAPI test so that makes sense about the warnings. Thanks for explaining!