MCPcopy Create free account
hub / github.com/middleapi/orpc / applySchemaOptionality

Function applySchemaOptionality

packages/openapi/src/schema-utils.ts:173–184  ·  view source on GitHub ↗
(required: boolean, schema: JSONSchema)

Source from the content-addressed store, hash-verified

171}
172
173export function applySchemaOptionality(required: boolean, schema: JSONSchema): JSONSchema {
174 if (required) {
175 return schema
176 }
177
178 return {
179 anyOf: [
180 schema,
181 { not: {} },
182 ],
183 }
184}
185
186/**
187 * Takes a JSON schema and, if it's primarily a union type (anyOf, oneOf),

Callers 2

#successResponseMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected