-
-
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.
docs: Improved descriptions and schema adjustments for API references (…
…#10976) <!-- IMPORTANT CHECKLIST Make sure you've done all the following (You can delete the checklist before submitting) - [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 - [ ] 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](https://github.com/openfoodfacts/openfoodfacts-server/blob/main/CONTRIBUTING.md) --> ### What This pull request updates the API reference documentation files (docs/api/ref/schemas/**/*.yaml) to: - Improve clarity and detail by adding descriptions and comments to properties and references. - Address potential issues related to rapidoc and generator errors. - Make adjustments to schema definitions for better accuracy. - Added recursive references for Ingredient and Nutrient schemas in api.yml to fix generator errors. - Reorganized the structure of the image.yaml, image_role.yaml, image_urls.yaml, nutrients.yaml, product_base.yaml, product_ecoscore.yaml, product_extended.yaml, and product_tags.yaml files for better clarity and maintainability. - Updated pattern properties and refactored the structure of these YAML files to ensure consistency and correctness. We believe these changes will enhance the usability and understanding of the API reference for developers. Please review the changes and let us know if you have any feedback. ### SCREENSHOT ![image](https://github.com/user-attachments/assets/9837bcaa-0893-4aaa-aac9-692f998345d9) --------- Co-authored-by: Stéphane Gigandet <[email protected]>
- Loading branch information
1 parent
8a40a64
commit eeefdf0
Showing
10 changed files
with
127 additions
and
112 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 |
---|---|---|
@@ -1,34 +1,40 @@ | ||
type: object | ||
title: image | ||
description: | | ||
This object represent an image that was uploaded to a product. | ||
"imgid" is an integer which is a sequential number unique to each picture. | ||
properties: | ||
sizes: | ||
type: object | ||
description: | | ||
The available image sizes for the product (both reduced and full). | ||
The reduced images are the ones with numbers as the key( 100, 200 etc) | ||
while the full images have `full` as the key. | ||
properties: | ||
full: | ||
$ref: ./image_size.yaml | ||
patternProperties: | ||
"(?<image_size>100|400)": | ||
description: | | ||
properties of thumbnail of size `image_size`. | ||
**TODO** explain how to compute name | ||
components: | ||
schemas: | ||
Sizes: | ||
type: object | ||
description: | | ||
The available image sizes for the product (both reduced and full). | ||
The reduced images are the ones with numbers as the key( 100, 200 etc) | ||
while the full images have `full` as the key. | ||
properties: | ||
full: | ||
$ref: ./image_size.yaml | ||
patternProperties: | ||
"(?<image_size>100|400)": | ||
description: | | ||
properties of thumbnail of size `image_size`. | ||
**TODO** explain how to compute name | ||
For real type: see description of property `full`. | ||
(Put this way because of a [bug in rapidoc](https://github.com/rapi-doc/RapiDoc/issues/880)) | ||
type: string | ||
uploaded_t: | ||
type: string | ||
example: "1457680652" | ||
description: | | ||
The time the image was uploaded (as unix timestamp). | ||
uploader: | ||
type: string | ||
example: openfoodfacts-contributors | ||
description: | | ||
The contributor that uploaded the image. | ||
For real type: see description of property `full`. | ||
(Put this way because of a [bug in rapidoc](https://github.com/rapi-doc/RapiDoc/issues/880)) | ||
type: string | ||
|
||
Image: | ||
type: object | ||
title: image | ||
description: | | ||
This object represent an image that was uploaded to a product. | ||
"imgid" is an integer which is a sequential number unique to each picture. | ||
properties: | ||
sizes: | ||
$ref: "#/components/schemas/Sizes" | ||
uploaded_t: | ||
type: string | ||
example: "1457680652" | ||
description: | | ||
The time the image was uploaded (as unix timestamp). | ||
uploader: | ||
type: string | ||
example: openfoodfacts-contributors | ||
description: | | ||
The contributor that uploaded the image. |
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 |
---|---|---|
@@ -1,5 +1,24 @@ | ||
type: object | ||
patternProperties: | ||
'(?<language_code>\w\w)': | ||
type: string | ||
description: url of the image for language `language_code` | ||
components: | ||
schemas: | ||
ImageUrls: | ||
type: object | ||
patternProperties: | ||
'(?<language_code>\w\w)': | ||
type: string | ||
description: url of the image for language `language_code` | ||
SelectedImage: | ||
type: object | ||
description: URLs of thumbnails image of image of type `image_type` | ||
properties: | ||
display: | ||
description: | | ||
Thumbnail urls of product image (front) adapted to display on product page | ||
$ref: "#/components/schemas/ImageUrls" | ||
small: | ||
description: | | ||
Thumbnail urls of product image (front) adapted to display on product list page | ||
$ref: "#/components/schemas/ImageUrls" | ||
thumb: | ||
description: | | ||
Thumbnail urls of product image (front) in smallest format | ||
$ref: "#/components/schemas/ImageUrls" |
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 |
---|---|---|
@@ -1,31 +1,30 @@ | ||
components: | ||
schemas: | ||
type: object | ||
Nutrient: | ||
type: object | ||
title: nutrient | ||
properties: | ||
id: | ||
type: string | ||
description: id of the nutrient | ||
name: | ||
type: string | ||
description: Name of the nutrient in the requested language | ||
important: | ||
type: boolean | ||
description: Indicates if the nutrient is always shown on the nutrition facts table | ||
display_in_edit_form: | ||
type: boolean | ||
description: Indicates if the nutrient should be shown in the nutrition facts edit form | ||
unit: | ||
description: Default unit of the nutrient | ||
$ref: "./nutrient_unit.yaml" | ||
nutrients: | ||
$ref: "#/components/schemas/Nutrients" | ||
Nutrients: | ||
type: array | ||
description: | | ||
Nutrients and sub-nutrients of a product, with their name and default unit. | ||
(e.g. saturated-fat is a sub-nutrient of fat). | ||
items: | ||
type: object | ||
title: nutrient | ||
properties: | ||
id: | ||
type: string | ||
description: id of the nutrient | ||
name: | ||
type: string | ||
description: Name of the nutrient in the requested language | ||
important: | ||
type: boolean | ||
description: Indicates if the nutrient is always shown on the nutrition facts table | ||
display_in_edit_form: | ||
type: boolean | ||
description: Indicates if the nutrient should be shown in the nutrition facts edit form | ||
unit: | ||
$ref: "./nutrient_unit.yaml" | ||
nutrients: | ||
type: array | ||
items: | ||
# self recursive | ||
$ref: "#/components/schemas/Nutrients/items" | ||
$ref: "#/components/schemas/Nutrient" |
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
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
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