cwl_utils.inputs_schema_gen
===========================

.. py:module:: cwl_utils.inputs_schema_gen

.. autoapi-nested-parse::

   Generate JSON Schema from CWL inputs object.



Attributes
----------

.. autoapisummary::

   cwl_utils.inputs_schema_gen.defaultStreamHandler
   cwl_utils.inputs_schema_gen.PRIMITIVE_TYPES_MAPPING
   cwl_utils.inputs_schema_gen.InputType


Classes
-------

.. autoapisummary::

   cwl_utils.inputs_schema_gen.JSONSchemaProperty


Functions
---------

.. autoapisummary::

   cwl_utils.inputs_schema_gen.get_is_required_from_input_parameter
   cwl_utils.inputs_schema_gen.generate_json_schema_property_from_input_parameter
   cwl_utils.inputs_schema_gen.generate_definition_from_schema
   cwl_utils.inputs_schema_gen.cwl_to_jsonschema
   cwl_utils.inputs_schema_gen.get_property_dependencies
   cwl_utils.inputs_schema_gen.slim_definitions
   cwl_utils.inputs_schema_gen.arg_parser
   cwl_utils.inputs_schema_gen.parse_args
   cwl_utils.inputs_schema_gen.main
   cwl_utils.inputs_schema_gen.get_cwl_url
   cwl_utils.inputs_schema_gen.run


Module Contents
---------------

.. py:data:: defaultStreamHandler

.. py:data:: PRIMITIVE_TYPES_MAPPING

.. py:data:: InputType

.. py:class:: JSONSchemaProperty(name, type_, description = '', required = False)

   Generate a JSON schema property from a CWL input parameter.


   .. py:attribute:: name
      :type:  str


   .. py:attribute:: type_
      :type:  InputType | list[InputType] | str | Any


   .. py:attribute:: description
      :value: ''



   .. py:attribute:: required
      :value: False



   .. py:attribute:: type_dict


   .. py:method:: generate_type_dict()

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



   .. py:method:: 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



   .. py:method:: generate_type_dict_from_type_list(type_)

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



   .. py:method:: to_dict()

      Return as a dictionary.



.. py:function:: get_is_required_from_input_parameter(input_parameter)

   Given an input parameter, return if it is required.


.. py:function:: generate_json_schema_property_from_input_parameter(input_parameter)

   Given an input parameter, generate a JSON schema property.

   :param input_parameter:
   :return:


.. py:function:: generate_definition_from_schema(schema)

   Given a schema, generate a JSON schema definition.

   :param schema:
   :return:


.. py:function:: 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)



.. py:function:: get_property_dependencies(property_dict, input_json_schema, existing_property_dependencies = None)

   Recursively collect all dependencies for a property.


.. py:function:: 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.


.. py:function:: arg_parser()

   Build the argument parser.


.. py:function:: parse_args(args)

   Parse the command line arguments.


.. py:function:: main()

   Console entry point.


.. py:function:: 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.


.. py:function:: run(args)

   Run the main program.


