Default implementation of a schema name resolver function
558573
def resolver(schema):
    
    name = schema.__name__
    if name.endswith("Schema"):
        return name[:-6] or name
    return name
900319
function lazy(schema, defaults, options) {
  if (kindOf(schema) !== 'function') {
    if (process.env.NODE_ENV !== 'production') {
      throw new Error(
        `Lazy structs must be defined as an function that returns a schema, but you passed: ${schema}`
      )
    } else {
      throw new Error(`Invalid schema: ${schema}`)
    }
  }

  let kind
  let struct
  const name = 'lazy'
  const type = `lazy...`
  const compile = value => {
    struct = schema()
    kind.name = struct.kind
    kind.type = struct.type
    kind.validate = struct.validate
    return kind.validate(value)
  }

  kind = new Kind(name, type, compile)
  return kind
}
26492
public static function fromNCNameAndDefault( $qname, $resolver, $defaultNs )
	{
		$qn = \lyquidity\xml\qname( $qname, $resolver->getNamespaces() );
		if ( ! $qn )
		{
			if ( strpos( $qname, ":" ) )
			{
				$prefix = strstr( $qname, ":", true );

				// Look to see if the default namespace is relevant
				$types = SchemaTypes::getInstance();
				$schemas = $types->getProcessedSchemas();
				if ( isset( $schemas[ $prefix ] ) )
				{
					$qn = \lyquidity\xml\qname( $qname, $schemas );
				}
				else
				{
					$namespace = $resolver->lookupNamespace( $prefix );
					if ( ! $namespace )
					{
						throw XPath2Exception::withErrorCodeAndParams( "XPST0081", Resources::XPST0081, array( $qname, "xs:QName" ) );
					}
				}
			}

			if ( ! $qn )
			{
				throw XPath2Exception::withErrorCodeAndParams( "FORG0001", Resources::FORG0001, array( $qname, "xs:QName" ) );
			}
		}

		if ( empty( $qn->prefix ) )
		{
			return QNameValue::fromParts( "", $qn->localName, $defaultNs, $resolver );
		}

		if ( empty( $qn->namespaceURI ) )
		{
			throw XPath2Exception::withErrorCodeAndParam( "XPST0081", Resources::XPST0081, $qn->prefix );
		}

		$pattern = NameValue::$ncName;
		if ( ! preg_match( "/" . NameValue::$ncName . "/u", $qn->localName ) )
		{
			throw XPath2Exception::withErrorCodeAndParams( "FORG0001", Resources::FORG0001, array( $qname, "xs:QName" ) );
		}

		// The prefix may defined with a local namespace:
		//
		// <el xmlns:z="http://example.com">z:qn</el>
		//
		// This qn will not be comparable with another qn with another definition in the parent
		//
		// <root xmlns:t="http://example.com">
		//   <el>t:qn</el>
		// <root>
		// To make the q names comparable make sure the prefix is that of the namespace defined in the parent if there is one
		// This can be done by removing the prefix from the list of namespaces.  If there is a parent namespace it will still
		// be in the list and can be located and the prefix changed accordingly.

		$namespaces = $resolver->getNamespaces();
		unset( $namespaces[ $qn->prefix ] );
		foreach ( $namespaces as $prefix => $namespace )
		{
			if ( $namespace == $qn->namespaceURI )
			{
				$qn->prefix = $prefix;
				break;
			}
		}
		return QNameValue::fromParts( $qn->prefix, $qn->localName, $qn->namespaceURI, $resolver );
	}
1242524
def build_request_to_validator_map(schema, resolver):
    
    schema_models = schema.get('models', {})
    return dict(
        (
            RequestMatcher(api['path'], operation['method']),
            ValidatorMap.from_operation(operation, schema_models, resolver)
        )
        for api in schema['apis']
        for operation in api['operations']
    )
613562
function resolve (manager, resolveReducer, accumulator, reducer) {
  const entity = manager.entities.get(reducer.id)
  return BaseEntity.resolve(
    manager,
    resolveReducer,
    accumulator,
    reducer,
    entity
  )
}
767147
function resolveRef(subobj, parent, parentKey) {
                    if (!subobj.resolved) {
                        Object.keys(subobj).forEach(function (key) {
                            var Ref, value = subobj[key];
                            if (key === "$ref") {
                                logger.debug("Resolving $ref: " + value);
                                Ref = refResolver(value);
                                value = typeof Ref === 'function' ? new Ref() : Ref;
                                if (!util.isUndefined(value) && !value.resolved) {
                                    subobj.resolved = true;
                                    resolveRef(value, subobj, key);
                                }
                                parent[parentKey] = value;
                            } else if (typeof value === "object") {
                                resolveRef(value, subobj, key);
                            }
                        });
                    }
                }
1177027
public static function defaultTypeResolver(
        $value,
        $context,
        ResolveInfo $info,
        AbstractTypeInterface $abstractType
    ) {
        // First, look for `__typename`.
        if (\is_array($value) && isset($value['__typename'])) {
            return $value['__typename'];
        }

        // Otherwise, test each possible type.

        /** @var ObjectType[] $possibleTypes */
        $possibleTypes = $info->getSchema()->getPossibleTypes($abstractType);
        $promises      = [];

        foreach ($possibleTypes as $index => $type) {
            $isTypeOf = $type->isTypeOf($value, $context, $info);

            if ($isTypeOf instanceof PromiseInterface) {
                $promises[$index] = $isTypeOf;
            }

            if (true === $isTypeOf) {
                return $type;
            }
        }

        if (!empty($promises)) {
            return \React\Promise\all($promises)->then(function ($resolvedPromises) use ($possibleTypes) {
                foreach ($resolvedPromises as $index => $result) {
                    if (true === $result) {
                        return $possibleTypes[$index];
                    }
                }

                return null;
            });
        }

        return null;
    }
404042
def schema():
        """"""
        return Schema({
            'script': And(Or(type(' '), type(u' ')), len),
            Optional('title', default=''): str,
            Optional('model', default={}): {Optional(And(str, len)): object},
            Optional('env', default={}): {Optional(And(str, len)): And(str, len)},
            Optional('item', default=None): object,
            Optional('dry_run', default=False): bool,
            Optional('debug', default=False): bool,
            Optional('strict', default=False): bool,
            Optional('variables', default={}): {
                Optional(And(Or(type(' '), type(u' ')), len, Regex(r'([a-zA-Z][_a-zA-Z]*)'))):
                    Or(type(' '), type(u' '))
            },
            Optional('temporary_scripts_path', default=''): Or(type(''), type(u'')),
            Optional('internal', default=False): bool
        })
1274712
function resolveRelatives( meta ) {
	var solvers = {
			string: function( relPath ){
				// strings are always converted to array internally
				if ( /[!*?]/.test( relPath ) ) {
					// resolves for globs
					return glob.sync( path.resolve( relPath ) );
				} else {
					if ( relPath.lastIndexOf( path.sep ) === relPath.length-1 ) {
						// resolves for a path
						return glob.sync( path.resolve( relPath + '*.json' ) );
					} else {
						// resolves for a filename
						if ( path.extname( relPath ) ) {
							return glob.sync( path.resolve( relPath ) );
						} else {
							return glob.sync( path.resolve( relPath + '.json' ) );
						} // if..else
					} // if..else
				} // if..else
			},
			array: function( paths ){
				return paths.map( function( relPath ){
					return solvers.string( relPath );
				});
			}
		},
		importsType = typeof meta.imports === 'string' ? 'string' : 'array';

	if ( meta.format === 'category' ) {
		meta.imports = solvers[ importsType ]( meta.imports );
	} else {
		if ( meta.format === 'language' ) {
			meta.imports = path.resolve( meta.imports );
		} // if
	} // if..else
	meta.dest = path.resolve( meta.dest );
}
1153784
def default_resolve_fn(source, info, **args):
    # type: (Any, ResolveInfo, **Any) -> Optional[Any]
    """"""
    name = info.field_name
    if isinstance(source, dict):
        property = source.get(name)
    else:
        property = getattr(source, name, None)
    if callable(property):
        return property()
    return property
744487
private String processSchemaName(String dbProductName, String userName, String schemaName) {
        String result = null;

        if (schemaName != null) {
            result = schemaName.toUpperCase();
        } else {
            if ("DB2".equals(dbProductName) == true || "Apache Derby".equals(dbProductName) == true || "Oracle".equals(dbProductName) == true) {
                if (userName != null) {
                    result = userName.toUpperCase();
                }
            } else if ("PostgreSQL".equals(dbProductName) == true) {
                // for PostgreSQL - if no schema specified - public should be used
                result = "public";
            }
        }

        return result;
    }
445883
private static String resolveName(Class<?> c, String name) {
       if (name == null) {
           return name;
       }
       if (!name.startsWith("/")) {
           while (c.isArray()) {
               c = c.getComponentType();
           }
           String baseName = c.getName();
           int index = baseName.lastIndexOf('.');
           if (index != -1) {
               name = baseName.substring(0, index).replace('.', '/')
                   +"/"+name;
           }
       } else {
           name = name.substring(1);
       }
       return name;
   }
478366
@Override
    public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context, Iterator<ModelConverter> next)
    {
        JavaType classType = TypeFactory.defaultInstance().constructType(annotatedType.getType());
        Class<?> rawClass = classType.getRawClass();
        JavaType resolvedType = classType;

        if ((rawClass != null) &&!resolvedType.isPrimitive())
        {
            // log.debug("resolvedType in " + resolvedType);
            if (rawClass.isAssignableFrom(ServerResponse.class))
            {
                resolvedType = classType.containedType(0);
            }
            else if (rawClass.isAssignableFrom(CompletableFuture.class))
            {
                Class<?> futureCls = classType.containedType(0).getRawClass();

                if (futureCls.isAssignableFrom(ServerResponse.class))
                {
                    // log.debug("class is assignable from ServerResponse");
                    final JavaType futureType = TypeFactory.defaultInstance().constructType(classType.containedType(0));

                    resolvedType = futureType.containedType(0);
                }
                else
                {
                    // log.debug("class is NOT assignable from ServerResponse");
                    resolvedType = classType.containedType(0);
                }
            }

            if (resolvedType != null)
            {
                if (resolvedType.getTypeName().contains("java.lang.Void"))
                {
                    resolvedType = TypeFactory.defaultInstance().constructFromCanonical(Void.class.getName());
                }
                else if (resolvedType.getTypeName().contains("Optional"))
                {
                    if (resolvedType.getTypeName().contains("java.nio.file.Path"))
                    {
                        resolvedType = TypeFactory.defaultInstance().constructParametricType(Optional.class, File.class);
                    }

                    if (resolvedType.getTypeName().contains("ByteBuffer"))
                    {
                        resolvedType = TypeFactory.defaultInstance().constructParametricType(Optional.class, File.class);
                    }
                }
                else
                {
                    if (resolvedType.getTypeName().contains("java.nio.file.Path"))
                    {
                        resolvedType = TypeFactory.defaultInstance().constructFromCanonical(File.class.getName());
                    }

                    if (resolvedType.getTypeName().contains("ByteBuffer"))
                    {
                        resolvedType = TypeFactory.defaultInstance().constructFromCanonical(File.class.getName());
                    }
                }

                annotatedType.setType(resolvedType);

                // log.debug("resolvedType out " + resolvedType);
            }
        }

        try {

            // log.info("Processing " + annotatedType + " " + classType + " " + annotatedType.getName());
            return super.resolve(annotatedType, context, next);

        } catch (Exception e) {

            log.error("Error processing " + annotatedType + " " + classType + " " + annotatedType.getName(), e);

            return null;
        }
    }
805952
private function resolveSchema($reference)
    {
        $schema = $reference;
        if (property_exists($reference, '$ref')) {
            $schemaResolver = $this->document->getSchemaResolver();
            $ref = new Reference($reference);
            $schema = $schemaResolver->resolveReference($ref)->getDocument();
        } elseif ($reference->type === 'array' && !empty($reference->items)) {
            $schema->items = $this->resolveSchema($reference->items);
        }

        // resolve properties
        if (!empty($schema->properties)) {
            $properties = (array) $schema->properties;
            foreach ($properties as $name => $property) {
                if (isset($property->type)
                    && $property->type === 'array'
                    && isset($property->items)
                    && property_exists($property->items, '$ref')
                    && !isset($schema->properties->$name->items)) {
                    $schema->properties->$name->items = $this->resolveSchema($property->items);
                } elseif (property_exists($property, '$ref') && !isset($schema->properties->$name)) {
                    $schema->properties->$name = $this->resolveSchema($property);
                }
            }
        }

        return $schema;
    }
959550
function resolveSchema(root, ref) {
  /* jshint validthis: true */
  var p = URI.parse(ref)
    , refPath = _getFullPath(p)
    , baseId = getFullPath(this._getId(root.schema));
  if (Object.keys(root.schema).length === 0 || refPath !== baseId) {
    var id = normalizeId(refPath);
    var refVal = this._refs[id];
    if (typeof refVal == 'string') {
      return resolveRecursive.call(this, root, refVal, p);
    } else if (refVal instanceof SchemaObject) {
      if (!refVal.validate) this._compile(refVal);
      root = refVal;
    } else {
      refVal = this._schemas[id];
      if (refVal instanceof SchemaObject) {
        if (!refVal.validate) this._compile(refVal);
        if (id == normalizeId(ref))
          return { schema: refVal, root: root, baseId: baseId };
        root = refVal;
      } else {
        return;
      }
    }
    if (!root.schema) return;
    baseId = getFullPath(this._getId(root.schema));
  }
  return getJsonPointer.call(this, p, baseId, root.schema, root);
}
990166
function Resolver(root, dot, sep) {
    if (!Is.instance(this, Resolver)) {
        return PKG.Builder(root, dot, sep).get();
    }

    this.aliases = {};
    /**
     * Root path.
     *
     * @private
     * @type {string}
     */
     this.root = PKG.ROOT;
    /**
     * Character separator used in path keys.
     *
     * @private
     * @type {string}
     * @default {@link Dotresolver.DOT}
     */
    this.dot = dot || PKG.DOT;
    /**
     * Character separator used in built path.
     *
     * @private
     * @type {string}
     * @default {@link Dotresolver.SEP}
     */
    this.sep = sep || PKG.SEP;

    this.setRoot(root);
}
1064
def load_validator(schema_path, schema):
    
    # Get correct prefix based on OS
    if os.name == 'nt':
        file_prefix = 'file:///'
    else:
        file_prefix = 'file:'

    resolver = RefResolver(file_prefix + schema_path.replace("\\", "/"), schema)
    validator = Draft4Validator(schema, resolver=resolver)

    return validator