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

open-api-mocker

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

open-api-mocker - npm Package Compare versions

Comparing version 1.3.1 to 1.4.0

lib/utils/http-methods.js

9

CHANGELOG.md

@@ -9,5 +9,12 @@ # Changelog

## [1.4.0] - 2020-07-03
### Added
- Added support for path level parameters (#8)
### Fixed
- Path objects are now correctly as they can have extra standard and extended properties (#8)
## [1.3.1] - 2020-04-25
### Fixed
- Support for every 3.x.x specification version
- Support for every 3.x.x specification version (#6)

@@ -14,0 +21,0 @@ ## [1.3.0] - 2020-04-05

@@ -7,2 +7,4 @@ 'use strict';

const { knownHttpMethods } = require('../utils/http-methods');
class Parser {

@@ -38,13 +40,22 @@

parsePath(uri, operations) {
const pathLevelParameters = operations.parameters || [];
return Object.entries(operations)
.map(([httpMethod, operationData]) => this.parseOperation(uri, httpMethod, operationData))
.map(([httpMethod, operationData]) => this.parseOperation(uri, httpMethod, operationData, pathLevelParameters))
.filter(Boolean);
}
parseOperation(uri, httpMethod, { parameters, requestBody, responses }) {
parseOperation(uri, httpMethod, { parameters, requestBody, responses }, pathLevelParameters) {
if(!knownHttpMethods.includes(httpMethod.toLowerCase()))
return;
return new Path({
uri,
httpMethod,
parameters,
parameters: [
...(parameters || []),
...pathLevelParameters
],
requestBody,

@@ -51,0 +62,0 @@ responses

14

lib/paths/structs.js

@@ -10,2 +10,4 @@ 'use strict';

const { knownHttpMethods } = require('../utils/http-methods');
const MediaTypeStruct = struct.interface({

@@ -34,8 +36,14 @@ schema: struct.optional(struct.union([

const HttpMethodsStruct = struct.enum(['get', 'post', 'put', 'patch', 'delete', 'options', 'head', 'trace']);
const PathStruct = struct.intersection([
'object',
struct.interface(knownHttpMethods.reduce((acum, httpMethod) => {
acum[httpMethod] = struct.union(['undefined', OperationStruct]);
return acum;
}, {
parameters: struct.optional([ParameterStruct])
}))
]);
const PathStruct = struct.dict([HttpMethodsStruct, OperationStruct]);
const Paths = struct.dict(['string', PathStruct]);
module.exports = Paths;
{
"name": "open-api-mocker",
"version": "1.3.1",
"version": "1.4.0",
"description": "A mock server based in Open API Specification",

@@ -5,0 +5,0 @@ "main": "lib/open-api-mocker.js",

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