diff --git a/.github/workflows/oas-check.yml b/.github/workflows/oas-check.yml index 0df85f2d..3c06d7a8 100644 --- a/.github/workflows/oas-check.yml +++ b/.github/workflows/oas-check.yml @@ -2,18 +2,14 @@ name: check-oas on: push: - paths: - - "src/objects/api/*/openapi.yaml" - - .github/workflows/oas-check.yml - branches: - - '**' workflow_dispatch: jobs: open-api-workflow-check-oas: - uses: maykinmedia/open-api-workflows/.github/workflows/oas-check.yml@v1 + uses: maykinmedia/open-api-workflows/.github/workflows/oas-check.yml@v5.0.0 with: schema-path: 'src/objects/api/v2/openapi.yaml' + schema-options: 'src/objects/api/v2/openapi.yaml' python-version: '3.11' django-settings-module: 'objects.conf.ci' apt-packages: 'libgdal-dev gdal-bin' diff --git a/bin/generate_schema.sh b/bin/generate_schema.sh index 61907011..7748d781 100755 --- a/bin/generate_schema.sh +++ b/bin/generate_schema.sh @@ -9,4 +9,4 @@ export SCHEMA_PATH=src/objects/api/v2/openapi.yaml OUTPUT_FILE=$1 -src/manage.py spectacular --file ${OUTPUT_FILE:-$SCHEMA_PATH} --validate +src/manage.py spectacular --file ${OUTPUT_FILE:-$SCHEMA_PATH} --validate --lang="en" diff --git a/requirements/base.txt b/requirements/base.txt index 6a3812f9..58ee7292 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -57,7 +57,7 @@ click-plugins==1.1.1 # via celery click-repl==0.3.0 # via celery -commonground-api-common==2.5.1 +commonground-api-common==2.5.2 # via open-api-framework coreapi==2.3.3 # via commonground-api-common diff --git a/requirements/ci.txt b/requirements/ci.txt index 376ac008..748ba2c8 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -115,7 +115,7 @@ click-repl==0.3.0 # celery codecov==2.1.13 # via -r requirements/test-tools.in -commonground-api-common==2.5.1 +commonground-api-common==2.5.2 # via # -c requirements/base.txt # -r requirements/base.txt diff --git a/requirements/dev.txt b/requirements/dev.txt index bf35084f..d7c75184 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -143,7 +143,7 @@ codecov==2.1.13 # via # -c requirements/ci.txt # -r requirements/ci.txt -commonground-api-common==2.5.1 +commonground-api-common==2.5.2 # via # -c requirements/ci.txt # -r requirements/ci.txt diff --git a/src/objects/api/v2/openapi.yaml b/src/objects/api/v2/openapi.yaml index 7fa40c26..a7f3efce 100644 --- a/src/objects/api/v2/openapi.yaml +++ b/src/objects/api/v2/openapi.yaml @@ -800,6 +800,8 @@ paths: components: schemas: GeoJSONGeometry: + title: GeoJSONGeometry + type: object oneOf: - $ref: '#/components/schemas/Point' - $ref: '#/components/schemas/MultiPoint' @@ -810,14 +812,6 @@ components: - $ref: '#/components/schemas/GeometryCollection' discriminator: propertyName: type - mapping: - Point: '#/components/schemas/Point' - MultiPoint: '#/components/schemas/MultiPoint' - LineString: '#/components/schemas/LineString' - MultiLineString: '#/components/schemas/MultiLineString' - Polygon: '#/components/schemas/Polygon' - MultiPolygon: '#/components/schemas/MultiPolygon' - GeometryCollection: '#/components/schemas/GeometryCollection' GeoWithin: type: object properties: @@ -833,7 +827,8 @@ components: url: https://tools.ietf.org/html/rfc7946#section-3.1 properties: type: - type: string + allOf: + - $ref: '#/components/schemas/TypeEnum' description: The geometry type GeometryCollection: type: object @@ -986,11 +981,11 @@ components: url: type: string format: uri + readOnly: true minLength: 1 maxLength: 1000 description: URL reference to this object. This is the unique identification and location of this object. - readOnly: true uuid: type: string format: uuid @@ -1143,11 +1138,11 @@ components: url: type: string format: uri + readOnly: true minLength: 1 maxLength: 1000 description: URL reference to this object. This is the unique identification and location of this object. - readOnly: true uuid: type: string format: uuid @@ -1228,6 +1223,18 @@ components: type: array items: $ref: '#/components/schemas/Point2D' + TypeEnum: + type: string + enum: + - Point + - MultiPoint + - LineString + - MultiLineString + - Polygon + - MultiPolygon + - Feature + - FeatureCollection + - GeometryCollection securitySchemes: tokenAuth: type: apiKey diff --git a/src/objects/utils/apps.py b/src/objects/utils/apps.py index b02dd150..5245b233 100644 --- a/src/objects/utils/apps.py +++ b/src/objects/utils/apps.py @@ -1,5 +1,19 @@ from django.apps import AppConfig +from drf_spectacular.extensions import OpenApiFilterExtension + + +def unregister_camelize_filter_extension(): + """ + CamelizeFilterExtension from vng_api_common is loaded automatically + and cannot be removed using SPECTACULAR_SETTINGS. + """ + OpenApiFilterExtension._registry = [ + ext + for ext in OpenApiFilterExtension._registry + if ext.__name__ != "CamelizeFilterExtension" + ] + class UtilsConfig(AppConfig): name = "objects.utils" @@ -7,3 +21,5 @@ class UtilsConfig(AppConfig): def ready(self): from . import checks # noqa from . import oas_extensions # noqa + + unregister_camelize_filter_extension()