Skip to content

Commit

Permalink
feat(openapi-v3): export a constant for the default openapi spec info
Browse files Browse the repository at this point in the history
Signed-off-by: Raymond Feng <enjoyjava@gmail.com>
  • Loading branch information
raymondfeng committed Sep 14, 2020
1 parent 9fe798f commit fce91a2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 6 additions & 3 deletions packages/openapi-v3/src/enhancers/spec-enhancer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import {config, extensionPoint, extensions, Getter} from '@loopback/core';
import debugModule from 'debug';
import * as _ from 'lodash';
import {inspect} from 'util';
import {OpenApiSpec, SecuritySchemeObject} from '../types';
import {
DEFAULT_OPENAPI_SPEC_INFO,
OpenApiSpec,
SecuritySchemeObject,
} from '../types';
import {OASEnhancerBindings} from './keys';
import {OASEnhancer} from './types';
const jsonmergepatch = require('json-merge-patch');
Expand Down Expand Up @@ -48,8 +52,7 @@ export class OASEnhancerService {
private _spec: OpenApiSpec = {
openapi: '3.0.0',
info: {
title: 'LoopBack Application',
version: '1.0.0',
...DEFAULT_OPENAPI_SPEC_INFO,
},
paths: {},
};
Expand Down
8 changes: 6 additions & 2 deletions packages/openapi-v3/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ export type OpenApiSpec = OpenAPIObject;
// Export also all spec interfaces
export * from 'openapi3-ts';

export const DEFAULT_OPENAPI_SPEC_INFO = {
title: 'LoopBack Application',
version: '1.0.0',
};

/**
* Create an empty OpenApiSpec object that's still a valid openapi document.
*
Expand All @@ -27,8 +32,7 @@ export function createEmptyApiSpec(): OpenApiSpec {
return {
openapi: '3.0.0',
info: {
title: 'LoopBack Application',
version: '1.0.0',
...DEFAULT_OPENAPI_SPEC_INFO,
},
paths: {},
servers: [{url: '/'}],
Expand Down

0 comments on commit fce91a2

Please sign in to comment.