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

fix: apidoc openApi ecoscore mapping #11009

Closed shinjigi closed 3 days ago

shinjigi commented 1 week ago

What

This PR introduces several improvements to the API documentation and schema organization:

  1. New Schema File for Country Codes

    • Created a dedicated country-code.yaml file to centralize country code definitions
    • Introduced reusable CountryCode enum with all supported country codes
    • Added CountryValues schema to standardize country-to-number mappings
    • Commented out pattern properties in favor of generator-friendly alternatives
  2. Product Ecoscore Schema Improvements

    • Refactored country-specific properties to use the new CountryValues schema
    • Added proper type handling for nullable integer fields (transportation_score)
    • Removed redundant pattern properties in favor of schema references
    • Enhanced type definitions for scores and values
  3. Packaging Schema Enhancements

    • Added comprehensive examples for packaging properties
    • Added missing fields with proper examples:
      • number_of_units
      • quantity_per_unit and related fields
      • recycling
      • weight_measured
  4. Agribalyse Schema Updates

    • Added agribalyse_proxy_food_code field
    • Added agribalyse_food_code field
    • Added co2_agriculture field

The changes improve code organization, reduce duplication, and enhance compatibility with OpenAPI code generators while maintaining backward compatibility with existing data structures.

Related issue(s) and discussion

This refactoring improves schema maintainability and provides better type safety through proper enum definitions and standardized patterns for country-specific data.

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 (a5004f8). Report is 761 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #11009 +/- ## ========================================== - 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