Skip to content

Commit

Permalink
Merge pull request #265 from CanDIG/sonchau/static_schema
Browse files Browse the repository at this point in the history
add schema to static folder
  • Loading branch information
daisieh authored Sep 19, 2024
2 parents 967ccaa + 71bd334 commit eaff22b
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 6,925 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/update-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,30 @@ jobs:
export DJANGO_SETTINGS_MODULE=config.settings.base
echo "CACHE_DURATION = 0" >> config/settings/base.py
echo "AGGREGATE_COUNT_THRESHOLD = 5" >> config/settings/base.py
python manage.py export_openapi_schema --api chord_metadata_service.mohpackets.apis.core.api | python -m json.tool > chord_metadata_service/mohpackets/docs/schema.json
python manage.py export_openapi_schema --api chord_metadata_service.mohpackets.apis.core.api | python -m json.tool > chord_metadata_service/mohpackets/docs/schemas/schema.json
- name: Install widdershins
run: npm install -g widdershins

- name: Convert schema to OpenAPI documentation
run: |
npx widdershins ./chord_metadata_service/mohpackets/docs/schema.json -o ./chord_metadata_service/mohpackets/docs/schema.md -u ./chord_metadata_service/mohpackets/docs/widdershins/templates/openapi3 -c true --omitHeader true
npx widdershins ./chord_metadata_service/mohpackets/docs/schemas/schema.json -o ./chord_metadata_service/mohpackets/docs/schemas/schema.md -u ./chord_metadata_service/mohpackets/docs/widdershins/templates/openapi3 -c true --omitHeader true
- name: Install PyYAML
run: pip install PyYAML

- name: Convert schema.json to schema.yml
run: python -c 'import json, yaml; json.load(open("chord_metadata_service/mohpackets/docs/schema.json")); print(yaml.dump(json.load(open("chord_metadata_service/mohpackets/docs/schema.json"))))' > chord_metadata_service/mohpackets/docs/schema.yml
run: python -c 'import json, yaml; json.load(open("chord_metadata_service/mohpackets/docs/schemas/schema.json")); print(yaml.dump(json.load(open("chord_metadata_service/mohpackets/docs/schemas/schema.json"))))' > chord_metadata_service/mohpackets/docs/schemas/schema.yml

- name: Update schemas
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Update schemas
file_pattern: "chord_metadata_service/mohpackets/docs/schema.json chord_metadata_service/mohpackets/docs/schema.md chord_metadata_service/mohpackets/docs/schema.yml"
file_pattern: "chord_metadata_service/mohpackets/docs/schemas/schema.json chord_metadata_service/mohpackets/docs/schemas/schema.md chord_metadata_service/mohpackets/docs/schemas/schema.yml"

- name: Get SHA commit of schema.json
id: get-sha
run: echo "SHA=$(git log -1 --format=%H chord_metadata_service/mohpackets/docs/schema.json)" >> $GITHUB_ENV
run: echo "SHA=$(git log -1 --format=%H chord_metadata_service/mohpackets/docs/schemas/schema.json)" >> $GITHUB_ENV

- name: Write SHA to schema_version.txt
run: echo ${{ env.SHA }} > chord_metadata_service/mohpackets/docs/schema_version.txt
Expand Down
9 changes: 3 additions & 6 deletions chord_metadata_service/mohpackets/docs/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,18 @@ This folder contains the schema and documentation for **MoH models**

## Katsu API Documentation

To view the API documentation, simply open [schema.md](schema.md) or [Redoc](https://redocly.github.io/redoc/?url=https://raw.githubusercontent.com/CanDIG/katsu/feature/manual_schema/chord_metadata_service/mohpackets/docs/schema_manual.yml).

> [!IMPORTANT]
> Katsu is currently being transitioned to MoH clinical data model v3.0.0. There is a manually created v3.0.0 of the OpenAPI schema at [schema_v3.yml](schema_v3.yml) that can be used as a reference in the interim period. This file will be replaced by the automatically generated schema documentaion files once katsu is fully transitioned to model v3.0.0.
To view the API documentation, simply open [schemas/schema.md](schema.md) or [Redoc](https://redocly.github.io/redoc/?url=https://raw.githubusercontent.com/CanDIG/katsu/feature/manual_schema/chord_metadata_service/mohpackets/docs/schemas/schema.json).

To generate the `schema.json` file, run the following command:

```bash
python manage.py export_openapi_schema --api chord_metadata_service.mohpackets.apis.core.api | python -m json.tool > chord_metadata_service/mohpackets/docs/schema.json
python manage.py export_openapi_schema --api chord_metadata_service.mohpackets.apis.core.api | python -m json.tool > chord_metadata_service/mohpackets/docs/schemas/schema.json
```

To generate the `schema.md` file, install [widdershins](https://github.com/Mermade/widdershins) and then run the following command:

```bash
widdershins ./chord_metadata_service/mohpackets/docs/schema.json -o ./chord_metadata_service/mohpackets/docs/schema.md -u ./chord_metadata_service/mohpackets/docs/widdershins/templates/openapi3 -c true --omitHeader true
widdershins ./chord_metadata_service/mohpackets/docs/schemas/schema.json -o ./chord_metadata_service/mohpackets/docs/schemas/schema.md -u ./chord_metadata_service/mohpackets/docs/widdershins/templates/openapi3 -c true --omitHeader true
```

This will create the schema.md file with the updated documentation.
Expand Down
Loading

0 comments on commit eaff22b

Please sign in to comment.