* add helper functions for generating Open API path/query params with defaults * tweak Open API schema - make description optional - allow null example + allowEmptyValue (for boolean query params) * convert examples --> openApi in amo * convert examples --> openApi in ansible * convert examples --> openApi in appveyor build/job * add re-usable Open API query param for test-results badges we can use these for all the 'test results' badges * convert examples --> openApi in appveyor tests * DRY up existing dynamic/endpoint param definitions * DRY up queryParam * allow enum param in serviceDefinition schema * improve misleading param name * check route and openApi are consistent on service load * fix mistake in ansible role route * documentation --> description * add pathParams and queryParams helpers +docstrings * give everything a search-friendly summary, check for duplicate summary * prettier fixup
43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
import { renderBuildStatusBadge } from '../build-status.js'
|
|
import { pathParams } from '../index.js'
|
|
import AppVeyorBase from './appveyor-base.js'
|
|
|
|
export default class AppVeyorBuild extends AppVeyorBase {
|
|
static route = this.buildRoute('appveyor/build')
|
|
|
|
static openApi = {
|
|
'/appveyor/build/{user}/{repo}': {
|
|
get: {
|
|
summary: 'AppVeyor Build',
|
|
parameters: pathParams(
|
|
{ name: 'user', example: 'gruntjs' },
|
|
{ name: 'repo', example: 'grunt' },
|
|
),
|
|
},
|
|
},
|
|
'/appveyor/build/{user}/{repo}/{branch}': {
|
|
get: {
|
|
summary: 'AppVeyor Build (with branch)',
|
|
parameters: pathParams(
|
|
{ name: 'user', example: 'gruntjs' },
|
|
{ name: 'repo', example: 'grunt' },
|
|
{ name: 'branch', example: 'master' },
|
|
),
|
|
},
|
|
},
|
|
}
|
|
|
|
static render({ status }) {
|
|
return renderBuildStatusBadge({ status })
|
|
}
|
|
|
|
async handle({ user, repo, branch }) {
|
|
const data = await this.fetch({ user, repo, branch })
|
|
if (!('build' in data)) {
|
|
// this project exists but no builds have been run on it yet
|
|
return this.constructor.render({ status: 'no builds found' })
|
|
}
|
|
return this.constructor.render({ status: data.build.status })
|
|
}
|
|
}
|