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()