openapi3-ts
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -23,5 +23,5 @@ import { ISpecificationExtension } from "./SpecificationExtension"; | ||
export interface ContactObject extends ISpecificationExtension { | ||
name: string; | ||
url: string; | ||
email: string; | ||
name?: string; | ||
url?: string; | ||
email?: string; | ||
} | ||
@@ -77,3 +77,3 @@ export interface LicenseObject extends ISpecificationExtension { | ||
export declare type PathObject = PathsObject; | ||
export declare function getPath(pathsObject: PathsObject, path: string): PathItemObject; | ||
export declare function getPath(pathsObject: PathsObject, path: string): PathItemObject | undefined; | ||
export interface PathItemObject extends ISpecificationExtension { | ||
@@ -215,2 +215,3 @@ $ref?: string; | ||
} | ||
export declare function isReferenceObject(obj: object): obj is ReferenceObject; | ||
export interface SchemaObject extends ISpecificationExtension { | ||
@@ -256,2 +257,3 @@ nullable?: boolean; | ||
} | ||
export declare function isSchemaObject(schema: SchemaObject | ReferenceObject): schema is SchemaObject; | ||
export interface SchemasObject { | ||
@@ -258,0 +260,0 @@ [schema: string]: SchemaObject; |
@@ -24,2 +24,10 @@ "use strict"; | ||
exports.getPath = getPath; | ||
function isReferenceObject(obj) { | ||
return obj.hasOwnProperty("$ref"); | ||
} | ||
exports.isReferenceObject = isReferenceObject; | ||
function isSchemaObject(schema) { | ||
return !schema.hasOwnProperty('$ref'); | ||
} | ||
exports.isSchemaObject = isSchemaObject; | ||
//# sourceMappingURL=OpenApi.js.map |
{ | ||
"name": "openapi3-ts", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "TS Model & utils for OpenAPI 3.0.x specification.", | ||
@@ -17,4 +17,4 @@ "main": "dist/index.js", | ||
"prepare": "npm run build", | ||
"test:tdd": "mocha --recursive --reporter min --compilers ts:ts-node/register --require source-map-support/register \"src/**/*.spec.ts\" --watch", | ||
"test": "mocha --recursive --compilers ts:ts-node/register --require source-map-support/register \"src/**/*.spec.ts\"", | ||
"test:tdd": "mocha --recursive --reporter min --require ts-node/register --require source-map-support/register \"src/**/*.spec.ts\" --watch", | ||
"test": "mocha --recursive --require ts-node/register --require source-map-support/register \"src/**/*.spec.ts\"", | ||
"cover": "nyc npm test" | ||
@@ -55,13 +55,13 @@ }, | ||
"@types/chai": "^4.1.7", | ||
"@types/mocha": "^5.2.5", | ||
"@types/node": "^10.12.1", | ||
"@types/mocha": "^5.2.6", | ||
"@types/node": "^12.0.2", | ||
"chai": "^4.2.0", | ||
"coveralls": "^3.0.2", | ||
"mocha": "^5.2.0", | ||
"nyc": "^13.1.0", | ||
"rimraf": "^2.6.2", | ||
"ts-node": "^7.0.1", | ||
"tslint": "^5.11.0", | ||
"typescript": "^3.1.4" | ||
"coveralls": "^3.0.3", | ||
"mocha": "^6.1.4", | ||
"nyc": "^14.1.1", | ||
"rimraf": "^2.6.3", | ||
"ts-node": "^8.2.0", | ||
"tslint": "^5.16.0", | ||
"typescript": "^3.4.5" | ||
} | ||
} |
@@ -37,2 +37,2 @@ # OpenApi3-TS | ||
(c) 2017-2018. [Pedro J. Molina](http://pjmolina.com) at Metadev S.L. [https://metadev.pro](https://metadev.pro) | ||
(c) 2017-2019. [Pedro J. Molina](http://pjmolina.com) at Metadev S.L. [https://metadev.pro](https://metadev.pro) & contributors. |
@@ -37,5 +37,5 @@ // Typed interfaces for OpenAPI 3.0.0-RC | ||
export interface ContactObject extends ISpecificationExtension { | ||
name: string; | ||
url: string; | ||
email: string; | ||
name?: string; | ||
url?: string; | ||
email?: string; | ||
} | ||
@@ -83,3 +83,3 @@ export interface LicenseObject extends ISpecificationExtension { | ||
export function getPath(pathsObject: PathsObject, path: string): PathItemObject { | ||
export function getPath(pathsObject: PathsObject, path: string): PathItemObject | undefined { | ||
if (SpecificationExtension.isValidExtension(path)) { | ||
@@ -250,5 +250,17 @@ return undefined; | ||
} | ||
export interface ReferenceObject { | ||
$ref: string; | ||
} | ||
/** | ||
* A type guard to check if the given value is a `ReferenceObject`. | ||
* See https://www.typescriptlang.org/docs/handbook/advanced-types.html#type-guards-and-differentiating-types | ||
* | ||
* @param obj The value to check. | ||
*/ | ||
export function isReferenceObject(obj: object): obj is ReferenceObject { | ||
return obj.hasOwnProperty("$ref"); | ||
} | ||
export interface SchemaObject extends ISpecificationExtension { | ||
@@ -295,2 +307,15 @@ nullable?: boolean; | ||
/** | ||
* A type guard to check if the given object is a `SchemaObject`. | ||
* Useful to distinguish from `ReferenceObject` values that can be used | ||
* in most places where `SchemaObject` is allowed. | ||
* | ||
* See https://www.typescriptlang.org/docs/handbook/advanced-types.html#type-guards-and-differentiating-types | ||
* | ||
* @param schema The value to check. | ||
*/ | ||
export function isSchemaObject(schema: SchemaObject | ReferenceObject): schema is SchemaObject { | ||
return !schema.hasOwnProperty('$ref'); | ||
} | ||
export interface SchemasObject { | ||
@@ -297,0 +322,0 @@ [schema: string]: SchemaObject; |
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
74474
38
1807