Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

oas-normalize

Package Overview
Dependencies
Maintainers
9
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oas-normalize - npm Package Compare versions

Comparing version 8.0.0 to 8.1.0

11

dist/index.d.ts

@@ -110,4 +110,15 @@ import type { OpenAPI } from 'openapi-types';

validate(opts?: {
/**
* Automatically convert the supplied API definition to the latest version of OpenAPI.
*/
convertToLatest?: boolean;
}): Promise<any>;
/**
* Retrieve OpenAPI, Swagger, or Postman version information about the supplied API definition.
*
*/
version(): Promise<{
specification: string;
version: any;
}>;
}

@@ -250,4 +250,32 @@ "use strict";

};
/**
* Retrieve OpenAPI, Swagger, or Postman version information about the supplied API definition.
*
*/
OASNormalize.prototype.version = function () {
return this.load().then(function (schema) {
switch ((0, exports.getAPIDefinitionType)(schema)) {
case 'openapi':
return {
specification: 'openapi',
version: schema.openapi
};
case 'postman':
// We don't have any way right now to know if a Postman collection is for v2.0 or v2.1.
return {
specification: 'postman',
version: 'unknown'
};
case 'swagger':
return {
specification: 'swagger',
version: schema.swagger
};
default:
throw new Error('Unknown file detected.');
}
});
};
return OASNormalize;
}());
exports["default"] = OASNormalize;

4

package.json
{
"name": "oas-normalize",
"version": "8.0.0",
"version": "8.1.0",
"description": "Tooling for converting, valiating, and parsing OpenAPI, Swagger, and Postman API definitions",

@@ -16,3 +16,2 @@ "main": "dist/index.js",

"microservice",
"postman",
"oai",

@@ -25,2 +24,3 @@ "oas",

"openapi specification",
"postman",
"swagger"

@@ -27,0 +27,0 @@ ],

@@ -115,2 +115,13 @@ <p align="center">

### `#version()`
Load and retrieve version information about a supplied API definition.
```js
await oas.version().then(({ specification, version }) => {
console.log(specification); // openapi
console.log(version); // 3.1.0
});
```
### Options

@@ -117,0 +128,0 @@

@@ -144,3 +144,10 @@ import type { OpenAPI } from 'openapi-types';

*/
async validate(opts: { convertToLatest?: boolean } = { convertToLatest: false }) {
async validate(
opts: {
/**
* Automatically convert the supplied API definition to the latest version of OpenAPI.
*/
convertToLatest?: boolean;
} = { convertToLatest: false }
) {
const convertToLatest = opts.convertToLatest;

@@ -194,2 +201,34 @@ const colorizeErrors = this.opts.colorizeErrors;

}
/**
* Retrieve OpenAPI, Swagger, or Postman version information about the supplied API definition.
*
*/
version() {
return this.load().then(schema => {
switch (getAPIDefinitionType(schema)) {
case 'openapi':
return {
specification: 'openapi',
version: schema.openapi,
};
case 'postman':
// We don't have any way right now to know if a Postman collection is for v2.0 or v2.1.
return {
specification: 'postman',
version: 'unknown',
};
case 'swagger':
return {
specification: 'swagger',
version: schema.swagger,
};
default:
throw new Error('Unknown file detected.');
}
});
}
}
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