Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include github contributors badge in docs site #10337

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/base-service/openapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function services2openapi(services, sort) {
for (const [key, value] of Object.entries(
addGlobalProperties(service.openApi),
)) {
if (key in paths && key !== '/github/{variant}/{user}/{repo}') {
if (key in paths) {
throw new Error(`Conflicting route: ${key}`)
}
paths[key] = value
Expand Down
16 changes: 10 additions & 6 deletions services/github/github-contributors.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,23 @@ export default class GithubContributors extends GithubAuthV3Service {
static category = 'activity'
static route = {
base: 'github',
pattern: ':variant(contributors|contributors-anon)/:user/:repo',
// note we call this param 'metric' instead of 'variant' because of
// https://github.com/badges/shields/issues/10323
pattern: ':metric(contributors|contributors-anon)/:user/:repo',
}

static openApi = {
'/github/{variant}/{user}/{repo}': {
'/github/{metric}/{user}/{repo}': {
get: {
summary: 'GitHub contributors',
description: documentation,
parameters: pathParams(
{
name: 'variant',
name: 'metric',
example: 'contributors',
schema: { type: 'string', enum: this.getEnum('variant') },
schema: { type: 'string', enum: this.getEnum('metric') },
description:
'`contributors-anon` includes anonymous commits, whereas `contributors` excludes them.',
},
{
name: 'user',
Expand All @@ -45,8 +49,8 @@ export default class GithubContributors extends GithubAuthV3Service {
return renderContributorBadge({ contributorCount })
}

async handle({ variant, user, repo }) {
const isAnon = variant === 'contributors-anon'
async handle({ metric, user, repo }) {
const isAnon = metric === 'contributors-anon'

const { res, buffer } = await this._request({
url: `/repos/${user}/${repo}/contributors`,
Expand Down
Loading