-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
npm run openapi-spec
to export the openapi spec
- Loading branch information
1 parent
6e669f6
commit dca78e1
Showing
19 changed files
with
286 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright IBM Corp. 2020. All Rights Reserved. | ||
// Node module: @loopback/example-access-control-migration | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
import {AccessControlApplication} from './application'; | ||
|
||
export async function migrate(args: string[]) { | ||
const existingSchema = args.includes('--rebuild') ? 'drop' : 'alter'; | ||
console.log('Migrating schemas (%s existing schema)', existingSchema); | ||
|
||
const app = new AccessControlApplication(); | ||
await app.boot(); | ||
await app.migrateSchema({existingSchema}); | ||
|
||
// Connectors usually keep a pool of opened connections, | ||
// this keeps the process running even after all work is done. | ||
// We need to exit explicitly. | ||
process.exit(0); | ||
} | ||
|
||
migrate(process.argv).catch(err => { | ||
console.error('Cannot migrate database schema', err); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright IBM Corp. 2020. All Rights Reserved. | ||
// Node module: @loopback/example-access-control-migration | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
import {ApplicationConfig} from '@loopback/core'; | ||
import {AccessControlApplication} 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 AccessControlApplication(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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright IBM Corp. 2020. All Rights Reserved. | ||
// Node module: @loopback/example-greeting-app | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
import {ApplicationConfig} from '@loopback/core'; | ||
import {GreetingApplication} 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 GreetingApplication(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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright IBM Corp. 2020. All Rights Reserved. | ||
// Node module: @loopback/example-lb3-application | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
import {ApplicationConfig} from '@loopback/core'; | ||
import {CoffeeShopApplication} 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 CoffeeShopApplication(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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright IBM Corp. 2020. All Rights Reserved. | ||
// Node module: @loopback/example-multi-tenancy | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
import {ApplicationConfig} from '@loopback/core'; | ||
import {ExampleMultiTenancyApplication} 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 ExampleMultiTenancyApplication(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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright IBM Corp. 2020. All Rights Reserved. | ||
// Node module: @loopback/example-rest-crud | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
import {ApplicationConfig} from '@loopback/core'; | ||
import {TodoApplication} 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 TodoApplication(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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright IBM Corp. 2020. All Rights Reserved. | ||
// Node module: @loopback/example-todo-jwt | ||
// 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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright IBM Corp. 2020. All Rights Reserved. | ||
// Node module: @loopback/example-todo-list | ||
// 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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright IBM Corp. 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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright IBM Corp. 2020. All Rights Reserved. | ||
// Node module: @loopback/example-validation-app | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
import {ApplicationConfig} from '@loopback/core'; | ||
import {ValidationApplication} 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 ValidationApplication(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); | ||
}); |