# cwl_utils.inputs_schema_gen

Generate JSON Schema from CWL inputs object.

## Attributes

`defaultStreamHandler` |
`PRIMITIVE_TYPES_MAPPING` |
`InputType` |

## Classes

`JSONSchemaProperty` | Generate a JSON schema property from a CWL input parameter.

## Functions

`get_is_required_from_input_parameter`(input_parameter) | Given an input parameter, return if it is required.
`generate_json_schema_property_from_input_parameter`(...) | Given an input parameter, generate a JSON schema property.
`generate_definition_from_schema`(schema) | Given a schema, generate a JSON schema definition.
`cwl_to_jsonschema`(cwl_obj) | cwl_obj: A CWL Object.
`get_property_dependencies`(property_dict, input_json_schema) | Recursively collect all dependencies for a property.
`slim_definitions`(input_json_schema) | Slim down the schema to only the definitions that are used by the properties.
`arg_parser`() | Build the argument parser.
`parse_args`(args) | Parse the command line arguments.
`main`() | Console entry point.
`get_cwl_url`(url) | Conform to uri format.
`run`(args) | Run the main program.

## Module Contents

cwl_utils.inputs_schema_gen.defaultStreamHandler

cwl_utils.inputs_schema_gen.PRIMITIVE_TYPES_MAPPING

cwl_utils.inputs_schema_gen.InputType

class cwl_utils.inputs_schema_gen.JSONSchemaProperty(name, type_, description='', required=False)

  Generate a JSON schema property from a CWL input parameter.

  Parameters:

    - name (str)

    - type_ (InputType | list[InputType] | str | Any)

    - description (str | None)

    - required (bool | None)

  name: str
  type_: InputType | list[InputType] | str | Any
  description = ''
  required = False
  type_dict
  generate_type_dict()

    Generate the type dict for a property from a CWL input parameter type.

    Return type:

      dict[str, Any]

  generate_type_dict_from_type(type_item)

    Generate the type dict for a property from a CWL input parameter type.

    We call this function for each type in the type_ list In the case there are multiple types, each dict is added to the oneOf list

    Parameters:

      type_item (Any)

    Return type:

      dict[str, Any]

  generate_type_dict_from_type_list(type_)

    Given a list of types, generate a JSON schema property dict wrapped in oneOf list.

    Parameters:

      type_ (list[InputType])

    Return type:

      dict[str, Any]

  to_dict()

    Return as a dictionary.

    Return type:

      dict[str, Any]

cwl_utils.inputs_schema_gen.get_is_required_from_input_parameter(input_parameter)

  Given an input parameter, return if it is required.

  Parameters:

    input_parameter (cwl_utils.parser.WorkflowInputParameter)

  Return type:

    bool

cwl_utils.inputs_schema_gen.generate_json_schema_property_from_input_parameter(input_parameter)

  Given an input parameter, generate a JSON schema property.

  Parameters:

    input_parameter (cwl_utils.parser.WorkflowInputParameter)

  Returns:

  Return type:

    JSONSchemaProperty

cwl_utils.inputs_schema_gen.generate_definition_from_schema(schema)

  Given a schema, generate a JSON schema definition.

  Parameters:

    schema (cwl_utils.parser.InputRecordSchema)

  Returns:

  Return type:

    dict[str, Any]

cwl_utils.inputs_schema_gen.cwl_to_jsonschema(cwl_obj)

  cwl_obj: A CWL Object.

  Returns:

    A JSONSchema object.

  Example:

    cwl_obj = load_document_by_uri(<CWL_URL>) jsonschema = cwl_to_jsonschema(cwl_inputs)

  Parameters:

    cwl_obj (cwl_utils.parser.Workflow | cwl_utils.parser.CommandLineTool)

  Return type:

    Any

cwl_utils.inputs_schema_gen.get_property_dependencies(property_dict, input_json_schema, existing_property_dependencies=None)

  Recursively collect all dependencies for a property.

  Parameters:

    - property_dict (dict[str, Any])

    - input_json_schema (dict[str, Any])

    - existing_property_dependencies (list[Any] | None)

  Return type:

    list[str]

cwl_utils.inputs_schema_gen.slim_definitions(input_json_schema)

  Slim down the schema to only the definitions that are used by the properties.

  Traverse the properties and return all definitions that are used. Remove all other definitions.

  Parameters:

    input_json_schema (dict[str, Any])

  Return type:

    dict[str, Any]

cwl_utils.inputs_schema_gen.arg_parser()

  Build the argument parser.

  Return type:

    argparse.ArgumentParser

cwl_utils.inputs_schema_gen.parse_args(args)

  Parse the command line arguments.

  Parameters:

    args (list[str])

  Return type:

    argparse.Namespace

cwl_utils.inputs_schema_gen.main()

  Console entry point.

  Return type:

    None

cwl_utils.inputs_schema_gen.get_cwl_url(url)

  Conform to uri format.

  If no scheme, then assert is a local file path and exists if scheme is file, then assert is a local file path and exists If scheme is not file, then assert is a valid Web URL Return either the url or the local path as a uri.

  Parameters:

    url (str)

  Return type:

    str

cwl_utils.inputs_schema_gen.run(args)

  Run the main program.

  Parameters:

    args (argparse.Namespace)

  Return type:

    int