src/swagger2x.py
def swagger_required_items(json_data, input_path):
    """
    get the required properties list from the schema that is referenced by the path in post (or get)
    :param json_data: the swagger file as json struct
    :param input_path: the path to which the if should be queried
    :return: list of if values
    """
    prop_block = []
    schema = None
    for path, path_item in json_data["paths"].items():
        if input_path == path:
            try:
                schema_param = path_item["post"]["parameters"]
                for item in schema_param:
                    schema_found = item.get("schema")
                    if schema_found is not None:
                        schema = schema_found
            except:
                try:
                    schema = path_item["get"]["responses"]["200"]["schema"]
                except:
                    pass
            if schema is not None:
                schema_ref = schema["$ref"]
                def_data = json_data["definitions"]
                for def_name, def_item in def_data.items():
                    full_def_name = "#/definitions/" + def_name
                    if full_def_name in [schema_ref]:
                        prop_block = find_key_link(def_item, "required")
            else:
                print("swagger_required_items: schema not found:", input_path)
    return prop_block

    get the required properties list from the schema that is referenced by the path in post (or get)
    :param json_data: the swagger file as json struct
    :param input_path: the path to which the if should be queried
    :return: list of if values
    
get the required properties list from the schema that is referenced by the path in post (or get)
get the required properties list from the schema that is referenced by the path in post ( or get )
def swagger_required_items(json_data, input_path):
    prop_block = []
    schema = None
    for path, path_item in json_data["paths"].items():
        if input_path == path:
            try:
                schema_param = path_item["post"]["parameters"]
                for item in schema_param:
                    schema_found = item.get("schema")
                    if schema_found is not None:
                        schema = schema_found
            except:
                try:
                    schema = path_item["get"]["responses"]["200"]["schema"]
                except:
                    pass
            if schema is not None:
                schema_ref = schema["$ref"]
                def_data = json_data["definitions"]
                for def_name, def_item in def_data.items():
                    full_def_name = "#/definitions/" + def_name
                    if full_def_name in [schema_ref]:
                        prop_block = find_key_link(def_item, "required")
            else:
                print("swagger_required_items: schema not found:", input_path)
    return prop_block
def swagger_required_items ( json_data , input_path ) : prop_block = [ ] schema = None for path , path_item in json_data [ "paths" ] . items ( ) : if input_path == path : try : schema_param = path_item [ "post" ] [ "parameters" ] for item in schema_param : schema_found = item . get ( "schema" ) if schema_found is not None : schema = schema_found except : try : schema = path_item [ "get" ] [ "responses" ] [ "200" ] [ "schema" ] except : pass if schema is not None : schema_ref = schema [ "$ref" ] def_data = json_data [ "definitions" ] for def_name , def_item in def_data . items ( ) : full_def_name = "#/definitions/" + def_name if full_def_name in [ schema_ref ] : prop_block = find_key_link ( def_item , "required" ) else : print ( "swagger_required_items: schema not found:" , input_path ) return prop_block
get the required properties list from the schema that is referenced by the path in post (or get)
get the required properties list from the schema that is referenced by the path in post ( or get )
"""
    get the required properties list from the schema that is referenced by the path in post (or get)
    :param json_data: the swagger file as json struct
    :param input_path: the path to which the if should be queried
    :return: list of if values
    """
list of if values
list of if values
json_data
the swagger file as json struct
the swagger file as json struct
input_path
the path to which the if should be queried
the path to which the if should be queried