• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

badges / shields / 45774165149

22 Nov 2026 09:43PM UTC coverage: 79.735% (-18.4%) from 98.17%
45774165149

push

github

web-flow
[Endpoint] Support message override and position it after label in API docs (#12235)

* [Endpoint] Support message override and position it after label in API docs

* Preserve error message when a message override is provided

3371 of 3616 branches covered (93.22%)

43 of 53 new or added lines in 3 files covered. (81.13%)

9589 existing lines in 490 files now uncovered.

41514 of 52065 relevant lines covered (79.73%)

51.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

68.0
/services/github/github-discussions.service.js
1
import gql from 'graphql-tag'
2 ✔
2
import Joi from 'joi'
2 ✔
3
import { pathParam } from '../index.js'
2 ✔
4
import { nonNegativeInteger } from '../validators.js'
2 ✔
5
import { GithubAuthV4Service } from './github-auth-service.js'
2 ✔
6
import { transformErrors } from './github-helpers.js'
2 ✔
7

2 ✔
8
const schema = Joi.object({
2 ✔
9
  data: Joi.object({
2 ✔
10
    repository: Joi.object({
2 ✔
11
      discussions: Joi.object({
2 ✔
12
        totalCount: nonNegativeInteger,
2 ✔
13
      }).required(),
2 ✔
14
    }).required(),
2 ✔
15
  }).required(),
2 ✔
16
}).required()
2 ✔
17

2 ✔
18
const variantConfig = {
2 ✔
19
  all: { color: 'blue', suffix: 'total', answered: null },
2 ✔
20
  answered: { color: 'brightgreen', suffix: 'answered', answered: true },
2 ✔
21
  unanswered: { color: 'orange', suffix: 'unanswered', answered: false },
2 ✔
22
}
2 ✔
23

2 ✔
24
export default class GithubDiscussions extends GithubAuthV4Service {
2 ✔
25
  static category = 'other'
2 ✔
26
  static route = {
2 ✔
27
    base: 'github/discussions',
2 ✔
28
    pattern: ':variant(all|answered|unanswered)?/:user/:repo',
2 ✔
29
  }
2 ✔
30

2 ✔
31
  static openApi = {
2 ✔
32
    '/github/discussions/all/{user}/{repo}': {
2 ✔
33
      get: {
2 ✔
34
        summary: 'GitHub Discussions (all)',
2 ✔
35
        parameters: [
2 ✔
36
          pathParam({ name: 'user', example: 'vercel' }),
2 ✔
37
          pathParam({ name: 'repo', example: 'next.js' }),
2 ✔
38
        ],
2 ✔
39
      },
2 ✔
40
    },
2 ✔
41
    '/github/discussions/answered/{user}/{repo}': {
2 ✔
42
      get: {
2 ✔
43
        summary: 'GitHub Answered Discussions',
2 ✔
44
        parameters: [
2 ✔
45
          pathParam({ name: 'user', example: 'vercel' }),
2 ✔
46
          pathParam({ name: 'repo', example: 'next.js' }),
2 ✔
47
        ],
2 ✔
48
      },
2 ✔
49
    },
2 ✔
50
    '/github/discussions/unanswered/{user}/{repo}': {
2 ✔
51
      get: {
2 ✔
52
        summary: 'GitHub Unanswered Discussions',
2 ✔
53
        parameters: [
2 ✔
54
          pathParam({ name: 'user', example: 'vercel' }),
2 ✔
55
          pathParam({ name: 'repo', example: 'next.js' }),
2 ✔
56
        ],
2 ✔
57
      },
2 ✔
58
    },
2 ✔
59
  }
2 ✔
60

2 ✔
61
  static defaultBadgeData = { label: 'discussions', color: 'blue' }
2 ✔
62

2 ✔
63
  static render({ discussions, color }) {
2 ✔
UNCOV
64
    return { message: discussions, color }
×
UNCOV
65
  }
×
66

2 ✔
67
  async fetch({ user, repo, answered }) {
2 ✔
UNCOV
68
    return this._requestGraphql({
×
UNCOV
69
      query: gql`
×
UNCOV
70
        query ($user: String!, $repo: String!, $answered: Boolean) {
×
UNCOV
71
          repository(name: $repo, owner: $user) {
×
UNCOV
72
            discussions(answered: $answered) {
×
UNCOV
73
              totalCount
×
UNCOV
74
            }
×
UNCOV
75
          }
×
UNCOV
76
        }
×
UNCOV
77
      `,
×
UNCOV
78
      variables: { user, repo, answered },
×
UNCOV
79
      schema,
×
UNCOV
80
      options: { headers: { 'GraphQL-Features': 'discussions_api' } },
×
UNCOV
81
      transformErrors,
×
UNCOV
82
    })
×
UNCOV
83
  }
×
84

2 ✔
85
  async handle({ user, repo, variant }) {
2 ✔
UNCOV
86
    const { answered, color, suffix } = variantConfig[variant || 'all']
×
UNCOV
87
    const json = await this.fetch({ user, repo, answered })
×
UNCOV
88
    const {
×
UNCOV
89
      data: {
×
UNCOV
90
        repository: {
×
UNCOV
91
          discussions: { totalCount },
×
UNCOV
92
        },
×
UNCOV
93
      },
×
UNCOV
94
    } = json
×
UNCOV
95
    return this.constructor.render({
×
UNCOV
96
      discussions: `${totalCount} ${suffix}`,
×
UNCOV
97
      color,
×
UNCOV
98
    })
×
UNCOV
99
  }
×
100
}
2 ✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc