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
92 changed files
with
10,047 additions
and
601 deletions.
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
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 @@ | ||
export type HashOf<T> = {[key: string]: T}; |
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
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
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,4 @@ | ||
src | ||
test | ||
tsconfig.compile.json | ||
tsconfig.json |
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,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": {} | ||
} |
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,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. |
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,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; | ||
} |
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 @@ | ||
export type OpenSpecHash<T> = {[key: string]: T}; |
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,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; | ||
} |
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,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; | ||
} |
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,10 @@ | ||
export interface OpenSpecPath<Operation> { | ||
$ref?: string; | ||
get?: Operation; | ||
put?: Operation; | ||
post?: Operation; | ||
delete?: Operation; | ||
options?: Operation; | ||
head?: Operation; | ||
patch?: Operation; | ||
} |
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,3 @@ | ||
export interface OpenSpecRef { | ||
$ref: string; | ||
} |
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,3 @@ | ||
import {OpenSpecHash} from "./OpenSpecHash"; | ||
|
||
export type OpenSpecSecurity = OpenSpecHash<string[]>[]; |
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,7 @@ | ||
import {OpenSpecExternalDocs} from "./OpenSpecExternalDocs"; | ||
|
||
export interface OpenSpecTag { | ||
name: string; | ||
description?: string; | ||
externalDocs?: OpenSpecExternalDocs; | ||
} |
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 @@ | ||
export type OpenSpecTypes = "string" | "number" | "integer" | "boolean" | "array" | "object" | "file"; |
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,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; |
Oops, something went wrong.