| 779 | } |
| 780 | |
| 781 | const makeErrorSchema = ( |
| 782 | api: HttpApi.HttpApi.AnyWithProps |
| 783 | ): Schema.Schema<unknown, HttpServerResponse.HttpServerResponse> => { |
| 784 | const schemas = new Set<Schema.Schema.Any>() |
| 785 | HttpApiSchema.deunionize(schemas, api.errorSchema) |
| 786 | for (const group of Object.values(api.groups)) { |
| 787 | for (const endpoint of Object.values(group.endpoints)) { |
| 788 | HttpApiSchema.deunionize(schemas, endpoint.errorSchema) |
| 789 | } |
| 790 | HttpApiSchema.deunionize(schemas, group.errorSchema) |
| 791 | } |
| 792 | return Schema.Union(...Array.from(schemas, toResponseError)) as any |
| 793 | } |
| 794 | |
| 795 | const decodeForbidden = <A>(_: A, __: AST.ParseOptions, ast: AST.Transformation) => |
| 796 | ParseResult.fail(new ParseResult.Forbidden(ast, _, "Encode only schema")) |