Skip to content

Commit aee3675

Browse files
author
Damien Guerin
committed
filter parameter becomes a regex
1 parent 21f27bd commit aee3675

File tree

7 files changed

+36
-23
lines changed

7 files changed

+36
-23
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ Global Options
125125
126126
-c, --config string Configuration file in JSON or YAML format where specifications are defined, default
127127
is config.json
128-
-f, --filter string Manage only one specification defined by its name (`api.info.title`) rather use the
129-
whole of enabled specifications declared
128+
-f, --filter string Manage some specifications defined by its name (`api.info.title`) and which match
129+
with this regex filter rather use the whole of enabled specifications declared
130130
into configuration file
131131
-v, --verbose Verbose mode, default is false
132132
-a, --urlDownloadTemplate string Rather to use specs from local FS, you can specify remote specs (using 'artifact'
@@ -177,8 +177,8 @@ Global Options
177177
178178
-c, --config string Configuration file in JSON or YAML format where specifications are defined, default
179179
is config.json
180-
-f, --filter string Manage only one specification defined by its name (`api.info.title`) rather use the
181-
whole of enabled specifications declared
180+
-f, --filter string Manage some specifications defined by its name (`api.info.title`) and which match
181+
with this regex filter rather use the whole of enabled specifications declared
182182
into configuration file
183183
-v, --verbose Verbose mode, default is false
184184
-a, --urlDownloadTemplate string Rather to use specs from local FS, you can specify remote specs (using 'artifact'
@@ -216,8 +216,8 @@ Global Options
216216
217217
-c, --config string Configuration file in JSON or YAML format where specifications are defined, default
218218
is config.json
219-
-f, --filter string Manage only one specification defined by its name (`api.info.title`) rather use the
220-
whole of enabled specifications declared
219+
-f, --filter string Manage some specifications defined by its name (`api.info.title`) and which match
220+
with this regex filter rather use the whole of enabled specifications declared
221221
into configuration file
222222
-v, --verbose Verbose mode, default is false
223223
-a, --urlDownloadTemplate string Rather to use specs from local FS, you can specify remote specs (using 'artifact'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lyra-network/openapi-dev-tool",
3-
"version": "9.10.0",
3+
"version": "9.10.1",
44
"description": "OpenAPI Development tool",
55
"main": "src/lib.js",
66
"scripts": {

src/commands/merge.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@ export function merge(config = { config: { specs: [] } }) {
3131
const api = await bundleSpec(config, spec);
3232

3333
// Apply filter if it is defined
34-
if (config.filter && api.info.title !== config.filter) {
35-
console.log("\tspec '%s': ignored by filter", api.info.title);
36-
resolve();
37-
return;
34+
if (config.filter) {
35+
const regex = new RegExp(config.filter);
36+
if (!regex.test(api.info.title)) {
37+
console.log("\tspec '%s': ignored by filter", api.info.title);
38+
resolve();
39+
return;
40+
}
3841
}
3942

4043
const outputDir = getOutputDirFromConfig(config);

src/commands/publish-local.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@ export function publishLocal(config = { config: { specs: [] } }) {
3131
const api = await bundleSpec(config, spec);
3232

3333
// Apply filter if it is defined
34-
if (config.filter && api.info.title !== config.filter) {
35-
console.log("\tspec '%s': ignored by filter", api.info.title);
36-
resolve();
37-
return;
34+
if (config.filter) {
35+
const regex = new RegExp(config.filter);
36+
if (!regex.test(api.info.title)) {
37+
console.log("\tspec '%s': ignored by filter", api.info.title);
38+
resolve();
39+
return;
40+
}
3841
}
3942

4043
let fileToArchive = spec.file;

src/commands/publish.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,13 @@ export function publish(config = { config: { specs: [] } }) {
3030
const api = await bundleSpec(config, spec);
3131

3232
// Apply filter if it is defined
33-
if (config.filter && api.info.title !== config.filter) {
34-
console.log("\tspec '%s': ignored by filter", api.info.title);
35-
resolve();
36-
return;
33+
if (config.filter) {
34+
const regex = new RegExp(config.filter);
35+
if (!regex.test(api.info.title)) {
36+
console.log("\tspec '%s': ignored by filter", api.info.title);
37+
resolve();
38+
return;
39+
}
3740
}
3841

3942
const tempDir = getTempDir();

src/lib/config-definitions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const globalOptionsDefinitions = [
4646
alias: 'f',
4747
type: String,
4848
description:
49-
'Manage only one specification defined by its name (`api.info.title`) rather use the whole of enabled specifications declared into configuration file',
49+
'Manage some specifications defined by its name (`api.info.title`) and which match with this regex filter rather use the whole of enabled specifications declared into configuration file',
5050
},
5151
{
5252
name: 'verbose',

src/lib/specs.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ export function loadSpecs(config) {
3232
} else {
3333
api = YAML.parse(raw);
3434
}
35-
if (config.filter && api.info.title !== config.filter) {
36-
console.log("\tspec '%s': ignored by filter", api.info.title);
37-
return false;
35+
// Apply filter if it is defined
36+
if (config.filter) {
37+
const regex = new RegExp(config.filter);
38+
if (!regex.test(api.info.title)) {
39+
console.log("\tspec '%s': ignored by filter", api.info.title);
40+
return;
41+
}
3842
}
3943
spec.api = api;
4044
return true;

0 commit comments

Comments
 (0)