Skip to content

Commit

Permalink
migrate examples to openApi part5; affects [itunes jetbrains jitp…
Browse files Browse the repository at this point in the history
…ack 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>
  • Loading branch information
chris48s and PyvesB authored Aug 21, 2023
1 parent 6823d38 commit 4f67ab7
Show file tree
Hide file tree
Showing 17 changed files with 211 additions and 147 deletions.
18 changes: 11 additions & 7 deletions services/itunes/itunes.service.js
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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' }

Expand Down
17 changes: 10 additions & 7 deletions services/jetbrains/jetbrains-downloads.service.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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
Expand Down
17 changes: 10 additions & 7 deletions services/jetbrains/jetbrains-version.service.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Joi from 'joi'
import { pathParams } from '../index.js'
import { renderVersionBadge } from '../version.js'
import JetbrainsBase from './jetbrains-base.js'

Expand Down Expand Up @@ -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' }

Expand Down
26 changes: 16 additions & 10 deletions services/jitpack/jitpack-version.service.js
Original file line number Diff line number Diff line change
@@ -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(),
Expand All @@ -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' }

Expand Down
20 changes: 11 additions & 9 deletions services/keybase/keybase-btc.service.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Joi from 'joi'
import { pathParams } from '../index.js'
import { nonNegativeInteger } from '../validators.js'
import KeybaseProfile from './keybase-profile.js'

Expand Down Expand Up @@ -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',
Expand Down
17 changes: 11 additions & 6 deletions services/keybase/keybase-pgp.service.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Joi from 'joi'
import { pathParams } from '../index.js'
import { nonNegativeInteger } from '../validators.js'
import KeybaseProfile from './keybase-profile.js'

Expand Down Expand Up @@ -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',
Expand Down
20 changes: 11 additions & 9 deletions services/keybase/keybase-xlm.service.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Joi from 'joi'
import { pathParams } from '../index.js'
import { nonNegativeInteger } from '../validators.js'
import KeybaseProfile from './keybase-profile.js'

Expand Down Expand Up @@ -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',
Expand Down
20 changes: 11 additions & 9 deletions services/keybase/keybase-zec.service.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Joi from 'joi'
import { pathParams } from '../index.js'
import { nonNegativeInteger } from '../validators.js'
import KeybaseProfile from './keybase-profile.js'

Expand Down Expand Up @@ -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',
Expand Down
21 changes: 11 additions & 10 deletions services/lemmy/lemmy.service.js
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -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' }

Expand Down
22 changes: 11 additions & 11 deletions services/liberapay/liberapay-gives.service.js
Original file line number Diff line number Diff line change
@@ -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 })
Expand Down
18 changes: 11 additions & 7 deletions services/liberapay/liberapay-goal.service.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
17 changes: 11 additions & 6 deletions services/liberapay/liberapay-patrons.service.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import { pathParams } from '../index.js'
import { metric } from '../text-formatters.js'
import { colorScale } from '../color-formatters.js'
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 {
Expand Down
Loading

0 comments on commit 4f67ab7

Please sign in to comment.