TypeSpec generated services
This repo uses https://microsoft.github.io/typespec/
To create your own project, follow these steps. (You must make sure to have Node.js 16 LTS or up, installed in your system, and at least npm version 7+.
$ npm install -g @typespec/compiler
$ mkdir my-tsp-project && cd my-tsp-project && tsp init
When prompted, select the Generic Rest API
template, your project name and the @typespec/openapi3
library.
Run
$ tsp install
That will create a basic tsp
project structure that looks like this:
package.json # Package manifest defining your typespec project as a node package.
tspconfig.yaml # TypeSpec project configuration letting you configure emitters, emitter options, compiler options, etc.
main.tsp # TypeSpec entrypoint.
Edit the main.tsp
file as necessary for your definition.
$ tsp format **/*.tsp # this will format all .tsp files in the project
Now you can compile the project running
$ tsp compile .
(if you're in a different folder than the project root, pass the path to the compile command)
To emit the specification file, run
$ tsp compile . --emit=@typespec/openapi3
You should have a new folder called tsp-output
by default, with your spec.
You're all set! 🚀