Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
openapi-schema.yml text eol=lf merge=binary
34 changes: 34 additions & 0 deletions .github/workflows/openapi-spec-freshness.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: OpenAPI spec freshness

on:
pull_request:

jobs:
verify-spec-fresh:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
prune-cache: false

- name: Install Python
run: uv python install 3.11

- name: Install dependencies
run: uv sync

- name: Verify openapi-schema.yml matches code
run: |
uv run python manage.py spectacular --file openapi-schema.yml
if ! git diff --exit-code -- openapi-schema.yml; then
echo "::error::openapi-schema.yml is out of date with the code on this branch."
echo "::error::Regenerate locally with:"
echo "::error:: uv run python manage.py spectacular --file openapi-schema.yml"
echo "::error::Then commit the updated file and push."
exit 1
fi
echo "openapi-schema.yml is up to date."
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ server/whoosh_index/
api/tests/approved_files/*.recieved.*

# Generated files
openapi-schema.yml

server/vector_index.pkl

# Temporary files for magic items update
Expand Down
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ All v1 content is still available for hosting your own version, if required
* [Build](#build)
+ [Search Indexing](#search-indexing)
* [Run](#run)
* [Building the OAS file](#building-the-oas-file)
* [OpenAPI Spec](#openapi-spec)
- [Contributing](#contributing)
* [Editing existing sources](#editing-existing-sources)
* [Adding a new source](#adding-a-new-source)
Expand Down Expand Up @@ -118,13 +118,22 @@ gunicorn -b :8888 server.wsgi:application

You can use our Dockerfile as inspiration, but it likely will not work without significant edits to your operating environment. We have customized our production environment to use it.

## Building the OAS file
## OpenAPI Spec

`openapi-schema.yml` (at the repo root) is the canonical API contract for `/v2/`,
generated from the serializers/views by drf-spectacular. It is committed to the
repo so consumers and reviewers can read and diff the contract directly.

CI verifies it stays in sync with the code on every PR into `staging-with-spec`.
If you change a serializer, view, model, or schema-affecting setting, regenerate:

After completing a build, you can generate an OAS file to be used by another application.
```bash
uv run python manage.py spectacular --color --file openapi-schema.yml
uv run python manage.py spectacular --file openapi-schema.yml
```

Then commit the updated file. Do **not** hand-edit `openapi-schema.yml` — it is
a build artifact.

# Contributing
See [contribution guide](.github/CONTRIBUTING.md).
# Tests
Expand Down
Loading
Loading