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

openapi-snippet

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openapi-snippet - npm Package Compare versions

Comparing version 0.7.1 to 0.8.0

test/parameter_schema_reference.json

27

openapi-to-har.js

@@ -150,2 +150,11 @@ /**

}
if (typeof param.schema !== 'undefined') {
if (typeof param.schema['$ref'] === 'string' &&
/^#/.test(param.schema['$ref'])) {
param.schema = resolveRef(openApi, param.schema['$ref'])
if (typeof param.schema.type === 'undefined') { // many schemas don't have an explicit type
param.schema.type = 'object';
}
}
}
if (typeof param.in !== 'undefined' && param.in.toLowerCase() === 'query') {

@@ -240,2 +249,8 @@ let value = 'SOME_' + (param.type || param.schema.type).toUpperCase() + '_VALUE'

const authType = secDefinition.type.toLowerCase();
let authScheme = null;
if(authType !== 'apikey' && secDefinition.scheme != null){
authScheme = secDefinition.scheme.toLowerCase();
}
switch (authType) {

@@ -253,2 +268,12 @@ case 'basic':

break
case 'http':
switch(authScheme){
case 'bearer':
oauthDef = secScheme
break
case 'basic':
basicAuthDef = secScheme
break
}
break
}

@@ -265,3 +290,3 @@ }

if(authType !== 'apikey'){
let authScheme = secDefinition.scheme.toLowerCase();
authScheme = secDefinition.scheme.toLowerCase();
}

@@ -268,0 +293,0 @@

2

package.json
{
"name": "openapi-snippet",
"version": "0.7.1",
"version": "0.8.0",
"description": "Generates code snippets from Open API (previously Swagger) documents.",

@@ -5,0 +5,0 @@ "repository": {

@@ -13,2 +13,3 @@ 'use strict'

const PetStoreOpenAPI3 = require('./petstore_oas.json')
const ParameterSchemaReferenceAPI = require('./parameter_schema_reference')

@@ -55,3 +56,3 @@ test('Getting snippets should not result in error or undefined', function (t) {

test('Getting snippets from OpenAPI 3.0.x shoudl work', function (t) {
test('Getting snippets from OpenAPI 3.0.x should work', function (t) {
t.plan(1)

@@ -110,2 +111,9 @@ // checks the 'Pages' schema...

t.end()
})
})
test('Parameters that are Schema References Are Dereferenced', function (t) {
const result = OpenAPISnippets.getEndpointSnippets(ParameterSchemaReferenceAPI, '/pets', 'post', ['node_request']);
const snippet = result.snippets[0].content;
t.true(/pet: 'SOME_OBJECT_VALUE'/.test(snippet))
t.end();
});
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