Comments (4)
@Birkbjo this is fixed in v0.27.33
🎉
I added a section on programmatic setup to README – https://github.com/nicolas-chaulet/openapi-typescript-codegen?tab=readme-ov-file#installation
Here's how I use it
import { createClient } from '@nicolas-chaulet/openapi-typescript-codegen'
const client = await createClient()
You can pass config to createClient()
, but it also tries to read config from a file so it's optional.
I need to do some quite specific transformations of the resulting types, like resolve refs (I see that this now includes this, but I dont think it will work for me because the schema im working doesn't directly reference the component...), and some renames etc
We can discuss this more if you want, I think there's some potential to unlock. I am now returning client
from createClient()
as opposed to not returning anything previously. I don't recommend using it as that's an internal API, but it's a good start as now you can have access to the same information openapi-ts
has when generating your client. In theory, you could even run const client = await createClient({ write: false })
to skip writing any files and re-implement the write operation yourself!
from openapi-ts.
@Birkbjo oh yes, you're correct, I changed that. Before I add the types back, can I ask why you're generating types programatically?
You're also correct on the ESM modules, are you able to share what kind of error message(s) you're seeing?
from openapi-ts.
@Birkbjo I just tried it and it works for me in a foo.ts
file, but I am also using "type": "module"
in my package.json
import { generate } from '@nicolas-chaulet/openapi-typescript-codegen'
generate()
I executed it with npx tsx foo.ts
. I will fix the missing types, thanks for flagging! Let me know more details about your execution if you need help with that too
from openapi-ts.
Thanks for the quick resolution!
I started looking into migrating to txs as well, need to cleanup my tsconfig etc.
As for the use-case - I use the codegen in a wrapper tool that is used to clean the results. I need to do some quite specific transformations of the resulting types, like resolve refs (I see that this now includes this, but I dont think it will work for me because the schema im working doesn't directly reference the component...), and some renames etc. Most of this is because the schema I'm working with isn't really ideal.
I couldve of course ran this in cli, but its quite convenient to just calll generate
from node when I already need a script anyways.
My project is here if you're interested https://github.com/Birkbjo/dhis2-open-api-ts
from openapi-ts.
Related Issues (20)
- schema compliance with jsr HOT 3
- Allow inlining types in services signature instead of reference to $OpenApiTs HOT 1
- Allow easy differentiation by status codes HOT 4
- invalid identifier created (starting with digits) HOT 1
- formData: mismatch Type HOT 5
- Remove service classes
- Typescript enums not generated HOT 3
- Default response types (error) override response types HOT 3
- Setting a custom httpsAgent on the generated AxiosInstance HOT 9
- Accessing Both Response Body and Headers HOT 2
- Export `OpenApiSchema` interface in the generated client HOT 2
- Pass APIRequestOptions to the response interceptor
- Client instance duplicate identifier
- Specify Line Endings HOT 1
- Dryrun flag checking causes the app not to run. HOT 8
- Inconsistent URL Encoding in Generated Services HOT 3
- Question regarding license HOT 9
- Switch to AbortSignal instead of CancellablePromise HOT 2
- Missed type for `type: ['array']`, produces unknown[] HOT 11
- Should "default" spec responses throw an error? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openapi-ts.