-
I'm able to successfully create a OpenAPI spec from my TypeSpec, as well as JSON Schema files. But how about something as simple as plain TypeScript interfaces? Is there a default emitter that can create these? I'm aware that I could do TypeSpec -> JSON Schema -> TypeScript, and I tried that already, but that seems a bit convoluted 🤨 // main.tsp
model Pet {}
model Person {
pet: Pet;
} would become // models.d.ts
export interface Pet {}
export interface Person {
pet: Pet;
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
I believe this should be coming soon as part of our Rest client emitter work, though I can't say for sure. We definitely intend to have "model emitters" in all languages we support eventually. If it's interesting or useful, we have a test emitter that does this, which you could perhaps use. Just note that it's just for testing purposes and you will have to copy/paste the code. You can find it here: https://github.com/microsoft/typespec/blob/main/packages/compiler/test/emitter-framework/typescript-emitter.ts |
Beta Was this translation helpful? Give feedback.
-
Since this is the only reasonable Google result when searching for TS interfaces from TSP, I'll stick this here. I have started work on a very simple emitter, which is capable of transforming at least basic TSP models to TypeScript interfaces. https://github.com/crowbait/typespec-typescript-emitter It can also generate a TS object based on ops when using the HTTP library, which can help writing things like abstracted API wrappers (which is my specific use case and why I started on this in the first place). May be a bit specific, but still, might help someone. |
Beta Was this translation helpful? Give feedback.
I believe this should be coming soon as part of our Rest client emitter work, though I can't say for sure. We definitely intend to have "model emitters" in all languages we support eventually.
If it's interesting or useful, we have a test emitter that does this, which you could perhaps use. Just note that it's just for testing purposes and you will have to copy/paste the code. You can find it here: https://github.com/microsoft/typespec/blob/main/packages/compiler/test/emitter-framework/typescript-emitter.ts