From 9c06d96a12a3a6dd97751c8eaa43626a713ab415 Mon Sep 17 00:00:00 2001 From: jannyHou Date: Mon, 1 Jan 2018 17:23:35 -0500 Subject: [PATCH] refactor: rename files --- packages/openapi-specgen/README.md | 78 +++++++++++++++++++ .../metadata.ts => controller-spec.ts} | 0 packages/openapi-specgen/src/index.ts | 2 +- .../controller-decorators.test.ts | 0 .../param-decorators}/param-body.test.ts | 0 .../param-decorators}/param-form-data.test.ts | 0 .../param-decorators}/param-header.test.ts | 0 .../param-decorators}/param-path.test.ts | 0 .../param-decorators}/param-query.test.ts | 0 .../param-decorators}/param.test.ts | 0 10 files changed, 79 insertions(+), 1 deletion(-) rename packages/openapi-specgen/src/{decorators/controller-decorators/metadata.ts => controller-spec.ts} (100%) rename packages/openapi-specgen/test/unit/{decorators => controller-spec}/controller-decorators.test.ts (100%) rename packages/openapi-specgen/test/unit/{decorators/controller-decorators/metadata => controller-spec/controller-decorators/param-decorators}/param-body.test.ts (100%) rename packages/openapi-specgen/test/unit/{decorators/controller-decorators/metadata => controller-spec/controller-decorators/param-decorators}/param-form-data.test.ts (100%) rename packages/openapi-specgen/test/unit/{decorators/controller-decorators/metadata => controller-spec/controller-decorators/param-decorators}/param-header.test.ts (100%) rename packages/openapi-specgen/test/unit/{decorators/controller-decorators/metadata => controller-spec/controller-decorators/param-decorators}/param-path.test.ts (100%) rename packages/openapi-specgen/test/unit/{decorators/controller-decorators/metadata => controller-spec/controller-decorators/param-decorators}/param-query.test.ts (100%) rename packages/openapi-specgen/test/unit/{decorators/controller-decorators/metadata => controller-spec/controller-decorators/param-decorators}/param.test.ts (100%) diff --git a/packages/openapi-specgen/README.md b/packages/openapi-specgen/README.md index e69de29bb2d1..2cb18f93580a 100644 --- a/packages/openapi-specgen/README.md +++ b/packages/openapi-specgen/README.md @@ -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 \ No newline at end of file diff --git a/packages/openapi-specgen/src/decorators/controller-decorators/metadata.ts b/packages/openapi-specgen/src/controller-spec.ts similarity index 100% rename from packages/openapi-specgen/src/decorators/controller-decorators/metadata.ts rename to packages/openapi-specgen/src/controller-spec.ts diff --git a/packages/openapi-specgen/src/index.ts b/packages/openapi-specgen/src/index.ts index 19f4d4b2b5d4..a7896a77e358 100644 --- a/packages/openapi-specgen/src/index.ts +++ b/packages/openapi-specgen/src/index.ts @@ -1 +1 @@ -export * from './decorators/controller-decorators/metadata'; +export * from './controller-spec'; diff --git a/packages/openapi-specgen/test/unit/decorators/controller-decorators.test.ts b/packages/openapi-specgen/test/unit/controller-spec/controller-decorators.test.ts similarity index 100% rename from packages/openapi-specgen/test/unit/decorators/controller-decorators.test.ts rename to packages/openapi-specgen/test/unit/controller-spec/controller-decorators.test.ts diff --git a/packages/openapi-specgen/test/unit/decorators/controller-decorators/metadata/param-body.test.ts b/packages/openapi-specgen/test/unit/controller-spec/controller-decorators/param-decorators/param-body.test.ts similarity index 100% rename from packages/openapi-specgen/test/unit/decorators/controller-decorators/metadata/param-body.test.ts rename to packages/openapi-specgen/test/unit/controller-spec/controller-decorators/param-decorators/param-body.test.ts diff --git a/packages/openapi-specgen/test/unit/decorators/controller-decorators/metadata/param-form-data.test.ts b/packages/openapi-specgen/test/unit/controller-spec/controller-decorators/param-decorators/param-form-data.test.ts similarity index 100% rename from packages/openapi-specgen/test/unit/decorators/controller-decorators/metadata/param-form-data.test.ts rename to packages/openapi-specgen/test/unit/controller-spec/controller-decorators/param-decorators/param-form-data.test.ts diff --git a/packages/openapi-specgen/test/unit/decorators/controller-decorators/metadata/param-header.test.ts b/packages/openapi-specgen/test/unit/controller-spec/controller-decorators/param-decorators/param-header.test.ts similarity index 100% rename from packages/openapi-specgen/test/unit/decorators/controller-decorators/metadata/param-header.test.ts rename to packages/openapi-specgen/test/unit/controller-spec/controller-decorators/param-decorators/param-header.test.ts diff --git a/packages/openapi-specgen/test/unit/decorators/controller-decorators/metadata/param-path.test.ts b/packages/openapi-specgen/test/unit/controller-spec/controller-decorators/param-decorators/param-path.test.ts similarity index 100% rename from packages/openapi-specgen/test/unit/decorators/controller-decorators/metadata/param-path.test.ts rename to packages/openapi-specgen/test/unit/controller-spec/controller-decorators/param-decorators/param-path.test.ts diff --git a/packages/openapi-specgen/test/unit/decorators/controller-decorators/metadata/param-query.test.ts b/packages/openapi-specgen/test/unit/controller-spec/controller-decorators/param-decorators/param-query.test.ts similarity index 100% rename from packages/openapi-specgen/test/unit/decorators/controller-decorators/metadata/param-query.test.ts rename to packages/openapi-specgen/test/unit/controller-spec/controller-decorators/param-decorators/param-query.test.ts diff --git a/packages/openapi-specgen/test/unit/decorators/controller-decorators/metadata/param.test.ts b/packages/openapi-specgen/test/unit/controller-spec/controller-decorators/param-decorators/param.test.ts similarity index 100% rename from packages/openapi-specgen/test/unit/decorators/controller-decorators/metadata/param.test.ts rename to packages/openapi-specgen/test/unit/controller-spec/controller-decorators/param-decorators/param.test.ts