dredd icon indicating copy to clipboard operation
dredd copied to clipboard

Dredd error - body: At '/... ...' Missing required property:

Open AAUyy opened this issue 5 years ago • 1 comments

Hi, It is my first time to use GitHub to register an issue. I want to test the OpenAPI for a PUT method. The objective is to find the specific project in the database and modify some of the keys. Could you give me some hint(s) to fix the errors? Man y thanks!

The keys are that: "title" "desc" "complexity" "status" "tags" "url_ed" "url_et" "url_sk_hierarchy" "url_sk_stress" "url_lmo_downtime" "url_lmo_maintenance" "hierarchy_ed" "hierarchy_et" "hierarchy_sk" "stress_sk" "lmo_downtime" "lmo_maintenance"

My backend is as follows: @bp.route('/rams//inputs', methods=['PUT']) def update_specific_inputs(id): try: instance = RamsProject.query.filter_by(id=id).first() if instance is None: raise TypeError body = request.get_json() instance.update(**body) db.session.add(instance) db.session.commit() return make_response(jsonify({'message': 'DB is updated!'}), 200) except TypeError: return jsonify({'message': 'DB is not updated!'}), 400

The hooks.before is as follows: @hooks.before("/rams/{ramsId}/inputs > Modifies a specific rams project > 201") @if_not_skipped def put_project_specific_201(transaction): """ Update a specific RAMS project """ print(transaction) request_body = json.loads(transaction['request']['body']) request_body['complexity'] = 3 transaction['request']['body'] = json.dumps(request_body) save_inputs(transaction)

The errors I got: fail: PUT (201) /rams/1/inputs duration: 33ms fail: body: At '/title' Missing required property: title body: At '/desc' Missing required property: desc body: At '/complexity' Missing required property: complexity body: At '/status' Missing required property: status body: At '/tags' Missing required property: tags body: At '/url_ed' Missing required property: url_ed body: At '/url_et' Missing required property: url_et body: At '/url_sk_hierarchy' Missing required property: url_sk_hierarchy body: At '/url_sk_stress' Missing required property: url_sk_stress body: At '/url_lmo_downtime' Missing required property: url_lmo_downtime body: At '/url_lmo_maintenance' Missing required property: url_lmo_maintenance body: At '/hierarchy_ed' Missing required property: hierarchy_ed body: At '/hierarchy_et' Missing required property: hierarchy_et body: At '/hierarchy_sk' Missing required property: hierarchy_sk body: At '/stress_sk' Missing required property: stress_sk body: At '/lmo_downtime' Missing required property: lmo_downtime body: At '/lmo_maintenance' Missing required property: lmo_maintenance statusCode: Expected status code '201', but got '400'.

AAUyy avatar Jun 30 '20 09:06 AAUyy

Looks like a duplicate of #1430

idoqo avatar Jul 15 '20 14:07 idoqo