-
-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: apidoc openApi ecoscore mapping (#11009)
- [x] PR title is prefixed by one of the following: feat, fix, docs, style, refactor, test, build, ci, chore, revert, l10n, taxonomy - [x] Code is well documented - [x] Include unit tests for new functionality - [x] Code passes GitHub workflow checks in your branch - [x] If you have multiple commits please combine them into one commit by squashing them. - [x] 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.
- Loading branch information
Showing
3 changed files
with
120 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
components: | ||
schemas: | ||
EcoscoreCountryCode: | ||
type: string | ||
enum: | ||
[ | ||
"ad", | ||
"al", | ||
"at", | ||
"ax", | ||
"ba", | ||
"be", | ||
"bg", | ||
"ch", | ||
"cy", | ||
"cz", | ||
"de", | ||
"dk", | ||
"dz", | ||
"ee", | ||
"eg", | ||
"es", | ||
"fi", | ||
"fo", | ||
"fr", | ||
"gg", | ||
"gi", | ||
"gr", | ||
"hr", | ||
"hu", | ||
"ie", | ||
"il", | ||
"im", | ||
"is", | ||
"it", | ||
"je", | ||
"lb", | ||
"li", | ||
"lt", | ||
"lu", | ||
"lv", | ||
"ly", | ||
"ma", | ||
"mc", | ||
"md", | ||
"me", | ||
"mk", | ||
"mt", | ||
"nl", | ||
"no", | ||
"pl", | ||
"ps", | ||
"pt", | ||
"ro", | ||
"rs", | ||
"se", | ||
"si", | ||
"sj", | ||
"sk", | ||
"sm", | ||
"sy", | ||
"tn", | ||
"tr", | ||
"ua", | ||
"uk", | ||
"us", | ||
"va", | ||
"world", | ||
"xk", | ||
] | ||
# patternProperties not supported by generators | ||
#patternProperties: | ||
# (?<country_code>\w\w): | ||
# type: integer | ||
EcoscoreCountryValues: | ||
type: object | ||
propertyNames: | ||
$ref: "#/components/schemas/EcoscoreCountryCode" | ||
additionalProperties: | ||
type: number | ||
default: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters