🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

openapi3-ts

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openapi3-ts - npm Package Compare versions

Comparing version

to
0.6.1

1

dist/model/index.js

@@ -7,3 +7,4 @@ "use strict";

__export(require("./SpecificationExtension"));
__export(require("./OpenApi"));
__export(require("./Server"));
//# sourceMappingURL=index.js.map

7

dist/model/OpenApi.d.ts
import { ISpecificationExtension } from "./SpecificationExtension";
export declare function getExtension(obj: ISpecificationExtension, extensionName: string): any;
export declare function addExtension(obj: ISpecificationExtension, extensionName: string, extension: any): void;
export interface OpenAPIObject extends ISpecificationExtension {

@@ -6,5 +8,3 @@ openapi: string;

servers?: ServerObject[];
paths: {
[path: string]: PathObject;
};
paths: PathObject;
components?: ComponentsObject;

@@ -76,2 +76,3 @@ security?: SecurityRequirementObject;

}
export declare function getPath(pathObject: PathObject, path: string): PathItemObject;
export interface PathItemObject extends ISpecificationExtension {

@@ -78,0 +79,0 @@ $ref?: string;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const SpecificationExtension_1 = require("./SpecificationExtension");
function getExtension(obj, extensionName) {
if (SpecificationExtension_1.SpecificationExtension.isValidExtension(extensionName)) {
return obj[extensionName];
}
return undefined;
}
exports.getExtension = getExtension;
function addExtension(obj, extensionName, extension) {
if (SpecificationExtension_1.SpecificationExtension.isValidExtension(extensionName)) {
obj[extensionName] = extension;
}
}
exports.addExtension = addExtension;
function getPath(pathObject, path) {
if (SpecificationExtension_1.SpecificationExtension.isValidExtension(path)) {
return undefined;
}
return pathObject[path];
}
exports.getPath = getPath;
//# sourceMappingURL=OpenApi.js.map

@@ -6,6 +6,6 @@ export interface ISpecificationExtension {

[extensionName: string]: any;
static isValidExtension(extensionName: any): boolean;
getExtension(extensionName: any): any;
addExtension(extensionName: any, payload: any): void;
static isValidExtension(extensionName: string): boolean;
getExtension(extensionName: string): any;
addExtension(extensionName: string, payload: any): void;
listExtensions(): string[];
}
{
"name": "openapi3-ts",
"version": "0.6.0",
"version": "0.6.1",
"description": "TS Model & utils for OpenAPI 3.0.x specification.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -230,3 +230,3 @@ import "mocha";

let s1: oa.ServerObject = {
url: "htto://api.quixote.org",
url: "http://api.quixote.org",
variables: {}

@@ -238,2 +238,39 @@ };

it("getPath", () => {
let path1 = {
get: {
responses: {
default: {
description: "object created"
}
}
}
};
const sut = OpenApiBuilder.create()
.addPath('/service7', path1)
.rootDoc;
oa.addExtension(sut.paths, 'x-my-extension', 42);
expect(oa.getPath(sut.paths, '/service7')).eql(path1);
expect(oa.getPath(sut.paths, '/service56')).eql(undefined);
});
it("getExtension", () => {
let path1 = {
get: {
responses: {
default: {
description: "object created"
}
}
}
};
const sut = OpenApiBuilder.create()
.addPath('/service7', path1)
.rootDoc;
oa.addExtension(sut.paths, 'x-my-extension', 42);
expect(oa.getExtension(sut.paths, 'x-my-extension')).eql(42);
expect(oa.getExtension(sut.paths, 'x-other')).eql(undefined);
});
describe("Serialize", () => {

@@ -240,0 +277,0 @@ it("getSpecAsJson", () => {

// Typed interfaces for OpenAPI 3.0.0-RC
// see https://github.com/OAI/OpenAPI-Specification/blob/3.0.0-rc0/versions/3.0.md
import { ISpecificationExtension } from "./SpecificationExtension";
import { ISpecificationExtension, SpecificationExtension } from "./SpecificationExtension";
export function getExtension(obj: ISpecificationExtension, extensionName: string): any {
if (SpecificationExtension.isValidExtension(extensionName)) {
return obj[extensionName];
}
return undefined;
}
export function addExtension(obj: ISpecificationExtension, extensionName: string, extension: any): void {
if (SpecificationExtension.isValidExtension(extensionName)) {
obj[extensionName] = extension;
}
}
export interface OpenAPIObject extends ISpecificationExtension {

@@ -10,3 +22,3 @@ openapi: string;

servers?: ServerObject[];
paths: {[path: string]: PathObject };
paths: PathObject;
components?: ComponentsObject;

@@ -59,2 +71,9 @@ security?: SecurityRequirementObject;

}
export function getPath(pathObject: PathObject, path: string): PathItemObject {
if (SpecificationExtension.isValidExtension(path)) {
return undefined;
}
return pathObject[path] as PathItemObject;
}
export interface PathItemObject extends ISpecificationExtension {

@@ -61,0 +80,0 @@ $ref?: string;

@@ -16,7 +16,7 @@ // Suport for Specification Extensions

static isValidExtension(extensionName) {
static isValidExtension(extensionName: string) {
return /^x\-/.test(extensionName);
}
getExtension(extensionName): any {
getExtension(extensionName: string): any {
if (!SpecificationExtension.isValidExtension(extensionName)) {

@@ -31,3 +31,3 @@ throw new Error("Invalid specification extension: '" +

}
addExtension(extensionName, payload: any): void {
addExtension(extensionName: string, payload: any): void {
if (!SpecificationExtension.isValidExtension(extensionName)) {

@@ -34,0 +34,0 @@ throw new Error("Invalid specification extension: '" +

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