Skip to content

Commit

Permalink
fixup!: improve api method
Browse files Browse the repository at this point in the history
Signed-off-by: jannyHou <juehou@ca.ibm.com>
  • Loading branch information
jannyHou committed Sep 16, 2019
1 parent 6283c6b commit 9e0bd5f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
16 changes: 7 additions & 9 deletions packages/shopping/src/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ export class ShoppingApplication extends BootMixin(
) {
constructor(options?: ApplicationConfig) {
super(options);
this.api({
openapi: '3.0.0',
info: {title: pkg.name, version: pkg.version},
paths: {},
components: {securitySchemas: SECURITY_SCHEMA_SPEC},
security: SECURITY_SPEC,
});

this.setUpBindings();

Expand Down Expand Up @@ -103,14 +110,5 @@ export class ShoppingApplication extends BootMixin(

async start(): Promise<void> {
await super.start();
const oaiSpec = this.getSync(RestBindings.API_SPEC);
this.api(
Object.assign(oaiSpec, {
components: {
...SECURITY_SCHEMA_SPEC,
},
security: SECURITY_SPEC,
}),
);
}
}
18 changes: 8 additions & 10 deletions packages/shopping/src/utils/security-spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
export const SECURITY_SPEC = [{bearerAuth: []}];
export const SECURITY_SPEC_OPERATION = [{basicAuth: []}];
export const SECURITY_SCHEMA_SPEC = {
securitySchemes: {
bearerAuth: {
type: 'http',
scheme: 'bearer',
bearerFormat: 'JWT',
},
basicAuth: {
type: 'http',
scheme: 'basic',
},
bearerAuth: {
type: 'http',
scheme: 'bearer',
bearerFormat: 'JWT',
},
basicAuth: {
type: 'http',
scheme: 'basic',
},
};

0 comments on commit 9e0bd5f

Please sign in to comment.