https://github.com/anfibiacreativa/contoso-services-typespec
Example of TypeSpec code to generate Contoso Real Estate API specification.
https://github.com/anfibiacreativa/contoso-services-typespec
openapi-specification openapi3 typescript typespec
Last synced: 23 days ago
JSON representation
Example of TypeSpec code to generate Contoso Real Estate API specification.
- Host: GitHub
- URL: https://github.com/anfibiacreativa/contoso-services-typespec
- Owner: anfibiacreativa
- Created: 2023-09-06T17:08:34.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-21T11:10:13.000Z (over 1 year ago)
- Last Synced: 2025-01-27T10:41:35.556Z (3 months ago)
- Topics: openapi-specification, openapi3, typescript, typespec
- Homepage: https://aka.ms/trytypespec
- Size: 46.9 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- jimsghstars - anfibiacreativa/contoso-services-typespec - Example of TypeSpec code to generate Contoso Real Estate API specification. (Others)
README
# contoso-services-typespec
TypeSpec generated servicesThis 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](https://nodejs.org/en/blog/release/v16.16.0) or up, installed in your system, and at least [npm](https://www.npmjs.com) 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! 🚀