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

Add ability to define custom summary and tags builders #148

Merged
merged 2 commits into from
Dec 2, 2023

Conversation

mercedesb
Copy link
Contributor

Love this project! We use it at my company for automated documentation (using widdershins to take the generated OpenAPI spec and create nice Slate docs). So thank you!

We'd love to have some control over how we decide what the summary and tags are for a given example.

For our use case, we want to be able to define tags on the parent example and have that applied to all the child examples rather than having to define them on every example.

I followed the existing pattern in the repo for custom descriptions so that any custom scenario could be supported.

@mercedesb mercedesb marked this pull request as ready for review November 30, 2023 19:40
Copy link

codecov bot commented Nov 30, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (c8ff1da) 96.75% compared to head (08f0c2a) 96.76%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #148      +/-   ##
==========================================
+ Coverage   96.75%   96.76%   +0.01%     
==========================================
  Files          14       14              
  Lines         431      433       +2     
  Branches       95       95              
==========================================
+ Hits          417      419       +2     
  Misses         14       14              

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

README.md Outdated
Comment on lines 170 to 171
# Generate a custom summary, given an RSpec example
RSpec::OpenAPI.summary_builder = -> (example) { example.metadata[:summary] }
Copy link
Owner

@exoego exoego Dec 1, 2023

Choose a reason for hiding this comment

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

Could you give a short example here and tags_builder, to give an idea of customization?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for all the quick reviews! I added 2 simple examples.

For our use case, we're doing a recursive look up and using the summary/tags from the nearest example/example group. Let me know if you think including that more complex example would be helpful.

Copy link
Owner

@exoego exoego left a comment

Choose a reason for hiding this comment

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

@mercedesb
Thanks.
The feature makes sense to me.
I think a short example of customization is helpful for other users.

Copy link
Owner

@exoego exoego left a comment

Choose a reason for hiding this comment

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

LGTM
Thanks

@exoego exoego added the enhancement New feature or request label Dec 2, 2023
@exoego exoego merged commit 7ea88d2 into exoego:master Dec 2, 2023
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants