From 587bc01f63c63c5231a5ae2d3768572c6d9174a9 Mon Sep 17 00:00:00 2001 From: "Mat.Busby" Date: Thu, 14 Nov 2024 11:57:42 -0700 Subject: [PATCH] update mine_report_permit_requirement response model to not break swagger --- .../resources/mine_report_permit_requirement.py | 1 + services/core-api/app/api/mines/response_models.py | 7 +++---- services/core-api/app/api/utils/helpers.py | 11 +---------- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/services/core-api/app/api/mines/reports/resources/mine_report_permit_requirement.py b/services/core-api/app/api/mines/reports/resources/mine_report_permit_requirement.py index a81d6fd733..323db4b4cd 100644 --- a/services/core-api/app/api/mines/reports/resources/mine_report_permit_requirement.py +++ b/services/core-api/app/api/mines/reports/resources/mine_report_permit_requirement.py @@ -28,6 +28,7 @@ class MineReportPermitRequirementResource(Resource, UserMixin): parser.add_argument('permit_condition_id', type=int, location='json') parser.add_argument('permit_amendment_id', type=int, location='json') + @api.expect(parser) @api.doc(description='creates a new mine report permit requirement') @api.marshal_with(MINE_REPORT_PERMIT_REQUIREMENT, code=201) @requires_any_of([EDIT_REPORT]) diff --git a/services/core-api/app/api/mines/response_models.py b/services/core-api/app/api/mines/response_models.py index 1326b048f7..4b91c68aaf 100644 --- a/services/core-api/app/api/mines/response_models.py +++ b/services/core-api/app/api/mines/response_models.py @@ -2,10 +2,9 @@ from app.api.compliance.response_models import COMPLIANCE_ARTICLE_MODEL from app.api.dams.dto import DAM_MODEL -from app.api.mines.reports.models.mine_report_permit_requirement import CimOrCpo +from app.api.mines.reports.models.mine_report_permit_requirement import CimOrCpo, OfficeDestination from app.api.parties.party_appt.models.mine_party_appt import MinePartyAppointmentStatus, MinePartyAcknowledgedStatus from app.api.parties.response_models import PARTY -from app.api.utils.helpers import EnumListField from app.extensions import api from app.api.utils.feature_flag import is_feature_enabled, Feature @@ -251,8 +250,8 @@ def format(self, value): 'mine_report_permit_requirement_id': fields.Integer, 'due_date_period_months': fields.Integer, 'initial_due_date': fields.Date, - 'cim_or_cpo': fields.String(enum=CimOrCpo, attribute='cim_or_cpo.name'), - 'ministry_recipient': EnumListField(), + 'cim_or_cpo': fields.String(enum=[e.value for e in CimOrCpo], attribute='cim_or_cpo.name'), + 'ministry_recipient': fields.List(fields.String(enum=[e.value for e in OfficeDestination])), 'permit_condition_id': fields.Integer } ) diff --git a/services/core-api/app/api/utils/helpers.py b/services/core-api/app/api/utils/helpers.py index b8f40d178f..7b8a21b8d4 100644 --- a/services/core-api/app/api/utils/helpers.py +++ b/services/core-api/app/api/utils/helpers.py @@ -100,13 +100,4 @@ def get_current_core_or_ms_env_url(app): return getattr(Config, core_config_property) elif app == 'ms': ms_config_property = f'MINESPACE_{(Config.ENVIRONMENT_NAME).upper()}_URL' - return getattr(Config, ms_config_property) - -class EnumListField(Raw): - def format(self, value): - if value is None: - return None - try: - return [enum.value for enum in value] - except AttributeError: - raise ValidationError("Invalid enum value") \ No newline at end of file + return getattr(Config, ms_config_property) \ No newline at end of file