Skip to content

Commit

Permalink
fixup!: apply feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jannyHou committed Dec 19, 2019
1 parent 8a74cc6 commit 2435327
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions docs/site/Extending-OpenAPI-specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ For example, to modify the `info` field of an OAS, you can create an
```ts
import {bind} from '@loopback/core';
import {
defaultMergeFn,
mergeOpenAPISpec,
asSpecEnhancer,
OASEnhancer,
OpenApiSpec,
Expand All @@ -52,7 +52,7 @@ export class InfoSpecEnhancer implements OASEnhancer {
info: {title: 'LoopBack Test Application', version: '1.0.1'},
};
// the example calls a default helper function to merge the fragment spec.
const mergedSpec = defaultMergeFn(spec, InfoPatchSpec);
const mergedSpec = mergeOpenAPISpec(spec, InfoPatchSpec);
return mergedSpec;
}
}
Expand All @@ -64,7 +64,7 @@ export class InfoSpecEnhancer implements OASEnhancer {
[extension point section](#oas-enhancer-service-as-extension-point)).
- The enhancer changes the current specification's `info` object in function
`modifySpec`.
- It calls [`defaultMergeFn`](#default-merge-function) to merge the
- It calls [`mergeOpenAPISpec`](#default-merge-function) to merge the
specification fragment into the current spec.

### Default Merge Function
Expand All @@ -74,7 +74,7 @@ operation: merge, delete, or more complicated changes. This is totally
determined by the extension contributor.

To apply the basic merging, we provide a default helper function called
`defaultMergeFn` that leverages
`mergeOpenAPISpec` that leverages
[`json-merge-patch`](https://github.com/pierreinglebert/json-merge-patch) to
merge two json objects. You can find its usage in the
[previous section](#adding-a-new-oas-enhancer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import {bind} from '@loopback/core';
import debugModule from 'debug';
import {inspect} from 'util';
import {defaultMergeFn} from '../../../..';
import {mergeOpenAPISpec} from '../../../..';
import {asSpecEnhancer, OASEnhancer} from '../../../../enhancers/types';
import {OpenApiSpec} from '../../../../types';
const debug = debugModule('loopback:openapi:spec-enhancer');
Expand All @@ -22,7 +22,7 @@ export class InfoSpecEnhancer implements OASEnhancer {
const InfoPatchSpec = {
info: {title: 'LoopBack Test Application', version: '1.0.1'},
};
const mergedSpec = defaultMergeFn(spec, InfoPatchSpec);
const mergedSpec = mergeOpenAPISpec(spec, InfoPatchSpec);
debug(`security spec extension, merged spec: ${inspect(mergedSpec)}`);
return mergedSpec;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {bind} from '@loopback/core';
import debugModule from 'debug';
import {inspect} from 'util';
import {
defaultMergeFn,
mergeOpenAPISpec,
ReferenceObject,
SecuritySchemeObject,
} from '../../../..';
Expand Down Expand Up @@ -37,7 +37,7 @@ export class SecuritySpecEnhancer implements OASEnhancer {

modifySpec(spec: OpenApiSpec): OpenApiSpec {
const patchSpec = {components: {securitySchemes: SECURITY_SCHEME_SPEC}};
const mergedSpec = defaultMergeFn(spec, patchSpec);
const mergedSpec = mergeOpenAPISpec(spec, patchSpec);
debug(`security spec extension, merged spec: ${inspect(mergedSpec)}`);
return mergedSpec;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/openapi-v3/src/enhancers/spec-enhancer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class OASEnhancerService {
* @param currentSpec The original spec
* @param patchSpec The patch spec to be merged into the original spec
*/
export function defaultMergeFn(
export function mergeOpenAPISpec(
currentSpec: Partial<OpenApiSpec>,
patchSpec: Partial<OpenApiSpec>,
) {
Expand Down

0 comments on commit 2435327

Please sign in to comment.