https://github.com/dpecos/rest-openapi-example
https://github.com/dpecos/rest-openapi-example
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/dpecos/rest-openapi-example
- Owner: dpecos
- Created: 2022-07-18T15:10:52.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-01-09T02:00:06.000Z (over 2 years ago)
- Last Synced: 2024-12-27T16:45:40.552Z (5 months ago)
- Language: TypeScript
- Size: 409 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# REST OpenAPI Example
## Usage
### Server
To run the server:
```
npm run server
```#### Testing the API
To retrieve the list of books:
```
curl http://localhost:3000/books | jq
```To retrieve a specific book:
```
curl http://localhost:3000/books/1 | jq
```To create a new book:
```
curl -s --request POST --url http://localhost:3000/books --header 'content-type: application/json' --data '{"id": 2, "title" : "New book", "author": "New author", "summary" : "This is a new Book"}' | jq
```#### Swagger UI
You can visit the Swagger generated documentation at this link:
http://localhost:3000/api-docs
## Client
To generate the OpenAPI clients (that could be imported directly in any TS project):
```
npm run generate-client
```