coding-kitties / flask-swagger-generator

A simple to use flask swagger generator working with the Flask web framework.
MIT License
6 stars 6 forks source link

Issue#28 : New Feature - Support for nested schema for json request/r… #29

Closed fizaashraf37 closed 1 year ago

fizaashraf37 commented 1 year ago

Issue#28

User can now specify nested json schemas in request and response. The nested objects e.g. list or dict will be added as example to keep things simple. As parsing each nested object will make schema very complex with increased nesting levels. With this simple approach user can add any level of nesting to json and yaml generated will be simple.

Example

request_schema = {
    "id": 10, 
    "name": "level01", 
    "nested_dict": {
        "id":1, 
        "name":"level02",
        "values" : {
            "id": 3,
            "name": "level03"
        }
    }, 
    "nested_list": [
        {"a":1},
        {"b":2}
    ]
}

@generator.request_body(request_schema)
@blueprint.route('/objects/<int:object_id>', methods=['PUT'])
def update_object(object_id):
    return jsonify({'id': 1, 'name': 'test_object_name'}), 201