(doc: OpenAPI.Document, schema: JSONSchema)
| 169 | const OPENAPI_JSON_SCHEMA_REF_PREFIX = /* @__PURE__ */ '#/components/schemas/' |
| 170 | |
| 171 | export function resolveOpenAPIJsonSchemaRef(doc: OpenAPI.Document, schema: JSONSchema): JSONSchema { |
| 172 | if (typeof schema !== 'object' || !schema.$ref?.startsWith(OPENAPI_JSON_SCHEMA_REF_PREFIX)) { |
| 173 | return schema |
| 174 | } |
| 175 | |
| 176 | const name = schema.$ref.slice(OPENAPI_JSON_SCHEMA_REF_PREFIX.length) |
| 177 | const resolved = doc.components?.schemas?.[name] |
| 178 | return resolved as JSONSchema ?? schema |
| 179 | } |
| 180 | |
| 181 | /** |
| 182 | * Simplifies composed object JSON Schemas (using anyOf, oneOf, allOf) by flattening nested compositions |
no outgoing calls
no test coverage detected