From 1e74635ea114cfec4d0525f901353a9f02d61de5 Mon Sep 17 00:00:00 2001 From: SonnyBA Date: Wed, 17 Jul 2024 15:57:49 +0200 Subject: [PATCH] [#17] add CI jobs to detect uncommitted OAS changes (#121) * [#17] add CI jobs to detect uncommitted OAS changes --- .github/workflows/ci.yml | 2 +- .github/workflows/code-quality.yml | 42 +++++++++++ bin/generate_schema.sh | 4 +- src/objecttypes/api/v1/openapi.yaml | 103 ++++++++++++++++++++------- src/objecttypes/api/v2/openapi.yaml | 105 ++++++++++++++++++++-------- 5 files changed, 199 insertions(+), 57 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a956dc2..1eeb4e56 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,7 @@ jobs: gdal-bin - name: Install dependencies - run: pip install -r requirements/ci.txt codecov + run: pip install -r requirements/ci.txt - name: Build frontend run: | npm ci diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index d39dd69b..af75f82b 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -33,3 +33,45 @@ jobs: - name: Run black run: | black --check src + + oas-up-to-date: + name: Check for unexepected OAS changes + runs-on: ubuntu-latest + strategy: + matrix: + version: ['v1', 'v2'] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - uses: actions/setup-node@v4 + with: + node-version: '18' + + - name: Install system packages + run: | + sudo apt-get update \ + && sudo apt-get install -y --no-install-recommends \ + libgdal-dev \ + gdal-bin + + - name: Install dependencies + run: pip install -r requirements/ci.txt + + - name: Generate OAS files + run: ./bin/generate_schema.sh ${{ matrix.version }} openapi-${{ matrix.version }}.yaml + env: + DJANGO_SETTINGS_MODULE: objecttypes.conf.ci + + - name: Check for OAS changes + run: | + diff openapi-${{ matrix.version }}.yaml src/objecttypes/api/${{ matrix.version }}/openapi.yaml + - name: Write failure markdown + if: ${{ failure() }} + run: | + echo 'Run the following command locally and commit the changes' >> $GITHUB_STEP_SUMMARY + echo '' >> $GITHUB_STEP_SUMMARY + echo '```bash' >> $GITHUB_STEP_SUMMARY + echo './bin/generate_schema.sh ${{ matrix.version }}' >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY diff --git a/bin/generate_schema.sh b/bin/generate_schema.sh index 02bc8265..fcd3f592 100755 --- a/bin/generate_schema.sh +++ b/bin/generate_schema.sh @@ -16,4 +16,6 @@ fi export SCHEMA_PATH=src/objecttypes/api/$1/openapi.yaml -src/manage.py spectacular --file $SCHEMA_PATH --validate --api-version $1 +OUTPUT_FILE=$2 + +src/manage.py spectacular --file ${OUTPUT_FILE:-$SCHEMA_PATH} --validate --api-version $1 diff --git a/src/objecttypes/api/v1/openapi.yaml b/src/objecttypes/api/v1/openapi.yaml index 28bbcccf..b3787fa6 100644 --- a/src/objecttypes/api/v1/openapi.yaml +++ b/src/objecttypes/api/v1/openapi.yaml @@ -40,7 +40,6 @@ paths: /objecttypes: get: operationId: objecttype_list - description: '' parameters: - in: query name: dataClassification @@ -51,7 +50,13 @@ paths: - intern - open - strictly_confidential - description: Confidential level of the object type + description: |- + Confidential level of the object type + + * `open` - Open + * `intern` - Intern + * `confidential` - Confidential + * `strictly_confidential` - Strictly confidential tags: - Objecttypes security: @@ -67,7 +72,6 @@ paths: description: OK post: operationId: objecttype_create - description: '' parameters: - in: header name: Content-Type @@ -97,7 +101,6 @@ paths: /objecttypes/{objecttype_uuid}/versions: get: operationId: objectversion_list - description: '' parameters: - in: path name: objecttype_uuid @@ -121,7 +124,6 @@ paths: description: OK post: operationId: objectversion_create - description: '' parameters: - in: header name: Content-Type @@ -157,7 +159,6 @@ paths: /objecttypes/{objecttype_uuid}/versions/{version}: get: operationId: objectversion_read - description: '' parameters: - in: path name: objecttype_uuid @@ -171,6 +172,7 @@ paths: schema: type: integer maximum: 32767 + minimum: 0 description: Integer version of the OBJECTTYPE required: true tags: @@ -186,7 +188,6 @@ paths: description: OK put: operationId: objectversion_update - description: '' parameters: - in: header name: Content-Type @@ -208,6 +209,7 @@ paths: schema: type: integer maximum: 32767 + minimum: 0 description: Integer version of the OBJECTTYPE required: true tags: @@ -228,7 +230,6 @@ paths: description: OK patch: operationId: objectversion_partial_update - description: '' parameters: - in: header name: Content-Type @@ -250,6 +251,7 @@ paths: schema: type: integer maximum: 32767 + minimum: 0 description: Integer version of the OBJECTTYPE required: true tags: @@ -270,7 +272,6 @@ paths: description: OK delete: operationId: objectversion_delete - description: '' parameters: - in: path name: objecttype_uuid @@ -284,6 +285,7 @@ paths: schema: type: integer maximum: 32767 + minimum: 0 description: Integer version of the OBJECTTYPE required: true tags: @@ -296,7 +298,6 @@ paths: /objecttypes/{uuid}: get: operationId: objecttype_read - description: '' parameters: - in: path name: uuid @@ -318,7 +319,6 @@ paths: description: OK put: operationId: objecttype_update - description: '' parameters: - in: header name: Content-Type @@ -354,7 +354,6 @@ paths: description: OK patch: operationId: objecttype_partial_update - description: '' parameters: - in: header name: Content-Type @@ -389,7 +388,6 @@ paths: description: OK delete: operationId: objecttype_delete - description: '' parameters: - in: path name: uuid @@ -414,6 +412,11 @@ components: - confidential - strictly_confidential type: string + description: |- + * `open` - Open + * `intern` - Intern + * `confidential` - Confidential + * `strictly_confidential` - Strictly confidential ObjectType: type: object properties: @@ -444,7 +447,13 @@ components: dataClassification: allOf: - $ref: '#/components/schemas/DataClassificationEnum' - description: Confidential level of the object type + description: |- + Confidential level of the object type + + * `open` - Open + * `intern` - Intern + * `confidential` - Confidential + * `strictly_confidential` - Strictly confidential maintainerOrganization: type: string description: Organization which is responsible for the object type @@ -470,7 +479,16 @@ components: updateFrequency: allOf: - $ref: '#/components/schemas/UpdateFrequencyEnum' - description: Indicates how often the object type is updated + description: |- + Indicates how often the object type is updated + + * `real_time` - Real-time + * `hourly` - Hourly + * `daily` - Daily + * `weekly` - Weekly + * `monthly` - Monthly + * `yearly` - Yearly + * `unknown` - Unknown providerOrganization: type: string description: Organization which is responsible for publication of the object @@ -482,8 +500,6 @@ components: description: Link to the documentation for the object type maxLength: 200 labels: - type: object - additionalProperties: {} description: Key-value pairs of keywords related for the object type createdAt: type: string @@ -537,10 +553,13 @@ components: status: allOf: - $ref: '#/components/schemas/StatusEnum' - description: Status of the object type version + description: |- + Status of the object type version + + * `published` - Published + * `draft` - Draft + * `deprecated` - Deprecated jsonSchema: - type: object - additionalProperties: {} title: JSON schema description: JSON schema for Object validation createdAt: @@ -557,6 +576,7 @@ components: type: string format: date readOnly: true + nullable: true title: Published_at description: Date when the version was published PatchedObjectType: @@ -589,7 +609,13 @@ components: dataClassification: allOf: - $ref: '#/components/schemas/DataClassificationEnum' - description: Confidential level of the object type + description: |- + Confidential level of the object type + + * `open` - Open + * `intern` - Intern + * `confidential` - Confidential + * `strictly_confidential` - Strictly confidential maintainerOrganization: type: string description: Organization which is responsible for the object type @@ -615,7 +641,16 @@ components: updateFrequency: allOf: - $ref: '#/components/schemas/UpdateFrequencyEnum' - description: Indicates how often the object type is updated + description: |- + Indicates how often the object type is updated + + * `real_time` - Real-time + * `hourly` - Hourly + * `daily` - Daily + * `weekly` - Weekly + * `monthly` - Monthly + * `yearly` - Yearly + * `unknown` - Unknown providerOrganization: type: string description: Organization which is responsible for publication of the object @@ -627,8 +662,6 @@ components: description: Link to the documentation for the object type maxLength: 200 labels: - type: object - additionalProperties: {} description: Key-value pairs of keywords related for the object type createdAt: type: string @@ -679,10 +712,13 @@ components: status: allOf: - $ref: '#/components/schemas/StatusEnum' - description: Status of the object type version + description: |- + Status of the object type version + + * `published` - Published + * `draft` - Draft + * `deprecated` - Deprecated jsonSchema: - type: object - additionalProperties: {} title: JSON schema description: JSON schema for Object validation createdAt: @@ -699,6 +735,7 @@ components: type: string format: date readOnly: true + nullable: true title: Published_at description: Date when the version was published StatusEnum: @@ -707,6 +744,10 @@ components: - draft - deprecated type: string + description: |- + * `published` - Published + * `draft` - Draft + * `deprecated` - Deprecated UpdateFrequencyEnum: enum: - real_time @@ -717,6 +758,14 @@ components: - yearly - unknown type: string + description: |- + * `real_time` - Real-time + * `hourly` - Hourly + * `daily` - Daily + * `weekly` - Weekly + * `monthly` - Monthly + * `yearly` - Yearly + * `unknown` - Unknown securitySchemes: tokenAuth: type: apiKey diff --git a/src/objecttypes/api/v2/openapi.yaml b/src/objecttypes/api/v2/openapi.yaml index 622a58b3..c7e4aa42 100644 --- a/src/objecttypes/api/v2/openapi.yaml +++ b/src/objecttypes/api/v2/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.3 info: title: Objecttypes API - version: 2.1.2 (v2) + version: 2.2.0 (v2) description: |+ An API to manage Object types. @@ -40,7 +40,6 @@ paths: /objecttypes: get: operationId: objecttype_list - description: '' parameters: - in: query name: dataClassification @@ -51,7 +50,13 @@ paths: - intern - open - strictly_confidential - description: Confidential level of the object type + description: |- + Confidential level of the object type + + * `open` - Open + * `intern` - Intern + * `confidential` - Confidential + * `strictly_confidential` - Strictly confidential - name: page required: false in: query @@ -77,7 +82,6 @@ paths: description: OK post: operationId: objecttype_create - description: '' parameters: - in: header name: Content-Type @@ -107,7 +111,6 @@ paths: /objecttypes/{objecttype_uuid}/versions: get: operationId: objectversion_list - description: '' parameters: - in: path name: objecttype_uuid @@ -141,7 +144,6 @@ paths: description: OK post: operationId: objectversion_create - description: '' parameters: - in: header name: Content-Type @@ -177,7 +179,6 @@ paths: /objecttypes/{objecttype_uuid}/versions/{version}: get: operationId: objectversion_read - description: '' parameters: - in: path name: objecttype_uuid @@ -191,6 +192,7 @@ paths: schema: type: integer maximum: 32767 + minimum: 0 description: Integer version of the OBJECTTYPE required: true tags: @@ -206,7 +208,6 @@ paths: description: OK put: operationId: objectversion_update - description: '' parameters: - in: header name: Content-Type @@ -228,6 +229,7 @@ paths: schema: type: integer maximum: 32767 + minimum: 0 description: Integer version of the OBJECTTYPE required: true tags: @@ -248,7 +250,6 @@ paths: description: OK patch: operationId: objectversion_partial_update - description: '' parameters: - in: header name: Content-Type @@ -270,6 +271,7 @@ paths: schema: type: integer maximum: 32767 + minimum: 0 description: Integer version of the OBJECTTYPE required: true tags: @@ -290,7 +292,6 @@ paths: description: OK delete: operationId: objectversion_delete - description: '' parameters: - in: path name: objecttype_uuid @@ -304,6 +305,7 @@ paths: schema: type: integer maximum: 32767 + minimum: 0 description: Integer version of the OBJECTTYPE required: true tags: @@ -316,7 +318,6 @@ paths: /objecttypes/{uuid}: get: operationId: objecttype_read - description: '' parameters: - in: path name: uuid @@ -338,7 +339,6 @@ paths: description: OK put: operationId: objecttype_update - description: '' parameters: - in: header name: Content-Type @@ -374,7 +374,6 @@ paths: description: OK patch: operationId: objecttype_partial_update - description: '' parameters: - in: header name: Content-Type @@ -409,7 +408,6 @@ paths: description: OK delete: operationId: objecttype_delete - description: '' parameters: - in: path name: uuid @@ -434,6 +432,11 @@ components: - confidential - strictly_confidential type: string + description: |- + * `open` - Open + * `intern` - Intern + * `confidential` - Confidential + * `strictly_confidential` - Strictly confidential ObjectType: type: object properties: @@ -464,7 +467,13 @@ components: dataClassification: allOf: - $ref: '#/components/schemas/DataClassificationEnum' - description: Confidential level of the object type + description: |- + Confidential level of the object type + + * `open` - Open + * `intern` - Intern + * `confidential` - Confidential + * `strictly_confidential` - Strictly confidential maintainerOrganization: type: string description: Organization which is responsible for the object type @@ -490,7 +499,16 @@ components: updateFrequency: allOf: - $ref: '#/components/schemas/UpdateFrequencyEnum' - description: Indicates how often the object type is updated + description: |- + Indicates how often the object type is updated + + * `real_time` - Real-time + * `hourly` - Hourly + * `daily` - Daily + * `weekly` - Weekly + * `monthly` - Monthly + * `yearly` - Yearly + * `unknown` - Unknown providerOrganization: type: string description: Organization which is responsible for publication of the object @@ -502,8 +520,6 @@ components: description: Link to the documentation for the object type maxLength: 200 labels: - type: object - additionalProperties: {} description: Key-value pairs of keywords related for the object type createdAt: type: string @@ -557,10 +573,13 @@ components: status: allOf: - $ref: '#/components/schemas/StatusEnum' - description: Status of the object type version + description: |- + Status of the object type version + + * `published` - Published + * `draft` - Draft + * `deprecated` - Deprecated jsonSchema: - type: object - additionalProperties: {} title: JSON schema description: JSON schema for Object validation createdAt: @@ -577,6 +596,7 @@ components: type: string format: date readOnly: true + nullable: true title: Published_at description: Date when the version was published PaginatedObjectTypeList: @@ -649,7 +669,13 @@ components: dataClassification: allOf: - $ref: '#/components/schemas/DataClassificationEnum' - description: Confidential level of the object type + description: |- + Confidential level of the object type + + * `open` - Open + * `intern` - Intern + * `confidential` - Confidential + * `strictly_confidential` - Strictly confidential maintainerOrganization: type: string description: Organization which is responsible for the object type @@ -675,7 +701,16 @@ components: updateFrequency: allOf: - $ref: '#/components/schemas/UpdateFrequencyEnum' - description: Indicates how often the object type is updated + description: |- + Indicates how often the object type is updated + + * `real_time` - Real-time + * `hourly` - Hourly + * `daily` - Daily + * `weekly` - Weekly + * `monthly` - Monthly + * `yearly` - Yearly + * `unknown` - Unknown providerOrganization: type: string description: Organization which is responsible for publication of the object @@ -687,8 +722,6 @@ components: description: Link to the documentation for the object type maxLength: 200 labels: - type: object - additionalProperties: {} description: Key-value pairs of keywords related for the object type createdAt: type: string @@ -739,10 +772,13 @@ components: status: allOf: - $ref: '#/components/schemas/StatusEnum' - description: Status of the object type version + description: |- + Status of the object type version + + * `published` - Published + * `draft` - Draft + * `deprecated` - Deprecated jsonSchema: - type: object - additionalProperties: {} title: JSON schema description: JSON schema for Object validation createdAt: @@ -759,6 +795,7 @@ components: type: string format: date readOnly: true + nullable: true title: Published_at description: Date when the version was published StatusEnum: @@ -767,6 +804,10 @@ components: - draft - deprecated type: string + description: |- + * `published` - Published + * `draft` - Draft + * `deprecated` - Deprecated UpdateFrequencyEnum: enum: - real_time @@ -777,6 +818,14 @@ components: - yearly - unknown type: string + description: |- + * `real_time` - Real-time + * `hourly` - Hourly + * `daily` - Daily + * `weekly` - Weekly + * `monthly` - Monthly + * `yearly` - Yearly + * `unknown` - Unknown securitySchemes: tokenAuth: type: apiKey