(ctx context.Context, client *github.Client, gitRef string)
| 56 | } |
| 57 | |
| 58 | func (o *openapiFile) loadDescription(ctx context.Context, client *github.Client, gitRef string) error { |
| 59 | contents, resp, err := client.Repositories.DownloadContents( |
| 60 | ctx, |
| 61 | descriptionsOwnerName, |
| 62 | descriptionsRepoName, |
| 63 | o.filename, |
| 64 | &github.RepositoryContentGetOptions{Ref: gitRef}, |
| 65 | ) |
| 66 | if err != nil { |
| 67 | return err |
| 68 | } |
| 69 | if resp.StatusCode != 200 { |
| 70 | return fmt.Errorf("unexpected status code: %v", resp.Status) |
| 71 | } |
| 72 | b, err := io.ReadAll(contents) |
| 73 | if err != nil { |
| 74 | return err |
| 75 | } |
| 76 | err = contents.Close() |
| 77 | if err != nil { |
| 78 | return err |
| 79 | } |
| 80 | o.description, err = openapi3.NewLoader().LoadFromData(b) |
| 81 | return err |
| 82 | } |
| 83 | |
| 84 | var dirPatterns = []*regexp.Regexp{ |
| 85 | regexp.MustCompile(`^(?P<plan>api\.github\.com)(-(?P<major>\d+)\.(?P<minor>\d+))?$`), |
no test coverage detected