Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

feat: adding a new metrics-enabled extension #104

Merged
merged 2 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { default as Oas, Operation } from 'oas';
export const CODE_SAMPLES = 'code-samples';
export const EXPLORER_ENABLED = 'explorer-enabled';
export const HEADERS = 'headers';
export const METRICS_ENABLED = 'metrics-enabled';
export const PROXY_ENABLED = 'proxy-enabled';
export const SAMPLES_ENABLED = 'samples-enabled';
export const SAMPLES_LANGUAGES = 'samples-languages';
Expand All @@ -20,6 +21,7 @@ export type Extensions = {
};
[EXPLORER_ENABLED]: boolean;
[HEADERS]: Record<string, string | number>[];
[METRICS_ENABLED]: boolean;
[PROXY_ENABLED]: boolean;
[SAMPLES_ENABLED]: boolean; // @deprecated
[SAMPLES_LANGUAGES]: string[];
Expand All @@ -31,6 +33,7 @@ export const defaults: Extensions = {
[CODE_SAMPLES]: undefined,
[EXPLORER_ENABLED]: true,
[HEADERS]: undefined,
[METRICS_ENABLED]: true,
[PROXY_ENABLED]: true,
[SAMPLES_ENABLED]: true,
[SAMPLES_LANGUAGES]: ['shell', 'node', 'ruby', 'php', 'python', 'java', 'csharp'],
Expand Down
4 changes: 3 additions & 1 deletion test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ describe('oas-extensions', function () {
'CODE_SAMPLES',
'EXPLORER_ENABLED',
'HEADERS',
'METRICS_ENABLED',
'PROXY_ENABLED',
'SAMPLES_ENABLED',
'SAMPLES_LANGUAGES',
'SEND_DEFAULTS',
'SIMPLE_MODE',
].forEach(extension => {
it(`\`${extension}\` extension should have a default value`, function () {
expect(extensions[extension] in extensions.defaults).to.be.true;
expect(extensions.defaults).to.have.property(extensions[extension]);
});
});

Expand Down Expand Up @@ -156,6 +157,7 @@ describe('oas-extensions', function () {
['EXPLORER_ENABLED', true, 'false', 'Boolean'],
['HEADERS', [{ key: 'X-API-Key', value: 'abc123' }], false, 'Array'],
['PROXY_ENABLED', true, 'yes', 'Boolean'],
['METRICS_ENABLED', false, 'no', 'Boolean'],
['SAMPLES_ENABLED', true, 'no', 'Boolean'],
['SAMPLES_LANGUAGES', ['swift'], {}, 'Array'],
['SEND_DEFAULTS', true, 'absolutely not', 'Boolean'],
Expand Down