Skip to content

Feature/gsk 1649 use openapi typescript generation tools instead of j2ts#1359

Merged
andreybavt merged 26 commits intomainfrom
feature/gsk-1649-use-openapi-typescript-generation-tools-instead-of-j2ts
Sep 4, 2023
Merged

Feature/gsk 1649 use openapi typescript generation tools instead of j2ts#1359
andreybavt merged 26 commits intomainfrom
feature/gsk-1649-use-openapi-typescript-generation-tools-instead-of-j2ts

Conversation

@andreybavt
Copy link
Copy Markdown
Contributor

@andreybavt andreybavt commented Aug 31, 2023

Added the necessary infrastructure to generate a typescript client based on Giskard's OpenAPI specs

This new autogenerated API will eventually replace the old api.ts, the advantages are:

  • no more need to manually call J2TS to generate typescript DTOS
  • the whole client is auto-created, not just DTOs

This PR doesn't replace the old api.ts, but contains a few examples. We should remove old api.ts usage gradually.

How to use:

There's a new gradle command to generate a web client:
./gradlew generateOpenApiClient

The generated code will be stored in frontend/src/generated

the new generateOpenApiClient task is already linked with the backend and frontend build, so simply running:

./gradlew build

will also do the necessary to generate the client

Example of use:

https://github.com/Giskard-AI/giskard/blob/c7652cb5eae7be13124e6af86ce9e82f61e41829/frontend/src/stores/main.ts#L95

once we finish migrating api.* to openapi.* we can delete api.ts and rename openapi to api to keep it simple

@linear
Copy link
Copy Markdown

linear Bot commented Aug 31, 2023

GSK-1649 Use OpenAPI-> typescript generation tools instead of J2TS

Having OpenAPI in place we can rely on it in order to generate TS typings (and even whole API client) instead of J2TS

@andreybavt andreybavt marked this pull request as ready for review August 31, 2023 14:46
…escript-generation-tools-instead-of-j2ts' into feature/gsk-1649-use-openapi-typescript-generation-tools-instead-of-j2ts
Copy link
Copy Markdown
Contributor

@Googleton Googleton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I guess there isn't that much work on migrating, is it just replacing api to api-v2 calls ?

Comment thread backend/build.gradle.kts Outdated
Co-authored-by: Googleton <hugo@giskard.ai>
@andreybavt
Copy link
Copy Markdown
Contributor Author

LGTM. I guess there isn't that much work on migrating, is it just replacing api to api-v2 calls ?

yes, it's mostly about replacing DTOs generated by openapi instead of J2TS ones (like I did in main.ts as an example in this PR)

…escript-generation-tools-instead-of-j2ts' into feature/gsk-1649-use-openapi-typescript-generation-tools-instead-of-j2ts
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Sep 4, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@andreybavt andreybavt merged commit 5baef4f into main Sep 4, 2023
@Hartorn Hartorn deleted the feature/gsk-1649-use-openapi-typescript-generation-tools-instead-of-j2ts branch September 22, 2023 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants