(operationID string)
| 114 | } |
| 115 | |
| 116 | func (s *Server) formatEndpointDetail(operationID string) string { |
| 117 | ep, ok := s.openAPIIndex.GetEndpoint(operationID) |
| 118 | if !ok { |
| 119 | return fmt.Sprintf("Unknown operationId: %s\n\nUse search_api(service=\"...\") to browse endpoints.", operationID) |
| 120 | } |
| 121 | |
| 122 | var sb strings.Builder |
| 123 | |
| 124 | fmt.Fprintf(&sb, "## %s/%s\n\n", ep.Service, ep.Method) |
| 125 | fmt.Fprintf(&sb, "%s\n\n", ep.Summary) |
| 126 | |
| 127 | if len(ep.Permissions) > 0 { |
| 128 | fmt.Fprintf(&sb, "**Permissions:** `%s`\n\n", strings.Join(ep.Permissions, "`, `")) |
| 129 | } |
| 130 | |
| 131 | // Request schema |
| 132 | if ep.RequestSchemaRef != "" { |
| 133 | props := s.openAPIIndex.GetRequestSchema(ep.RequestSchemaRef) |
| 134 | if len(props) > 0 { |
| 135 | sb.WriteString("### Request Body\n```json\n{\n") |
| 136 | for _, prop := range props { |
| 137 | s.formatProperty(&sb, prop) |
| 138 | } |
| 139 | sb.WriteString("}\n```\n\n") |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | // Response schema |
| 144 | if ep.ResponseSchemaRef != "" { |
| 145 | props := s.openAPIIndex.GetRequestSchema(ep.ResponseSchemaRef) // same method works for response |
| 146 | if len(props) > 0 { |
| 147 | sb.WriteString("### Response Body\n```json\n{\n") |
| 148 | for _, prop := range props { |
| 149 | s.formatProperty(&sb, prop) |
| 150 | } |
| 151 | sb.WriteString("}\n```\n") |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | return sb.String() |
| 156 | } |
| 157 | |
| 158 | func (s *Server) formatSchemaDetail(schemaName string) string { |
| 159 | props, ok := s.openAPIIndex.GetSchema(schemaName) |
no test coverage detected