Skip to content

Commit

Permalink
Merge pull request #231 from jrel/master
Browse files Browse the repository at this point in the history
feat: add timeout option

Fixes #230
  • Loading branch information
luisfpg authored Mar 19, 2020
2 parents e2e57c1 + 483c1cb commit d46114d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
15 changes: 15 additions & 0 deletions ng-swagger-gen
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ argParser.addArgument(
dest: "genConfig"
}
);
argParser.addArgument(
["--timeout"],
{
help: "The amount of time (in milliseconds) to wait for a response from the" +
" server when downloading files. The default is 20 seconds.",
type: "int",
dest: "timeout"
}
);
var args = argParser.parseArgs();

var config = args.config;
Expand All @@ -87,6 +96,9 @@ if (args.genConfig) {
if (args.output) {
options.output = args.output;
}
if (args.timeout) {
options.timeout = args.timeout;
}
run(options);
} else if (args.swagger) {
// The args variables are the same one as the options
Expand Down Expand Up @@ -155,5 +167,8 @@ function run(options) {
if (options.customFileSuffix == null) {
options.customFileSuffix = schema.properties.customFileSuffix.default;
}
if (options.timeout == null) {
options.timeout = schema.properties.timeout.default;
}
ngSwaggerGen(options);
}
5 changes: 5 additions & 0 deletions ng-swagger-gen-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@
"example": ".example",
"service": ".service"
}
},
"timeout":{
"description": "The amount of time (in milliseconds) to wait for a response from the server when downloading files. The default is 20 seconds.",
"type": "number",
"default": 20000
}
}
}
2 changes: 1 addition & 1 deletion ng-swagger-gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function ngSwaggerGen(options) {

$RefParser.bundle(options.swagger,
{ dereference: { circular: false },
resolve: { http: { timeout: 20000 } } }).then(
resolve: { http: { timeout: options.timeout } } }).then(
data => {
doGenerate(data, options);
},
Expand Down

0 comments on commit d46114d

Please sign in to comment.