openapi-snippet
Advanced tools
Comparing version 0.7.1 to 0.8.0
@@ -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 @@ |
{ | ||
"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(); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1195022
15
40718