Skip to content

anyOf required produces empty loose type #229

@jdguzman

Description

@jdguzman

Given the json schema:

{
  "title": "CreateAppUserInput",
  "type": "object",
  "properties": {
    "accountId": { "type":  "string" },
    "applicationId": { "type": "string" },
    "avatarUrl": { "type":  "string" },
    "dateOfBirth": { "type":  "string", "format": "date-time" },
    "email": { "type":  "string" },
    "firstName": { "type": "string" },
    "gender": {
      "type": "string",
      "enum": ["FEMALE", "MALE", "OTHER"]
    },
    "lastName": { "type":  "string" },
    "organizationId": { "type": "string" },
    "phoneNumber": { "type" :  "string" },
    "sourceId": { "type":  "string" }
  },
  "required": ["applicationId", "organizationId"],
  "anyOf": [
    { "required": ["email"] },
    { "required": ["phoneNumber"] }
  ],
  "minProperties": 1,
  "additionalProperties": false
}

I am getting the type of:

export type CreateAppUserInput = {
  [k: string]: any;
};

The issue is the anyOf, the requirement is that at least one of those two be present. The validator that uses this schema is working correctly so I'm just unsure if maybe there something I could change to get a correct type?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions