diff --git a/services/itunes/itunes.service.js b/services/itunes/itunes.service.js index bcb367bc8abd0..541ba5a8f988f 100644 --- a/services/itunes/itunes.service.js +++ b/services/itunes/itunes.service.js @@ -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' } diff --git a/services/jetbrains/jetbrains-downloads.service.js b/services/jetbrains/jetbrains-downloads.service.js index 5d2bcf6962df4..74f16d25c692e 100644 --- a/services/jetbrains/jetbrains-downloads.service.js +++ b/services/jetbrains/jetbrains-downloads.service.js @@ -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 diff --git a/services/jetbrains/jetbrains-version.service.js b/services/jetbrains/jetbrains-version.service.js index 252f611bef647..8d349167bc5c3 100644 --- a/services/jetbrains/jetbrains-version.service.js +++ b/services/jetbrains/jetbrains-version.service.js @@ -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' } diff --git a/services/jitpack/jitpack-version.service.js b/services/jitpack/jitpack-version.service.js index 7b088dbffeea1..136211e82abbd 100644 --- a/services/jitpack/jitpack-version.service.js +++ b/services/jitpack/jitpack-version.service.js @@ -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' } diff --git a/services/keybase/keybase-btc.service.js b/services/keybase/keybase-btc.service.js index 1ac8d87658a4b..1a2f8b0cb3584 100644 --- a/services/keybase/keybase-btc.service.js +++ b/services/keybase/keybase-btc.service.js @@ -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', diff --git a/services/keybase/keybase-pgp.service.js b/services/keybase/keybase-pgp.service.js index a6330ea373f00..a7b1cb2a7e995 100644 --- a/services/keybase/keybase-pgp.service.js +++ b/services/keybase/keybase-pgp.service.js @@ -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', diff --git a/services/keybase/keybase-xlm.service.js b/services/keybase/keybase-xlm.service.js index 11fe7a5ca530e..99e56e693b85e 100644 --- a/services/keybase/keybase-xlm.service.js +++ b/services/keybase/keybase-xlm.service.js @@ -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', diff --git a/services/keybase/keybase-zec.service.js b/services/keybase/keybase-zec.service.js index d8fdfd7236c1f..3afed7044db06 100644 --- a/services/keybase/keybase-zec.service.js +++ b/services/keybase/keybase-zec.service.js @@ -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', diff --git a/services/lemmy/lemmy.service.js b/services/lemmy/lemmy.service.js index c8ff71ea21abe..0a325cc43e535 100644 --- a/services/lemmy/lemmy.service.js +++ b/services/lemmy/lemmy.service.js @@ -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' } diff --git a/services/liberapay/liberapay-gives.service.js b/services/liberapay/liberapay-gives.service.js index 127a3a34e8509..4e6491b26c6cc 100644 --- a/services/liberapay/liberapay-gives.service.js +++ b/services/liberapay/liberapay-gives.service.js @@ -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 }) diff --git a/services/liberapay/liberapay-goal.service.js b/services/liberapay/liberapay-goal.service.js index 4c7ae71e42767..a1d9ce13aeeb2 100644 --- a/services/liberapay/liberapay-goal.service.js +++ b/services/liberapay/liberapay-goal.service.js @@ -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 { diff --git a/services/liberapay/liberapay-patrons.service.js b/services/liberapay/liberapay-patrons.service.js index dbcf4d8639637..b21d265306069 100644 --- a/services/liberapay/liberapay-patrons.service.js +++ b/services/liberapay/liberapay-patrons.service.js @@ -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 { diff --git a/services/liberapay/liberapay-receives.service.js b/services/liberapay/liberapay-receives.service.js index 7d828f90bd684..e44572c7f9b1f 100644 --- a/services/liberapay/liberapay-receives.service.js +++ b/services/liberapay/liberapay-receives.service.js @@ -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 }) diff --git a/services/luarocks/luarocks.service.js b/services/luarocks/luarocks.service.js index 15ed4501932e6..6bad664e23e6c 100644 --- a/services/luarocks/luarocks.service.js +++ b/services/luarocks/luarocks.service.js @@ -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', diff --git a/services/maintenance/maintenance.service.js b/services/maintenance/maintenance.service.js index e974e0ddc4e7e..929f9e4ae02d0 100644 --- a/services/maintenance/maintenance.service.js +++ b/services/maintenance/maintenance.service.js @@ -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', diff --git a/services/open-vsx/open-vsx-release-date.service.js b/services/open-vsx/open-vsx-release-date.service.js index c201306c8eb6a..5455bfaa1df99 100644 --- a/services/open-vsx/open-vsx-release-date.service.js +++ b/services/open-vsx/open-vsx-release-date.service.js @@ -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' } diff --git a/services/open-vsx/open-vsx-version.service.js b/services/open-vsx/open-vsx-version.service.js index 45f342a94c4e0..97b1880b3d943 100644 --- a/services/open-vsx/open-vsx-version.service.js +++ b/services/open-vsx/open-vsx-version.service.js @@ -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 })