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

feat: add possibility to ignore properties from schema #2416

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

Conversation

DominicLuidold
Copy link
Contributor

@DominicLuidold DominicLuidold commented Jan 7, 2025

Description

Adds a #[Ignore] attribute that allows a property to be excluded from the generated schema.

Closes #2306

What type of PR is this? (check all applicable)

  • Bug Fix
  • Feature
  • Refactor
  • Deprecation
  • Breaking Change
  • Documentation Update
  • CI

Checklist

  • I have made corresponding changes to the documentation (docs/)
  • I have made corresponding changes to the changelog (CHANGELOG.md)

@DominicLuidold
Copy link
Contributor Author

@DjordyKoert This is the initial implementation of the feature — it's a very basic, functional version but still requires significant work.

I’d appreciate your input on a couple of points:

  • Is the ObjectModelDescriber the right place to handle the attribute?
  • Where would be the best location to integrate logic for handling the annotation in environments using PHP <8.0?

Looking forward to your feedback!

@DominicLuidold DominicLuidold changed the title feature(#2306): Add possibility to ignore property from schrema feature(#2306): Add possibility to ignore properties from schema Jan 7, 2025
@DominicLuidold DominicLuidold changed the title feature(#2306): Add possibility to ignore properties from schema feat(#2306): Add possibility to ignore properties from schema Jan 7, 2025
@DjordyKoert
Copy link
Collaborator

Is the ObjectModelDescriber the right place to handle the attribute?

Probably not, this would prevent the attribute from working on other environments (Hateoas / JMS / Form). I think you can add a new method. I think its easiest to add a new method to https://github.com/nelmio/NelmioApiDocBundle/blob/master/src/ModelDescriber/Annotations/AnnotationsReader.php (something like shouldDescribeProperty()).

Where would be the best location to integrate logic for handling the annotation in environments using PHP <8.0?

IMO annotation logic for PHP <8.0 isn't necessary to reduce complexity & annotations are about to be removed in 5.x

@DominicLuidold DominicLuidold force-pushed the 2306-ignore-properties branch from aa8b81e to 8586a1e Compare January 9, 2025 14:05
@DominicLuidold DominicLuidold changed the title feat(#2306): Add possibility to ignore properties from schema feat: Add possibility to ignore properties from schema Jan 9, 2025
@DominicLuidold DominicLuidold changed the title feat: Add possibility to ignore properties from schema feat: add possibility to ignore properties from schema Jan 9, 2025
@DominicLuidold
Copy link
Contributor Author

@DjordyKoert I've updated the implementation and added some tests. Could you please give it a quick look if this approach works better?

If so, I'd look into the failing tests that are mainly related to Symfony 5.4 🤔

@DjordyKoert
Copy link
Collaborator

@DjordyKoert I've updated the implementation and added some tests. Could you please give it a quick look if this approach works better?

If so, I'd look into the failing tests that are mainly related to Symfony 5.4 🤔

Looking good 😄

@DominicLuidold DominicLuidold force-pushed the 2306-ignore-properties branch 2 times, most recently from 54656fa to 4e597f1 Compare January 28, 2025 14:13
Copy link

codecov bot commented Jan 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.22%. Comparing base (8b4803f) to head (dfe2ca1).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2416      +/-   ##
==========================================
+ Coverage   90.18%   90.22%   +0.03%     
==========================================
  Files          94       94              
  Lines        3067     3079      +12     
==========================================
+ Hits         2766     2778      +12     
  Misses        301      301              

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

@DominicLuidold DominicLuidold marked this pull request as ready for review January 28, 2025 14:24
@DominicLuidold
Copy link
Contributor Author

@DjordyKoert Thanks for your input, the PR should be ready to review now 😄

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