migrate examples to openApi part 23; affects [wordpress] (#9732)
* migrate some services from examples to openApi * whoops. missed a spot
This commit is contained in:
@@ -85,7 +85,7 @@ export class BaseWordpress extends BaseJsonService {
|
||||
}
|
||||
}
|
||||
|
||||
export const documentation = `
|
||||
export const description = `
|
||||
<p>
|
||||
These badges rely on an API that is no longer supported by Wordpress. You are
|
||||
still free to use them, simply bear in mind that Shields.io cannot guarantee
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import Joi from 'joi'
|
||||
import { renderDownloadsBadge } from '../downloads.js'
|
||||
import { documentation, BaseWordpress } from './wordpress-base.js'
|
||||
import { pathParams } from '../index.js'
|
||||
import { description, BaseWordpress } from './wordpress-base.js'
|
||||
|
||||
const dateSchema = Joi.object()
|
||||
.pattern(Joi.date().iso(), Joi.number().integer())
|
||||
@@ -52,14 +53,28 @@ function DownloadsForExtensionType(extensionType) {
|
||||
pattern: ':interval(dd|dw|dm|dy|dt)/:slug',
|
||||
}
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: `WordPress ${capt} Downloads`,
|
||||
namedParams: { interval: 'dm', slug: exampleSlug },
|
||||
staticPreview: this.render({ interval: 'dm', downloads: 200000 }),
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
static get openApi() {
|
||||
const key = `/wordpress/${extensionType}/{interval}/{slug}`
|
||||
const route = {}
|
||||
route[key] = {
|
||||
get: {
|
||||
summary: `WordPress ${capt} Downloads`,
|
||||
description,
|
||||
parameters: pathParams(
|
||||
{
|
||||
name: 'interval',
|
||||
example: 'dm',
|
||||
schema: { type: 'string', enum: this.getEnum('interval') },
|
||||
},
|
||||
{
|
||||
name: 'slug',
|
||||
example: exampleSlug,
|
||||
},
|
||||
),
|
||||
},
|
||||
}
|
||||
return route
|
||||
}
|
||||
|
||||
static defaultBadgeData = { label: 'downloads' }
|
||||
|
||||
@@ -114,14 +129,21 @@ function InstallsForExtensionType(extensionType) {
|
||||
pattern: ':slug',
|
||||
}
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: `WordPress ${capt} Active Installs`,
|
||||
namedParams: { slug: exampleSlug },
|
||||
staticPreview: renderDownloadsBadge({ downloads: 300000 }),
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
static get openApi() {
|
||||
const key = `/wordpress/${extensionType}/installs/{slug}`
|
||||
const route = {}
|
||||
route[key] = {
|
||||
get: {
|
||||
summary: `WordPress ${capt} Active Installs`,
|
||||
description,
|
||||
parameters: pathParams({
|
||||
name: 'slug',
|
||||
example: exampleSlug,
|
||||
}),
|
||||
},
|
||||
}
|
||||
return route
|
||||
}
|
||||
|
||||
static defaultBadgeData = { label: 'active installs' }
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import dayjs from 'dayjs'
|
||||
import customParseFormat from 'dayjs/plugin/customParseFormat.js'
|
||||
import { InvalidResponse } from '../index.js'
|
||||
import { InvalidResponse, pathParams } from '../index.js'
|
||||
import { formatDate } from '../text-formatters.js'
|
||||
import { age as ageColor } from '../color-formatters.js'
|
||||
import { documentation, BaseWordpress } from './wordpress-base.js'
|
||||
import { description, BaseWordpress } from './wordpress-base.js'
|
||||
dayjs.extend(customParseFormat)
|
||||
|
||||
const extensionData = {
|
||||
@@ -32,14 +32,21 @@ function LastUpdateForType(extensionType) {
|
||||
pattern: ':slug',
|
||||
}
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: `WordPress ${capt} Last Updated`,
|
||||
namedParams: { slug: exampleSlug },
|
||||
staticPreview: this.render({ lastUpdated: '2020-08-11' }),
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
static get openApi() {
|
||||
const key = `/wordpress/${extensionType}/last-updated/{slug}`
|
||||
const route = {}
|
||||
route[key] = {
|
||||
get: {
|
||||
summary: `WordPress ${capt} Last Updated`,
|
||||
description,
|
||||
parameters: pathParams({
|
||||
name: 'slug',
|
||||
example: exampleSlug,
|
||||
}),
|
||||
},
|
||||
}
|
||||
return route
|
||||
}
|
||||
|
||||
static defaultBadgeData = { label: 'last updated' }
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NotFound } from '../index.js'
|
||||
import { NotFound, pathParams } from '../index.js'
|
||||
import { addv } from '../text-formatters.js'
|
||||
import { version as versionColor } from '../color-formatters.js'
|
||||
import { documentation, BaseWordpress } from './wordpress-base.js'
|
||||
import { description, BaseWordpress } from './wordpress-base.js'
|
||||
import { versionColorForWordpressVersion } from './wordpress-version-color.js'
|
||||
|
||||
const extensionData = {
|
||||
@@ -28,14 +28,21 @@ function WordpressRequiresVersion(extensionType) {
|
||||
pattern: ':slug',
|
||||
}
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: `WordPress ${capt}: Required WP Version`,
|
||||
namedParams: { slug: exampleSlug },
|
||||
staticPreview: this.render({ wordpressVersion: '4.8' }),
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
static get openApi() {
|
||||
const key = `/wordpress/${extensionType}/wp-version/{slug}`
|
||||
const route = {}
|
||||
route[key] = {
|
||||
get: {
|
||||
summary: `WordPress ${capt}: Required WP Version`,
|
||||
description,
|
||||
parameters: pathParams({
|
||||
name: 'slug',
|
||||
example: exampleSlug,
|
||||
}),
|
||||
},
|
||||
}
|
||||
return route
|
||||
}
|
||||
|
||||
static defaultBadgeData = { label: 'wordpress' }
|
||||
|
||||
@@ -71,16 +78,18 @@ class WordpressPluginTestedVersion extends BaseWordpress {
|
||||
pattern: ':slug',
|
||||
}
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: 'WordPress Plugin: Tested WP Version',
|
||||
namedParams: { slug: 'bbpress' },
|
||||
staticPreview: this.renderStaticPreview({
|
||||
testedVersion: '4.9.8',
|
||||
}),
|
||||
documentation,
|
||||
static openApi = {
|
||||
'/wordpress/plugin/tested/{slug}': {
|
||||
get: {
|
||||
summary: 'WordPress Plugin: Tested WP Version',
|
||||
description,
|
||||
parameters: pathParams({
|
||||
name: 'slug',
|
||||
example: 'bbpress',
|
||||
}),
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static defaultBadgeData = { label: 'wordpress' }
|
||||
|
||||
@@ -125,14 +134,21 @@ function RequiresPHPVersionForType(extensionType) {
|
||||
pattern: ':slug',
|
||||
}
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: `WordPress ${capt} Required PHP Version`,
|
||||
namedParams: { slug: exampleSlug },
|
||||
staticPreview: this.render({ version: '5.5' }),
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
static get openApi() {
|
||||
const key = `/wordpress/${extensionType}/required-php/{slug}`
|
||||
const route = {}
|
||||
route[key] = {
|
||||
get: {
|
||||
summary: `WordPress ${capt} Required PHP Version`,
|
||||
description,
|
||||
parameters: pathParams({
|
||||
name: 'slug',
|
||||
example: exampleSlug,
|
||||
}),
|
||||
},
|
||||
}
|
||||
return route
|
||||
}
|
||||
|
||||
static defaultBadgeData = { label: 'php' }
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { starRating, metric } from '../text-formatters.js'
|
||||
import { floorCount } from '../color-formatters.js'
|
||||
import { documentation, BaseWordpress } from './wordpress-base.js'
|
||||
import { pathParams } from '../index.js'
|
||||
import { starRating, metric } from '../text-formatters.js'
|
||||
import { description, BaseWordpress } from './wordpress-base.js'
|
||||
|
||||
const extensionData = {
|
||||
plugin: {
|
||||
@@ -30,17 +31,21 @@ function RatingForExtensionType(extensionType) {
|
||||
pattern: ':slug',
|
||||
}
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: `WordPress ${capt} Rating`,
|
||||
namedParams: { slug: exampleSlug },
|
||||
staticPreview: this.render({
|
||||
rating: 80,
|
||||
numRatings: 100,
|
||||
}),
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
static get openApi() {
|
||||
const key = `/wordpress/${extensionType}/rating/{slug}`
|
||||
const route = {}
|
||||
route[key] = {
|
||||
get: {
|
||||
summary: `WordPress ${capt} Rating`,
|
||||
description,
|
||||
parameters: pathParams({
|
||||
name: 'slug',
|
||||
example: exampleSlug,
|
||||
}),
|
||||
},
|
||||
}
|
||||
return route
|
||||
}
|
||||
|
||||
static render({ rating, numRatings }) {
|
||||
const scaledAndRounded = ((rating / 100) * 5).toFixed(1)
|
||||
@@ -71,17 +76,21 @@ function StarsForExtensionType(extensionType) {
|
||||
pattern: '(stars|r)/:slug',
|
||||
}
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: `WordPress ${capt} Rating`,
|
||||
pattern: 'stars/:slug',
|
||||
namedParams: { slug: exampleSlug },
|
||||
staticPreview: this.render({
|
||||
rating: 80,
|
||||
}),
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
static get openApi() {
|
||||
const key = `/wordpress/${extensionType}/stars/{slug}`
|
||||
const route = {}
|
||||
route[key] = {
|
||||
get: {
|
||||
summary: `WordPress ${capt} Stars`,
|
||||
description,
|
||||
parameters: pathParams({
|
||||
name: 'slug',
|
||||
example: exampleSlug,
|
||||
}),
|
||||
},
|
||||
}
|
||||
return route
|
||||
}
|
||||
|
||||
static render({ rating }) {
|
||||
const scaled = (rating / 100) * 5
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { pathParams } from '../index.js'
|
||||
import { addv } from '../text-formatters.js'
|
||||
import { version as versionColor } from '../color-formatters.js'
|
||||
import { documentation, BaseWordpress } from './wordpress-base.js'
|
||||
import { description, BaseWordpress } from './wordpress-base.js'
|
||||
|
||||
function VersionForExtensionType(extensionType) {
|
||||
const { capt, exampleSlug } = {
|
||||
@@ -24,14 +25,21 @@ function VersionForExtensionType(extensionType) {
|
||||
pattern: ':slug',
|
||||
}
|
||||
|
||||
static examples = [
|
||||
{
|
||||
title: `WordPress ${capt} Version`,
|
||||
namedParams: { slug: exampleSlug },
|
||||
staticPreview: this.render({ version: 2.5 }),
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
static get openApi() {
|
||||
const key = `/wordpress/${extensionType}/v/{slug}`
|
||||
const route = {}
|
||||
route[key] = {
|
||||
get: {
|
||||
summary: `WordPress ${capt} Version`,
|
||||
description,
|
||||
parameters: pathParams({
|
||||
name: 'slug',
|
||||
example: exampleSlug,
|
||||
}),
|
||||
},
|
||||
}
|
||||
return route
|
||||
}
|
||||
|
||||
static defaultBadgeData = { label: extensionType }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user