https://github.com/kkirsche/openapi-demo
This is a demo repository for working with the OpenAPI spec
https://github.com/kkirsche/openapi-demo
Last synced: 8 months ago
JSON representation
This is a demo repository for working with the OpenAPI spec
- Host: GitHub
- URL: https://github.com/kkirsche/openapi-demo
- Owner: kkirsche
- Created: 2019-07-17T13:16:02.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-04-20T18:22:17.000Z (about 5 years ago)
- Last Synced: 2025-06-02T02:50:08.626Z (about 1 year ago)
- Language: Python
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# OpenAPI Demonstration Application
This application is designed to assist with learning how to work with the OpenAPI standard.
## Usage
### Application
To use the application locally, the following commands (prefixed by `$` to indicate that these should be run from a terminal):
```shell
$ python3 -m venv venv
$ source ./venv/bin/activate
$ python3 -m pip -r requirements.txt
$ export FLASK_APP=main.py
$ flask run
```
This will begin the application on port 5000 bound to localhost (127.0.0.1).
### Unit Tests
To run the unit tests for the API, the following commands may be used. This assumes that the virtual environment from the Application Usage was not completed yet.
```shell
$ python3 -m venv venv
$ source ./venv/bin/activate
$ python3 -m pip -r requirements.txt
$ pytest -v
```
## Endpoints
This application exposes the following endpoints on the host running the application:
* `GET /api/v1/fighters` - List fighters
* `GET /api/v1/fighters/{id}` - Show fighter
* `POST /api/v1/fighters` - Create fighter
* `PUT /api/v1/fighters/{id}` - Update fighter
* `DELETE /api/v1/fighters/{id}` - Destroy fighter
## Structures
### Fighter
A fighter includes the following information:
* `id` - The numeric ID representing the entry
* `name` - The fighter's name
* `weightclass` - The fighter's weightclass
An example of a fighter would be:
```json
{
"id": 1,
"name": "Jon Jones",
"weightclass": "Light heavyweight (205 lbs)"
}
```
### Error
An error includes the following information:
* `error` - The error message
An example of an error would be:
```json
{
"error": "404 - Not Found"
}
```