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

docs: Improve api def - tested ts client generation #10913

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

Conversation

shinjigi
Copy link
Contributor

@shinjigi shinjigi commented Oct 18, 2024

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:

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

client_generation.mp4

Related issue(s) and discussion

- Remove x-stoplight metadata from YAML files
- Add missing enum values and descriptions
- Standardize type definitions and examples
- Fix typos and inconsistencies in various schemas
- Add missing titles to response and request schemas
- Standardize schema references using #/components/schemas/
- Remove x-stoplight useless metadata
- Fix inconsistencies in data types and enums
- Improve description and examples in various schemas
- Restructure image_role schema for better organization
- Update product schema to use centralized component references
@shinjigi shinjigi requested a review from a team as a code owner October 18, 2024 21:28
@github-actions github-actions bot added 📦 Packaging https://wiki.openfoodfacts.org/Category:Recycling 📚 Documentation Documentation issues improve the project for everyone. 📖 Knowledge Panels https://wiki.openfoodfacts.org/Knowledge_panels labels Oct 18, 2024
Copy link

sonarcloud bot commented Oct 18, 2024

@shinjigi shinjigi changed the title docs: Improve api def - tested ts client generation docs: Improve api def - tested ts client generation Oct 18, 2024
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 49.11%. Comparing base (dc04d18) to head (824ca62).
Report is 708 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10913      +/-   ##
==========================================
- Coverage   49.54%   49.11%   -0.44%     
==========================================
  Files          67       77      +10     
  Lines       20650    22197    +1547     
  Branches     4980     5306     +326     
==========================================
+ Hits        10231    10902     +671     
- Misses       9131     9963     +832     
- Partials     1288     1332      +44     

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 Documentation Documentation issues improve the project for everyone. 📖 Knowledge Panels https://wiki.openfoodfacts.org/Knowledge_panels 📦 Packaging https://wiki.openfoodfacts.org/Category:Recycling
Projects
Status: In progress
Status: Todo
Status: Todo
Development

Successfully merging this pull request may close these issues.

2 participants