Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/morellodev/openapi-demo
https://github.com/morellodev/openapi-demo
Last synced: 24 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/morellodev/openapi-demo
- Owner: morellodev
- Created: 2023-10-07T13:28:22.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-25T06:39:26.000Z (about 1 year ago)
- Last Synced: 2024-05-01T16:20:00.723Z (6 months ago)
- Language: TypeScript
- Size: 451 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# OpenAPI Demo
This is a little demo to show how to share an OpenAPI schema between client and server in a web app.
The server exposes a REST API with CRUD operations on the `Todo` resource, and the client consumes the auto-generated functions from the same schema used by the server.
## Pre-requisites
You will need `node@20` and `pnpm` installed. Refer to the [pnpm docs](https://pnpm.io/installation) for installation instructions.
## Getting started
1. Clone the repo
2. Run `pnpm install` to install dependencies
3. Run `pnpm dev` to start the server and client## Mocking
The `@app/mocks` package contains mocked resources and API interceptors for the client and tests, powered by [msw](https://mswjs.io).
To enable mocking in development, uncomment the following lines in [@app/client/src/main.tsx](./packages/client/src/main.tsx):
```ts
if (import.meta.env.DEV) {
const { worker } = await import("@app/mocks/browser");
await worker.start();
}
```