Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • erp5 erp5
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Merge requests 141
    • Merge requests 141
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Jobs
  • Commits
Collapse sidebar
  • nexedi
  • erp5erp5
  • Merge requests
  • !1765

Merged
Created Apr 03, 2023 by Jérome Perrin@jeromeOwner

open_api: new business template

  • Overview 35
  • Commits 1
  • Pipelines 7
  • Changes 88

This is a simple framework to implement services in ERP5 based on an OpenAPI document.

A new type "Open API Type" (similar to "Base Type") is introduced, this is responsible for the definition of operations and types. The Open API document is set as text content of the Open API Type and can be edited from the Open API Type.

For each service, a new portal type will be created. The portal type use OpenAPIService as class and this is responsible for serving requests. The process of serving requests is:

  • find the matching operation from the request method and request path
  • extracting request parameters and request body using the parameter definitions from the Open API Document
  • validate parameters and request body according to the schema from the Open API document
  • finding the method, this is done by using _getTypeBasedMethod with the operationId
  • calling the method and formatting the result or handling error. The default handling of errors is to reply with rfc7807 json responses, but it can be customized by defining an handleException type based method.

Typically, the services will be created in portal_web_services. From there, there is also a view using a new SwaggerUI gadget to try out the API.

What's not supported:

  • OpenAPI document in YAML format is only partially supported and have some limitations over JSON:
    • On python2 the order of operations is lost, the lookup of operations is not made in the order of the operations from the document. Also the operations are not in order in the SwaggerUI gadget.
    • The text editor does not provide rich editing of YAML
  • "partial" parameters in path elements ( /users/{user_id} is supported, but /documents/report.{format} is not )
  • XML (decoding of request bodies and parsing of responses) is not supported.
Edited Apr 04, 2023 by Jérome Perrin
Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: feat/open-api
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7