unitycatalog / unitycatalog-ui

Unity Catalog UI
Apache License 2.0
39 stars 14 forks source link

Use the official OpenAPI specification to generate types #57

Open jamieknight-db opened 4 months ago

jamieknight-db commented 4 months ago

Discussed in https://github.com/unitycatalog/unitycatalog-ui/discussions/54

Originally posted by **ognis1205** July 26, 2024 The URL paths, requests, and responses of the backend server to be used are strictly defined by the OpenAPI specification. I think it is better to automatically generate TypeScript interfaces from OpenAPI and then define the paths as union types and the requests and responses as interfaces synchronized with the OpenAPI specification using utility types. Additionally, rather than using fetch, if you use third-party libraries like axios and implement some utilities, you can implement everything in a type-safe manner with interfaces synchronized with OpenAPI in a single API.
ognis1205 commented 4 months ago

@jamieknight-db

Thank you for filing the issue! Please feel free to assign it to me. Sorry for the late reply.

everettVT commented 4 months ago

Just curious what tool you were planning on using @ognis1205 Something along the lines of this? https://github.com/openapi-ts/openapi-typescript/tree/main/packages/openapi-typescript

ognis1205 commented 4 months ago

@everettVT

Just curious what tool you were planning on using @ognis1205

The implementation of client-related components around OpenAPI and gRPC is progressing in Python, Rust, TypeScript, and Java. Since it seems that OpenAPI Generator is being used for Java, Python, and Rust/OpenAPI, I thought of using OpenAPI Generator if there is consensus here. Personally, I initially planned to use openapi-typescript and define some utility types.

Something along the lines of this? https://github.com/openapi-ts/openapi-typescript/tree/main/packages/openapi-typescript

Therefore, the implementation method you pointed out will be the baseline, but I intended to make the url-path, request, and response types more type-safe by enabling inference at compile(transpile) time.

If you are going to implement the CreateTable API and the auto-generation of the API interfaces, you can take this issue as well. Otherwise, in case of just implementing the CreateTable API alone, please follow the conventional implementation.

Reference: https://github.com/unitycatalog/unitycatalog/discussions/208#discussioncomment-10223757

everettVT commented 3 months ago

Sounds like you are on the right path. I am new to contributing so feel free to proceed as you see fit.

ognis1205 commented 3 months ago

@everettVT Thank you for asking. If you have any advice, please feel free to let me know anytime.

dennyglee commented 2 months ago

As part of the migration, you can find the new issue at unitycatalog #431