| 779 | } |
| 780 | |
| 781 | function inputFields(schema: Schema.Top | undefined, source: InputField["source"], operation: string) { |
| 782 | if (schema === undefined) return [] |
| 783 | const ast = Schema.toType(schema).ast |
| 784 | if (!SchemaAST.isObjects(ast) || ast.indexSignatures.length > 0) { |
| 785 | throw new GenerationError({ reason: `Input schema must be a struct: ${operation}.${source}` }) |
| 786 | } |
| 787 | return ast.propertySignatures.map((field) => { |
| 788 | if (typeof field.name !== "string") { |
| 789 | throw new GenerationError({ reason: `Input field must have a string name: ${operation}.${source}` }) |
| 790 | } |
| 791 | return { |
| 792 | name: field.name, |
| 793 | source, |
| 794 | optional: SchemaAST.isOptional(field.type), |
| 795 | } |
| 796 | }) |
| 797 | } |
| 798 | |
| 799 | function responseSchemas(schema: Schema.Top, path: string): Array<readonly [string, Schema.Top]> { |
| 800 | if (HttpApiSchema.isNoContent(schema.ast)) return [] |