@tsoa/runtime
Advanced tools
Comparing version 3.4.0 to 3.5.0
@@ -169,2 +169,9 @@ import * as ts from 'typescript'; | ||
authenticationModule?: string; | ||
/** | ||
* When enabled, the `@SuccessResponse` annotations' code is used for responses by default. | ||
* Otherwise, non-empty responses default to 200 and empty responses to 204. | ||
* | ||
* @default false | ||
*/ | ||
useSuccessResponseCode?: boolean; | ||
} |
@@ -0,1 +1,2 @@ | ||
export declare function Options(value?: string): Function; | ||
export declare function Get(value?: string): Function; | ||
@@ -2,0 +3,0 @@ export declare function Post(value?: string): Function; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Head = exports.Delete = exports.Patch = exports.Put = exports.Post = exports.Get = void 0; | ||
exports.Head = exports.Delete = exports.Patch = exports.Put = exports.Post = exports.Get = exports.Options = void 0; | ||
function Options(value) { | ||
return function () { | ||
return; | ||
}; | ||
} | ||
exports.Options = Options; | ||
function Get(value) { | ||
@@ -5,0 +11,0 @@ return function () { |
@@ -1,3 +0,4 @@ | ||
export declare function SuccessResponse(name: string | number, description?: string): Function; | ||
export declare function Response<T>(name: string | number, description?: string, example?: T): Function; | ||
import { IsValidHeader } from '../utils/isHeaderType'; | ||
export declare function SuccessResponse<HeaderType extends IsValidHeader<HeaderType> = {}>(name: string | number, description?: string): Function; | ||
export declare function Response<ExampleType, HeaderType extends IsValidHeader<HeaderType> = {}>(name: string | number, description?: string, example?: ExampleType): Function; | ||
/** | ||
@@ -4,0 +5,0 @@ * Inject a library-agnostic responder function that can be used to construct type-checked (usually error-) responses. |
@@ -10,3 +10,3 @@ "use strict"; | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
@@ -13,0 +13,0 @@ Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -6,7 +6,7 @@ export declare class Controller { | ||
getStatus(): number | undefined; | ||
setHeader(name: string, value?: string): void; | ||
getHeader(name: string): string | undefined; | ||
setHeader(name: string, value?: string | string[]): void; | ||
getHeader(name: string): string | string[] | undefined; | ||
getHeaders(): { | ||
[name: string]: string | undefined; | ||
[name: string]: string | string[] | undefined; | ||
}; | ||
} |
@@ -0,2 +1,3 @@ | ||
import { IsValidHeader } from '../utils/isHeaderType'; | ||
export declare type HttpStatusCodeLiteral = 100 | 101 | 102 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 422 | 423 | 424 | 426 | 428 | 429 | 431 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511; | ||
export declare type TsoaResponse<T extends HttpStatusCodeLiteral, U, V extends {} = {}> = (status: T, data: U, headers?: V) => any; | ||
export declare type TsoaResponse<T extends HttpStatusCodeLiteral, BodyType, HeaderType extends IsValidHeader<HeaderType> = {}> = (status: T, data: BodyType, headers?: HeaderType) => any; |
@@ -24,2 +24,3 @@ import { ExtensionType } from '../decorators/extension'; | ||
responses: Response[]; | ||
successStatus?: number; | ||
security: Security[]; | ||
@@ -67,2 +68,3 @@ summary?: string; | ||
examples?: unknown[]; | ||
headers?: HeaderType; | ||
} | ||
@@ -185,2 +187,3 @@ interface Property { | ||
} | ||
type HeaderType = Tsoa.NestedObjectLiteralType | Tsoa.RefObjectType; | ||
} |
@@ -6,3 +6,3 @@ "use strict"; | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
@@ -142,3 +142,3 @@ }; | ||
var _this = this; | ||
if (!(value instanceof Object) || Array.isArray(value)) { | ||
if (typeof value !== 'object' || value === null || Array.isArray(value)) { | ||
fieldErrors[parent + name] = { | ||
@@ -670,3 +670,3 @@ message: "invalid object", | ||
var fieldPath_1 = parent + name; | ||
if (!(value instanceof Object)) { | ||
if (typeof value !== 'object' || value === null || Array.isArray(value)) { | ||
fieldErrors[fieldPath_1] = { | ||
@@ -673,0 +673,0 @@ message: "invalid object", |
@@ -229,3 +229,3 @@ export declare namespace Swagger { | ||
headers?: { | ||
[name: string]: Header; | ||
[name: string]: Header3; | ||
}; | ||
@@ -280,5 +280,33 @@ } | ||
} | ||
export interface Header extends BaseSchema { | ||
type: 'integer' | 'number' | 'boolean' | 'string' | 'array'; | ||
export interface Header { | ||
description?: string; | ||
type: 'string' | 'number' | 'integer' | 'boolean' | 'array'; | ||
format?: string; | ||
items?: BaseSchema; | ||
collectionFormat?: 'csv' | 'ssv' | 'tsv' | 'pipes' | 'multi'; | ||
default?: string | boolean | number | any; | ||
maximum?: number; | ||
exclusiveMaximum?: boolean; | ||
minimum?: number; | ||
exclusiveMinimum?: boolean; | ||
maxLength?: number; | ||
minLength?: number; | ||
pattern?: string; | ||
maxItems?: number; | ||
minItems?: number; | ||
uniqueItems?: boolean; | ||
enum?: Array<string | number | null>; | ||
multipleOf?: number; | ||
} | ||
export interface Header3 extends BaseSchema { | ||
required?: boolean; | ||
description?: string; | ||
example?: unknown; | ||
examples?: { | ||
[name: string]: Example3 | string; | ||
}; | ||
schema: Schema; | ||
type?: DataType; | ||
format?: DataFormat; | ||
} | ||
export interface XML { | ||
@@ -344,3 +372,3 @@ type?: string; | ||
export type OAuthFlow = { | ||
[flowName in OAuth2FlowTypes]: OAuth2SecurityFlow3; | ||
[flowName in OAuth2FlowTypes]?: OAuth2SecurityFlow3; | ||
}; | ||
@@ -347,0 +375,0 @@ export type OAuth2FlowTypes = 'authorizationCode' | 'implicit' | 'password' | 'clientCredentials'; |
{ | ||
"name": "@tsoa/runtime", | ||
"description": "Build swagger-compliant REST APIs using TypeScript and Node", | ||
"version": "3.4.0", | ||
"version": "3.5.0", | ||
"main": "./dist/index.js", | ||
@@ -33,3 +33,3 @@ "typings": "./dist/index.d.ts", | ||
"@types/node": "^14.11.1", | ||
"typescript": "^3.9.2" | ||
"typescript": "^4.1.2" | ||
}, | ||
@@ -48,3 +48,3 @@ "repository": { | ||
}, | ||
"gitHead": "5de342b790df1aabf35e6d7f9880b34e9ebb9e83" | ||
"gitHead": "337b85817ce61be53cea98e3d0c3db96166d01bd" | ||
} |
@@ -203,2 +203,10 @@ import * as ts from 'typescript'; | ||
authenticationModule?: string; | ||
/** | ||
* When enabled, the `@SuccessResponse` annotations' code is used for responses by default. | ||
* Otherwise, non-empty responses default to 200 and empty responses to 204. | ||
* | ||
* @default false | ||
*/ | ||
useSuccessResponseCode?: boolean; | ||
} |
@@ -0,1 +1,7 @@ | ||
export function Options(value?: string): Function { | ||
return () => { | ||
return; | ||
}; | ||
} | ||
export function Get(value?: string): Function { | ||
@@ -2,0 +8,0 @@ return () => { |
@@ -1,2 +0,4 @@ | ||
export function SuccessResponse(name: string | number, description?: string): Function { | ||
import { IsValidHeader } from '../utils/isHeaderType'; | ||
export function SuccessResponse<HeaderType extends IsValidHeader<HeaderType> = {}>(name: string | number, description?: string): Function { | ||
return () => { | ||
@@ -7,3 +9,3 @@ return; | ||
export function Response<T>(name: string | number, description?: string, example?: T): Function { | ||
export function Response<ExampleType, HeaderType extends IsValidHeader<HeaderType> = {}>(name: string | number, description?: string, example?: ExampleType): Function { | ||
return () => { | ||
@@ -10,0 +12,0 @@ return; |
export class Controller { | ||
private statusCode?: number = undefined; | ||
private headers = {} as { [name: string]: string | undefined }; | ||
private headers = {} as { [name: string]: string | string[] | undefined }; | ||
@@ -13,3 +13,3 @@ public setStatus(statusCode: number) { | ||
public setHeader(name: string, value?: string) { | ||
public setHeader(name: string, value?: string | string[]) { | ||
this.headers[name] = value; | ||
@@ -16,0 +16,0 @@ } |
@@ -0,1 +1,3 @@ | ||
import { IsValidHeader } from '../utils/isHeaderType'; | ||
export type HttpStatusCodeLiteral = | ||
@@ -61,2 +63,2 @@ | 100 | ||
export type TsoaResponse<T extends HttpStatusCodeLiteral, U, V extends {} = {}> = (status: T, data: U, headers?: V) => any; | ||
export type TsoaResponse<T extends HttpStatusCodeLiteral, BodyType, HeaderType extends IsValidHeader<HeaderType> = {}> = (status: T, data: BodyType, headers?: HeaderType) => any; |
@@ -27,2 +27,3 @@ import { ExtensionType } from '../decorators/extension'; | ||
responses: Response[]; | ||
successStatus?: number; | ||
security: Security[]; | ||
@@ -74,2 +75,3 @@ summary?: string; | ||
examples?: unknown[]; | ||
headers?: HeaderType; | ||
} | ||
@@ -264,2 +266,4 @@ | ||
} | ||
export type HeaderType = Tsoa.NestedObjectLiteralType | Tsoa.RefObjectType; | ||
} |
@@ -87,3 +87,3 @@ import * as moment from 'moment'; | ||
) { | ||
if (!(value instanceof Object) || Array.isArray(value)) { | ||
if (typeof value !== 'object' || value === null || Array.isArray(value)) { | ||
fieldErrors[parent + name] = { | ||
@@ -640,3 +640,3 @@ message: `invalid object`, | ||
if (!(value instanceof Object)) { | ||
if (typeof value !== 'object' || value === null || Array.isArray(value)) { | ||
fieldErrors[fieldPath] = { | ||
@@ -643,0 +643,0 @@ message: `invalid object`, |
@@ -211,3 +211,3 @@ export namespace Swagger { | ||
content?: { [name: string]: Schema & Example }; | ||
headers?: { [name: string]: Header }; | ||
headers?: { [name: string]: Header3 }; | ||
} | ||
@@ -264,6 +264,35 @@ | ||
export interface Header extends BaseSchema { | ||
type: 'integer' | 'number' | 'boolean' | 'string' | 'array'; | ||
export interface Header { | ||
description?: string; | ||
type: 'string' | 'number' | 'integer' | 'boolean' | 'array'; | ||
format?: string; | ||
items?: BaseSchema; | ||
collectionFormat?: 'csv' | 'ssv' | 'tsv' | 'pipes' | 'multi'; | ||
default?: string | boolean | number | any; | ||
maximum?: number; | ||
exclusiveMaximum?: boolean; | ||
minimum?: number; | ||
exclusiveMinimum?: boolean; | ||
maxLength?: number; | ||
minLength?: number; | ||
pattern?: string; | ||
maxItems?: number; | ||
minItems?: number; | ||
uniqueItems?: boolean; | ||
enum?: Array<string | number | null>; | ||
multipleOf?: number; | ||
} | ||
export interface Header3 extends BaseSchema { | ||
required?: boolean; | ||
description?: string; | ||
example?: unknown; | ||
examples?: { | ||
[name: string]: Example3 | string; | ||
}; | ||
schema: Schema; | ||
type?: DataType; | ||
format?: DataFormat; | ||
} | ||
export interface XML { | ||
@@ -342,3 +371,3 @@ type?: string; | ||
export type OAuthFlow = { | ||
[flowName in OAuth2FlowTypes]: OAuth2SecurityFlow3; | ||
[flowName in OAuth2FlowTypes]?: OAuth2SecurityFlow3; | ||
}; | ||
@@ -345,0 +374,0 @@ export type OAuth2FlowTypes = 'authorizationCode' | 'implicit' | 'password' | 'clientCredentials'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
223331
96
3939