Skip to content

Commit

Permalink
openapi spec and client gen
Browse files Browse the repository at this point in the history
  • Loading branch information
martinjrobins committed May 2, 2023
1 parent e7a5b6a commit dcf338f
Show file tree
Hide file tree
Showing 5 changed files with 3,454 additions and 3 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,26 @@ a file (say) called `test_models.py` use
`python manage.py test pkpdapp.tests.test_models`
- code coverage tests: can't be done locally
## Generating OpenAPI spec
The front-end communicates with the back-end using a REST API. The API can be
described using the OpenAPI specification. To generate the OpenAPI
specification, run the following command:
```bash
python manage.py generateschema --file schema.yml
```
## Generating RTX Query API class
The front-end uses the Redux Toolkit RTX Query tool to automatically generate a
client for the api based on the OpenAPI spec described above. To generate the
client, run the following command in the frontend directory:
```bash
npx @rtk-query/codegen-openapi openapi-config.json
```
# Running the cache
Install the cache using
Expand Down
1 change: 0 additions & 1 deletion pkpdapp/pkpdapp/models/likelihoods.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ class LogLikelihood(models.Model):
related_name='parents',
symmetrical=False,
through=LogLikelihoodParameter,
blank=True, null=True,
through_fields=('parent', 'child'),
)

Expand Down
3 changes: 3 additions & 0 deletions pkpdapp/pkpdapp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
# Set BASE_DIR to two directories up
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# setup automatic pk column for models
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
Expand Down
2 changes: 0 additions & 2 deletions pkpdapp/pkpdapp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,5 @@
path('api/logout/', api.logout_view, name='auth-logout'),
path('api/session/', api.SessionView.as_view(), name='auth-session'),
path('api/whoami/', api.WhoAmIView.as_view(), name='auth-whoami'),
path('auth/', include('djoser.urls')),
path('auth/', include('djoser.urls.authtoken')),
path('api-auth/', include('rest_framework.urls'))
]
Loading

0 comments on commit dcf338f

Please sign in to comment.