-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrate some services from examples to openApi (#9737)
- Loading branch information
Showing
5 changed files
with
143 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, pathParam, queryParam } from '../index.js' | ||
|
||
const schema = Joi.object({ | ||
size: Joi.object({ | ||
|
@@ -11,18 +11,16 @@ const queryParamSchema = Joi.object({ | |
exports: Joi.string(), | ||
}).required() | ||
|
||
const keywords = ['node', 'bundlejs'] | ||
|
||
const esbuild = | ||
'<a href="https://github.com/evanw/esbuild" target="_blank" rel="noopener">esbuild</a>' | ||
const denoflate = | ||
'<a href="https://github.com/hazae41/denoflate" target="_blank" rel="noopener">denoflate</a>' | ||
const bundlejs = | ||
'<a href="https://bundlejs.com/" target="_blank" rel="noopener">bundlejs</a>' | ||
|
||
const documentation = ` | ||
const description = ` | ||
<p> | ||
View ${esbuild} minified and ${denoflate} gzipped size of a package or selected exports, via ${bundlejs}. | ||
View ${esbuild} minified and ${denoflate} gzipped size of a javascript package or selected exports, via ${bundlejs}. | ||
</p> | ||
` | ||
|
||
|
@@ -35,67 +33,48 @@ export default class BundlejsPackage extends BaseJsonService { | |
queryParamSchema, | ||
} | ||
|
||
static examples = [ | ||
{ | ||
title: 'npm package minimized gzipped size', | ||
pattern: ':packageName', | ||
namedParams: { | ||
packageName: 'react', | ||
}, | ||
staticPreview: this.render({ size: '2.94 kB' }), | ||
keywords, | ||
documentation, | ||
}, | ||
{ | ||
title: 'npm package minimized gzipped size (version)', | ||
pattern: ':packageName', | ||
namedParams: { | ||
packageName: '[email protected]', | ||
}, | ||
staticPreview: this.render({ size: '2.94 kB' }), | ||
keywords, | ||
documentation, | ||
}, | ||
{ | ||
title: 'npm package minimized gzipped size (scoped)', | ||
pattern: ':scope/:packageName', | ||
namedParams: { | ||
scope: '@cycle', | ||
packageName: 'rx-run', | ||
static openApi = { | ||
'/bundlejs/size/{packageName}': { | ||
get: { | ||
summary: 'npm package minimized gzipped size', | ||
description, | ||
parameters: [ | ||
pathParam({ | ||
name: 'packageName', | ||
example: '[email protected]', | ||
description: | ||
'This can either be a package name e.g: `value-enhancer`, or a package name and version e.g: `[email protected]`', | ||
}), | ||
queryParam({ | ||
name: 'exports', | ||
example: 'isVal,val', | ||
}), | ||
], | ||
}, | ||
staticPreview: this.render({ size: '32.3 kB' }), | ||
keywords, | ||
documentation, | ||
}, | ||
{ | ||
title: 'npm package minimized gzipped size (select exports)', | ||
pattern: ':packageName', | ||
namedParams: { | ||
packageName: 'value-enhancer', | ||
'/bundlejs/size/{scope}/{packageName}': { | ||
get: { | ||
summary: 'npm package minimized gzipped size (scoped)', | ||
description, | ||
parameters: [ | ||
pathParam({ | ||
name: 'scope', | ||
example: '@ngneat', | ||
}), | ||
pathParam({ | ||
name: 'packageName', | ||
example: '[email protected]', | ||
description: | ||
'This can either be a package name e.g: `falso`, or a package name and version e.g: `[email protected]`', | ||
}), | ||
queryParam({ | ||
name: 'exports', | ||
example: 'randEmail,randFullName', | ||
}), | ||
], | ||
}, | ||
queryParams: { | ||
exports: 'isVal,val', | ||
}, | ||
staticPreview: this.render({ size: '823 B' }), | ||
keywords, | ||
documentation, | ||
}, | ||
{ | ||
title: | ||
'npm package minimized gzipped size (scoped version select exports)', | ||
pattern: ':scope/:packageName', | ||
namedParams: { | ||
scope: '@ngneat', | ||
packageName: '[email protected]', | ||
}, | ||
queryParams: { | ||
exports: 'randEmail,randFullName', | ||
}, | ||
staticPreview: this.render({ size: '17.8 kB' }), | ||
keywords, | ||
documentation, | ||
}, | ||
] | ||
} | ||
|
||
static defaultBadgeData = { label: 'bundlejs', color: 'informational' } | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters