Skip to main content
Glama
custom-resolvers.test.js1.49 kB
'use strict' const assert = require('node:assert/strict') const { test } = require('node:test') const { mergeSchemas } = require('../index') const { defaultResolver } = require('./utils') test('should use a custom resolver instead of default one', () => { const schema1 = { type: 'string' } const schema2 = { type: 'number' } const mergedSchema = mergeSchemas( [schema1, schema2], { resolvers: { type: (keyword, values, mergedSchema, schemas) => { assert.strictEqual(keyword, 'type') assert.deepStrictEqual(values, ['string', 'number']) assert.deepStrictEqual(schemas, [schema1, schema2]) mergedSchema[keyword] = 'custom-type' } }, defaultResolver } ) assert.deepStrictEqual(mergedSchema, { type: 'custom-type' }) }) test('should use a custom resolver for unknown keyword', () => { const schema1 = { customKeyword: 'string' } const schema2 = { customKeyword: 'number' } const mergedSchema = mergeSchemas( [schema1, schema2], { resolvers: { customKeyword: (keyword, values, mergedSchema, schemas) => { assert.strictEqual(keyword, 'customKeyword') assert.deepStrictEqual(values, ['string', 'number']) assert.deepStrictEqual(schemas, [schema1, schema2]) mergedSchema[keyword] = 'custom-type' } }, defaultResolver } ) assert.deepStrictEqual(mergedSchema, { customKeyword: 'custom-type' }) })

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/krtw00/search-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server