How to use the rest-hooks.schemas.Union function in rest-hooks

To help you get started, we’ve selected a few rest-hooks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github coinbase / rest-hooks / __tests__ / common.ts View on Github external
static listShape(
    this: T,
  ): ReadShape>> {
    const schema = [
      new schemas.Union(
        {
          first: FirstUnionResource.getEntitySchema(),
          second: SecondUnionResource.getEntitySchema(),
        },
        (input: FirstUnionResource | SecondUnionResource) => input['type'],
      ),
    ];
    return {
      ...super.detailShape(),
      schema,
    };
  }
}
github coinbase / rest-hooks / __tests__ / common.ts View on Github external
static detailShape(
    this: T,
  ): ReadShape>> {
    const schema = new schemas.Union(
      {
        first: FirstUnionResource.getEntitySchema(),
        second: SecondUnionResource.getEntitySchema(),
      },
      'type',
    );
    return {
      ...super.detailShape(),
      schema,
    };
  }
  static listShape(