Skip to content

Commit

Permalink
Merge pull request #545 from maykinmedia/issue/fix-oas-check
Browse files Browse the repository at this point in the history
👷 [maykinmedia/open-api-framework#115] Always run OAS check
  • Loading branch information
stevenbal authored Mar 7, 2025
2 parents 3261425 + 90eb4b5 commit 9ae7d61
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 21 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/oas-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
2 changes: 1 addition & 1 deletion bin/generate_schema.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 18 additions & 11 deletions src/objects/api/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,8 @@ paths:
components:
schemas:
GeoJSONGeometry:
title: GeoJSONGeometry
type: object
oneOf:
- $ref: '#/components/schemas/Point'
- $ref: '#/components/schemas/MultiPoint'
Expand All @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions src/objects/utils/apps.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
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"

def ready(self):
from . import checks # noqa
from . import oas_extensions # noqa

unregister_camelize_filter_extension()

0 comments on commit 9ae7d61

Please sign in to comment.