MCPcopy Index your code
hub / github.com/anomalyco/opencode / inputFields

Function inputFields

packages/httpapi-codegen/src/index.ts:781–797  ·  view source on GitHub ↗
(schema: Schema.Top | undefined, source: InputField["source"], operation: string)

Source from the content-addressed store, hash-verified

779}
780
781function 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
799function responseSchemas(schema: Schema.Top, path: string): Array<readonly [string, Schema.Top]> {
800 if (HttpApiSchema.isNoContent(schema.ast)) return []

Callers 1

onEndpointFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected