Skip to content

Commit

Permalink
Merge adc6f13 into e7878dc
Browse files Browse the repository at this point in the history
  • Loading branch information
Romakita committed Oct 10, 2020
2 parents e7878dc + adc6f13 commit f3aecb4
Show file tree
Hide file tree
Showing 92 changed files with 10,047 additions and 601 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -79,7 +79,7 @@
"consolidate": "0.16.0"
},
"devDependencies": {
"@tsed/monorepo-utils": "1.9.5",
"@tsed/monorepo-utils": "1.10.0",
"@typedproject/ts-doc": "4.0.9",
"@types/chai": "4.2.12",
"@types/chai-as-promised": "7.1.3",
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/interfaces/HashOf.ts
@@ -0,0 +1 @@
export type HashOf<T> = {[key: string]: T};
1 change: 1 addition & 0 deletions packages/core/src/interfaces/index.ts
Expand Up @@ -3,3 +3,4 @@ export * from "./Env";
export * from "./DecoratorParameters";
export * from "./MetadataTypes";
export * from "./ValueOf";
export * from "./HashOf";
9 changes: 6 additions & 3 deletions packages/core/src/utils/deepExtends.ts
@@ -1,13 +1,16 @@
import {HashOf} from "../interfaces/HashOf";
import {classOf, isArrayOrArrayClass, isPrimitive, isPrimitiveOrPrimitiveClass} from "./ObjectUtils";

export type DeepExtendsReducers = HashOf<(collection: any[], value: any) => any>;

/**
*
* Deep extends a model with another one.
* @param out
* @param obj
* @param {{[p: string]: (collection: any[], value: any) => any}} reducers
* @param reducers
* @returns {any}
*/
export function deepExtends(out: any, obj: any, reducers: {[key: string]: (collection: any[], value: any) => any} = {}): any {
export function deepExtends(out: any, obj: any, reducers: DeepExtendsReducers = {}): any {
if (obj === undefined || obj === null) {
return out;
}
Expand Down
4 changes: 4 additions & 0 deletions packages/openspec/.npmignore
@@ -0,0 +1,4 @@
src
test
tsconfig.compile.json
tsconfig.json
24 changes: 24 additions & 0 deletions packages/openspec/package.json
@@ -0,0 +1,24 @@
{
"name": "@tsed/openspec",
"version": "6.0.0-beta.13",
"description": "OpenSpec2 and OpenSpec3 interfaces declarations for TypeScript application",
"main": "./lib/index.js",
"typings": "./lib/index.d.ts",
"keywords": [
"TypeScript",
"interfaces",
"OpenSpec",
"open-spec",
"swagger",
"OAS3",
"OAS2",
"JsonSchema"
],
"dependencies": {},
"scripts": {
"build": "tsc --build tsconfig.compile.json"
},
"private": false,
"devDependencies": {},
"peerDependencies": {}
}
60 changes: 60 additions & 0 deletions packages/openspec/readme.md
@@ -0,0 +1,60 @@
# @tsed/openspec

[![Build Status](https://travis-ci.org/TypedProject/tsed.svg?branch=master)](https://travis-ci.org/TypedProject/tsed)
[![Coverage Status](https://coveralls.io/repos/github/TypedProject/tsed/badge.svg?branch=production)](https://coveralls.io/github/TypedProject/tsed?branch=production)
[![Known Vulnerabilities](https://snyk.io/test/github/TypedProject/tsed/badge.svg)](https://snyk.io/test/github/TypedProject/tsed)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![backers](https://opencollective.com/tsed/tiers/badge.svg)](https://opencollective.com/tsed)

> A package of Ts.ED framework. See website: https://tsed.io/
OpenSpec2 and OpenSpec3 interfaces declarations for TypeScript application.

## Documentation

Documentation is available on [https://tsed.io](https://tsed.io/tutorials/swagger.html)

## Installation

You can get the latest release and the type definitions using npm:

```bash
npm install --save @tsed/openspec
```

## Usage

```typescript
import {OpenSpec3, OpenSpec2} from "@tsed/openspec";

const spec3: OpenSpec3 = { openapi: '3.0.1', paths: {}};
const spec2: OpenSpec2 = { swagger: '2.0', paths: {}};
```

## Contributors
Please read [contributing guidelines here](https://tsed.io/CONTRIBUTING.html)

<a href="https://github.com/TypedProject/ts-express-decorators/graphs/contributors"><img src="https://opencollective.com/tsed/contributors.svg?width=890" /></a>

## Backers

Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/tsed#backer)]

<a href="https://opencollective.com/tsed#backers" target="_blank"><img src="https://opencollective.com/tsed/tiers/backer.svg?width=890"></a>

## Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/tsed#sponsor)]

## License

The MIT License (MIT)

Copyright (c) 2016 - 2018 Romain Lenzotti

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.
10 changes: 10 additions & 0 deletions packages/openspec/src/common/OpenSpecExternalDocs.ts
@@ -0,0 +1,10 @@
export interface OpenSpecExternalDocs {
/**
* The URL for the target documentation. Value MUST be in the format of a URL.
*/
url: string;
/**
* A short description of the target documentation. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation.
*/
description?: string;
}
1 change: 1 addition & 0 deletions packages/openspec/src/common/OpenSpecHash.ts
@@ -0,0 +1 @@
export type OpenSpecHash<T> = {[key: string]: T};
52 changes: 52 additions & 0 deletions packages/openspec/src/common/OpenSpecInfo.ts
@@ -0,0 +1,52 @@
export interface OpenSpecContact {
/**
* The identifying name of the contact person/organization.
*/
name?: string;
/**
* The email address of the contact person/organization. MUST be in the format of an email address.
*/
email?: string;
/**
* The URL pointing to the contact information. MUST be in the format of a URL.
*/
url?: string;
}

export interface OpenSpecLicense {
/**
* The license name used for the API.
*/
name: string;
/**
* A URL to the license used for the API. MUST be in the format of a URL.
*/
url?: string;
}

export interface OpenSpecInfo {
/**
* The title of the application.
*/
title: string;
/**
* The version of the OpenAPI document (which is distinct from the [OpenAPI Specification](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#oasVersion) version or the API implementation version).
*/
version: string;
/**
* A short description of the application. [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation.
*/
description?: string;
/**
* A URL to the Terms of Service for the API. MUST be in the format of a URL.
*/
termsOfService?: string;
/**
* The contact information for the exposed API.
*/
contact?: OpenSpecContact;
/**
* The license information for the exposed API.
*/
license?: OpenSpecLicense;
}
153 changes: 153 additions & 0 deletions packages/openspec/src/common/OpenSpecJsonSchema.ts
@@ -0,0 +1,153 @@
import {OpenSpecHash} from "./OpenSpecHash";
import {OpenSpecRef} from "./OpenSpecRef";
import {OpenSpecTypes} from "./OpenSpecTypes";

export interface OpenSpecBaseJsonSchema {
$ref?: string;
/**
* This attribute is a string that provides a short description of the instance property.
*
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.2
*/
title?: string;
/**
* Must be strictly greater than 0.
* A numeric instance is valid only if division by this keyword's value results in an integer.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.1
*/
multipleOf?: number;
/**
* Representing an inclusive upper limit for a numeric instance.
* This keyword validates only if the instance is less than or exactly equal to "maximum".
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.2
*/
maximum?: number;
/**
* Representing an exclusive upper limit for a numeric instance.
* This keyword validates only if the instance is strictly less than (not equal to) to "exclusiveMaximum".
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.3
*/
exclusiveMaximum?: boolean;
/**
* Representing an inclusive lower limit for a numeric instance.
* This keyword validates only if the instance is greater than or exactly equal to "minimum".
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.4
*/
minimum?: number;
/**
* Representing an exclusive lower limit for a numeric instance.
* This keyword validates only if the instance is strictly greater than (not equal to) to "exclusiveMinimum".
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.5
*/
exclusiveMinimum?: boolean;
/**
* Must be a non-negative integer.
* A string instance is valid against this keyword if its length is less than, or equal to, the value of this keyword.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.6
*/
maxLength?: number;
/**
* Must be a non-negative integer.
* A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.
* Omitting this keyword has the same behavior as a value of 0.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.7
*/
minLength?: number;
/**
* Should be a valid regular expression, according to the ECMA 262 regular expression dialect.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.8
*/
pattern?: string;
/**
* Must be a non-negative integer.
* An array instance is valid against "maxItems" if its size is less than, or equal to, the value of this keyword.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.11
*/
maxItems?: number;
/**
* Must be a non-negative integer.
* An array instance is valid against "maxItems" if its size is greater than, or equal to, the value of this keyword.
* Omitting this keyword has the same behavior as a value of 0.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.12
*/
minItems?: number;
/**
* If this keyword has boolean value false, the instance validates successfully.
* If it has boolean value true, the instance validates successfully if all of its elements are unique.
* Omitting this keyword has the same behavior as a value of false.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.13
*/
uniqueItems?: boolean;
/**
* Must be a non-negative integer.
* An object instance is valid against "maxProperties" if its number of properties is less than, or equal to, the value of this keyword.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.15
*/
maxProperties?: number;
/**
* Must be a non-negative integer.
* An object instance is valid against "maxProperties" if its number of properties is greater than,
* or equal to, the value of this keyword.
* Omitting this keyword has the same behavior as a value of 0.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.16
*/
minProperties?: number;
/**
* This provides an enumeration of all possible values that are valid
* for the instance property. This MUST be an array, and each item in
* the array represents a possible value for the instance value. If
* this attribute is defined, the instance value MUST be one of the
* values in the array in order for the schema to be valid.
*
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.23
*/
enum?: any[];
/**
* This attribute is a string that provides a full description of the of purpose the instance property.
*
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.2
*/
description?: string;
/**
* This keyword can be used to supply a default JSON value associated with a particular schema.
* It is RECOMMENDED that a default value be valid against the associated schema.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.3
*/
default?: any;
/**
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-8
*/
format?: string;
/**
* A single type, or a union of simple types
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.25
*/
type?: OpenSpecTypes;
}

export interface OpenSpecJsonSchema<Schema = any> extends OpenSpecBaseJsonSchema {
/**
* Required if type is "array". Describes the type of items in the array.
*/
items?: Schema | OpenSpecRef;
/**
* A free-form property to include an example of an instance for this schema.
*/
required?: string[];
/**
* Value can be boolean or object. Inline or referenced schema MUST be of a Schema Object and not a standard JSON Schema.
*/
additionalProperties?: Schema | boolean;
/**
* Property definitions MUST be a Schema Object and not a standard JSON Schema (inline or referenced).
*/
properties?: OpenSpecHash<Schema>;
/**
* Inline or referenced schema MUST be of a [Schema Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#schemaObject) and not a standard JSON Schema.
*/
allOf?: (Schema | OpenSpecRef)[];
/**
* Additional external documentation for this schema.
*/
example?: any;
}
10 changes: 10 additions & 0 deletions packages/openspec/src/common/OpenSpecPath.ts
@@ -0,0 +1,10 @@
export interface OpenSpecPath<Operation> {
$ref?: string;
get?: Operation;
put?: Operation;
post?: Operation;
delete?: Operation;
options?: Operation;
head?: Operation;
patch?: Operation;
}
3 changes: 3 additions & 0 deletions packages/openspec/src/common/OpenSpecRef.ts
@@ -0,0 +1,3 @@
export interface OpenSpecRef {
$ref: string;
}
3 changes: 3 additions & 0 deletions packages/openspec/src/common/OpenSpecSecurity.ts
@@ -0,0 +1,3 @@
import {OpenSpecHash} from "./OpenSpecHash";

export type OpenSpecSecurity = OpenSpecHash<string[]>[];
7 changes: 7 additions & 0 deletions packages/openspec/src/common/OpenSpecTag.ts
@@ -0,0 +1,7 @@
import {OpenSpecExternalDocs} from "./OpenSpecExternalDocs";

export interface OpenSpecTag {
name: string;
description?: string;
externalDocs?: OpenSpecExternalDocs;
}
1 change: 1 addition & 0 deletions packages/openspec/src/common/OpenSpecTypes.ts
@@ -0,0 +1 @@
export type OpenSpecTypes = "string" | "number" | "integer" | "boolean" | "array" | "object" | "file";
3 changes: 3 additions & 0 deletions packages/openspec/src/common/OpenSpecVersions.ts
@@ -0,0 +1,3 @@
export type OS2Versions = "2.0";
export type OS3Versions = "3.0.1" | "3.0.2" | "3.0.3" | "3.1.0";
export type OpenSpecVersions = OS2Versions | OS3Versions;

0 comments on commit f3aecb4

Please sign in to comment.