-
-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Improve api def - tested ts client generation (#10913)
feat(api): improve OpenAPI schema consistency and structure ### What This pull request enhances the consistency and structure of OpenAPI schemas in the Open Food Facts project. The main changes include: - Added missing titles to response and request schemas for better identification - Standardized schema references using #/components/schemas/ for improved consistency - Removed unnecessary x-stoplight metadata - Fixed inconsistencies in data types and enums - Improved descriptions and examples in various schemas - Restructured the image_role schema for better organization - Updated the product schema to use centralized component references These changes improve the readability, maintainability, and consistency of the API definition, making it easier for developers to use and integrate. The updated schema has been tested with the following OpenAPI generators and tools: - OpenAPI Generator: - typescript-fetch - typescript - javascript - @hey-api/openapi-ts - Swagger Editor (editor-next.swagger.io) The primary configuration used for testing was: ```yaml generatorName: typescript-fetch outputDir: ./clients/ts-fetch inputSpec: ./fork-shinjigi-4pullrequest-api-ref/api.yml verbose: false additionalProperties: npmName: "@iside/ec-open-food-facts-client-ts-fetch" npmVersion: "1.122.0" npmRepository: "http://" snapshot: false supportsES6: false modelPropertyNaming: "original" enumPropertyNaming: "original" paramNaming: "original" enablePostProcessFile: true modelNameMappings: ingredient_1: Ingredient product_extended_owner_fields_1: ProductExtendedOwnerFields product_extended_owner_fields_1_additionalProperties: ProductExtendedOwnerFieldsAdditionalProperties product_ecoscore_data_1: ProductEcoscoreData globalProperties: debugOpenAPI: true ``` ### Screenshot ![graph](https://github.com/user-attachments/assets/05da6b7c-ad85-4217-bbf3-57339fd6d883) https://github.com/user-attachments/assets/61f50394-8992-4b8e-bd9c-76c8c138390a ### Related issue(s) and discussion - Fixes/RelatedTo: #8039 #8042
- Loading branch information
Showing
34 changed files
with
221 additions
and
220 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
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,8 +1,9 @@ | ||
type: object | ||
title: add_or_edit_a_product_response | ||
properties: | ||
status_verbose: | ||
type: string | ||
example: fields saved | ||
status: | ||
type: integer | ||
example: 1 | ||
example: 1 |
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,8 +1,9 @@ | ||
type: object | ||
title: change_ref_properties_response | ||
properties: | ||
status_verbose: | ||
type: string | ||
example: fields saved | ||
status: | ||
type: integer | ||
example: 1 | ||
example: 1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
x-stoplight: | ||
id: cfk5obotr63sa | ||
type: object | ||
title: get_product_by_barcode_response | ||
allOf: | ||
- $ref: ./get_product_by_barcode_base.yaml | ||
- properties: | ||
product: | ||
$ref: ../schemas/product.yaml | ||
$ref: ../schemas/product.yaml |
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,4 +1,5 @@ | ||
type: object | ||
title: ocr_on_product_response | ||
properties: | ||
status: | ||
type: integer | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
type: object | ||
title: search_for_products_response | ||
properties: | ||
count: | ||
type: integer | ||
|
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
Oops, something went wrong.