openfoodfacts / openfoodfacts-server

Open Food Facts database, API server and web interface - 🐪🦋 Perl, CSS and JS coders welcome 😊 For helping in Python, see Robotoff or taxonomy-editor
http://openfoodfacts.github.io/openfoodfacts-server/
GNU Affero General Public License v3.0
660 stars 389 forks source link

feat: openApi refactor fields parameter to support multiple values with enum validation (getProductByBarCode/search) #11012

Closed shinjigi closed 3 days ago

shinjigi commented 1 week ago

What

This PR improves the OpenAPI specification for the fields parameter in the product and search endpoint.

The changes make the API specification more accurate and provide better validation and documentation for the fields parameter, which is critical for controlling response payload size and structure.

Related issue(s) and discussion

Implementation details

  1. Created new file parameters/product_available-fields.yaml to house fields parameter definition
  2. Updated main API spec to reference the new parameter definition
  3. Removed redundant fields parameter definition from individual endpoints
  4. Added comprehensive enum of available field values
  5. Added validation rules and examples

Testing

Note: This change is purely to the API specification and does not affect the actual API implementation.

codecov-commenter commented 1 week ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 49.03%. Comparing base (dc04d18) to head (0acef3a). Report is 762 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #11012 +/- ## ========================================== - Coverage 49.54% 49.03% -0.52% ========================================== Files 67 77 +10 Lines 20650 22243 +1593 Branches 4980 5318 +338 ========================================== + Hits 10231 10906 +675 - Misses 9131 10003 +872 - Partials 1288 1334 +46 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

sonarcloud[bot] commented 1 week ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud