migrate some services from examples to openApi (#9915)

This commit is contained in:
chris48s
2024-01-29 11:05:35 +00:00
committed by GitHub
parent 90d2a230ba
commit af19335c5a
5 changed files with 267 additions and 326 deletions

View File

@@ -1,6 +1,7 @@
import gql from 'graphql-tag'
import Joi from 'joi'
import dayjs from 'dayjs'
import { pathParam, queryParam } from '../index.js'
import { metric, maybePluralize } from '../text-formatters.js'
import { nonNegativeInteger } from '../validators.js'
import { GithubAuthV4Service } from './github-auth-service.js'
@@ -9,7 +10,7 @@ import {
transformErrors,
} from './github-helpers.js'
const documentation = `
const description = `
This badge is designed for projects hosted on GitHub which are
participating in
[Hacktoberfest](https://hacktoberfest.digitalocean.com),
@@ -55,40 +56,24 @@ export default class GithubHacktoberfestCombinedStatus extends GithubAuthV4Servi
queryParamSchema,
}
static examples = [
{
title: 'GitHub Hacktoberfest combined status',
namedParams: {
year: '2023',
user: 'snyk',
repo: 'snyk',
static openApi = {
'/github/hacktoberfest/{year}/{user}/{repo}': {
get: {
summary: 'GitHub Hacktoberfest combined status',
description,
parameters: [
pathParam({
name: 'year',
example: '2023',
schema: { type: 'string', enum: this.getEnum('year') },
}),
pathParam({ name: 'user', example: 'tmrowco' }),
pathParam({ name: 'repo', example: 'tmrowapp-contrib' }),
queryParam({ name: 'suggestion_label', example: 'help wanted' }),
],
},
staticPreview: this.render({
suggestedIssueCount: 12,
contributionCount: 8,
daysLeft: 15,
}),
documentation,
},
{
title: 'GitHub Hacktoberfest combined status (suggestion label override)',
namedParams: {
year: '2023',
user: 'tmrowco',
repo: 'tmrowapp-contrib',
},
queryParams: {
suggestion_label: 'help wanted',
},
staticPreview: this.render({
year: '2023',
suggestedIssueCount: 12,
contributionCount: 8,
daysLeft: 15,
}),
documentation,
},
]
}
static defaultBadgeData = { label: 'hacktoberfest', color: 'orange' }