Skip to content

Commit

Permalink
migrate examples to openApi part 8; affects [ubuntu uptimerobot vaadi…
Browse files Browse the repository at this point in the history
…n vcpkg visualstudiomarketplace wheelmap] (#9463)

* migrate some services from examples to openApi

* improve and de-dupe service titles
  • Loading branch information
chris48s authored Aug 31, 2023
1 parent 170d29e commit 2c07375
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 75 deletions.
33 changes: 26 additions & 7 deletions services/ubuntu/ubuntu.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, NotFound } from '../index.js'
import { BaseJsonService, NotFound, pathParams } from '../index.js'

const schema = Joi.object({
entries: Joi.array()
Expand All @@ -20,13 +20,32 @@ export default class Ubuntu extends BaseJsonService {
pattern: ':packageName/:series?',
}

static examples = [
{
title: 'Ubuntu package',
namedParams: { series: 'bionic', packageName: 'ubuntu-wallpapers' },
staticPreview: renderVersionBadge({ version: '18.04.1-0ubuntu1' }),
static openApi = {
'/ubuntu/v/{packageName}/{series}': {
get: {
summary: 'Ubuntu Package Version (for series)',
parameters: pathParams(
{
name: 'packageName',
example: 'ubuntu-wallpapers',
},
{
name: 'series',
example: 'bionic',
},
),
},
},
'/ubuntu/v/{packageName}': {
get: {
summary: 'Ubuntu Package Version',
parameters: pathParams({
name: 'packageName',
example: 'ubuntu-wallpapers',
}),
},
},
]
}

static defaultBadgeData = {
label: 'ubuntu',
Expand Down
17 changes: 10 additions & 7 deletions services/uptimerobot/uptimerobot-status.service.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { pathParams } from '../index.js'
import UptimeRobotBase from './uptimerobot-base.js'

export default class UptimeRobotStatus extends UptimeRobotBase {
Expand All @@ -6,15 +7,17 @@ export default class UptimeRobotStatus extends UptimeRobotBase {
pattern: ':monitorSpecificKey',
}

static examples = [
{
title: 'Uptime Robot status',
namedParams: {
monitorSpecificKey: 'm778918918-3e92c097147760ee39d02d36',
static openApi = {
'/uptimerobot/status/{monitorSpecificKey}': {
get: {
summary: 'Uptime Robot status',
parameters: pathParams({
name: 'monitorSpecificKey',
example: 'm778918918-3e92c097147760ee39d02d36',
}),
},
staticPreview: this.render({ status: 2 }),
},
]
}

static defaultBadgeData = {
label: 'status',
Expand Down
19 changes: 11 additions & 8 deletions services/vaadin-directory/vaadin-directory-rating-count.service.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { pathParams } from '../index.js'
import { metric } from '../text-formatters.js'
import { floorCount as floorCountColor } from '../color-formatters.js'
import { BaseVaadinDirectoryService } from './vaadin-directory-base.js'
Expand All @@ -10,15 +11,17 @@ export default class VaadinDirectoryRatingCount extends BaseVaadinDirectoryServi
pattern: ':alias(rc|rating-count)/:packageName',
}

static examples = [
{
title: 'Vaadin Directory',
pattern: 'rating-count/:packageName',
namedParams: { packageName: 'vaadinvaadin-grid' },
staticPreview: this.render({ ratingCount: 6 }),
keywords: ['vaadin-directory', 'rating-count'],
static openApi = {
'/vaadin-directory/rating-count/{packageName}': {
get: {
summary: 'Vaadin Directory Rating Count',
parameters: pathParams({
name: 'packageName',
example: 'vaadinvaadin-grid',
}),
},
},
]
}

static defaultBadgeData = {
label: 'rating count',
Expand Down
19 changes: 11 additions & 8 deletions services/vaadin-directory/vaadin-directory-release-date.service.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { pathParams } from '../index.js'
import { formatDate } from '../text-formatters.js'
import { age as ageColor } from '../color-formatters.js'
import { BaseVaadinDirectoryService } from './vaadin-directory-base.js'
Expand All @@ -10,15 +11,17 @@ export default class VaadinDirectoryReleaseDate extends BaseVaadinDirectoryServi
pattern: ':alias(rd|release-date)/:packageName',
}

static examples = [
{
title: 'Vaadin Directory',
pattern: 'release-date/:packageName',
namedParams: { packageName: 'vaadinvaadin-grid' },
staticPreview: this.render({ date: '2018-12-12' }),
keywords: ['vaadin-directory', 'date', 'latest release date'],
static openApi = {
'/vaadin-directory/release-date/{packageName}': {
get: {
summary: 'Vaadin Directory Release Date',
parameters: pathParams({
name: 'packageName',
example: 'vaadinvaadin-grid',
}),
},
},
]
}

static defaultBadgeData = {
label: 'latest release date',
Expand Down
18 changes: 11 additions & 7 deletions services/vaadin-directory/vaadin-directory-status.service.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { pathParams } from '../index.js'
import { BaseVaadinDirectoryService } from './vaadin-directory-base.js'

export default class VaadinDirectoryStatus extends BaseVaadinDirectoryService {
Expand All @@ -8,14 +9,17 @@ export default class VaadinDirectoryStatus extends BaseVaadinDirectoryService {
pattern: ':packageName',
}

static examples = [
{
title: 'Vaadin Directory',
namedParams: { packageName: 'vaadinvaadin-grid' },
staticPreview: this.render({ status: 'published' }),
keywords: ['vaadin-directory', 'status'],
static openApi = {
'/vaadin-directory/status/{packageName}': {
get: {
summary: 'Vaadin Directory Status',
parameters: pathParams({
name: 'packageName',
example: 'vaadinvaadin-grid',
}),
},
},
]
}

static defaultBadgeData = {
label: 'vaadin directory',
Expand Down
19 changes: 11 additions & 8 deletions services/vaadin-directory/vaadin-directory-version.service.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { pathParams } from '../index.js'
import { renderVersionBadge } from '../version.js'
import { BaseVaadinDirectoryService } from './vaadin-directory-base.js'

Expand All @@ -9,15 +10,17 @@ export default class VaadinDirectoryVersion extends BaseVaadinDirectoryService {
pattern: ':alias(v|version)/:packageName',
}

static examples = [
{
title: 'Vaadin Directory',
pattern: 'v/:packageName',
namedParams: { packageName: 'vaadinvaadin-grid' },
staticPreview: renderVersionBadge({ version: 'v5.3.0-alpha4' }),
keywords: ['vaadin-directory', 'latest'],
static openApi = {
'/vaadin-directory/v/{packageName}': {
get: {
summary: 'Vaadin Directory Version',
parameters: pathParams({
name: 'packageName',
example: 'vaadinvaadin-grid',
}),
},
},
]
}

static defaultBadgeData = {
label: 'vaadin directory',
Expand Down
18 changes: 11 additions & 7 deletions services/vcpkg/vcpkg-version.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Joi from 'joi'
import { ConditionalGithubAuthV3Service } from '../github/github-auth-service.js'
import { fetchJsonFromRepo } from '../github/github-common-fetch.js'
import { renderVersionBadge } from '../version.js'
import { NotFound } from '../index.js'
import { NotFound, pathParams } from '../index.js'
import { parseVersionFromVcpkgManifest } from './vcpkg-version-helpers.js'

// Handle the different version fields available in Vcpkg manifests
Expand All @@ -29,13 +29,17 @@ export default class VcpkgVersion extends ConditionalGithubAuthV3Service {

static route = { base: 'vcpkg/v', pattern: ':portName' }

static examples = [
{
title: 'Vcpkg',
namedParams: { portName: 'entt' },
staticPreview: this.render({ version: '3.11.1' }),
static openApi = {
'/vcpkg/v/{portName}': {
get: {
summary: 'Vcpkg Version',
parameters: pathParams({
name: 'portName',
example: 'entt',
}),
},
},
]
}

static defaultBadgeData = { label: 'vcpkg' }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { pathParams } from '../index.js'
import { age } from '../color-formatters.js'
import { formatDate } from '../text-formatters.js'
import VisualStudioMarketplaceBase from './visual-studio-marketplace-base.js'
Expand All @@ -11,15 +12,17 @@ export default class VisualStudioMarketplaceLastUpdated extends VisualStudioMark
'(visual-studio-marketplace|vscode-marketplace)/last-updated/:extensionId',
}

static examples = [
{
title: 'Visual Studio Marketplace Last Updated',
pattern: 'visual-studio-marketplace/last-updated/:extensionId',
namedParams: { extensionId: 'yasht.terminal-all-in-one' },
staticPreview: this.render({ lastUpdated: '2019-04-13T07:50:27.000Z' }),
keywords: this.keywords,
static openApi = {
'/visual-studio-marketplace/last-updated/{extensionId}': {
get: {
summary: 'Visual Studio Marketplace Last Updated',
parameters: pathParams({
name: 'extensionId',
example: 'yasht.terminal-all-in-one',
}),
},
},
]
}

static defaultBadgeData = {
label: 'last updated',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { pathParams } from '../index.js'
import { age } from '../color-formatters.js'
import { formatDate } from '../text-formatters.js'
import VisualStudioMarketplaceBase from './visual-studio-marketplace-base.js'
Expand All @@ -11,15 +12,17 @@ export default class VisualStudioMarketplaceReleaseDate extends VisualStudioMark
'(visual-studio-marketplace|vscode-marketplace)/release-date/:extensionId',
}

static examples = [
{
title: 'Visual Studio Marketplace Release Date',
pattern: 'visual-studio-marketplace/release-date/:extensionId',
namedParams: { extensionId: 'yasht.terminal-all-in-one' },
staticPreview: this.render({ releaseDate: '2019-04-13T07:50:27.000Z' }),
keywords: this.keywords,
static openApi = {
'/visual-studio-marketplace/release-date/{extensionId}': {
get: {
summary: 'Visual Studio Marketplace Release Date',
parameters: pathParams({
name: 'extensionId',
example: 'yasht.terminal-all-in-one',
}),
},
},
]
}

static defaultBadgeData = {
label: 'release date',
Expand Down
18 changes: 11 additions & 7 deletions services/wheelmap/wheelmap.service.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Joi from 'joi'
import { BaseJsonService } from '../index.js'
import { BaseJsonService, pathParams } from '../index.js'

const schema = Joi.object({
node: Joi.object({
Expand All @@ -21,13 +21,17 @@ export default class Wheelmap extends BaseJsonService {
isRequired: true,
}

static examples = [
{
title: 'Wheelmap',
namedParams: { nodeId: '26699541' },
staticPreview: this.render({ accessibility: 'yes' }),
static openApi = {
'/wheelmap/a/{nodeId}': {
get: {
summary: 'Wheelmap',
parameters: pathParams({
name: 'nodeId',
example: '26699541',
}),
},
},
]
}

static defaultBadgeData = { label: 'accessibility' }

Expand Down

0 comments on commit 2c07375

Please sign in to comment.