Skip to content

Commit

Permalink
Merge pull request #24 from maykinmedia/drf-spectacular
Browse files Browse the repository at this point in the history
Remove drf yasg
  • Loading branch information
annashamray authored Dec 11, 2024
2 parents d415652 + 9daa877 commit 684b6b9
Show file tree
Hide file tree
Showing 70 changed files with 2,224 additions and 3,646 deletions.
2 changes: 2 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ current_version = 2.2.0
[bumpversion:file:package.json]

[bumpversion:file:vng_api_common/__init__.py]

[bumpversion:file:docs/conf.py]
15 changes: 12 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ jobs:
django: ['4.2']
services:
postgres:
image: postgres:14
image: postgis/postgis:14-3.2
env:
POSTGRES_HOST_AUTH_METHOD: trust

ports:
- 5432:5432

# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

name: Run the test suite (Python ${{ matrix.python }}, Django ${{ matrix.django }})

steps:
Expand All @@ -39,9 +41,16 @@ jobs:
with:
python-version: ${{ matrix.python }}

- name: Install dependencies
- name: Install pip dependencies
run: pip install tox tox-gh-actions

- name: Install system dependencies
run: |
sudo apt-get update \
&& sudo apt-get install -y --no-install-recommends \
libgdal-dev \
gdal-bin
- name: Run tests
run: tox
env:
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/code_quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,16 @@ jobs:
- uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install dependencies

- name: Install pip dependencies
run: pip install tox tox-gh-actions

- name: Install system dependencies
run: |
sudo apt-get update \
&& sudo apt-get install -y --no-install-recommends \
libgdal-dev \
gdal-bin
- run: tox
env:
TOXENV: ${{ matrix.toxenv }}
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
Change history
==============

2.3.0 (WIP)
------------

* [#29] Replaced drf-yasg with drf-spectacular
* [#29] Removed management commands to generate markdown files for scopes and notifications channels:
* ``generate_autorisaties``
* ``generate_notificaties``


2.2.0 (2024-12-10)
------------------

Expand Down
13 changes: 1 addition & 12 deletions bin/generate_notifications_api_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,4 @@ if [[ -z "$VIRTUAL_ENV" ]]; then
exit 1
fi

toplevel=$(git rev-parse --show-toplevel)
cd $toplevel

./manage.py generate_swagger \
--overwrite \
-f yaml \
notifications-webhook-2.0.yaml

echo "Converting Swagger to OpenAPI 3.0..."
npm run convert

MANAGE=manage.py ./bin/patch_content_types notifications-webhook.yaml
DJANGO_SETTINGS_MODULE=notifications_webhook.settings ./manage.py spectacular --file notifications-webhook.yaml --validate
30 changes: 2 additions & 28 deletions bin/generate_schema
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,5 @@ if [[ -z "$VIRTUAL_ENV" ]]; then
exit 1
fi

echo "Generating Swagger schema"
src/manage.py generate_swagger \
./src/swagger2.0.json \
--overwrite \
--format=json \
--mock-request \
--url https://example.com/api/v1

echo "Converting Swagger to OpenAPI 3.0..."
npm run convert
patch_content_types

echo "Generating unresolved OpenAPI 3.0 schema"
use_external_components

echo "Generating resources document"
src/manage.py generate_swagger \
./src/resources.md \
--overwrite \
--mock-request \
--url https://example.com/api/v1 \
--to-markdown-table

echo "Generating autorisaties.md"
src/manage.py generate_autorisaties --output-file ./src/autorisaties.md

echo "Generating notificaties.md"
src/manage.py generate_notificaties --output-file ./src/notificaties.md
echo "generate schema"
src/manage.py spectacular --file src/openapi.yaml --validate
15 changes: 0 additions & 15 deletions bin/patch_content_types

This file was deleted.

16 changes: 0 additions & 16 deletions bin/use_external_components

This file was deleted.

36 changes: 7 additions & 29 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,14 @@
#
import os
import sys
from pathlib import Path

import django
from django.conf import settings

sys.path.insert(0, os.path.abspath(".."))

from vng_api_common import __version__ # noqa isort:skip
from vng_api_common.conf import api as api_settings # noqa isort:skip

settings.configure(
INSTALLED_APPS=[
"django.contrib.sites",
"rest_framework",
"django_filters",
"vng_api_common",
"vng_api_common.notifications",
"drf_yasg",
"solo",
],
DATABASES={
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": "docs",
"USER": "docs",
"PASSWORD": "docs",
}
},
BASE_DIR=sys.path[0],
**{name: getattr(api_settings, name) for name in api_settings.__all__}
)

_root_dir = Path(__file__).parent.parent.resolve()
sys.path.insert(0, str(_root_dir))
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testapp.settings")

django.setup()

# -- Project information -----------------------------------------------------
Expand All @@ -51,7 +29,7 @@
author = "VNG-Realisatie, Maykin Media"

# The full version, including alpha/beta/rc tags
release = __version__
release = "1.13.2"


# -- General configuration ---------------------------------------------------
Expand Down
27 changes: 4 additions & 23 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Installation
Pre-requisites
--------------

* Python 3.6 or higher
* Python 3.10 or higher
* Setuptools 30.3.0 or higher
* Only the PostgreSQL database is supported

Expand All @@ -21,12 +21,6 @@ Install from PyPI with pip:
pip install vng-api-common
You will also need the NPM package ``swagger2openapi``:

.. code-block:: bash
npm install swagger2openapi
Configure the Django settings
-----------------------------

Expand All @@ -39,12 +33,13 @@ Configure the Django settings
'django.contrib.sites', # required if using the notifications
'django_filters',
'vng_api_common', # before drf_yasg to override the management command
'vng_api_common',
'vng_api_common.authorizations',
'vng_api_common.notifications', # optional
'vng_api_common.audittrails', # optional
'drf_yasg',
'drf_spectacular',
'rest_framework',
'rest_framework_gis',
'solo', # required for authorizations and notifications
...
]
Expand Down Expand Up @@ -80,18 +75,6 @@ Configure the Django settings

4. See ``vng_api_common/conf/api.py`` for a list of available settings.

Configure the Node tooling
--------------------------

In the ``package.json`` of your project, add the scripts entry for ``convert``:

.. code-block:: json
{
"scripts": {
"convert": "swagger2openapi src/swagger2.0.json -o src/openapi.yaml"
}
}

Usage
=====
Expand All @@ -107,9 +90,7 @@ To generate the API spec, run:
This will output:

* ``src/swagger2.0.json``: the OAS 2 specification
* ``src/openapi.yaml``: the OAS 3 specification
* ``src/resources.md``: a list of the exposed resources

See the reference implementations of `ZRC`_, `DRC`_, `BRC`_ en `ZTC`_ to see it
in action.
Expand Down
Loading

0 comments on commit 684b6b9

Please sign in to comment.