mirror of
https://github.com/badges/shields.git
synced 2025-04-18 19:44:04 +03:00
migrate examples
to openApi
part5; affects [itunes jetbrains jitpack keybase lemmy luarocks maintenance openvsx] (#9431)
* migrate some services from examples to openApi * improve and de-dupe service titles * revert changes to jsdelivr * Update services/jetbrains/jetbrains-downloads.service.js Co-authored-by: Pierre-Yves Bigourdan <10694593+PyvesB@users.noreply.github.com> --------- Co-authored-by: Pierre-Yves Bigourdan <10694593+PyvesB@users.noreply.github.com>
This commit is contained in:
parent
6823d38ddf
commit
4f67ab7a09
@ -1,7 +1,7 @@
|
||||
import Joi from 'joi'
|
||||
import { renderVersionBadge } from '../version.js'
|
||||
import { nonNegativeInteger } from '../validators.js'
|
||||
import { BaseJsonService, NotFound } from '../index.js'
|
||||
import { BaseJsonService, NotFound, pathParams } from '../index.js'
|
||||
|
||||
const schema = Joi.object({
|
||||
resultCount: nonNegativeInteger,
|
||||
@ -18,13 +18,17 @@ export default class Itunes extends BaseJsonService {
|
||||
pattern: ':bundleId',
|
||||
}
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: 'iTunes App Store',
|
||||
namedParams: { bundleId: '803453959' },
|
||||
staticPreview: renderVersionBadge({ version: 'v3.3.3' }),
|
||||
static openApi = {
|
||||
'/itunes/v/{bundleId}': {
|
||||
get: {
|
||||
summary: 'iTunes App Store',
|
||||
parameters: pathParams({
|
||||
name: 'bundleId',
|
||||
example: '803453959',
|
||||
}),
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static defaultBadgeData = { label: 'itunes app store' }
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import Joi from 'joi'
|
||||
import { pathParams } from '../index.js'
|
||||
import { renderDownloadsBadge } from '../downloads.js'
|
||||
import { nonNegativeInteger } from '../validators.js'
|
||||
import JetbrainsBase from './jetbrains-base.js'
|
||||
@ -29,15 +30,17 @@ export default class JetbrainsDownloads extends JetbrainsBase {
|
||||
pattern: ':pluginId',
|
||||
}
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: 'JetBrains plugins',
|
||||
namedParams: {
|
||||
pluginId: '1347',
|
||||
static openApi = {
|
||||
'/jetbrains/plugin/d/{pluginId}': {
|
||||
get: {
|
||||
summary: 'JetBrains Plugin Downloads',
|
||||
parameters: pathParams({
|
||||
name: 'pluginId',
|
||||
example: '1347',
|
||||
}),
|
||||
},
|
||||
staticPreview: renderDownloadsBadge({ downloads: 10200000 }),
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
async handle({ pluginId }) {
|
||||
let downloads
|
||||
|
@ -1,4 +1,5 @@
|
||||
import Joi from 'joi'
|
||||
import { pathParams } from '../index.js'
|
||||
import { renderVersionBadge } from '../version.js'
|
||||
import JetbrainsBase from './jetbrains-base.js'
|
||||
|
||||
@ -35,15 +36,17 @@ export default class JetbrainsVersion extends JetbrainsBase {
|
||||
pattern: ':pluginId',
|
||||
}
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: 'JetBrains Plugins',
|
||||
namedParams: {
|
||||
pluginId: '9630',
|
||||
static openApi = {
|
||||
'/jetbrains/plugin/v/{pluginId}': {
|
||||
get: {
|
||||
summary: 'JetBrains Plugin Version',
|
||||
parameters: pathParams({
|
||||
name: 'pluginId',
|
||||
example: '9630',
|
||||
}),
|
||||
},
|
||||
staticPreview: this.render({ version: 'v1.7' }),
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static defaultBadgeData = { label: 'jetbrains plugin' }
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import Joi from 'joi'
|
||||
import { renderVersionBadge } from '../version.js'
|
||||
import { BaseJsonService } from '../index.js'
|
||||
import { BaseJsonService, pathParams } from '../index.js'
|
||||
|
||||
const schema = Joi.object({
|
||||
version: Joi.string().required(),
|
||||
@ -17,17 +17,23 @@ export default class JitPackVersion extends BaseJsonService {
|
||||
pattern: ':groupId/:artifactId',
|
||||
}
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: 'JitPack',
|
||||
namedParams: {
|
||||
groupId: 'com.github.jitpack',
|
||||
artifactId: 'maven-simple',
|
||||
static openApi = {
|
||||
'/jitpack/version/{groupId}/{artifactId}': {
|
||||
get: {
|
||||
summary: 'JitPack',
|
||||
parameters: pathParams(
|
||||
{
|
||||
name: 'groupId',
|
||||
example: 'com.github.jitpack',
|
||||
},
|
||||
{
|
||||
name: 'artifactId',
|
||||
example: 'maven-simple',
|
||||
},
|
||||
),
|
||||
},
|
||||
staticPreview: renderVersionBadge({ version: 'v1.1' }),
|
||||
keywords: ['java', 'maven'],
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static defaultBadgeData = { label: 'jitpack' }
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import Joi from 'joi'
|
||||
import { pathParams } from '../index.js'
|
||||
import { nonNegativeInteger } from '../validators.js'
|
||||
import KeybaseProfile from './keybase-profile.js'
|
||||
|
||||
@ -32,16 +33,17 @@ export default class KeybaseBTC extends KeybaseProfile {
|
||||
pattern: ':username',
|
||||
}
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: 'Keybase BTC',
|
||||
namedParams: { username: 'skyplabs' },
|
||||
staticPreview: this.render({
|
||||
address: '12ufRLmbEmgjsdGzhUUFY4pcfiQZyRPV9J',
|
||||
}),
|
||||
keywords: ['bitcoin'],
|
||||
static openApi = {
|
||||
'/keybase/btc/{username}': {
|
||||
get: {
|
||||
summary: 'Keybase BTC',
|
||||
parameters: pathParams({
|
||||
name: 'username',
|
||||
example: 'skyplabs',
|
||||
}),
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static defaultBadgeData = {
|
||||
label: 'btc',
|
||||
|
@ -1,4 +1,5 @@
|
||||
import Joi from 'joi'
|
||||
import { pathParams } from '../index.js'
|
||||
import { nonNegativeInteger } from '../validators.js'
|
||||
import KeybaseProfile from './keybase-profile.js'
|
||||
|
||||
@ -28,13 +29,17 @@ export default class KeybasePGP extends KeybaseProfile {
|
||||
pattern: ':username',
|
||||
}
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: 'Keybase PGP',
|
||||
namedParams: { username: 'skyplabs' },
|
||||
staticPreview: this.render({ fingerprint: '1863145FD39EE07E' }),
|
||||
static openApi = {
|
||||
'/keybase/pgp/{username}': {
|
||||
get: {
|
||||
summary: 'Keybase PGP',
|
||||
parameters: pathParams({
|
||||
name: 'username',
|
||||
example: 'skyplabs',
|
||||
}),
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static defaultBadgeData = {
|
||||
label: 'pgp',
|
||||
|
@ -1,4 +1,5 @@
|
||||
import Joi from 'joi'
|
||||
import { pathParams } from '../index.js'
|
||||
import { nonNegativeInteger } from '../validators.js'
|
||||
import KeybaseProfile from './keybase-profile.js'
|
||||
|
||||
@ -30,16 +31,17 @@ export default class KeybaseXLM extends KeybaseProfile {
|
||||
pattern: ':username',
|
||||
}
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: 'Keybase XLM',
|
||||
namedParams: { username: 'skyplabs' },
|
||||
staticPreview: this.render({
|
||||
address: 'GCGH37DYONEBPGAZGCHJEZZF3J2Q3EFYZBQBE6UJL5QKTULCMEA6MXLA',
|
||||
}),
|
||||
keywords: ['stellar'],
|
||||
static openApi = {
|
||||
'/keybase/xlm/{username}': {
|
||||
get: {
|
||||
summary: 'Keybase XLM',
|
||||
parameters: pathParams({
|
||||
name: 'username',
|
||||
example: 'skyplabs',
|
||||
}),
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static defaultBadgeData = {
|
||||
label: 'xlm',
|
||||
|
@ -1,4 +1,5 @@
|
||||
import Joi from 'joi'
|
||||
import { pathParams } from '../index.js'
|
||||
import { nonNegativeInteger } from '../validators.js'
|
||||
import KeybaseProfile from './keybase-profile.js'
|
||||
|
||||
@ -32,16 +33,17 @@ export default class KeybaseZEC extends KeybaseProfile {
|
||||
pattern: ':username',
|
||||
}
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: 'Keybase ZEC',
|
||||
namedParams: { username: 'skyplabs' },
|
||||
staticPreview: this.render({
|
||||
address: 't1RJDxpBcsgqAotqhepkhLFMv2XpMfvnf1y',
|
||||
}),
|
||||
keywords: ['zcash'],
|
||||
static openApi = {
|
||||
'/keybase/zec/{username}': {
|
||||
get: {
|
||||
summary: 'Keybase ZEC',
|
||||
parameters: pathParams({
|
||||
name: 'username',
|
||||
example: 'skyplabs',
|
||||
}),
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static defaultBadgeData = {
|
||||
label: 'zec',
|
||||
|
@ -1,6 +1,6 @@
|
||||
import Joi from 'joi'
|
||||
import { metric } from '../text-formatters.js'
|
||||
import { BaseJsonService, InvalidParameter } from '../index.js'
|
||||
import { BaseJsonService, InvalidParameter, pathParams } from '../index.js'
|
||||
|
||||
const lemmyCommunitySchema = Joi.object({
|
||||
community_view: Joi.object({
|
||||
@ -18,16 +18,17 @@ export default class Lemmy extends BaseJsonService {
|
||||
pattern: ':community',
|
||||
}
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: 'Lemmy',
|
||||
namedParams: { community: 'asklemmy@lemmy.ml' },
|
||||
staticPreview: this.render({
|
||||
community: 'asklemmy@lemmy.ml',
|
||||
members: 42,
|
||||
}),
|
||||
static openApi = {
|
||||
'/lemmy/{community}': {
|
||||
get: {
|
||||
summary: 'Lemmy',
|
||||
parameters: pathParams({
|
||||
name: 'community',
|
||||
example: 'asklemmy@lemmy.ml',
|
||||
}),
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static defaultBadgeData = { label: 'community' }
|
||||
|
||||
|
@ -1,20 +1,20 @@
|
||||
import { InvalidResponse } from '../index.js'
|
||||
import { InvalidResponse, pathParams } from '../index.js'
|
||||
import { renderCurrencyBadge, LiberapayBase } from './liberapay-base.js'
|
||||
|
||||
export default class LiberapayGives extends LiberapayBase {
|
||||
static route = this.buildRoute('gives')
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: 'Liberapay giving',
|
||||
namedParams: { entity: 'Changaco' },
|
||||
staticPreview: renderCurrencyBadge({
|
||||
label: 'gives',
|
||||
amount: '2.58',
|
||||
currency: 'EUR',
|
||||
}),
|
||||
static openApi = {
|
||||
'/liberapay/gives/{entity}': {
|
||||
get: {
|
||||
summary: 'Liberapay giving',
|
||||
parameters: pathParams({
|
||||
name: 'entity',
|
||||
example: 'Changaco',
|
||||
}),
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
async handle({ entity }) {
|
||||
const data = await this.fetch({ entity })
|
||||
|
@ -1,17 +1,21 @@
|
||||
import { colorScale } from '../color-formatters.js'
|
||||
import { InvalidResponse } from '../index.js'
|
||||
import { InvalidResponse, pathParams } from '../index.js'
|
||||
import { LiberapayBase } from './liberapay-base.js'
|
||||
|
||||
export default class LiberapayGoal extends LiberapayBase {
|
||||
static route = this.buildRoute('goal')
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: 'Liberapay goal progress',
|
||||
namedParams: { entity: 'Changaco' },
|
||||
staticPreview: this.render({ percentAchieved: 33 }),
|
||||
static openApi = {
|
||||
'/liberapay/goal/{entity}': {
|
||||
get: {
|
||||
summary: 'Liberapay goal progress',
|
||||
parameters: pathParams({
|
||||
name: 'entity',
|
||||
example: 'Changaco',
|
||||
}),
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static render({ percentAchieved }) {
|
||||
return {
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { pathParams } from '../index.js'
|
||||
import { metric } from '../text-formatters.js'
|
||||
import { colorScale } from '../color-formatters.js'
|
||||
import { LiberapayBase } from './liberapay-base.js'
|
||||
@ -5,13 +6,17 @@ import { LiberapayBase } from './liberapay-base.js'
|
||||
export default class LiberapayPatrons extends LiberapayBase {
|
||||
static route = this.buildRoute('patrons')
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: 'Liberapay patrons',
|
||||
namedParams: { entity: 'Changaco' },
|
||||
staticPreview: this.render({ patrons: 10 }),
|
||||
static openApi = {
|
||||
'/liberapay/patrons/{entity}': {
|
||||
get: {
|
||||
summary: 'Liberapay patrons',
|
||||
parameters: pathParams({
|
||||
name: 'entity',
|
||||
example: 'Changaco',
|
||||
}),
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static render({ patrons }) {
|
||||
return {
|
||||
|
@ -1,20 +1,20 @@
|
||||
import { InvalidResponse } from '../index.js'
|
||||
import { InvalidResponse, pathParams } from '../index.js'
|
||||
import { renderCurrencyBadge, LiberapayBase } from './liberapay-base.js'
|
||||
|
||||
export default class LiberapayReceives extends LiberapayBase {
|
||||
static route = this.buildRoute('receives')
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: 'Liberapay receiving',
|
||||
namedParams: { entity: 'Changaco' },
|
||||
staticPreview: renderCurrencyBadge({
|
||||
label: 'receives',
|
||||
amount: '98.32',
|
||||
currency: 'EUR',
|
||||
}),
|
||||
static openApi = {
|
||||
'/liberapay/receives/{entity}': {
|
||||
get: {
|
||||
summary: 'Liberapay receiving',
|
||||
parameters: pathParams({
|
||||
name: 'entity',
|
||||
example: 'Changaco',
|
||||
}),
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
async handle({ entity }) {
|
||||
const data = await this.fetch({ entity })
|
||||
|
@ -1,6 +1,6 @@
|
||||
import Joi from 'joi'
|
||||
import { addv } from '../text-formatters.js'
|
||||
import { BaseJsonService, NotFound } from '../index.js'
|
||||
import { BaseJsonService, NotFound, pathParams } from '../index.js'
|
||||
import { latestVersion } from './luarocks-version-helpers.js'
|
||||
|
||||
const schema = Joi.object({
|
||||
@ -20,16 +20,23 @@ export default class Luarocks extends BaseJsonService {
|
||||
pattern: ':user/:moduleName/:version?',
|
||||
}
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: 'LuaRocks',
|
||||
namedParams: {
|
||||
user: 'mpeterv',
|
||||
moduleName: 'luacheck',
|
||||
static openApi = {
|
||||
'/luarocks/v/{user}/{moduleName}': {
|
||||
get: {
|
||||
summary: 'LuaRocks',
|
||||
parameters: pathParams(
|
||||
{
|
||||
name: 'user',
|
||||
example: 'mpeterv',
|
||||
},
|
||||
{
|
||||
name: 'moduleName',
|
||||
example: 'luacheck',
|
||||
},
|
||||
),
|
||||
},
|
||||
staticPreview: this.render({ version: '0.23.0-1' }),
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static defaultBadgeData = {
|
||||
label: 'luarocks',
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { BaseService } from '../index.js'
|
||||
import { BaseService, pathParams } from '../index.js'
|
||||
|
||||
export default class Maintenance extends BaseService {
|
||||
static category = 'other'
|
||||
@ -8,18 +8,23 @@ export default class Maintenance extends BaseService {
|
||||
pattern: ':maintained/:year(\\d{4})',
|
||||
}
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: 'Maintenance',
|
||||
pattern: ':maintained(yes|no)/:year',
|
||||
namedParams: {
|
||||
maintained: 'yes',
|
||||
year: '2019',
|
||||
static openApi = {
|
||||
'/maintenance/{maintained}/{year}': {
|
||||
get: {
|
||||
summary: 'Maintenance',
|
||||
parameters: pathParams(
|
||||
{
|
||||
name: 'maintained',
|
||||
example: 'yes',
|
||||
},
|
||||
{
|
||||
name: 'year',
|
||||
example: '2019',
|
||||
},
|
||||
),
|
||||
},
|
||||
staticPreview: this.render({ isMaintained: false, targetYear: '2018' }),
|
||||
keywords: ['maintained'],
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static defaultBadgeData = {
|
||||
label: 'maintained',
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { pathParams } from '../index.js'
|
||||
import { age } from '../color-formatters.js'
|
||||
import { formatDate } from '../text-formatters.js'
|
||||
import OpenVSXBase from './open-vsx-base.js'
|
||||
@ -10,19 +11,23 @@ export default class OpenVSXReleaseDate extends OpenVSXBase {
|
||||
pattern: 'release-date/:namespace/:extension',
|
||||
}
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: 'Open VSX Release Date',
|
||||
namedParams: {
|
||||
namespace: 'redhat',
|
||||
extension: 'java',
|
||||
static openApi = {
|
||||
'/open-vsx/release-date/{namespace}/{extension}': {
|
||||
get: {
|
||||
summary: 'Open VSX Release Date',
|
||||
parameters: pathParams(
|
||||
{
|
||||
name: 'namespace',
|
||||
example: 'redhat',
|
||||
},
|
||||
{
|
||||
name: 'extension',
|
||||
example: 'java',
|
||||
},
|
||||
),
|
||||
},
|
||||
staticPreview: this.render({
|
||||
releaseDate: '2020-10-15T13:40:16.986723Z',
|
||||
}),
|
||||
keywords: this.keywords,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static defaultBadgeData = { label: 'release date' }
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { pathParams } from '../index.js'
|
||||
import { renderVersionBadge } from '../version.js'
|
||||
import OpenVSXBase from './open-vsx-base.js'
|
||||
|
||||
@ -9,14 +10,23 @@ export default class OpenVSXVersion extends OpenVSXBase {
|
||||
pattern: 'v/:namespace/:extension',
|
||||
}
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: 'Open VSX Version',
|
||||
namedParams: { namespace: 'redhat', extension: 'java' },
|
||||
staticPreview: this.render({ version: '0.69.0' }),
|
||||
keywords: this.keywords,
|
||||
static openApi = {
|
||||
'/open-vsx/v/{namespace}/{extension}': {
|
||||
get: {
|
||||
summary: 'Open VSX Version',
|
||||
parameters: pathParams(
|
||||
{
|
||||
name: 'namespace',
|
||||
example: 'redhat',
|
||||
},
|
||||
{
|
||||
name: 'extension',
|
||||
example: 'java',
|
||||
},
|
||||
),
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static render({ version }) {
|
||||
return renderVersionBadge({ version })
|
||||
|
Loading…
x
Reference in New Issue
Block a user