Skip to content

Commit

Permalink
refactor: rename files
Browse files Browse the repository at this point in the history
  • Loading branch information
jannyHou committed Jan 2, 2018
1 parent 1f727f5 commit 72b7a9b
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 1 deletion.
78 changes: 78 additions & 0 deletions packages/openapi-specgen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
@loopback/openapi-specgen

Utilities that tranfer LoopBack remoting metadata to swagger specifications

## Overview



## Installation

```
$ npm install --save @loopback/openapi-specgen
```

## Basic use

Currently this package only has spec generator for controllers.
It generates swagger `paths` and `basePath` specs for a given decorated controller class.

Here is an example of calling function `getControllerSpec` to generate the swagger spec:

```js
import {api, getControllerSpec} from '@loopback/openapi-specgen';

@api(somePathSpec)
class MyController {
greet() {
return 'Hello world!';
}
}

const myControllerSpec = getControllerSpec(MyController);
```

then the `myControllerSpec` will be:
```js
{
swagger: '2.0',
basePath: '/',
info: { title: 'LoopBack Application', version: '1.0.0' },
paths: {
'/greet': {
get: {
responses: {
'200': {
description: 'The string result.',
schema: { type: 'string' }
}
},
'x-operation-name': 'greet'
}
}
}
}
```

For details of how to apply controller decorators, please check http://loopback.io/doc/en/lb4/Decorators.html#route-decorators

## Related resources

See https://www.openapis.org/ and [version 2.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md)
of OpenAPI Specification.

## Contributions

IBM/StrongLoop is an active supporter of open source and welcomes contributions to our projects as well as those of the Node.js community in general. For more information on how to contribute please refer to the [Contribution Guide](https://loopback.io/doc/en/contrib/index.html).

# Tests

run `npm test` from the root folder.

# Contributors

See [all contributors](https://github.com/strongloop/loopback-next/graphs/contributors).

# License

MIT
2 changes: 1 addition & 1 deletion packages/openapi-specgen/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './decorators/controller-decorators/metadata';
export * from './controller-spec';

0 comments on commit 72b7a9b

Please sign in to comment.