[OpenAPI]: Parse basic Blueprinter fields: identifier, field, and fields#300
Open
Abishekcs wants to merge 3 commits into
Open
[OpenAPI]: Parse basic Blueprinter fields: identifier, field, and fields#300Abishekcs wants to merge 3 commits into
Abishekcs wants to merge 3 commits into
Conversation
b4b6c8b to
ff9d969
Compare
8 tasks
- Statically parses top-level identifier, field, and fields declarations. - Maps each to type: string by default. - Handles the `name`: option for key renaming - Fields defined with a block also produce a string entry. - Uses Prism AST visitor to statically analyze blueprint source files - Supports Collections using Array<> or [] syntax for arrays - Further Blueprinter features (views, association, transformer) will be built on top of this foundation
ff9d969 to
da9b3a4
Compare
- Remove unused `@hashes` from VisitorContext
- Use `node.value.unescaped` instead of `node.value.slice` in
`visit_assoc_node` for cleaner string extraction
- Replace `context.keywords.any?` with `context.keywords["name"]`
for a more explicit nil check
- Remove `delete_prefix(":")` since `unescaped` returns the clean
value without the colon prefix
Contributor
Author
|
Hi @rsamoilov can you review this PR whenever you're free. Thank you! |
Member
|
Hey @Abishekcs , I'm so sorry about the delay! I'll be looking closely into the changes this weekend. |
Contributor
Author
|
No worries. Take your time. |
rsamoilov
reviewed
May 31, 2026
Member
rsamoilov
left a comment
There was a problem hiding this comment.
Hi @Abishekcs ,
This looks great, and I like the tests too!
Several observations:
- the parser currently only supports symbol field names, although Blueprinter works fine with string fields too:
class UserBlueprint < Blueprinter::Base
fields "id", "name", "email", "age"
end- One of the guarantees Blueprinter provides for the
identifierfields is that "When rendering, identifier fields are always sorted first, before other fields". Let's also ensure identifiers are rendered first in the OpenAPI spec.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
closes #289
What this PR does?
Adds support for parsing basic Blueprinter fields:
identifierfieldfieldsAlso supports:
name:option (e.g.field :email, name: :login)field(:full_name) { |u| ... }) , defaults tostringtype since the block can't be statically evaluatedArray<UserBlueprint>or[UserBlueprint]syntaxSample Code
routes.rbproducts_controller.rbuser_blueprint.rbScreenrecording
Before.mp4
After.mp4
collectionAfter.Collection.mp4