Skip to content

[FEATURE] Autogenerate typescript sdk and documentation #90

@jacksonjacobs1

Description

@jacksonjacobs1

Description

The current client utilizes a handwritten typescript sdk which is tedious to maintain in sync with a changing python api.

Because the API is OpenAPI 3.0, we can instead utilize openapi-generator to create the javascript sdk.
https://openapi-generator.tech/

Technical Notes

  1. Install the openapi-generator-cli within the development environment
npm install @openapitools/openapi-generator-cli -g
  1. Install java
apt update && apt install -y default-jre
  1. Generate the typescript sdk
openapi-generator-cli generate -i http://localhost:5000/api/v1/openapi.json -g typescript-fetch -o ./generated-ts-sdk

The following folder structure was generated in my case:

generated-ts-sdk/
|-- apis
|   |-- AnnotationApi.ts
|   |-- AnnotationClassApi.ts
|   |-- ImageApi.ts
|   |-- NotificationApi.ts
|   |-- ProjectApi.ts
|   |-- SettingApi.ts
|   |-- TileApi.ts
|   `-- index.ts
|-- index.ts
|-- models
|   |-- AnnClassResp.ts
|   |-- AnnResp.ts
|   |-- GetAnnByTileIdsArgs.ts
|   |-- GetAnnWithinPolyArgs.ts
|   |-- ImageResp.ts
|   |-- ModelError.ts
|   |-- NotificationResp.ts
|   |-- OperationArgs.ts
|   |-- PaginationMetadata.ts
|   |-- PostAnnsArgs.ts
|   |-- PostProjectArgs.ts
|   |-- ProjectResp.ts
|   |-- PutAnnArgs.ts
|   |-- PutProjectArgs.ts
|   |-- SearchTileByPolygonArgs.ts
|   |-- SettingResp.ts
|   |-- TileBoundingBoxResp.ts
|   |-- TileIdResp.ts
|   |-- TileResp.ts
|   `-- index.ts
`-- runtime.ts

Additionally, sdk documentation can be auto-generated using typedoc tool:
https://typedoc.org/documents/Overview.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestv2.0Pertains to the v2.0 branch

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions