Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/authentication/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@loopback/authentication",
"version": "4.0.0-alpha.1",
"description": "",
"main": "index",
"scripts": {
"acceptance": "mocha --opts ../../test/mocha.opts 'test/acceptance/**/*.ts'",
"integration": "mocha --opts ../../test/mocha.opts 'test/integration/**/*.ts'",
"test": "mocha --opts ../../test/mocha.opts 'test/unit/**/*.ts' 'test/integration/**/*.ts' 'test/acceptance/**/*.ts'",
"unit": "mocha --opts ../../test/mocha.opts 'test/unit/**/*.ts'"
},
"author": "IBM",
"license": "MIT",
"dependencies": {
},
"devDependencies": {
"@loopback/openapi-spec-builder": "^4.0.0-alpha.1",
"@loopback/testlab": "^4.0.0-alpha.1",
"mocha": "^3.2.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import {Application, Server, api, OpenApiSpec, ParameterObject, OperationObject} from 'loopback';
import {Client} from 'loopback/test/support/client';
import {expect} from 'testlab';
import {givenOpenApiSpec} from 'loopback/test/support/OpenApiSpecBuilder';
import {givenOpenApiSpec} from '@loopback/openapi-spec-builder';

/* # Feature: Routing
* - In order to build REST APIs
Expand Down
1 change: 1 addition & 0 deletions packages/loopback/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"path-to-regexp": "^1.7.0"
},
"devDependencies": {
"@loopback/openapi-spec-builder": "^4.0.0-alpha.1",
"@loopback/testlab": "^4.0.0-alpha.1",
"mocha": "^3.2.0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import {Application, Server, api, OpenApiSpec, ParameterObject, OperationObject} from '../../..';
import {Client} from './../../support/client';
import {expect} from 'testlab';
import {givenOpenApiSpec} from '../../support/OpenApiSpecBuilder';
import {givenOpenApiSpec} from '@loopback/openapi-spec-builder';
import {inject} from '@loopback/context';

/* # Feature: Routing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as bluebird from 'bluebird';
import {expect} from 'testlab';
import {listen} from '../../support/util';
import {OpenApiSpec, ParameterObject} from '@loopback/openapi-spec';
import {givenOpenApiSpec} from '../../support/OpenApiSpecBuilder';
import {givenOpenApiSpec} from '@loopback/openapi-spec-builder';

describe('SwaggerRouter', () => {
beforeEach(givenRouter);
Expand Down
25 changes: 25 additions & 0 deletions packages/openapi-spec-builder/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Copyright (c) IBM Corp. 2013,2017. All Rights Reserved.
Node module: @loopback/openapi-spec-builder
This project is licensed under the MIT License, full text below.

--------

MIT license

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
74 changes: 74 additions & 0 deletions packages/openapi-spec-builder/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# @loopback/openapi-spec-builder

Make it easy to create OpenAPI (Swagger) specification documents in your
tests using the builder pattern.

## Overview

Creating a full OpenAPI spec document in automated tests is rather cumbersome,
long JSON-like objects pollute the test test code and make it difficult
for readers to distinguish between what's important in the test and what's just
shared swagger boilerplate.

OpenApiSpecBuilder utilizes
[Test Data Builder pattern](http://www.natpryce.com/articles/000714.html)
to provide a TypeScript/JavaScript API allowing users to create
full OpenAPI Spec documents in few lines of code.

## Installation

```shell
$ npm install --save-dev @loopback/openapi-spec-builder
```

_This package is typically used in tests, save it to `devDependencies` via `--save-dev`._

## Basic use

```ts
import {givenOpenApiSpec, OpenApiSpecBuilder} from '@loopback/openapi-spec-builder';

const spec = givenOpenApiSpec()
.withOperationReturningString('get', '/hello', 'greet')
.build();

// which is equivalent to the following longer form

const spec = new OpenApiSpecBuilder()
.withOperation('get', '/hello', {
'x-operation-name': 'greet',
responses: {
'200': { type: 'string' },
},
})
.build();

// the spec

const spec = {
basePath: '/',
paths: {
'/hello': {
get: {
'x-operation-name': 'greet',
responses: {
'200': { type: 'string' },
},
}
}
}
};
```

## 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).

## License

MIT
6 changes: 6 additions & 0 deletions packages/openapi-spec-builder/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright IBM Corp. 2013,2017. All Rights Reserved.
// Node module: @loopback/openapi-spec
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

export * from './src/OpenApiSpecBuilder';
17 changes: 17 additions & 0 deletions packages/openapi-spec-builder/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "@loopback/openapi-spec-builder",
"version": "4.0.0-alpha.1",
"description": "Make it easy to create OpenAPI (Swagger) specification documents in your tests using the builder pattern.",
"author": "IBM",
"license": "MIT",
"keywords": [
"Swagger",
"OpenAPI Spec",
"TypeScript",
"Builder",
"Testing"
],
"dependencies": {
"@loopback/openapi-spec": "^4.0.0-alpha.1"
}
}