* Processes a path item object, handling all nested schemas * @param pathItem The path item to process
(pathItem: OpenAPIV3.PathItemObject)
| 61 | * @param pathItem The path item to process |
| 62 | */ |
| 63 | private processPathItem(pathItem: OpenAPIV3.PathItemObject): void { |
| 64 | const operations = [ |
| 65 | "get", |
| 66 | "put", |
| 67 | "post", |
| 68 | "delete", |
| 69 | "options", |
| 70 | "head", |
| 71 | "patch", |
| 72 | "trace", |
| 73 | ]; |
| 74 | |
| 75 | for (const op of operations) { |
| 76 | const operation = pathItem[ |
| 77 | op as keyof OpenAPIV3.PathItemObject |
| 78 | ] as OpenAPIV3.OperationObject; |
| 79 | if (!operation) continue; |
| 80 | |
| 81 | // Process request body schema |
| 82 | if (operation.requestBody) { |
| 83 | const requestBody = |
| 84 | operation.requestBody as OpenAPIV3.RequestBodyObject; |
| 85 | for (const mediaType of Object.values(requestBody.content || {})) { |
| 86 | if (mediaType.schema) { |
| 87 | mediaType.schema = this.processSchema(mediaType.schema); |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | // Process response schemas |
| 93 | for (const response of Object.values(operation.responses || {})) { |
| 94 | const responseObj = response as OpenAPIV3.ResponseObject; |
| 95 | if (responseObj.content) { |
| 96 | for (const mediaType of Object.values(responseObj.content)) { |
| 97 | if (mediaType.schema) { |
| 98 | mediaType.schema = this.processSchema(mediaType.schema); |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | // Process parameter schemas |
| 105 | if (operation.parameters) { |
| 106 | for (const param of operation.parameters) { |
| 107 | const paramObj = param as OpenAPIV3.ParameterObject; |
| 108 | if (paramObj.schema) { |
| 109 | paramObj.schema = this.processSchema(paramObj.schema); |
| 110 | } |
| 111 | } |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Processes a schema object, merging allOf if present |
no test coverage detected