| 78 | } |
| 79 | |
| 80 | func (s *Server) GetOpenAPI() string { |
| 81 | jsonBytes, err := s.api.OpenAPI().Downgrade() |
| 82 | if err != nil { |
| 83 | return "" |
| 84 | } |
| 85 | // unmarshal the json and pretty print it |
| 86 | var jsonObj any |
| 87 | if err := json.Unmarshal(jsonBytes, &jsonObj); err != nil { |
| 88 | return "" |
| 89 | } |
| 90 | |
| 91 | // Normalize |
| 92 | normalized := s.NormalizeSchema(jsonObj) |
| 93 | |
| 94 | prettyJSON, err := json.MarshalIndent(normalized, "", " ") |
| 95 | if err != nil { |
| 96 | return "" |
| 97 | } |
| 98 | return string(prettyJSON) |
| 99 | } |
| 100 | |
| 101 | // That's about 40 frames per second. It's slightly less |
| 102 | // because the action of taking a snapshot takes time too. |