Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Required resolver not being executed #41

Open
danthegoodman1 opened this issue Mar 8, 2023 · 0 comments
Open

Required resolver not being executed #41

danthegoodman1 opened this issue Mar 8, 2023 · 0 comments

Comments

@danthegoodman1
Copy link

danthegoodman1 commented Mar 8, 2023

eIt seems as if the required value resolved is not firing when mixing required and non-required values:

export function mergeSchemas(schemas: any[]) {
  return mergeAllOf({
    allOf: schemas,
  }, {
    resolvers: {
      type: (values) => {
        const finalType = []
        for (const value of values) {
          if (Array.isArray(value)) {
            finalType.push(...value)
          } else {
            finalType.push(value)
          }
        }
        return finalType as any
      },
      required: (values) => {
        console.log("required resolver", values)
        return false
      }
    }
  })
}

console.log(mergeSchemas([ {
			"type": "object",
			"properties": {
				"hey": {
					"type": "string",
					"required": true
				},
				"this": {
					"type": "number",
					"required": true
				},
				"is": {
					"type": "array",
					"items": {
						"type": "string",
						"required": true
					},
					"required": true
				}
			},
			"required": true
		},  {
			"type": "object",
			"properties": {
				"hey": {
					"type": "string"
				},
				"this": {
					"type": "number"
				},
				"is": {
					"type": "array",
					"items": {
						"type": "string"
					}
				}
			}
		}]))

Outputs:

{
  type: 'object',
  required: true,
  properties: {
    hey: { type: 'string', required: true },
    this: { type: 'number', required: true },
    is: { type: 'array', required: true, items: [Object] }
  }
}

notice that:

  1. I am returning false always for the resolver
  2. There is no console logging of the required resolver line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant