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

Draft
wants to merge 1 commit 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 🤔

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