-
-
Notifications
You must be signed in to change notification settings - Fork 11
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: generate types from OpenAPI schemas #33
Conversation
β Deploy Preview for nuxt-api-party ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Dang, that was fast. π Will take me some time to review. But thanks in advance! |
src/runtime/types.ts
Outdated
body: string | Blob | ||
headers: { 'content-type': 'application/octet-stream' } | ||
} | ||
: {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick question: What do you mean by {}
?
We shouldn't use {}
as a type. {}
actually means "any non-nullish value", according to ESLint.
- If you want a type meaning "any object", you probably want
object
instead. - If you want a type meaning "any value", you probably want
unknown
instead. - If you want a type meaning "empty object", you probably want
Record<string, never>
instead.
...
See the eslint@typescript-eslint/ban-types.
Hey @killjoy1221 I just reviewed most of your code. Looks quite promising. I have refactored some code, to bring it closer to Nuxt standards. For example, instead of relying on const hasOpenAPIPkg = await tryResolveModule('openapi-typescript', [nuxt.options.rootDir]) But in the end, minor optimizations. I haven't touched your logic a lot. The OpenAPI stuff is complicated and I might get 75 % of it. Looking good tho. I have one question left β see review tab. Then, I will have to take a look at why the tests are failing. |
No problem. I always expect a bit of nitpicking when it comes to coding standards. I agree that the OpenAPI types are complex. I tried to support path parameters via template strings |
Yeah, maybe TS can't infer the type from a concatenated string. There is the Anyway, thanks for your contribution. It's a hell of a lot of work! I will release a new package version later today. Glad you helped. :) |
@killjoy1221 Nuxt API Party v0.14 just released! π |
π Linked Issue
#32
β Type of change
π Description
Types can now be generated for an API if it defines an OpenAPI schema. By specifying the schema on the endpoint as a url, file, schema object, or function returning the schema object, types for the paths and components will be generated in
.nuxt/types/nuxt-api-party-types.d.ts
.Types can be imported directly via
Resolves #32
π Checklist