Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Scaffold ts phoenix client using openapi-typescript #4928

Merged
merged 3 commits into from
Oct 16, 2024

Conversation

mikeldking
Copy link
Contributor

No description provided.

@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Oct 9, 2024
@@ -14,23 +14,24 @@
"scripts": {
"clean": "rimraf dist",
"prebuild": "pnpm run clean && pnpm run generate",
"generate": "openapi-ts",
"generate": "openapi-typescript ../../../schemas/openapi.json -o ./src/lib/api/v1.d.ts",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
"generate": "openapi-typescript ../../../schemas/openapi.json -o ./src/lib/api/v1.d.ts",
"generate": "openapi-typescript ../../../schemas/openapi.json -o ./src/schema.d.ts",

@cephalization why not just put it at the root of src?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

alternatively could use relay syntax __generated__

Copy link
Contributor

Choose a reason for hiding this comment

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

Leaving root open lets us build out wrapping structures or extra utils on top of the generated code without co-mingling it. I can rename to generated though

};

export const createClient = (
options: ClientOptions = { baseUrl: "http://localhost:6006" },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we should support the same environment variables here

Copy link
Contributor

Choose a reason for hiding this comment

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

Good call, although I am a bit wary because it makes the code less isomorphic. I can do some feature detection on process.env probably so that this code still runs in all runtimes

};
"/v1/datasets/{id}": {
parameters: {
query?: never;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cephalization this is weird - is it something we can configure? it should be at least any here

Copy link
Contributor

Choose a reason for hiding this comment

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

Something is definitely messed up. The last openapi codegen tool I used strongly typed the query parameters of each endpoint and I'd expect the same here

Copy link
Contributor

Choose a reason for hiding this comment

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

image

Looks like later on in the generated types it overrides these never types with the appropriate types

@mikeldking mikeldking merged commit 7a63e1d into phoenix-ts-sdk Oct 16, 2024
2 checks passed
@mikeldking mikeldking deleted the phoenix-ts-sdk--openapi-typescript branch October 16, 2024 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants