-
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(rest): add openapi enhancer service
add openapi spec enhancer to rest server impl. #4380 Signed-off-by: Douglas McConnachie <[email protected]>
- Loading branch information
1 parent
fe3df1b
commit 62d55eb
Showing
3 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
packages/rest/src/__tests__/unit/rest.server/fixtures/info.spec.extension.ts
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,33 @@ | ||
// Copyright IBM Corp. 2019. All Rights Reserved. | ||
// Node module: @loopback/openapi-v3 | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
import {bind} from '@loopback/core'; | ||
import debugModule from 'debug'; | ||
import {inspect} from 'util'; | ||
import { | ||
asSpecEnhancer, | ||
mergeOpenAPISpec, | ||
OASEnhancer, | ||
OpenApiSpec, | ||
} from '../../../..'; | ||
|
||
const debug = debugModule('loopback:openapi:spec-enhancer'); | ||
|
||
/** | ||
* A spec enhancer to add OpenAPI info spec | ||
*/ | ||
@bind(asSpecEnhancer) | ||
export class InfoSpecEnhancer implements OASEnhancer { | ||
name = 'info'; | ||
|
||
modifySpec(spec: OpenApiSpec): OpenApiSpec { | ||
const InfoPatchSpec = { | ||
info: {title: 'LoopBack Test Application', version: '1.0.1'}, | ||
}; | ||
const mergedSpec = mergeOpenAPISpec(spec, InfoPatchSpec); | ||
debug(`security spec extension, merged spec: ${inspect(mergedSpec)}`); | ||
return mergedSpec; | ||
} | ||
} |
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