swagger2openapi
Advanced tools
Comparing version 1.1.11 to 1.1.12
@@ -44,4 +44,4 @@ 'use strict'; | ||
if (scheme.flow == 'accessCode') flowName = 'authorizationCode'; | ||
if (typeof scheme.authorizationUrl !== 'undefined') flow.authorizationUrl = scheme.authorizationUrl; | ||
if (typeof scheme.tokenUrl !== 'undefined') flow.tokenUrl = scheme.tokenUrl; | ||
if (typeof scheme.authorizationUrl !== 'undefined') flow.authorizationUrl = scheme.authorizationUrl||'/'; | ||
if (typeof scheme.tokenUrl !== 'undefined') flow.tokenUrl = scheme.tokenUrl||'/'; | ||
flow.scopes = scheme.scopes||{}; | ||
@@ -48,0 +48,0 @@ scheme.flow = {}; |
{ | ||
"name": "swagger2openapi", | ||
"version": "1.1.11", | ||
"version": "1.1.12", | ||
"description": "Convert Swagger 2.0 specifications to OpenApi 3.0", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -64,3 +64,3 @@ # swagger2openapi | ||
The test harness currently expects files with a `.json` or `.yaml` extension, or a single named file, and has been tested against | ||
The test harness currently expects files with a `.json` or `.yaml` extension, or a single named file, and has been tested on Node.js versions 4.x and 6.x against | ||
@@ -67,0 +67,0 @@ * [APIs.guru](https://github.com/APIs-guru/openapi-directory) |
@@ -0,1 +1,2 @@ | ||
var url = require('url'); | ||
var should = require('should'); | ||
@@ -7,3 +8,10 @@ | ||
// TODO validate with ajv when schema published | ||
// TODO requestBody.content may become REQUIRED in RC1 | ||
function validateUrl(s) { | ||
if (s === '') throw(new Error('Invalid URL')); | ||
var u = url.parse(s); | ||
return true; // if we haven't thrown | ||
} | ||
function checkParam(param,openapi){ | ||
@@ -40,2 +48,6 @@ if (param.$ref) { | ||
op.should.not.have.property('produces'); | ||
if (op.externalDocs) { | ||
op.externalDocs.should.have.key('url'); | ||
validateUrl(op.externalDocs.url).should.not.throw(); | ||
} | ||
} | ||
@@ -54,3 +66,14 @@ } | ||
} | ||
// TODO servers,server,variable,default | ||
if (openapi.servers) { | ||
for (var server of openapi.servers) { | ||
if (server.url) { // TODO may change to REQUIRED in RC1 | ||
validateUrl(server.url).should.not.throw(); | ||
} | ||
if (server.variables) { | ||
for (var v in server.variables) { | ||
server.variables[v].should.have.key('default'); | ||
} | ||
} | ||
} | ||
} | ||
openapi.should.have.key('paths'); | ||
@@ -64,5 +87,16 @@ openapi.should.not.have.key('definitions'); | ||
if (openapi.externalDocs) { | ||
openapi.externalDocs.should.have.key('url'); // and MUST be a URL | ||
openapi.externalDocs.should.have.key('url'); | ||
validateUrl(openapi.externalDocs.url).should.not.throw(); | ||
} | ||
// TODO externalDocs.url in schemas? | ||
if (openapi.tags) { | ||
for (var tag of openapi.tags) { | ||
if (tag.externalDocs) { | ||
tag.externalDocs.should.have.key('url'); | ||
validateUrl(tag.externalDocs.url).should.not.throw(); | ||
} | ||
} | ||
} | ||
if (openapi.components && openapi.components.securitySchemes) { | ||
@@ -85,3 +119,4 @@ for (var s in openapi.components.securitySchemes) { | ||
if ((f == 'implicit') || (f == 'authorizationCode')) { | ||
flow.should.have.property('authorizationUrl'); | ||
flow.should.have.property('authorizationUrl'); | ||
validateUrl(flow.authorizationUrl).should.not.throw(); | ||
} | ||
@@ -91,2 +126,3 @@ if ((f == 'password') || (f == 'clientCredentials') || | ||
flow.should.have.property('tokenUrl'); | ||
validateUrl(flow.tokenUrl).should.not.throw(); | ||
} | ||
@@ -98,2 +134,3 @@ flow.should.have.property('scopes'); | ||
scheme.should.have.property('openIdConnectUrl'); | ||
validateUrl(scheme.openIdConnectUrl).should.not.throw(); | ||
} | ||
@@ -100,0 +137,0 @@ } |
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
48827
879