From 2cbfe5781de4916f4f38acc6dee668157fd6f881 Mon Sep 17 00:00:00 2001 From: yohan <783b8c87@scimetis.net> Date: Thu, 6 Jun 2024 22:45:58 +0200 Subject: [PATCH] Put back api.model because reqparse documentation is bad. --- thermostat.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/thermostat.py b/thermostat.py index 0a4c5af..cd036b1 100644 --- a/thermostat.py +++ b/thermostat.py @@ -175,14 +175,18 @@ cursor.execute("CREATE TABLE IF NOT EXISTS set_mode (name TEXT PRIMARY KEY DEFAU Set_mode_parser = api.parser() Set_mode_parser.add_argument( - "value", type=str, choices=targets+modes, required=True, help="value", location="json" + "value", type=str, choices=targets+modes, required=True, help="Thermostat mode", location="json" ) +Set_mode_resource_fields = { + 'value': fields.String(required=True, description='Thermostat mode', enum=targets+modes), +} +Set_mode_model = api.model('Set_mode_Model', Set_mode_resource_fields) + @ns_thermostat.route('/set_mode') class Set_mode_thermostat(Resource): @auth_required - @api.doc(parser=Set_mode_parser) - @api.expect(Set_mode_parser, validate=True) + @api.expect(Set_mode_model, validate=True) def post(self): global new_forced_mode try: @@ -205,10 +209,15 @@ Set_verbosity_parser.add_argument( "value", type=str, choices=["DEBUG", "INFO", "WARNING"], required=True, help="Verbosity", location="json" ) +Set_verbosity_resource_fields = { + 'value': fields.String(required=True, description='Verbosity', enum=["DEBUG", "INFO", "WARNING"]) +} +Set_verbosity_model = api.model('Set_verbosity_Model', Set_verbosity_resource_fields) + @ns_thermostat.route('/set_verbosity') class Set_verbosity_thermostat(Resource): @auth_required - @api.expect(Set_verbosity_parser, validate=True) + @api.expect(Set_verbosity_model, validate=True) def put(self): try: args = Set_verbosity_parser.parse_args()