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

fix: apidoc openApi ecoscore mapping #11009

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

shinjigi
Copy link
Contributor

  • PR title is prefixed by one of the following: feat, fix, docs, style, refactor, test, build, ci, chore, revert, l10n, taxonomy
  • Code is well documented
  • Include unit tests for new functionality
  • Code passes GitHub workflow checks in your branch
  • If you have multiple commits please combine them into one commit by squashing them.
  • Read and understood the contribution guidelines

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

  • Fixes #[ISSUE NUMBER]

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

- fix transportation_values
- fix values
- fix transportation_score
- agribalyse_food_code => agribalyse_proxy_food_code
@shinjigi shinjigi requested a review from a team as a code owner November 12, 2024 16:52
@github-actions github-actions bot added the 📚 Documentation Documentation issues improve the project for everyone. label Nov 12, 2024
@codecov-commenter
Copy link

codecov-commenter commented Nov 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 49.03%. Comparing base (dc04d18) to head (a5004f8).
Report is 761 commits behind head on main.

Additional details and impacted files
@@            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     

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

@teolemon teolemon added the 🌱 Eco-Score https://world.openfoodfacts.org/eco-score-the-environmental-impact-of-food-products label Nov 13, 2024
@github-actions github-actions bot added Agribalyse French LCA database used in Eco-Score computations 📚 OpenAPI labels Nov 15, 2024
Copy link

sonarcloud bot commented Nov 15, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Agribalyse French LCA database used in Eco-Score computations 📚 Documentation Documentation issues improve the project for everyone. 🌱 Eco-Score https://world.openfoodfacts.org/eco-score-the-environmental-impact-of-food-products 📚 OpenAPI
Development

Successfully merging this pull request may close these issues.

4 participants