migrate examples to openApi part 11: enums; affects [codefactor conda depfu homebrew jsdelivr reddit sourceforge testspace vaadin github] (#9437)

* WIP enums

* WIP moar enums

* add a helper function for extracting enum from route pattern

* add enum schemas to services

* review and improve service names

* convert some more services with enums

* review and improve service names

* fix issue/pull request detail
This commit is contained in:
chris48s
2023-08-30 17:14:18 +01:00
committed by GitHub
parent fdeda3e3f9
commit e8157100b8
17 changed files with 399 additions and 163 deletions

View File

@@ -1,5 +1,5 @@
import Joi from 'joi'
import { BaseSvgScrapingService } from '../index.js'
import { BaseSvgScrapingService, pathParams } from '../index.js'
import { isValidGrade, gradeColor } from './codefactor-helpers.js'
const schema = Joi.object({
@@ -13,18 +13,52 @@ export default class CodeFactorGrade extends BaseSvgScrapingService {
pattern: ':vcsType(github|bitbucket)/:user/:repo/:branch*',
}
static examples = [
{
title: 'CodeFactor Grade',
namedParams: {
vcsType: 'github',
user: 'microsoft',
repo: 'powertoys',
branch: 'main',
static openApi = {
'/codefactor/grade/{vcsType}/{user}/{repo}/{branch}': {
get: {
summary: 'CodeFactor Grade (with branch)',
parameters: pathParams(
{
name: 'vcsType',
example: 'github',
schema: { type: 'string', enum: this.getEnum('vcsType') },
},
{
name: 'user',
example: 'microsoft',
},
{
name: 'repo',
example: 'powertoys',
},
{
name: 'branch',
example: 'main',
},
),
},
staticPreview: this.render({ grade: 'B+' }),
},
]
'/codefactor/grade/{vcsType}/{user}/{repo}': {
get: {
summary: 'CodeFactor Grade',
parameters: pathParams(
{
name: 'vcsType',
example: 'github',
schema: { type: 'string', enum: this.getEnum('vcsType') },
},
{
name: 'user',
example: 'microsoft',
},
{
name: 'repo',
example: 'powertoys',
},
),
},
},
}
static defaultBadgeData = { label: 'code quality' }