(section_option: dict)
return type_data
Builds the data structure with the type information (example, default value, nested types...)
Builds the data structure with the type information (example, default value, nested types...)
Builds the data structure with the type information ( example default value nested types ... )
def _build_type_data(section_option: dict) -> dict:
    """
    Builds the data structure with the type information (example, default value, nested types...)
    """
    type_data = None
    if 'value' in section_option:
        # Simple type like str, number
        type_data = section_option['value']
    # Some integrations (like `mysql`) have options that are grouped under a top-level option
    elif 'options' in section_option:
        # Object type
        nested_properties = []
        type_data = {'type': 'object', 'properties': nested_properties}
        for nested_option in section_option['options']:
            nested_type_data = nested_option['value']

            # Remove fields that aren't part of the OpenAPI specification
            for extra_field in set(nested_type_data) - ALLOWED_TYPE_FIELDS:
                nested_type_data.pop(extra_field, None)

            nested_properties.append({'name': nested_option['name'], **nested_type_data})
    return type_data
def _build_type_data ( section_option : dict ) -> dict : type_data = None if 'value' in section_option : # Simple type like str, number type_data = section_option [ 'value' ] # Some integrations (like `mysql`) have options that are grouped under a top-level option elif 'options' in section_option : # Object type nested_properties = [ ] type_data = { 'type' : 'object' , 'properties' : nested_properties } for nested_option in section_option [ 'options' ] : nested_type_data = nested_option [ 'value' ] # Remove fields that aren't part of the OpenAPI specification for extra_field in set ( nested_type_data ) - ALLOWED_TYPE_FIELDS : nested_type_data . pop ( extra_field , None ) nested_properties . append ( { 'name' : nested_option [ 'name' ] , * * nested_type_data } ) return type_data