migrate some services from examples to openApi part 28; affects [aur cran mastodon matrix npmstat nyc thunderstore twitter] (#9855)

* migrate some services from examples to openApi

* always use capitals in period/interval description
This commit is contained in:
chris48s
2023-12-31 14:14:57 +00:00
committed by GitHub
parent 04254e5905
commit bfa712469a
13 changed files with 232 additions and 169 deletions

View File

@@ -1,5 +1,10 @@
import Joi from 'joi'
import { BaseJsonService, InvalidParameter } from '../index.js'
import {
BaseJsonService,
InvalidParameter,
pathParam,
queryParam,
} from '../index.js'
const queryParamSchema = Joi.object({
server_fqdn: Joi.string().hostname(),
@@ -26,12 +31,12 @@ const matrixStateSchema = Joi.array()
)
.required()
const documentation = `
const description = `
<p>
In order for this badge to work, the host of your room must allow guest accounts or dummy accounts to register, and the room must be world readable (chat history visible to anyone).
<br>
<br />
The following steps will show you how to setup the badge URL using the Element Matrix client.
<br>
<br />
<ul>
<li>Select the desired room inside the Element client</li>
<li>Click on the room settings button (gear icon) located near the top right of the client</li>
@@ -41,11 +46,11 @@ const documentation = `
<li>Remove the starting hash character (<code>#</code>)</li>
<li>The final badge URL should look something like this <code>/matrix/twim:matrix.org.svg</code></li>
</ul>
<br>
<br />
Some Matrix homeservers don't hold a server name matching where they live (e.g. if the homeserver <code>example.com</code> that created the room alias <code>#mysuperroom:example.com</code> lives at <code>matrix.example.com</code>).
<br>
<br />
If that is the case of the homeserver that created the room alias used for generating the badge, you will need to add the server's FQDN (fully qualified domain name) as a query parameter.
<br>
<br />
The final badge URL should then look something like this <code>/matrix/mysuperroom:example.com.svg?server_fqdn=matrix.example.com</code>.
</p>
`
@@ -59,21 +64,24 @@ export default class Matrix extends BaseJsonService {
queryParamSchema,
}
static examples = [
{
title: 'Matrix',
namedParams: { roomAlias: 'twim:matrix.org' },
staticPreview: this.render({ members: 42 }),
documentation,
static openApi = {
'/matrix/{roomAlias}': {
get: {
summary: 'Matrix',
description,
parameters: [
pathParam({
name: 'roomAlias',
example: 'twim:matrix.org',
}),
queryParam({
name: 'server_fqdn',
example: 'matrix.org',
}),
],
},
},
{
title: 'Matrix',
namedParams: { roomAlias: 'twim:matrix.org' },
queryParams: { server_fqdn: 'matrix.org' },
staticPreview: this.render({ members: 42 }),
documentation,
},
]
}
static _cacheLength = 30