'Return the schema of the specified type.
:param cnxt: RPC context.
:param type_name: Name of the resource type to obtain the schema of.
:param with_description: Return result with description or not.'

def resource_schema(self, cnxt, type_name, with_description=False):

    self.resource_enforcer.enforce(cnxt, type_name)
    try:
        resource_class = resources.global_env().get_class(type_name)
    except exception.NotFound:
        LOG.exception('Error    loading    resource    type    %s    from    global    environment.', type_name)
        raise exception.InvalidGlobalResource(type_name=type_name)
    assert (resource_class is not None)
    if (resource_class.support_status.status == support.HIDDEN):
        raise exception.NotSupported(feature=type_name)
    try:
        svc_available = resource_class.is_service_available(cnxt)[0]
    except Exception as exc:
        raise exception.ResourceTypeUnavailable(service_name=resource_class.default_client_name, resource_type=type_name, reason=six.text_type(exc))
    else:
        if (not svc_available):
            raise exception.ResourceTypeUnavailable(service_name=resource_class.default_client_name, resource_type=type_name, reason='Service    endpoint    not    in    service    catalog.')
    def properties_schema():
        for (name, schema_dict) in resource_class.properties_schema.items():
            schema = properties.Schema.from_legacy(schema_dict)
            if (schema.implemented and (schema.support_status.status != support.HIDDEN)):
                (yield (name, dict(schema)))
    def attributes_schema():
        for (name, schema_data) in itertools.chain(resource_class.attributes_schema.items(), resource_class.base_attributes_schema.items()):
            schema = attributes.Schema.from_attribute(schema_data)
            if (schema.support_status.status != support.HIDDEN):
                (yield (name, dict(schema)))
    result = {rpc_api.RES_SCHEMA_RES_TYPE: type_name, rpc_api.RES_SCHEMA_PROPERTIES: dict(properties_schema()), rpc_api.RES_SCHEMA_ATTRIBUTES: dict(attributes_schema()), rpc_api.RES_SCHEMA_SUPPORT_STATUS: resource_class.support_status.to_dict()}
    if with_description:
        result[rpc_api.RES_SCHEMA_DESCRIPTION] = resource_class.getdoc()
    return result
