Skip to content

Commit

Permalink
migrate examples to openApi part 7; affects [reuse sourceforge source…
Browse files Browse the repository at this point in the history
…graph spack stackexchange testspace treeware twitch] (#9464)

* migrate some services from examples to openApi

* capitalize all words in sourceforge titles
  • Loading branch information
chris48s authored Sep 4, 2023
1 parent d179816 commit 0bc5127
Show file tree
Hide file tree
Showing 15 changed files with 189 additions and 138 deletions.
19 changes: 10 additions & 9 deletions services/reuse/reuse-compliance.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'
import { isReuseCompliance, COLOR_MAP } from './reuse-compliance-helper.js'

const responseSchema = Joi.object({
Expand All @@ -14,16 +14,17 @@ export default class Reuse extends BaseJsonService {
pattern: ':remote+',
}

static examples = [
{
title: 'REUSE Compliance',
namedParams: {
remote: 'github.com/fsfe/reuse-tool',
static openApi = {
'/reuse/compliance/{remote}': {
get: {
summary: 'REUSE Compliance',
parameters: pathParams({
name: 'remote',
example: 'github.com/fsfe/reuse-tool',
}),
},
staticPreview: this.render({ status: 'compliant' }),
keywords: ['license'],
},
]
}

static defaultBadgeData = {
label: 'reuse',
Expand Down
20 changes: 10 additions & 10 deletions services/sourceforge/sourceforge-commit-count.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'
import { metric } from '../text-formatters.js'

const schema = Joi.object({
Expand All @@ -14,17 +14,17 @@ export default class SourceforgeCommitCount extends BaseJsonService {
pattern: ':project',
}

static examples = [
{
title: 'SourceForge commit count',
namedParams: {
project: 'guitarix',
static openApi = {
'/sourceforge/commit-count/{project}': {
get: {
summary: 'SourceForge Commit Count',
parameters: pathParams({
name: 'project',
example: 'guitarix',
}),
},
staticPreview: this.render({
commitCount: 1365,
}),
},
]
}

static defaultBadgeData = { label: 'commit count' }

Expand Down
19 changes: 10 additions & 9 deletions services/sourceforge/sourceforge-contributors.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 { renderContributorBadge } from '../contributor-count.js'
import BaseSourceForgeService from './sourceforge-base.js'

Expand All @@ -14,17 +15,17 @@ export default class SourceforgeContributors extends BaseSourceForgeService {
pattern: ':project',
}

static examples = [
{
title: 'SourceForge contributors',
namedParams: {
project: 'guitarix',
static openApi = {
'/sourceforge/contributors/{project}': {
get: {
summary: 'SourceForge Contributors',
parameters: pathParams({
name: 'project',
example: 'guitarix',
}),
},
staticPreview: this.render({
contributorCount: 9,
}),
},
]
}

static defaultBadgeData = { label: 'contributors' }

Expand Down
17 changes: 10 additions & 7 deletions services/sourceforge/sourceforge-languages.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 { metric } from '../text-formatters.js'
import BaseSourceForgeService from './sourceforge-base.js'

Expand All @@ -16,15 +17,17 @@ export default class SourceforgeLanguages extends BaseSourceForgeService {
pattern: ':project',
}

static examples = [
{
title: 'SourceForge languages',
namedParams: {
project: 'mingw',
static openApi = {
'/sourceforge/languages/{project}': {
get: {
summary: 'SourceForge Languages',
parameters: pathParams({
name: 'project',
example: 'mingw',
}),
},
staticPreview: this.render(6),
},
]
}

static defaultBadgeData = { label: 'languages' }

Expand Down
20 changes: 10 additions & 10 deletions services/sourceforge/sourceforge-last-commit.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'
import { formatDate } from '../text-formatters.js'
import { age as ageColor } from '../color-formatters.js'

Expand All @@ -21,17 +21,17 @@ export default class SourceforgeLastCommit extends BaseJsonService {
pattern: ':project',
}

static examples = [
{
title: 'SourceForge last commit',
namedParams: {
project: 'guitarix',
static openApi = {
'/sourceforge/last-commit/{project}': {
get: {
summary: 'SourceForge Last Commit',
parameters: pathParams({
name: 'project',
example: 'guitarix',
}),
},
staticPreview: this.render({
commitDate: 1653556285,
}),
},
]
}

static defaultBadgeData = { label: 'last commit' }

Expand Down
19 changes: 10 additions & 9 deletions services/sourceforge/sourceforge-platform.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 BaseSourceForgeService from './sourceforge-base.js'

const schema = Joi.object({
Expand All @@ -19,17 +20,17 @@ export default class SourceforgePlatform extends BaseSourceForgeService {
pattern: ':project',
}

static examples = [
{
title: 'SourceForge Platform',
namedParams: {
project: 'guitarix',
static openApi = {
'/sourceforge/platform/{project}': {
get: {
summary: 'SourceForge Platform',
parameters: pathParams({
name: 'project',
example: 'guitarix',
}),
},
staticPreview: this.render({
platforms: ['linux', 'bsd'],
}),
},
]
}

static defaultBadgeData = { label: 'platform' }

Expand Down
19 changes: 10 additions & 9 deletions services/sourceforge/sourceforge-translations.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 { metric } from '../text-formatters.js'
import BaseSourceForgeService from './sourceforge-base.js'

Expand All @@ -16,17 +17,17 @@ export default class SourceforgeTranslations extends BaseSourceForgeService {
pattern: ':project',
}

static examples = [
{
title: 'SourceForge Translations',
namedParams: {
project: 'guitarix',
static openApi = {
'/sourceforge/translations/{project}': {
get: {
summary: 'SourceForge Translations',
parameters: pathParams({
name: 'project',
example: 'guitarix',
}),
},
staticPreview: this.render({
translationCount: 4,
}),
},
]
}

static defaultBadgeData = { label: 'translations' }

Expand Down
19 changes: 10 additions & 9 deletions services/sourcegraph/sourcegraph.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 projectsCountRegex = /^\s[0-9]*(\.[0-9]k)?\sprojects$/
const schema = Joi.object({
Expand All @@ -14,16 +14,17 @@ export default class Sourcegraph extends BaseJsonService {
pattern: ':repo(.*?)',
}

static examples = [
{
title: 'Sourcegraph for Repo Reference Count',
pattern: ':repo',
namedParams: {
repo: 'github.com/gorilla/mux',
static openApi = {
'/sourcegraph/rrc/{repo}': {
get: {
summary: 'Sourcegraph for Repo Reference Count',
parameters: pathParams({
name: 'repo',
example: 'github.com/gorilla/mux',
}),
},
staticPreview: this.render({ projectsCount: '9.9k projects' }),
},
]
}

static defaultBadgeData = { color: 'brightgreen', label: 'used by' }

Expand Down
19 changes: 11 additions & 8 deletions services/spack/spack.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({
latest_version: Joi.string().required(),
}).required()
Expand All @@ -13,14 +13,17 @@ export default class SpackVersion extends BaseJsonService {
pattern: ':packageName',
}

static examples = [
{
title: 'Spack',
namedParams: { packageName: 'adios2' },
staticPreview: this.render({ version: '2.8.0' }),
keywords: ['hpc'],
static openApi = {
'/spack/v/{packageName}': {
get: {
summary: 'Spack',
parameters: pathParams({
name: 'packageName',
example: 'adios2',
}),
},
},
]
}

static defaultBadgeData = { label: 'spack' }

Expand Down
28 changes: 17 additions & 11 deletions services/stackexchange/stackexchange-monthlyquestions.service.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import dayjs from 'dayjs'
import Joi from 'joi'
import { pathParams } from '../index.js'
import { nonNegativeInteger } from '../validators.js'
import {
renderQuestionsBadge,
Expand All @@ -16,18 +17,23 @@ export default class StackExchangeMonthlyQuestions extends StackExchangeBase {
pattern: ':stackexchangesite/qm/:query',
}

static examples = [
{
title: 'Stack Exchange monthly questions',
namedParams: { stackexchangesite: 'stackoverflow', query: 'dayjs' },
staticPreview: this.render({
stackexchangesite: 'stackoverflow',
query: 'dayjs',
numValue: 2000,
}),
keywords: ['stackexchange', 'stackoverflow'],
static openApi = {
'/stackexchange/{stackexchangesite}/qm/{query}': {
get: {
summary: 'Stack Exchange monthly questions',
parameters: pathParams(
{
name: 'stackexchangesite',
example: 'stackoverflow',
},
{
name: 'query',
example: 'dayjs',
},
),
},
},
]
}

static render(props) {
return renderQuestionsBadge({
Expand Down
27 changes: 17 additions & 10 deletions services/stackexchange/stackexchange-reputation.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 { metric } from '../text-formatters.js'
import { floorCount as floorCountColor } from '../color-formatters.js'
import { StackExchangeBase } from './stackexchange-base.js'
Expand All @@ -20,17 +21,23 @@ export default class StackExchangeReputation extends StackExchangeBase {
pattern: ':stackexchangesite/r/:query',
}

static examples = [
{
title: 'Stack Exchange reputation',
namedParams: { stackexchangesite: 'stackoverflow', query: '123' },
staticPreview: this.render({
stackexchangesite: 'stackoverflow',
numValue: 10,
}),
keywords: ['stackexchange', 'stackoverflow'],
static openApi = {
'/stackexchange/{stackexchangesite}/r/{query}': {
get: {
summary: 'Stack Exchange reputation',
parameters: pathParams(
{
name: 'stackexchangesite',
example: 'stackoverflow',
},
{
name: 'query',
example: '123',
},
),
},
},
]
}

static render({ stackexchangesite, numValue }) {
const label = `${stackexchangesite} reputation`
Expand Down
Loading

0 comments on commit 0bc5127

Please sign in to comment.