-
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.
- Loading branch information
Showing
10 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
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,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 |
File renamed without changes.
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 |
---|---|---|
@@ -1 +1 @@ | ||
export * from './decorators/controller-decorators/metadata'; | ||
export * from './controller-spec'; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.