Skip to content

Example of TypeSpec code to generate Contoso Real Estate API specification.

Notifications You must be signed in to change notification settings

anfibiacreativa/contoso-services-typespec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

contoso-services-typespec

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+.

Step 1 - Install the tsp compiler running in your terminal

$ npm install -g @typespec/compiler

Step 2 - Create a directory and initialize tsp

$ 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.

Step 3 - Install the tsp dependencies

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)

Emit the OpenAPI spec yaml file

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! 🚀

About

Example of TypeSpec code to generate Contoso Real Estate API specification.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published