-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathopenapi-spec.ts
More file actions
28 lines (25 loc) · 876 Bytes
/
openapi-spec.ts
File metadata and controls
28 lines (25 loc) · 876 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright IBM Corp. and LoopBack contributors 2018,2020. All Rights Reserved.
// Node module: @loopback/example-todo
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
import {ApplicationConfig} from '@loopback/core';
import {TodoListApplication} from './application';
/**
* Export the OpenAPI spec from the application
*/
async function exportOpenApiSpec(): Promise<void> {
const config: ApplicationConfig = {
rest: {
port: +(process.env.PORT ?? 3000),
host: process.env.HOST ?? 'localhost',
},
};
const outFile = process.argv[2] ?? '';
const app = new TodoListApplication(config);
await app.boot();
await app.exportOpenApiSpec(outFile);
}
exportOpenApiSpec().catch(err => {
console.error('Fail to export OpenAPI spec from the application.', err);
process.exit(1);
});