Socket
Socket
Sign inDemoInstall

openapi3-ts

Package Overview
Dependencies
Maintainers
1
Versions
50
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 2.0.2 to 3.0.0

dist/cjs/dsl/index.d.ts

10

Changelog.md
# Changelog: openapi3-ts
## Version 3.0.0
2022.08.07
- PR [#80](https://github.com/metadevpro/openapi3-ts/pull/80) contributed by @jonluca
- Updated libs
- Breaking change: Changed build system to output esm as well as cjs (folders `dist/mjs` and `dist/cjs` now respectively, instead of `dist` for cjs previously).
- Changed test system to use vite
- Added stricter extension prefix typing
## Version 2.0.2

@@ -4,0 +14,0 @@

120

package.json
{
"name": "openapi3-ts",
"version": "2.0.2",
"description": "TS Model & utils for OpenAPI 3.x specification.",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/metadevpro/openapi3-ts.git"
},
"scripts": {
"clean": "rimraf dist",
"build": "rimraf dist && npm run lint && tsc -p tsconfig.json",
"build:w": "tsc -p tsconfig.json -w",
"lint": "eslint src/**/*.ts",
"lint:fix": "eslint src/**/*.ts --fix",
"prepare": "npm run build",
"test:tdd": "mocha --recursive --reporter min -r ts-node/register -r source-map-support/register \"src/**/*.spec.ts\" --watch",
"test": "set TS_NODE_COMPILER_OPTIONS={\"module\": \"commonjs\" } && mocha --recursive -r ts-node/register -r source-map-support/register \"src/**/*.spec.ts\"",
"test:ci": "mocha --recursive -r ts-node/register -r source-map-support/register --reporter mocha-teamcity-reporter \"src/**/*.spec.ts\"",
"cover:ci": "nyc --reporter teamcity --reporter html --reporter json --reporter text npm run test:ci",
"cover": "nyc npm test"
},
"keywords": [
"openapi3",
"ts",
"typescript"
],
"author": "Pedro J. Molina / Metadev",
"license": "MIT",
"nyc": {
"include": [
"src/*.ts",
"src/**/*.ts"
"name": "openapi3-ts",
"version": "3.0.0",
"description": "TS Model & utils for OpenAPI 3.x specification.",
"main": "dist/cjs/index.js",
"module": "dist/mjs/index.js",
"typings": "dist/mjs/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/metadevpro/openapi3-ts.git"
},
"scripts": {
"clean": "rimraf dist",
"build": "rimraf dist && npm run lint && tsc && tsc -p tsconfig-cjs.json",
"build:w": "BUILD_WATCH=true node build.mjs",
"lint": "eslint src/**/*.ts",
"lint:fix": "eslint src/**/*.ts --fix",
"prepare": "npm run build",
"test:tdd": "vitest -w",
"test": "vitest",
"test:ci": "npm run test",
"cover:ci": "npm run cover",
"cover": "vitest --coverage"
},
"keywords": [
"openapi3",
"ts",
"typescript"
],
"exclude": [
"node_modules",
"typings",
"**/*.spec.ts",
"**/*.d.ts"
],
"extension": [
".ts"
],
"require": [
"ts-node/register"
],
"reporter": [
"json",
"html",
"text"
],
"all": true
},
"dependencies": {
"yaml": "^1.10.2"
},
"devDependencies": {
"@types/mocha": "9.1.0",
"@types/node": "16.6.2",
"@typescript-eslint/eslint-plugin": "^5.12.0",
"@typescript-eslint/parser": "^5.12.0",
"chai": "^4.3.6",
"coveralls": "^3.1.1",
"eslint": "^8.9.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"mocha": "~9.2.0",
"mocha-teamcity-reporter": "^4.2.0",
"nyc": "^15.1.0",
"prettier": "^2.5.1",
"rimraf": "^3.0.2",
"ts-node": "^10.5.0",
"typescript": "3.6.5"
}
"author": "Pedro J. Molina / Metadev",
"license": "MIT",
"dependencies": {
"yaml": "^2.1.1"
},
"devDependencies": {
"@types/node": "18.6.4",
"@typescript-eslint/eslint-plugin": "^5.32.0",
"@typescript-eslint/parser": "^5.32.0",
"c8": "^7.12.0",
"coveralls": "^3.1.1",
"eslint": "^8.21.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"typescript": "4.7.4",
"vitest": "^0.21.0",
"vitest-teamcity-reporter": "^0.1.7"
}
}

@@ -1,1 +0,1 @@

export * from './OpenApiBuilder';
export * from './OpenApiBuilder.js';

@@ -1,3 +0,1 @@

import 'mocha';
import { expect } from 'chai';
import { OpenApiBuilder } from '.';

@@ -66,42 +64,14 @@ import * as oa from '../model';

});
it('addOpenApiVersion invalid', (done) => {
try {
OpenApiBuilder.create().addOpenApiVersion('a.b.4').rootDoc;
done('failed');
} catch (err) {
done();
}
it('addOpenApiVersion invalid', ({ expect }) => {
expect(() => OpenApiBuilder.create().addOpenApiVersion('a.b.4').rootDoc).toThrow();
});
it('addOpenApiVersion missing value', (done) => {
try {
OpenApiBuilder.create().addOpenApiVersion(null).rootDoc;
done('failed');
} catch (err) {
done();
}
it('addOpenApiVersion missing value', ({ expect }) => {
expect(() => OpenApiBuilder.create().addOpenApiVersion(null).rootDoc).toThrow();
});
it('addOpenApiVersion empty', (done) => {
try {
OpenApiBuilder.create().addOpenApiVersion('').rootDoc;
done('failed');
} catch (err) {
done();
}
it('addOpenApiVersion empty', ({ expect }) => {
expect(() => OpenApiBuilder.create().addOpenApiVersion('').rootDoc).toThrow();
});
it('addOpenApiVersion null', (done) => {
try {
OpenApiBuilder.create().addOpenApiVersion(null).rootDoc;
done('failed');
} catch (err) {
done();
}
it('addOpenApiVersion lower than 3', ({ expect }) => {
expect(() => OpenApiBuilder.create().addOpenApiVersion('2.5.6').rootDoc).toThrow();
});
it('addOpenApiVersion lower than 3', (done) => {
try {
OpenApiBuilder.create().addOpenApiVersion('2.5.6').rootDoc;
done('failed');
} catch (err) {
done();
}
});
it('addInfo', () => {

@@ -108,0 +78,0 @@ const info: oa.InfoObject = {

import * as yaml from 'yaml';
import * as oa from '../model';
import * as oa from '../model/index.js';

@@ -41,3 +41,7 @@ // Internal DSL for building an OpenAPI 3.0.x contract

}
getSpecAsJson(replacer?: (key: string, value: unknown) => unknown, space?: string | number): string {
getSpecAsJson(
replacer?: (key: string, value: unknown) => unknown,
space?: string | number
): string {
return JSON.stringify(this.rootDoc, replacer, space);

@@ -64,3 +68,3 @@ }

throw new Error(
'Invalid OpnApi version: ' + openApiVersion + '. Follow convention: 3.x.y'
'Invalid OpenApi version: ' + openApiVersion + '. Follow convention: 3.x.y'
);

@@ -67,0 +71,0 @@ }

@@ -1,6 +0,3 @@

import { expect } from 'chai';
import 'mocha';
import { OpenApiBuilder, Server, ServerVariable } from '.';
describe('Top barrel', () => {

@@ -7,0 +4,0 @@ it('OpenApiBuilder is exported', () => {

@@ -1,2 +0,2 @@

export * from './model';
export * from './dsl';
export * from './model/index.js';
export * from './dsl/index.js';

@@ -1,3 +0,3 @@

export * from './SpecificationExtension';
export * from './OpenApi';
export * from './Server';
export * from './SpecificationExtension.js';
export * from './OpenApi.js';
export * from './Server.js';

@@ -1,3 +0,1 @@

import 'mocha';
import { expect } from 'chai';
import {

@@ -10,2 +8,3 @@ addExtension,

} from './OpenApi';
import { IExtensionName, IExtensionType } from './SpecificationExtension';

@@ -52,2 +51,3 @@ describe('type-guards unit tests', () => {

class TestSchemaObject implements SchemaObject {
[k: IExtensionName]: IExtensionType;
// empty schema

@@ -54,0 +54,0 @@ }

@@ -5,3 +5,3 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

import { ISpecificationExtension, SpecificationExtension } from './SpecificationExtension';
import { ISpecificationExtension, SpecificationExtension } from './SpecificationExtension.js';

@@ -244,3 +244,5 @@ export function getExtension(obj: ISpecificationExtension, extensionName: string): any {

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface HeaderObject extends BaseParameterObject {}
export interface HeaderObject extends BaseParameterObject {
$ref?: string;
}
export interface TagObject extends ISpecificationExtension {

@@ -306,5 +308,5 @@ name: string;

maximum?: number;
exclusiveMaximum?: boolean;
exclusiveMaximum?: number;
minimum?: number;
exclusiveMinimum?: boolean;
exclusiveMinimum?: number;
maxLength?: number;

@@ -311,0 +313,0 @@ minLength?: number;

@@ -1,3 +0,1 @@

import { expect } from 'chai';
import 'mocha';
import { Server, ServerVariable } from './Server';

@@ -4,0 +2,0 @@

import * as oa from './OpenApi';
import { IExtensionName, IExtensionType } from './SpecificationExtension.js';
// Server & Server Variable
export class Server implements oa.ServerObject {

@@ -9,2 +9,3 @@ url: string;

variables: { [v: string]: ServerVariable };
[k: IExtensionName]: IExtensionType;

@@ -25,4 +26,9 @@ constructor(url: string, desc?: string) {

description?: string;
[k: IExtensionName]: IExtensionType;
constructor(defaultValue: string | boolean | number, enums?: string[] | boolean[] | number[], description?: string) {
constructor(
defaultValue: string | boolean | number,
enums?: string[] | boolean[] | number[],
description?: string
) {
this.default = defaultValue;

@@ -29,0 +35,0 @@ this.enum = enums;

@@ -1,3 +0,1 @@

import 'mocha';
import { expect } from 'chai';
import { SpecificationExtension } from './SpecificationExtension';

@@ -13,11 +11,6 @@

});
it('addExtension() invalid', (done) => {
it('addExtension() invalid', ({ expect }) => {
const sut = new SpecificationExtension();
const extensionValue = { payload: 5 };
try {
sut.addExtension('y-name', extensionValue);
done('Must fail. Invalid extension');
} catch (err) {
done();
}
expect(() => sut.addExtension('y-name', extensionValue)).toThrow();
});

@@ -34,10 +27,5 @@ it('getExtension() ok', () => {

});
it('getExtension() invalid', (done) => {
it('getExtension() invalid', ({ expect }) => {
const sut = new SpecificationExtension();
try {
sut.getExtension('y-name');
done('Error. invalid extension');
} catch (err) {
done();
}
expect(() => sut.getExtension('y-name')).toThrow();
});

@@ -44,0 +32,0 @@ it('getExtension() not found', () => {

@@ -9,10 +9,10 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

// ^x-
export interface ISpecificationExtension {
// Cannot constraint to "^x-" but can filter them later to access to them
[extensionName: string]: any;
}
export type IExtensionName = `x-${string}`;
export type IExtensionType = any;
export type ISpecificationExtension = {
[extensionName: IExtensionName]: IExtensionType;
};
export class SpecificationExtension implements ISpecificationExtension {
// Cannot constraint to "^x-" but can filter them later to access to them
[extensionName: string]: any;
[extensionName: IExtensionName]: any;

@@ -19,0 +19,0 @@ static isValidExtension(extensionName: string): boolean {

{
"compilerOptions": {
"declaration": true,
"target": "es2020",
"module": "commonjs",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"noImplicitAny": false,
"removeComments": true,
"preserveConstEnums": true,
"noEmitHelpers": true,
"outDir": "dist",
"rootDir": "src"
},
"compileOnSave": true,
"buildOnSave": true,
"exclude": [
"**/*.spec.ts",
"bin",
"dist",
"node_modules/**"
]
"compilerOptions": {
"declaration": true,
"target": "ES2020",
"module": "ESNext",
"moduleResolution": "Node16",
"experimentalDecorators": true,
"noImplicitAny": false,
"removeComments": true,
"preserveConstEnums": true,
"noEmitHelpers": true,
"skipLibCheck": true,
"outDir": "dist/mjs",
"rootDir": "src",
"types": ["vitest/globals", "node"]
},
"compileOnSave": true,
"buildOnSave": true,
"exclude": ["**/*.spec.ts", "bin", "dist", "vite.config.ts", "node_modules/**"]
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc