phprs\apis\ApiExporter::createExceptionDoc PHP Method

createExceptionDoc() private method

生成响应的示例和说明
private createExceptionDoc ( array $api ) : array
$api array
return array [sample, doc]
    private function createExceptionDoc($api)
    {
        // 'name' => $fun_name,
        // 'args' => $args,
        // 'doc' => $anns['return'][$id]['doc']
        $res = array();
        foreach ($api['throws'] as $name => $throws) {
            $status = "HTTP/1.1 500 Internal Server Error\r\n";
            $header = '';
            $doc = '';
            $body = '';
            foreach ($throws as $throw) {
                $info = $this->getResponseInfo($throw);
                if (isset($info['status'])) {
                    $status = $info['status'];
                }
                if (isset($info['header'])) {
                    $header .= $info['header'];
                }
                if (isset($info['body'])) {
                    if (is_array($info['body'])) {
                        $body .= json_encode($info['body']);
                    } else {
                        $body .= $info['body'];
                    }
                }
                if (isset($info['doc']) && $info['doc']) {
                    $doc .= $info['doc'];
                }
            }
            $sample = $status . $header . "\r\n" . $body;
            $res[$name] = array($sample, $doc);
        }
        return $res;
    }