https://github.com/speakeasy-api/nestjs-openapi-example
An example for generating OpenAPI from a NestJS app
https://github.com/speakeasy-api/nestjs-openapi-example
Last synced: 5 months ago
JSON representation
An example for generating OpenAPI from a NestJS app
- Host: GitHub
- URL: https://github.com/speakeasy-api/nestjs-openapi-example
- Owner: speakeasy-api
- Created: 2024-11-01T11:44:43.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-11-05T11:19:22.000Z (8 months ago)
- Last Synced: 2025-01-28T20:12:12.155Z (5 months ago)
- Language: TypeScript
- Size: 144 KB
- Stars: 0
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This example NestJS app demonstrates Speakeasy-recommended practices for generating clear OpenAPI specifications and SDKs.
This project was bootstrapped with [NestJS-CLI](https://docs.nestjs.com/cli/overview).
## Prerequisites
You need to have Node.js version >= 16 and the Nest CLI installed on your system to run this project. If you don't have these installed, you can download them from [here](https://nodejs.org/) and [here](https://github.com/nestjs/nest-cli).
To generate an SDK, you'll also need the Speakeasy CLI installed, or use the Speakeasy dashboard.
## Installation
To install the application on your local machine:
1. Clone the repository:
```bash
git clone https://github.com/speakeasy-api/nestjs-openapi-example.git
```2. Navigate into the directory:
```bash
cd speakeasy-nestjs-example
```3. Install all dependencies for the application using NPM:
```bash
npm install
```4. [Install Speakeasy CLI](https://github.com/speakeasy-api/speakeasy#installation):
```bash
brew install speakeasy-api/homebrew-tap/speakeasy
```## Running the application for development
You can use the provided script to run the application in development mode. It will watch for any changes in the source code and automatically restart the server.
> Move the `sdk-typescript` folder to a new location outside this project before starting the dev server.
```bash
npm run start:dev
```### Creating an OpenAPI specification
An OpenAPI specification `openapi.yaml` file is generated in the root directory, using JS-YAML, when the development server is started.
## Generating an SDK using Speakeasy
To generate a Speakeasy SDK run:
```bash
speakeasy quickstart
```## License
This project is licensed under the terms of the Apache 2.0 license.