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(#1461): filter JMS properties by route area #2407

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

Conversation

jneidel
Copy link

@jneidel jneidel commented Dec 9, 2024

Description

This PR uses the area configured in the route (like /api/{area}/doc/) to filter out properties on the model, which should be excluded based on JMS's versioning (also see demo below.)

Closes #1461
Refs #2129

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)

Demo from our project

We have an entity property:

// MyEntity.php

#[Serializer\Until('v3')]
private \DateTimeInterface $createdAt;                                                                                                     

Opening the docs on the route: /api/v4.3/doc/,
which is configured as:

# config/routes/nelmio_api_doc.yaml

nelmio_api_doc_index:
  path: /api/{area}/doc/
  defaults: { _controller: nelmio_api_doc.controller.swagger_ui }
  methods: [GET]

before this PR
Screenshot 2024-12-09 at 12 53 27
after this PR
Screenshot 2024-12-09 at 12 54 45

Implementation

I opted for the word "area", since it is used in the route definition.
I proceeded as adviced in #1461.

Could you point me to where you would like to see tests created/adjusted?

Copy link

codecov bot commented Dec 9, 2024

Codecov Report

Attention: Patch coverage is 94.11765% with 1 line in your changes missing coverage. Please review.

Project coverage is 89.51%. Comparing base (9411e9c) to head (427d9d7).

Files with missing lines Patch % Lines
src/ModelDescriber/JMSModelDescriber.php 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2407      +/-   ##
==========================================
+ Coverage   89.50%   89.51%   +0.01%     
==========================================
  Files          78       78              
  Lines        2896     2910      +14     
==========================================
+ Hits         2592     2605      +13     
- Misses        304      305       +1     

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

@@ -1,5 +1,7 @@
# CHANGELOG

* Add filtering model properties by route area to `JMSModelDescriber`
Copy link
Author

Choose a reason for hiding this comment

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

Suggested change
* Add filtering model properties by route area to `JMSModelDescriber`
* Added filtering model properties by route area to `JMSModelDescriber`

@jneidel jneidel changed the title feat: filter JMS properties by route area feat(#1461): filter JMS properties by route area Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Documentation for versioned api
1 participant