Skip to content

Commit

Permalink
bugfix: checking http statuscode from swagger endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
frankthelen committed Jan 19, 2018
1 parent 2b373e0 commit 39c7d1b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,17 @@ const register = async (server, {
});
// Pre-compile static html page at server startup
try {
const { payload: swaggerJson } = await server.inject({
const { payload, statusCode } = await server.inject({
url: swaggerEndpoint,
headers,
});
await writeFile(fileSwaggerJson, swaggerJson);
await createHtml(bootprintOptions);
server.log(['info'], 'static swagger documentation successfully pre-compiled');
if (statusCode === 200) {
await writeFile(fileSwaggerJson, payload);
await createHtml(bootprintOptions);
server.log(['info'], 'static swagger documentation successfully pre-compiled');
} else {
server.log(['error'], `error requesting ${swaggerEndpoint}: http ${statusCode}`);
}
} catch (error) {
server.log(['error'], error);
}
Expand Down

0 comments on commit 39c7d1b

Please sign in to comment.