Skip to content

Commit

Permalink
TP: Added a "test" button to GUI, shared OpenAPI Spec
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Helma <[email protected]>
  • Loading branch information
chelma committed Dec 16, 2024
1 parent 46a5ebd commit e4a82ca
Show file tree
Hide file tree
Showing 25 changed files with 3,463 additions and 107 deletions.
1 change: 1 addition & 0 deletions TransformationPlayground/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ langchain = "*"
langchain-aws = "*"
requests = "*"
django-cors-headers = "*"
drf-spectacular = "*"

[dev-packages]

Expand Down
212 changes: 185 additions & 27 deletions TransformationPlayground/Pipfile.lock

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion TransformationPlayground/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,17 @@ The `test_target_url` is optional, but enables the system to test the output Ind

#### Frontend

To run the Frontend, first start the backend and ensure it's running. Then, execute the following commands:
If you changed the Backend API specification, you'll first need to generate new client code. The Backend uses `drf-spectacular` to auto-supply OpenAPI specs to facilitate this process. You can generate the new client code like so:

```bash
# Start in the repo root

(cd playground && python3 manage.py spectacular --file schema.json)

(cd playground_frontend && npm install && npm run generate-api-client)
```

To run the Frontend, first start the Backend and ensure it's running. Then, execute the following commands:

```bash
# Start in the repo root
Expand Down
12 changes: 12 additions & 0 deletions TransformationPlayground/playground/playground/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
'django.contrib.staticfiles',
'rest_framework',
'corsheaders',
'drf_spectacular',
'transform_api'
]

Expand Down Expand Up @@ -76,6 +77,17 @@

WSGI_APPLICATION = 'playground.wsgi.application'

# API Spec generation
REST_FRAMEWORK = {
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
}

SPECTACULAR_SETTINGS = {
'TITLE': 'Transformation API',
'DESCRIPTION': 'API for JSON transformation logic.',
'VERSION': '0.1.0',
}


# Database
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
Expand Down
8 changes: 7 additions & 1 deletion TransformationPlayground/playground/playground/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
from django.urls import path
from transform_api.views import TransformsIndexView
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView

from transform_api.views import TransformsIndexView, TransformsIndexTestView


urlpatterns = [
path('api/schema/', SpectacularAPIView.as_view(), name='schema'),
path('api/docs/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
path('transforms/index/', TransformsIndexView.as_view(), name='transforms_index'),
path('transforms/index/test/', TransformsIndexTestView.as_view(), name='transforms_index_test'),
]
Loading

0 comments on commit e4a82ca

Please sign in to comment.