jitsu icon indicating copy to clipboard operation
jitsu copied to clipboard

Generate API and docs with Open API

Open xtreding opened this issue 4 years ago • 0 comments

Problem

At the moment Jitsu has two servers with JSON-based APIs:

  • Configurator
  • Server

Both of them have manual API documentation which are not always in sync with actual implementation. [1]

The other problem that is related to APIs is the way how Jitsu UI communicates with Configurator. If UI needs to update any of the core entities (destination, api_key, source etc), it updates the whole list of entities which is not efficient and exposes UI to change conflicts. [2]

Solution

We need to descript API with OpenAPI 3.0 spec and make sure that servers conforms with the spec (via codegen).

Since the change is pretty significant, we're going to roll it in stages

  • [x] Define a new Configurator API that addresses [2] (see above). See feature/openapi-spec branch
  • [x] Configure codegen for configurator. Implement /api/v2/objects/* part of the API
  • [x] #785
  • [ ] Remove depricated APIs from /api/v1/configurations/* from Configurator, describe all other APIs, implemented them with generated code / interfaces. Will be resolved by #816
  • [ ] Define Server APIs with OpenAPI spec
  • [ ] Generate docs based on spec; integrate docs with jitsu.com/docs (related to #725 )

Note:

Use the following commands to verify open-api spec in feature/openapi-spec

npm i -g openapi-generator-cli
cd openapi
openapi-generator-cli generate -g typescript -i configurator.yml -o ts   
openapi-generator-cli generate -g go -i configurator.yml -o go 

Sometimes go generator fails, and ts doesn't (and vice-verse). If two generators don't fail, it's a good chance that open-api spec is good to go

Collateral Changes

  • Support Authrization: Bearer <token> in addition to current (and non-standard) X-Client-Auth: <token>
  • Get rid of globally signed JWT in authorization, replace it with session kept in Redis, or with JWTs signed by by-user secrets

xtreding avatar Jun 14 '21 17:06 xtreding